Tizen Native API  7.0
Media Source

The Media Source API provides functions to manage media sources to communicate with the remote peer.

Required Header

#include <webrtc.h>

Overview

The WebRTC Media Source API allows you to:

  • add/remove the media source (audiotest, videotest, mic, camera, screen, media file, media packet)
  • pause/mute the media source
  • get/set the transceiver direction to the media source (sendrecv, sendonly, recvonly)
  • set/get the video resolution of the media source
  • push a media packet in case of the media packet source

Related Features

This API is related with the following features:

  • http://tizen.org/feature/microphone
  • http://tizen.org/feature/camera

It is recommended to design feature related codes in your application for reliability.
You can check if a device supports the related features for this API by using System Information, thereby controlling the procedure of your application.
To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.
More details on featuring your application can be found from Feature Element.

Functions

int webrtc_add_media_source (webrtc_h webrtc, webrtc_media_source_type_e type, unsigned int *source_id)
 Adds a media source.
int webrtc_remove_media_source (webrtc_h webrtc, unsigned int source_id)
 Removes the media source.
int webrtc_media_source_set_transceiver_direction (webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, webrtc_transceiver_direction_e direction)
 Sets the transceiver direction to the media source with specified media type.
int webrtc_media_source_get_transceiver_direction (webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, webrtc_transceiver_direction_e *direction)
 Gets the transceiver direction of the media source with specified media type.
int webrtc_media_source_foreach_supported_transceiver_codec (webrtc_h webrtc, webrtc_media_source_type_e source_type, webrtc_media_type_e media_type, webrtc_media_source_supported_transceiver_codec_cb callback, void *user_data)
 Retrieves all the supported transceiver codecs.
int webrtc_media_source_set_transceiver_codec (webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, webrtc_transceiver_codec_e codec)
 Sets the transceiver codec to the media source.
int webrtc_media_source_get_transceiver_codec (webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, webrtc_transceiver_codec_e *codec)
 Gets the transceiver codec of the media source.
int webrtc_media_source_set_pause (webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, bool pause)
 Sets pause to the media source.
int webrtc_media_source_get_pause (webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, bool *paused)
 Gets the pause state of the media source.
int webrtc_media_source_set_mute (webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, bool mute)
 Sets mute to the media source.
int webrtc_media_source_get_mute (webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, bool *muted)
 Gets the mute state of the media source.
int webrtc_media_source_set_encoder_bitrate (webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, int target_bitrate)
 Sets an encoder target bitrate(in bits/sec) to the media source.
int webrtc_media_source_get_encoder_bitrate (webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, int *target_bitrate)
 Gets the encoder target bitrate(in bits/sec) of the media source.
int webrtc_media_source_set_video_resolution (webrtc_h webrtc, unsigned int source_id, int width, int height)
 Sets a video resolution to the media source.
int webrtc_media_source_get_video_resolution (webrtc_h webrtc, unsigned int source_id, int *width, int *height)
 Gets the video resolution of the media source.
int webrtc_media_source_set_video_framerate (webrtc_h webrtc, unsigned int source_id, int framerate)
 Sets a video source frame rate, also known as FPS.
int webrtc_media_source_get_video_framerate (webrtc_h webrtc, unsigned int source_id, int *framerate)
 Gets the video source frame rate, also known as FPS.
int webrtc_mic_source_set_sound_stream_info (webrtc_h webrtc, unsigned int source_id, sound_stream_info_h stream_info)
 Sets the mic source's sound manager stream information.
int webrtc_camera_source_set_device_id (webrtc_h webrtc, unsigned int source_id, unsigned int device_id)
 Sets a camera device id to the camera source.
int webrtc_camera_source_get_device_id (webrtc_h webrtc, unsigned int source_id, unsigned int *device_id)
 Gets the camera device id of the camera source.
int webrtc_media_packet_source_set_buffer_state_changed_cb (webrtc_h webrtc, unsigned int source_id, webrtc_media_packet_source_buffer_state_changed_cb callback, void *user_data)
 Sets a callback function to be invoked when the buffer state of media packet source is changed.
