RTC Engine
  • 개요
  • Web
    • Demo 실행
    • SDK 빠른 실행
    • 기본 기능
      • 화면 공유
      • 라이브 방송
      • 미디어 장치
      • 볼륨
      • 인코딩 구성 파일 설정
      • 네트워크 품질 검사
      • 검출 능력
    • 고급 기능
      • AI 노이즈 캔슬링 활성화
      • 오디오 믹싱 활성화
      • 워터마크 활성화
      • Enable Virtual Background
      • 뷰티 및 특수효과 활성화
      • 데이터 메시지
      • 사용자 정의 수집 및 렌더링
    • 인터페이스 목록
    • 배포 설명
    • 플랫폼 지원
    • Web 관련 자주 받는 질문
      • 다중 사용자 비디오 통화 최적화
      • 자동 재생 제한 처리
      • 방화벽 제한 대응
      • 기타
  • Android
    • Run Sample Code
    • Integration
    • 통합
      • 7. 네트워크 품질 검사
      • 8. 화면 공유 활성화
      • 9. 비디오 품질 설정
      • 10. 비디오 회전
    • Advanced Features
      • 네트워크 품질 테스트
      • 사용자 정의 수집 및 렌더링
      • 사용자 정의 오디오 수집 및 재생
    • 고객 인터페이스
      • 개요
      • TRTCCloud
      • TRTCStatistics
      • TRTCCloudListener
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • 유형 정의
      • 인터페이스 폐기
      • 에러코드
    • 솔루션
      • 실시간 합창 (TUIKaraoke)
        • 빠른 통합
        • 실시 절차
        • 노래 동기화
        • 가사 동기화
        • 음성 동기화
        • 혼합 스트림 솔루션
        • TRTCKaraoke 관련 인터페이스
        • 자주 받는 질문들
    • 배포 설명
  • iOS
    • Run Sample Code
    • Integration
    • 통합
      • 7. 네트워크 품질 검사
      • 8. 화면 공유 활성화
      • 9. 비디오 품질 설정
      • 10. 비디오 회전
    • Advanced Features
      • 네트워크 품질 테스트
      • 사용자 정의 수집 및 렌더링
      • 사용자 정의 오디오 수집 및 재생
    • 고객 인터페이스
      • 개요
      • TRTCCloud
      • TRTCCloudDelegate
      • TRTCStatistics
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • 유형 정의
      • 인터페이스 폐기
      • ErrorCode
    • 솔루션
      • 빠른 통합
      • 실시 절차
      • 노래 동기화
      • 가사 동기화
      • 음성 동기화
      • 혼합 스트림 솔루션
      • TRTCKaraoke 관련 인터페이스
      • 자주 받는 질문들
    • 배포 설명
  • macOS
    • Run Sample Code
    • Integration
    • 통합
      • 7. 네트워크 품질 검사
      • 8. 화면 공유 활성화
      • 9. 컴퓨터 소리 공유
      • 10. 비디오 품질 설정
      • 11. 비디오 회전
    • Advanced Features
      • 하드웨어 장치 테스트
      • 네트워크 품질 테스트
      • 사용자 정의 수집 및 렌더링
      • 사용자 정의 오디오 수집 및 재생
    • 고객 인터페이스
      • 개요
      • TRTCCloud
      • TRTCCloudDelegate
      • TRTCStatistics
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • 유형 정의
      • 인터페이스 폐기
      • ErrorCode
      • 배포 설명
    • 배포 설명
  • Windows
    • Run Sample Code
    • Integration
    • 통합
      • 7. 네트워크 품질 검사
      • 8. 화면 공유 활성화
      • 9. 비디오 품질 설정
      • 10. 비디오 회전
    • Advanced Features
      • 하드웨어 장치 테스트
      • 네트워크 품질 테스트
      • 사용자 정의 수집 및 렌더링
      • 사용자 정의 오디오 수집 및 재생
    • 고객 인터페이스
      • 개요
      • ITRTCCloud
      • ITRTCStatistics
      • TRTCCloudCallback
      • ITXAudioEffectManager
      • ITXDeviceManager
      • 유형 정의
      • 인터페이스 폐기
      • 에러코드
    • 배포 설명
  • Electron
    • 통합
      • 1. 인터페이스 예시
      • 2. SDK 가져오기
      • 3. 룸 들어가기
      • 4. 오디오/비디오 스트림 구독
      • 5. 오디오/비디오 스트림 배포
      • 6. 룸 퇴출
      • 7. 네트워크 품질 검사
      • 8. 화면 공유 활성화
      • 9. 컴퓨터 소리 공유
      • 10. 비디오 품질 설정
      • 11. 비디오 회전
    • 고객 인터페이스
      • 개요
      • 에러코드
  • Flutter
    • 통합
      • 1. 인터페이스 예시
      • 2. SDK 가져오기
      • 3. 룸 들어가기
      • 4. 오디오/비디오 스트림 구독
      • 5. 오디오/비디오 스트림 배포
      • 6. 룸 퇴출
      • 7. 네트워크 품질 검사
      • 8. 화면 공유 활성화
      • 9. 컴퓨터 소리 공유
      • 10. 비디오 품질 설정
      • 11. 비디오 회전
    • 고객 인터페이스
      • 개요
      • 에러코드
  • Unity
    • 통합
      • 1. 인터페이스 예시
      • 2. SDK 가져오기
    • 고객 인터페이스
      • 개요
      • 에러코드
  • QT
    • 통합
      • 1. SDK 가져오기
  • 개요
    • 개요
  • 개념
  • Features
  • 성능 통계
  • 가격
    • 무료시간
    • RTC-Engine 패키지
    • 구독 패키지 기간 과금 설명
    • 종량제
      • 오디오 및 비디오 시간 과금 설명
      • 클라우드 녹화 과금 설명
      • 믹스 트랜스코딩 및 CDN 중계 과금 설명
  • 자주 받는 질문들
    • 자주 받는 질문들
    • 마이그레이션 가이드
      • Twilio Video에서 TRTC로의 마이그레이션
      • 과금
      • Features
      • UserSig
      • 방화벽 제한
      • 설치 패키지 축소 방법
      • TRTCCalling Web 관련
      • 오디오/비디오 품질
      • 기타
