すべてのプロダクト
Search
ドキュメントセンター

ApsaraVideo Live:自動ストリームの取り込みと引き

最終更新日:Sep 03, 2024

Alibaba Real-Time Communication (ARTC) SDKは、ストリームの自動取り込みとプル機能を提供します。 デフォルトでは、この機能は有効になっています。 自動ストリームの取り込みとプル機能を使用すると、チャネルへの参加、チャネルからの離脱、ロールの切り替えに使用されるメソッドを呼び出すことで、オーディオおよびビデオストリームの取り込みとプルをアプリで実装できます。 このトピックでは、ストリームの自動取り込みとプル機能の動作について説明し、関連するサンプルコードを提供します。

サンプルコード

自動ストリームの取り込みと引きを無効にする

ARTC SDKを使用すると、ビジネス要件に基づいて、アプリのオーディオおよびビデオストリームの取り込みとプルを無効にできます。

オーディオおよびビデオストリームの自動取り込みを無効にする

  • 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);
  • 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];
  • 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);

自動オーディオおよびビデオストリームのプルを無効にする

  • 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);
  • 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];
  • 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);