int webrtc_media_packet_source_unset_buffer_state_changed_cb (webrtc_h webrtc, unsigned int source_id)
 Unsets the buffer state changed callback function.
int webrtc_media_packet_source_set_format (webrtc_h webrtc, unsigned int source_id, media_format_h format)
 Sets media format to the media packet source.
int webrtc_media_packet_source_push_packet (webrtc_h webrtc, unsigned int source_id, media_packet_h packet)
 Pushes media packet to the media packet source.
int webrtc_file_source_set_path (webrtc_h webrtc, unsigned int source_id, const char *path)
 Sets media path of the file source.
int webrtc_file_source_set_looping (webrtc_h webrtc, unsigned int source_id, bool looping)
 Sets looping mode of the file source.
int webrtc_file_source_get_looping (webrtc_h webrtc, unsigned int source_id, bool *looping)
 Gets looping mode of the file source.
int webrtc_screen_source_set_crop (webrtc_h webrtc, unsigned int source_id, int x, int y, int width, int height)
 Sets the crop coordinates of a screen source.
int webrtc_screen_source_unset_crop (webrtc_h webrtc, unsigned int source_id)
 Unsets the crop coordinates of a screen source.

Typedefs

typedef void(* webrtc_media_packet_source_buffer_state_changed_cb )(unsigned int source_id, webrtc_media_packet_source_buffer_state_e state, void *user_data)
 Called when the buffer state of media packet source is changed.
typedef bool(* webrtc_media_source_supported_transceiver_codec_cb )(webrtc_transceiver_codec_e codec, void *user_data)
 Called iteratively to report all the supported transceiver codecs.

Typedef Documentation

typedef void(* webrtc_media_packet_source_buffer_state_changed_cb)(unsigned int source_id, webrtc_media_packet_source_buffer_state_e state, void *user_data)

Called when the buffer state of media packet source is changed.

Since :
6.5
Parameters:
[in]source_idThe media source id
[in]stateThe buffer state (underflow or overflow)
[in]user_dataThe user data passed from the callback registration function
See also:
webrtc_media_packet_source_set_buffer_state_changed_cb()
webrtc_media_packet_source_unset_buffer_state_changed_cb()

Called iteratively to report all the supported transceiver codecs.

Since :
7.0
Parameters:
[in]codecThe supported codec
[in]user_dataThe user data passed from the callback registration function
Returns:
true to continue with the next iteration of the loop, otherwise false to break out of the loop
See also:
webrtc_media_source_foreach_supported_transceiver_codec()

Enumeration Type Documentation

Enumeration for buffer state type of media packet source.

Since :
6.5
Enumerator:
WEBRTC_MEDIA_PACKET_SOURCE_BUFFER_STATE_UNDERFLOW 

Buffer underflow

WEBRTC_MEDIA_PACKET_SOURCE_BUFFER_STATE_OVERFLOW 

Buffer overflow

Enumeration for WebRTC media source type.

Since :
6.5
Enumerator:
WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST 

Audio test

WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST 

Video test

WEBRTC_MEDIA_SOURCE_TYPE_MIC 

Audio from microphone

WEBRTC_MEDIA_SOURCE_TYPE_CAMERA 

Camera preview

WEBRTC_MEDIA_SOURCE_TYPE_SCREEN 

Screen capture

WEBRTC_MEDIA_SOURCE_TYPE_FILE 

Media file

WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET 

Media packet

WEBRTC_MEDIA_SOURCE_TYPE_NULL 

Null (Since 7.0)

Enumeration for WebRTC transceiver codec.

Since :
7.0
Enumerator:
WEBRTC_TRANSCEIVER_CODEC_PCMU 

PCMU audio codec

WEBRTC_TRANSCEIVER_CODEC_PCMA 

PCMA audio codec

WEBRTC_TRANSCEIVER_CODEC_OPUS 

OPUS audio codec

WEBRTC_TRANSCEIVER_CODEC_VP8 