RTC Engine
이 페이지는 현재 영어로만 제공되며 한국어 버전은 곧 제공될 예정입니다. 기다려 주셔서 감사드립니다.

4. 오디오/비디오 스트림 구독

This document primarily elucidates the process of subscribing to the audio and video streams of other users in a room, essentially illustrating how to play others' audio and video. For the sake of convenience, throughout the remainder of this document, we will collectively refer to 'other users in the room' as 'remote users'.

Call Guidelines

Step 1. Perform prerequisite steps

Refer to the document Import SDK into the project to accomplish the import of SDK and for the configuration of App permissions.

Step 2. Set the subscription mode (optional)

You can set the subscription mode by calling setDefaultStreamRecvMode interface in TRTCCloud. TRTC provides two subscription modes:
Automatic subscription: The SDK automatically plays remote users' audios. This is the default subscription mode.
Manual subscription: The SDK does not automatically pull and play the audio of remote users. You need to manually invoke muteRemoteAudio(userId, false) to trigger the playback of the audio.
Note:
It is important to note that it's perfectly fine if you don't invoke setDefaultStreamRecvMode; by default, the SDK is set to automatic subscription. However, if manual subscription is preferred, ensure that setDefaultStreamRecvMode is invoked before entering a room as it only takes effect when done so.

Step 3. Enter a TRTC room

Follow the instructions in Entering a Room to allow a user to enter a TRTC room. The user can only subscribe to the audio or video streams of other users after successfully entering the room.

Step 4. Play the audio of a remote user

You have the option to mute or unmute a specified user by invoking the muteRemoteAudio interface.
// Mute user with id denny
trtcCloud.muteRemoteAudio('denny', true);
// Unmute user with id denny
trtcCloud.muteRemoteAudio('denny', false);

Step 5. Play the video of a remote user

1. Initiate and Terminate Playback (startRemoteView + stopRemoteView)

You are able to initiate the projection of the video image of remote users by invoking the startRemoteView API. However, the precondition is that you need to pass a view object to the SDK to serve as the rendering control for the user's video image.
The first parameter of startRemoteView is the userId of the remote user, the second is the stream type of the remote user, the third is the view object that you need to pass. Among them, the second parameter streamType has three optional values, which are:
TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG : This signifies the primary stream of the user, typically used to transmit the image from the user's camera.
TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_SUB : This represents the auxiliary stream of the user, generally used to transmit the screen sharing image of the user.
TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_SMALL : Pertaining to the user's low-resolution thumbnail image, this nomenclature is relative to the primary route image. It is only after the remote user has tacitly enabled "dual-channel encoding (enableEncSmallVideoStream)", we can then render their low-resolution image. Notwithstanding, a choice must be made between the primary route image and the low-resolution thumbnail - only one can be utilized simultaneously.
By calling the stopRemoteView interface, you can stop playing the video of a specific remote user or halt all video playbacks from remote users through the stopAllRemoteView interface.
// Rendering the video output from Denny's camera (aptly referred to by us as the "primary route image")
trtcCloud.startRemoteView('denny', TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG, cameraViewId);
// Displaying the screen that Denny shares (which we term as the "auxiliary route image")
trtcCloud.startRemoteView('denny', TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_SUB, screenViewId);
// Play back the lower quality video of `denny` (The original and lower quality streams cannot be played back at the same time)
trtcCloud.startRemoteView('denny', TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_SMALL, cameraViewId);
// Stop playing back the camera image of `denny`
trtcCloud.stopRemoteView('denny', TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG, cameraViewId);
// Stop the playback of all video footages
trtcCloud.stopAllRemoteView();

2. Set playback parameters (updateRemoteView + setRemoteRenderParams)

