setDefaultStreamRecvMode abstract method

void setDefaultStreamRecvMode(
  1. bool autoRecvAudio,
  2. bool autoRecvVideo
)

Set Subscription Mode (which must be set before room entry for it to take effect)

You can switch between the "automatic subscription" and "manual subscription" modes through this API:

  • Automatic subscription: This is the default mode, where the user will immediately receive the audio/video streams in the room after room entry, so that the audio will be automatically played back, and the video will be automatically decoded (you still need to bind the rendering control through the startRemoteView API).

  • Manual subscription: After room entry, the user needs to manually call the startRemoteView API to start subscribing to and decoding the video stream and call the muteRemoteAudio (false) API to start playing back the audio stream.

In most scenarios, users will subscribe to the audio/video streams of all anchors in the room after room entry. Therefore, TRTC adopts the automatic subscription mode by default in order to achieve the best "instant streaming experience".

In your application scenario, if there are many audio/video streams being published at the same time in each room, and each user only wants to subscribe to 1–2 streams of them, we recommend you use the "manual subscription" mode to reduce the traffic costs.

Parameters:

  • autoRecvAudio (bool):

    • true: Automatic subscription to audio.
    • false: Manual subscription to audio by calling muteRemoteAudio (false) .
    • Default value: true.
  • autoRecvVideo (bool):

    • true: Automatic subscription to video.
    • false: Manual subscription to video by calling startRemoteView.
    • Default value: true.

Note

  1. The configuration takes effect only if this API is called before room entry (enterRoom).
  2. In the automatic subscription mode, if the user does not call startRemoteView to subscribe to the video stream after room entry, the SDK will automatically stop subscribing to the video stream in order to reduce traffic consumption.

Implementation

void setDefaultStreamRecvMode(bool autoRecvAudio, bool autoRecvVideo);