VP8 video codec

WEBRTC_TRANSCEIVER_CODEC_VP9 

VP9 video codec

WEBRTC_TRANSCEIVER_CODEC_H264 

H264 video codec

Enumeration for WebRTC transceiver direction type.

Since :
6.5
Enumerator:
WEBRTC_TRANSCEIVER_DIRECTION_SENDONLY 

Send only

WEBRTC_TRANSCEIVER_DIRECTION_RECVONLY 

Receive only

WEBRTC_TRANSCEIVER_DIRECTION_SENDRECV 

Send and receive


Function Documentation

int webrtc_add_media_source ( webrtc_h  webrtc,
webrtc_media_source_type_e  type,
unsigned int *  source_id 
)

Adds a media source.

Since :
6.5
Remarks:
The camera privilege(http://tizen.org/privilege/camera) should be added if type is WEBRTC_MEDIA_SOURCE_TYPE_CAMERA.
The recorder privilege(http://tizen.org/privilege/recorder) should be added if type is WEBRTC_MEDIA_SOURCE_TYPE_MIC.
With type of WEBRTC_MEDIA_SOURCE_TYPE_NULL, you can configure a transceiver only for receiving audio or video stream. (Since 7.0)
type of WEBRTC_MEDIA_SOURCE_TYPE_SCREEN is not allowed to be used by third-party applications due to the security reasons. (Since 7.0)
Parameters:
[in]webrtcWebRTC handle
[in]typeThe media source type to be added
[out]source_idThe media source id
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_NOT_SUPPORTEDNot supported
WEBRTC_ERROR_PERMISSION_DENIEDPermission denied
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
WEBRTC_ERROR_INVALID_STATEInvalid state
Precondition:
webrtc state must be set to WEBRTC_STATE_IDLE.
See also:
webrtc_remove_media_source()
webrtc_media_source_set_transceiver_direction()
webrtc_media_source_get_transceiver_direction()
webrtc_media_source_foreach_supported_transceiver_codec()
webrtc_media_source_set_transceiver_codec()
webrtc_media_source_get_transceiver_codec()
webrtc_media_source_set_pause()
webrtc_media_source_get_pause()
webrtc_media_source_set_mute()
webrtc_media_source_get_mute()
webrtc_media_source_set_encoder_bitrate()
webrtc_media_source_get_encoder_bitrate()
webrtc_media_source_set_video_resolution()
webrtc_media_source_get_video_resolution()
webrtc_media_source_set_video_framerate()
webrtc_media_source_get_video_framerate()
webrtc_media_source_set_audio_loopback()
webrtc_media_source_unset_audio_loopback()
webrtc_media_source_set_video_loopback()
webrtc_media_source_unset_video_loopback()
webrtc_mic_source_set_sound_stream_info()
webrtc_camera_source_set_device_id()
webrtc_camera_source_get_device_id()
webrtc_file_source_set_path()
webrtc_file_source_set_looping()
webrtc_file_source_get_looping()
webrtc_media_packet_source_set_buffer_state_changed_cb()
webrtc_media_packet_source_unset_buffer_state_changed_cb()
webrtc_media_packet_source_set_format()
webrtc_media_packet_source_push_packet()
int webrtc_camera_source_get_device_id ( webrtc_h  webrtc,
unsigned int  source_id,
unsigned int *  device_id 
)

Gets the camera device id of the camera source.

Since :
7.0
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe camera source id
[out]device_idThe camera device id
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
Precondition:
Add camera source to webrtc to get source_id by calling webrtc_add_media_source().
See also:
webrtc_add_media_source()
webrtc_camera_source_set_device_id()
int webrtc_camera_source_set_device_id ( webrtc_h  webrtc,
unsigned int  source_id,
unsigned int  device_id 
)

Sets a camera device id to the camera source.

Since :
7.0
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe camera source id
[in]device_idThe camera device id
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
WEBRTC_ERROR_INVALID_STATEInvalid state
Precondition:
Add camera source to webrtc to get source_id by calling webrtc_add_media_source().
webrtc state must be set to WEBRTC_STATE_IDLE.
See also:
webrtc_add_media_source()
webrtc_camera_source_get_device_id()
int webrtc_file_source_get_looping ( webrtc_h  webrtc,
unsigned int  source_id,
bool *  looping 
)

Gets looping mode of the file source.

Since :
7.0
Remarks:
The default value is false.
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe file source id
[out]loopingThe looping state: (true = looping, false = non-looping)
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
See also:
webrtc_file_source_set_looping()
int webrtc_file_source_set_looping ( webrtc_h  webrtc,
unsigned int  source_id,
bool  looping 
)

Sets looping mode of the file source.

If looping is true, the transfer starts again from the beginning of the file source after reaching the end of the file. If it is false, it won't. The default value is false.

Since :
7.0
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe file source id
[in]loopingThe new looping state: (true = looping, false = non-looping)
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
See also:
webrtc_file_source_get_looping()
int webrtc_file_source_set_path ( webrtc_h  webrtc,
unsigned int  source_id,
const char *  path 
)

Sets media path of the file source.

Since :
7.0
Remarks:
http://tizen.org/privilege/mediastorage is needed if path is relevant to internal media storage.
http://tizen.org/privilege/externalstorage is needed if path is relevant to external media storage.
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe file source id
[in]pathThe media path
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_PERMISSION_DENIEDPermission denied
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_STATEInvalid state
Precondition:
Add file source to webrtc to get source_id by calling webrtc_add_media_source().
webrtc state must be set to WEBRTC_STATE_IDLE.
int webrtc_media_packet_source_push_packet ( webrtc_h  webrtc,
unsigned int  source_id,
media_packet_h  packet 
)

Pushes media packet to the media packet source.

Since :
6.5
Remarks:
This function takes ownership of the packet.
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe media packet source id
[in]packetThe media packet
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
Precondition:
Add media packet source to webrtc to get source_id by calling webrtc_add_media_source().
webrtc_media_packet_source_set_format() must be called before calling this function.
webrtc_media_packet_source_buffer_state_changed_cb() must be set by calling webrtc_media_packet_source_set_buffer_state_changed_cb().
See also:
webrtc_media_packet_source_set_format()
webrtc_media_packet_source_set_buffer_state_changed_cb()
int webrtc_media_packet_source_set_buffer_state_changed_cb ( webrtc_h  webrtc,
unsigned int  source_id,
webrtc_media_packet_source_buffer_state_changed_cb  callback,
void *  user_data 
)

Sets a callback function to be invoked when the buffer state of media packet source is changed.

Since :
6.5
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe media packet source id
[in]callbackCallback function pointer
[in]user_dataThe user data to be passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
Precondition:
Add media packet source to webrtc to get source_id by calling webrtc_add_media_source().
Postcondition:
webrtc_media_packet_source_buffer_state_changed_cb() will be invoked.
See also:
webrtc_media_packet_source_push_packet()
webrtc_media_packet_source_unset_buffer_state_changed_cb()
webrtc_media_packet_source_buffer_state_changed_cb()
int webrtc_media_packet_source_set_format ( webrtc_h  webrtc,
unsigned int  source_id,
media_format_h  format 
)

Sets media format to the media packet source.

Since :
6.5
Remarks:
The following media format mimetypes can be used to create the format :
MEDIA_FORMAT_VORBIS
MEDIA_FORMAT_OPUS
MEDIA_FORMAT_PCM_S16LE
MEDIA_FORMAT_PCMU
MEDIA_FORMAT_PCMA
MEDIA_FORMAT_H264_SP
MEDIA_FORMAT_H264_MP
MEDIA_FORMAT_H264_HP
MEDIA_FORMAT_MJPEG
MEDIA_FORMAT_VP8
MEDIA_FORMAT_VP9
MEDIA_FORMAT_I420
MEDIA_FORMAT_NV12
For more details, please refer to Media Format.
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe media packet source id
[in]formatThe media format
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
WEBRTC_ERROR_INVALID_STATEInvalid state
Precondition:
Add media packet source to webrtc to get source_id by calling webrtc_add_media_source().
webrtc state must be set to WEBRTC_STATE_IDLE.
See also:
webrtc_media_packet_source_push_packet()
webrtc_media_packet_source_set_buffer_state_changed_cb()
int webrtc_media_packet_source_unset_buffer_state_changed_cb ( webrtc_h  webrtc,
unsigned int  source_id 
)

Unsets the buffer state changed callback function.

Since :
6.5
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe media packet source id
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
Precondition:
Add media packet source to webrtc to get source_id by calling webrtc_add_media_source().
See also:
webrtc_media_packet_source_set_buffer_state_changed_cb()

Retrieves all the supported transceiver codecs.

Since :
7.0
Remarks:
If source_type is WEBRTC_MEDIA_SOURCE_TYPE_FILE or WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET, this function will return WEBRTC_ERROR_INVALID_PARAMETER.
Parameters:
[in]webrtcWebRTC handle
[in]source_typeThe media source type
[in]media_typeThe media type
[in]callbackCallback function pointer
[in]user_dataThe user data to be passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
See also:
webrtc_media_source_supported_transceiver_codec_cb()
webrtc_media_source_set_transceiver_codec()
webrtc_media_source_get_transceiver_codec()
int webrtc_media_source_get_encoder_bitrate ( webrtc_h  webrtc,
unsigned int  source_id,
webrtc_media_type_e  media_type,
int *  target_bitrate 
)

Gets the encoder target bitrate(in bits/sec) of the media source.

If source_id is a media source of WEBRTC_MEDIA_SOURCE_TYPE_FILE or WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET or WEBRTC_MEDIA_SOURCE_TYPE_NULL, this function will return WEBRTC_ERROR_INVALID_PARAMETER.

Since :
7.0
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe media source id
[in]media_typeThe media type
[out]target_bitrateThe target bitrate of the encoder
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
Precondition:
Add media source to webrtc to get source_id by calling webrtc_add_media_source().
See also:
webrtc_add_media_source()
webrtc_media_source_set_encoder_bitrate()
int webrtc_media_source_get_mute ( webrtc_h  webrtc,
unsigned int  source_id,
webrtc_media_type_e  media_type,
bool *  muted 
)

Gets the mute state of the media source.

If source_id is a media source of WEBRTC_MEDIA_SOURCE_TYPE_FILE or WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET or WEBRTC_MEDIA_SOURCE_TYPE_NULL (Since 7.0), this function will return WEBRTC_ERROR_INVALID_PARAMETER.

Since :
6.5
Remarks:
The default value is false.
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe media source id
[in]media_typeThe media type
[out]mutedMuted or not (true = muted, false = not muted)
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
See also:
webrtc_media_source_set_mute()
int webrtc_media_source_get_pause ( webrtc_h  webrtc,
unsigned int  source_id,
webrtc_media_type_e  media_type,
bool *  paused 
)

Gets the pause state of the media source.

Since :
6.5
Remarks:
The default value is false.
If source_id is a media source of WEBRTC_MEDIA_SOURCE_TYPE_NULL, this function will return WEBRTC_ERROR_INVALID_PARAMETER. (Since 7.0)
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe media source id
[in]media_typeThe media type
[out]pausedPaused or not (true = paused, false = playing)
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
See also:
webrtc_media_source_set_pause()
int webrtc_media_source_get_transceiver_codec ( webrtc_h  webrtc,
unsigned int  source_id,
webrtc_media_type_e  media_type,
webrtc_transceiver_codec_e codec 
)

Gets the transceiver codec of the media source.

Since :
7.0
Remarks:
If source_id is a media source of WEBRTC_MEDIA_SOURCE_TYPE_FILE or WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET, this function will return WEBRTC_ERROR_INVALID_PARAMETER.
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe media source id
[in]media_typeThe media type
[out]codecCurrent transceiver codec
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
Precondition:
Add media source to webrtc to get source_id by calling webrtc_add_media_source().
See also:
webrtc_media_source_set_transceiver_codec()
webrtc_media_source_foreach_supported_transceiver_codec()
int webrtc_media_source_get_transceiver_direction ( webrtc_h  webrtc,
unsigned int  source_id,
webrtc_media_type_e  media_type,
webrtc_transceiver_direction_e direction 
)

Gets the transceiver direction of the media source with specified media type.

Since :
6.5
Remarks:
The default value is WEBRTC_TRANSCEIVER_DIRECTION_SENDRECV except for a media source of WEBRTC_MEDIA_SOURCE_TYPE_NULL.
If source_id is a media source of WEBRTC_MEDIA_SOURCE_TYPE_NULL, the default value is WEBRTC_TRANSCEIVER_DIRECTION_RECVONLY. (Since 7.0)
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe media source id
[in]media_typeThe media type
[out]directionCurrent transceiver direction
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
Precondition:
Add media source to webrtc to get source_id by calling webrtc_add_media_source().
webrtc_media_packet_source_set_format() must be called if source_id is a media source of WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET.
See also:
webrtc_media_source_set_transceiver_direction()
int webrtc_media_source_get_video_framerate ( webrtc_h  webrtc,
unsigned int  source_id,
int *  framerate 
)

Gets the video source frame rate, also known as FPS.

The following media source types contain video:
WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST
WEBRTC_MEDIA_SOURCE_TYPE_CAMERA
WEBRTC_MEDIA_SOURCE_TYPE_SCREEN

Since :
7.0
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe video source id
[out]framerateThe video frame rate
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
Precondition:
Add media source to webrtc to get source_id by calling webrtc_add_media_source().
See also:
webrtc_add_media_source()
webrtc_media_source_set_video_framerate()
int webrtc_media_source_get_video_resolution ( webrtc_h  webrtc,
unsigned int  source_id,
int *  width,
int *  height 
)

Gets the video resolution of the media source.

The following media source types contain video:
WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST
WEBRTC_MEDIA_SOURCE_TYPE_CAMERA
WEBRTC_MEDIA_SOURCE_TYPE_SCREEN

Since :
6.5
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe video source id
[out]widthThe video width
[out]heightThe video height
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
Precondition:
Add media source to webrtc to get source_id by calling webrtc_add_media_source().
See also:
webrtc_media_source_set_video_resolution()
int webrtc_media_source_set_encoder_bitrate ( webrtc_h  webrtc,
unsigned int  source_id,
webrtc_media_type_e  media_type,
int  target_bitrate 
)

Sets an encoder target bitrate(in bits/sec) to the media source.

If source_id is a media source of WEBRTC_MEDIA_SOURCE_TYPE_FILE or WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET or WEBRTC_MEDIA_SOURCE_TYPE_NULL, this function will return WEBRTC_ERROR_INVALID_PARAMETER.

Since :
7.0
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe media source id
[in]media_typeThe media type
[in]target_bitrateThe target bitrate of the encoder
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
Precondition:
Add media source to webrtc to get source_id by calling webrtc_add_media_source().
See also:
webrtc_add_media_source()
webrtc_media_source_get_encoder_bitrate()
int webrtc_media_source_set_mute ( webrtc_h  webrtc,
unsigned int  source_id,
webrtc_media_type_e  media_type,
bool  mute 
)

Sets mute to the media source.

If mute is set to true, black frame or silent sound will be transmitted to the remote peer according to the media type of the source_id.
If source_id is a media source of WEBRTC_MEDIA_SOURCE_TYPE_FILE or WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET or WEBRTC_MEDIA_SOURCE_TYPE_NULL (Since 7.0), this function will return WEBRTC_ERROR_INVALID_PARAMETER.

Since :
6.5
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe media source id
[in]media_typeThe media type
[in]muteMute or not (true = mute, false = not mute)
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
See also:
webrtc_media_source_get_mute()
int webrtc_media_source_set_pause ( webrtc_h  webrtc,
unsigned int  source_id,
webrtc_media_type_e  media_type,
bool  pause 
)

Sets pause to the media source.

Since :
6.5
Remarks:
If source_id is a media source of WEBRTC_MEDIA_SOURCE_TYPE_NULL, this function will return WEBRTC_ERROR_INVALID_PARAMETER. (Since 7.0)
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe media source id
[in]media_typeThe media type
[in]pausePause or play (true = pause, false = play)
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
See also:
webrtc_media_source_get_pause()
int webrtc_media_source_set_transceiver_codec ( webrtc_h  webrtc,
unsigned int  source_id,
webrtc_media_type_e  media_type,
webrtc_transceiver_codec_e  codec 
)

Sets the transceiver codec to the media source.

Since :
7.0
Remarks:
If source_id is a media source of WEBRTC_MEDIA_SOURCE_TYPE_FILE or WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET, this function will return WEBRTC_ERROR_INVALID_PARAMETER.
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe media source id
[in]media_typeThe media type
[in]codecThe transceiver codec to set
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
WEBRTC_ERROR_INVALID_STATEInvalid state
Precondition:
Add media source to webrtc to get source_id by calling webrtc_add_media_source().
webrtc state must be set to WEBRTC_STATE_IDLE.
See also:
webrtc_media_source_get_transceiver_codec()
webrtc_media_source_foreach_supported_transceiver_codec()
int webrtc_media_source_set_transceiver_direction ( webrtc_h  webrtc,
unsigned int  source_id,
webrtc_media_type_e  media_type,
webrtc_transceiver_direction_e  direction 
)

Sets the transceiver direction to the media source with specified media type.

Since :
6.5
Remarks:
If source_id is a media source of WEBRTC_MEDIA_SOURCE_TYPE_NULL, it only allows WEBRTC_TRANSCEIVER_DIRECTION_RECVONLY. (Since 7.0)
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe media source id
[in]media_typeThe media type
[in]directionThe transceiver direction to set
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
WEBRTC_ERROR_INVALID_STATEInvalid state
Precondition:
Add media source to webrtc to get source_id by calling webrtc_add_media_source().
webrtc_media_packet_source_set_format() must be called if source_id is a media source of WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET.
webrtc state must be set to WEBRTC_STATE_IDLE.
See also:
webrtc_media_source_get_transceiver_direction()
int webrtc_media_source_set_video_framerate ( webrtc_h  webrtc,
unsigned int  source_id,
int  framerate 
)

Sets a video source frame rate, also known as FPS.

The following media source types contain video:
WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST
WEBRTC_MEDIA_SOURCE_TYPE_CAMERA
WEBRTC_MEDIA_SOURCE_TYPE_SCREEN

Since :
7.0
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe video source id
[in]framerateThe video frame rate
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
Precondition:
Add media source to webrtc to get source_id by calling webrtc_add_media_source().
See also:
webrtc_add_media_source()
webrtc_media_source_get_video_framerate()
int webrtc_media_source_set_video_resolution ( webrtc_h  webrtc,
unsigned int  source_id,
int  width,
int  height 
)

Sets a video resolution to the media source.

The following media source types contain video:
WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST
WEBRTC_MEDIA_SOURCE_TYPE_CAMERA
WEBRTC_MEDIA_SOURCE_TYPE_SCREEN

Since :
6.5
Remarks:
If source_id does not support for the dynamic resolution change, WEBRTC_ERROR_INVALID_OPERATION will be returned
while webrtc state is WEBRTC_STATE_NEGOTIATING or WEBRTC_STATE_PLAYING. Since 7.0, this function supports dynamic resolution change regardless of state for all video sources mentioned in details.
However, some sources cannot be changed to a greater value than the resolution set in the WEBRTC_STATE_IDLE.
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe video source id
[in]widthThe video width
[in]heightThe video height
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
Precondition:
Add media source to webrtc to get source_id by calling webrtc_add_media_source().
See also:
webrtc_media_source_get_video_resolution()
int webrtc_mic_source_set_sound_stream_info ( webrtc_h  webrtc,
unsigned int  source_id,
sound_stream_info_h  stream_info 
)

Sets the mic source's sound manager stream information.

If source_id is not a media source of WEBRTC_MEDIA_SOURCE_TYPE_MIC, this function will return WEBRTC_ERROR_INVALID_PARAMETER.

Since :
6.5
Remarks:
You can set sound stream information including audio routing.
The following sound stream types can be used to create the stream_info :
SOUND_STREAM_TYPE_MEDIA
SOUND_STREAM_TYPE_VOICE_RECOGNITION
SOUND_STREAM_TYPE_VOIP
SOUND_STREAM_TYPE_MEDIA_EXTERNAL_ONLY
For more details, please refer to Sound Manager.
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe mic source id
[in]stream_infoThe sound stream information
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
WEBRTC_ERROR_INVALID_STATEInvalid state
Precondition:
webrtc state must be set to WEBRTC_STATE_IDLE.
See also:
sound_stream_info_h
sound_manager_create_stream_information()
sound_manager_destroy_stream_information()
int webrtc_remove_media_source ( webrtc_h  webrtc,
unsigned int  source_id 
)

Removes the media source.

Since :
6.5
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe media source id to be removed
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
WEBRTC_ERROR_INVALID_STATEInvalid state
Precondition:
Add media source to webrtc to get source_id by calling webrtc_add_media_source().
webrtc state must be set to WEBRTC_STATE_IDLE.
See also:
webrtc_add_media_source()
int webrtc_screen_source_set_crop ( webrtc_h  webrtc,
unsigned int  source_id,
int  x,
int  y,
int  width,
int  height 
)

Sets the crop coordinates of a screen source.

Warning:
This is not for use by third-party applications.
Since :
7.0
Remarks:
The coordinates are in UI (screen) units, and the start coordinate refers to the upper left corner of the video display area on the screen.
If we give a rectangle within that area (described by x, y, width, height) then this sub-area will be sent to peer and it changes the video resolution. The changed resolution can be checked through webrtc_media_source_get_video_resolution().
Even when the crop area is changed again, the rectangle coordinates are still based on the original UI (screen) as in the first setting.
If the video resolution is changed by webrtc_media_source_set_video_resolution(), then crop cannot be performed.
Crop and resolution change cannot be done at the same time.
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe screen source id
[in]xThe start X coordinate of the UI for cropping
[in]yThe start Y coordinate of the UI for cropping
[in]widthWidth of the UI for cropping
[in]heightHeight of the UI for cropping
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_PERMISSION_DENIEDPermission denied
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
WEBRTC_ERROR_INVALID_STATEInvalid state
Precondition:
Add screen source to webrtc to get source_id by calling webrtc_add_media_source().
webrtc state must be set to WEBRTC_STATE_NEGOTIATING or WEBRTC_STATE_PLAYING.
See also:
webrtc_screen_source_unset_crop()
webrtc_media_source_get_video_resolution()
int webrtc_screen_source_unset_crop ( webrtc_h  webrtc,
unsigned int  source_id 
)

Unsets the crop coordinates of a screen source.

Warning:
This is not for use by third-party applications.
Since :
7.0
Parameters:
[in]webrtcWebRTC handle
[in]source_idThe screen source id
Returns:
0 on success, otherwise a negative error value
Return values:
WEBRTC_ERROR_NONESuccessful
WEBRTC_ERROR_PERMISSION_DENIEDPermission denied
WEBRTC_ERROR_INVALID_PARAMETERInvalid parameter
WEBRTC_ERROR_INVALID_OPERATIONInvalid operation
WEBRTC_ERROR_INVALID_STATEInvalid state
Precondition:
Add screen source to webrtc to get source_id by calling webrtc_add_media_source().
webrtc state must be set to WEBRTC_STATE_NEGOTIATING or WEBRTC_STATE_PLAYING.
See also:
webrtc_screen_source_set_crop()