By invoking the updateRemoteView API, you can modify the view object while playing, which is very useful when switching video rendering controls. By using setRemoteRenderParams, you can configure the screen's fill mode, rotation angle and mirror settings.
Fill mode: You can use the fill mode or fit mode. In both modes, the original image aspect ratio is not changed. The difference is whether black bars are displayed.
Rotation angle: You can set the rotation angle to 0, 90, 180, or 270 degrees.
Mirror mode: Indicates whether to flip the image horizontally.
// Switch the primary view of `denny` to a floating mini-window (assuming the mini-window is `miniFloatingView`)
trtcCloud.updateRemoteView('denny', TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG,miniFloatingViewId);

// Rotate the primary view of the remote user `denny` 90 degrees clockwise, set it to fill mode, and forcibly disable the mirror mode
TRTCRenderParams params = TRTCRenderParams(
rotation: TRTCCloudDef.TRTC_VIDEO_ROTATION_90,
fillMode: TRTCCloudDef.TRTC_VIDEO_RENDER_MODE_FILL,
mirrorType: TRTCCloudDef.TRTC_VIDEO_MIRROR_TYPE_DISABLE);
trtcCloud.setRemoteRenderParams('denny', TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG, params);

Step 6. Get the audio/video status of a remote user in the room

In Steps 4 and 5, you can control the playback of audio and video from remote users, but without sufficient information, you would not ascertain:
What users are in the current room
Whether they have turned on their cameras and microphones?
To solve this problem, you need to listen for the following event callbacks from the SDK:
Notification of Audio Status Change(onUserAudioAvailable) You can monitor the status change when the remote user turns the microphone on or off by listening to onUserAudioAvailable(userId,bool).

Notification of Video Status Change(onUserVideoAvailable) You can monitor the status change when the remote user activates or deactivates the camera feed by listening to onUserVideoAvailable(userId,bool). You can likewise monitor the status change when the remote user enables or disables screen sharing by listening onUserSubStreamAvailable(userId,bool).

Notification of User Joining and Leaving the Room(onRemoteUserEnter/onRemoteUserLeaveRoom) When a remote user enters the current room, you can get his/her userId through onRemoteUserEnterRoom(userId). When a remote user leaves the room, you can understand the userId of this user and his/her reasons for leaving through onRemoteUserLeaveRoom(userId, reason).
Note:
To put it precisely, onRemoteUserEnter/LeaveRoom can only perceive the notification of the entry and exit of users who are cast as anchors. Such design is purposed to prevent the so-called 'signaling storm' attack caused by the frequent entry and exit of people, particularly when the online audience inside a room is quite substantial.
Note:
In Dart, we receive and process callbacks of the TRTC SDK through a method, which is categorized as ListenerValue, the parameter that needs to be inputted in registerListener. ListenerValue has two parameters, representing the callback type 'type' and 'params', the parameters of the callback returned by the SDK.
With these event webhooks, you can grasp which users are in the room as well as whether they have turned on their cameras and microphones. Refer to the example code below. In this piece of exemplary code, we have employed userList, cameraUserList, and microphoneUserList to separately maintain:
What users (anchors) are in the room
Which users have turned on their cameras
Which users have turned on their mics
onRtcListener(type, param) async {
if (type == TRTCCloudListener.onUserAudioAvailable) {
String userId = param['userId'];
bool available = param['available'];
available ? microphoneUserList.add(userId) : microphoneUserList.remove(userId);
}
if (type == TRTCCloudListener.onUserVideoAvailable) {
String userId = param['userId'];
bool available = param['available'];
available ? cameraUserList.add(userId) : cameraUserList.remove(userId);
} if (type == TRTCCloudListener.onRemoteUserEnterRoom) { userList.add({ 'userId': param }); }
if (type == TRTCCloudListener.onRemoteUserLeaveRoom) { String userId = param['userId'];
userList.removeWhere((user) => user['userId'] == userId); }
}

Advanced Guide

1. Both are "mute", what is the difference?

As your business requirements continually deepen, you will discover three distinct types of 'silence'. Although they are all termed 'silence', their counting principles are entirely distinct:
First method: The player stops Subscription to the audio stream If you call the muteRemoteAudio("denny", true) function, it indicates your desire to cease hearing the audio of remote user 'denny'. At this point, the SDK will stop fetching the data stream of denny's audio. This pattern is more bandwidth-efficient. However, should you wish to hear denny's audio again, the SDK needs to initiate the process of fetching the audio data anew. Therefore, the transition from 'mute' to 'unmute' states can be a rather slow process.
The second approach: adjust the playback volume to zero If your business scenario requires a faster response for mute switching, you can set the playback volume of the remote user 'Denny' to zero using setRemoteAudioVolume("denny", 0). Since this interface does not involve network operations, the effect is exceptionally swift.
The third case: the remote user turns off the microphone themselves All the operations introduced in this document pertain to the instruction of the playback end and their effects only apply to the current user. For instance, if you mute a remote user 'Denny' through the function muteRemoteAudio("denny", true), the voice of 'Denny' can still be heard by other users in the room. In order to effectively "silence" Denny, it would be necessary to influence Denny's audio publishing behavior. We will discuss this in detail in our following document titled Relay of audio and video streams.