This topic describes the advanced functions of the Mobile Real-Time Communication (MRTC) calling API for Android.
Set up an audio and video call or an audio call
To set up an audio call, when initializing the engine, configure publishConfig depending on the call type:
publishConfig = new PublishConfig();Audio call
publishConfig.videoSource = VIDEO_SOURCE_NULL; publishConfig.audioSource = AUDIO_SOURCE_MIC;Video call
publishConfig.videoSource = VIDEO_SOURCE_CAMERA; publishConfig.audioSource = AUDIO_SOURCE_MIC;
Dynamically adjust the resolution
After a call is successfully established, you can use the following method to dynamically adjust the resolution sent by the local end:
public void updateVideoProfile( VideoProfile videoProfile, int maxBitrate )Where:
videoProfile: the settings about the new resolution.maxBitrate: the new bit rate. The default value is0.
Monitor the call quality
After a call is successfully established, use the following callback listeners to query the current video call quality in real time:
void onStatisticDebugInfo( StatisticInfoForDebug infoForDebug, FeedInfo feedInfo ); //Queries the debugging information during a call process.
void onRealTimeStatisticInfo( RealTimeStatisticReport report, FeedInfo feedInfo ); //Queries the real-time monitoring information.Where feedInfo indicates the information about the local stream and peer stream.
Monitor the network changes
After a call is successfully established, use the following callback listener to query the bandwidth information:
void onBandwidthImportanceChangeNotify( boolean isLow, double currentBandwidth, FeedInfo feedInfo ); //Notification for insufficient bandwidth.The value isLow is returned if the bandwidth is too low, which may result in a disconnected call or poor call quality.
Screen sharing
Before enabling the screen sharing function, do the following to share the screen at the same time in a video call:
When initializing the engine, you cannot configure the automatic publishing but the automatic subscription. That is:
rtcEngine.setAutoPublishSubscribe( autoPublish, autoSubscribe );Where:
The
autoPublishmust be set tofalse.For
autoSubscribe, there is no requirement on the value.
After initialization, when creating or joining the room, call the following method:
publishConfig = new PublishConfig(); publishConfig.videoSource = VIDEO_SOURCE_SCREEN; rtcEngine.publish( publishConfig );
Snapshot taking
After a call is established, use the following method to take a snapshot:
public void snapshot( FeedInfo info )In the method, feedInfo indicates the information about the stream of which a snapshot is taken.
Use the following callback method to return the snapshot taking result:
void onSnapShotComplete( Bitmap image, FeedInfo feedInfo ); //Callback result of the snapshot taking operation.Custom ingest-stream
Enable the custom ingest-stream.
Same as screen sharing, when initializing the engine, you cannot configure the automatic publishing, but you can configure the automatic subscription. That is,
rtcEngine.setAutoPublishSubscribe( autoPublish, autoSubscribe );Where:
The
autoPublishparameter must be set tofalse.There is no special requirement on
autoSubscribe.
After creating or joining a room, call:
publishConfig = new PublishConfig(); publishConfig.videoSource = VIDEO_SOURCE_CUSTOM; rtcEngine.publish( publishConfig );After the publishing is successful, input graphic data continuously by using the following method:
public void pushCustomVideoData(byte[] bytes, int width, int height, int rotation ) //Customizes the stream data for ingestion. Currently, only data in nv21 format is supported.
Local preview
If you want to enable the preview before entering a video call, call the following method to enable the camera preview after the engine is initialized:
public void startCameraPreview()For information about the view to be previewed, see Listen on the local and peer view.