Alibaba Real-Time Communication (ARTC) SDK provides the automatic stream ingest and pulling feature. By default, the feature is enabled. The automatic stream ingest and pulling feature allows your app to implement audio and video stream ingest and pulling by calling methods that are used to join a channel, leave a channel, and switch roles. This topic describes how the automatic stream ingest and pulling feature works and provides the relevant sample code.
Sample code
Disable automatic stream ingest and pulling
ARTC SDK allows you to disable audio and video stream ingest and pulling for your app based on your business requirements.
Disable automatic audio and video stream ingest
Sample code for Android:
/* If you set the parameter to false, video streams are not ingested after a user joins the channel. The app needs to call the method to ingest video streams. */ /* If you set the parameter to true, video streams are ingested after a user joins the channel. Default value: true. */ mAliRtcEngine.publishLocalVideoStream(false); /* If you set the parameter to false, audio streams are not ingested after a user joins the channel. The app needs to call the method to ingest audio streams. */ /* If you set the parameter to true, audio streams are ingested after a user joins the channel. Default value: true. */ mAliRtcEngine.publishLocalAudioStream(false);
Sample code for iOS:
/* If you set the parameter to NO, video streams are not ingested after a user joins the channel. The app needs to call the method to ingest video streams. */ /* If you set the parameter to YES, video streams are ingested after a user joins the channel. Default value: YES. */ [self.engine publishLocalVideoStream:NO]; /* If you set the parameter to NO, audio streams are not ingested after a user joins the channel. The app needs to call the method to ingest audio streams. */ /* If you set the parameter to YES, audio streams are ingested after a user joins the channel. Default value: YES. */ [self.engine publishLocalAudioStream:NO];
Sample code for Windows:
/* If you set the parameter to false, video streams are not ingested after a user joins the channel. The app needs to call the method to ingest video streams. */ /* If you set the parameter to true, video streams are ingested after a user joins the channel. Default value: true. */ mAliRtcEngine->PublishLocalVideoStream(false); /* If you set the parameter to false, audio streams are not ingested after a user joins the channel. The app needs to call the method to ingest audio streams. */ /* If you set the parameter to true, audio streams are ingested after a user joins the channel. Default value: true. */ mAliRtcEngine->PublishLocalAudioStream(false);
Disable automatic audio and video stream pulling
Sample code for Android:
/* If you set the parameter to false, video streams are not subscribed to after a user joins the channel. The app needs to call the subscribeRemoteMediaStream or subscribeRemoteVideoStream method to subscribe to video streams. */ /* If you set the parameter to true, video streams are subscribed to after a user joins the channel. Default value: true. */ mAliRtcEngine.setDefaultSubscribeAllRemoteVideoStreams(false); /* If you set the parameter to false, audio streams are not subscribed to after a user joins the channel. The app needs to call the subscribeRemoteMediaStream or subscribeRemoteAudioStream method to subscribe to audio streams. */ /* If you set the parameter to true, audio streams are subscribed to after a user joins the channel. Default value: true. */ mAliRtcEngine.setDefaultSubscribeAllRemoteAudioStreams(false);
Sample code for iOS:
/* If you set the parameter to NO, video streams are not subscribed to after a user joins the channel. The app needs to call the subscribeRemoteMediaStream or subscribeRemoteVideoStream method to subscribe to video streams. */ /* If you set the parameter to YES, video streams are subscribed to after a user joins the channel. Default value: YES. * / [self.engine setDefaultSubscribeAllRemoteVideoStreams:NO]; /* If you set the parameter to NO, audio streams are not subscribed to after a user joins the channel. The app needs to call the subscribeRemoteMediaStream or subscribeRemoteAudioStream method to subscribe to audio streams. */ /* If you set the parameter to YES, audio streams are subscribed to after a user joins the channel. Default value: YES. * / [self.engine setDefaultSubscribeAllRemoteAudioStreams:NO];
Sample code for Windows:
/* If you set the parameter to false, video streams are not subscribed to after a user joins the channel. The app needs to call the SubscribeRemoteMediaStream or SubscribeRemoteVideoStream method to subscribe to video streams. */ /* If you set the parameter to true, video streams are subscribed to after a user joins the channel. Default value: true. */ mAliRtcEngine.SetDefaultSubscribeAllRemoteVideoStreams(false); /* If you set the parameter to false, audio streams are not subscribed to after a user joins the channel. The app needs to call the SubscribeRemoteMediaStream or SubscribeRemoteAudioStream method to subscribe to audio streams. */ /* If you set the parameter to true, audio streams are subscribed to after a user joins the channel. Default value: true. */ mAliRtcEngine.SetDefaultSubscribeAllRemoteAudioStreams(false);