
// Set the preview mode of the local video image: Enable horizontal mirroring and set the fill mode for the video imageTRTCCloudDef.TRTCRenderParams param = new TRTCCloudDef.TRTCRenderParams();param.fillMode = TRTCCloudDef.TRTC_VIDEO_RENDER_MODE_FILL;param.mirrorType = TRTCCloudDef.TRTC_VIDEO_MIRROR_TYPE_AUTO;mCloud.setLocalRenderParams(param);// Enable local camera preview (`localCameraVideo` is the control used to render the local video image)TXCloudVideoView cameraVideo = findViewById(R.id.txcvv_main_local);mCloud.startLocalPreview(true, cameraVideo);// Use `TXDeviceManager` to enable autofocus and turn on the flashTXDeviceManager manager = mCloud.getDeviceManager();if (manager.isAutoFocusEnabled()) {manager.enableCameraAutoFocus(true);}manager.enableCameraTorch(true);
self.trtcCloud = [TRTCCloud sharedInstance];// Set the preview mode of the local video image: Enable horizontal mirroring and set the fill mode for the video imageTRTCRenderParams *param = [[TRTCRenderParams alloc] init];param.fillMode = TRTCVideoFillMode_Fill;param.mirrorType = TRTCVideoMirrorTypeAuto;[self.trtcCloud setLocalRenderParams:param];// Enable local camera preview (`localCameraVideoView` is the control used to render the local video image)[self.trtcCloud startLocalPreview:YES view:localCameraVideoView];// Use `TXDeviceManager` to enable autofocus and turn on the flashTXDeviceManager *manager = [self.trtcCloud getDeviceManager];if ([manager isAutoFocusEnabled]) {[manager enableCameraAutoFocus:YES];}[manager enableCameraTorch:YES];
self.trtcCloud = [TRTCCloud sharedInstance];// Set the preview mode of the local video image: Enable horizontal mirroring and set the fill mode for the video imageTRTCRenderParams *param = [[TRTCRenderParams alloc] init];param.fillMode = TRTCVideoFillMode_Fill;param.mirrorType = TRTCVideoMirrorTypeAuto;[self.trtcCloud setLocalRenderParams:param];// Enable local camera preview (`localCameraVideoView` is the control used to render the local video image)[self.trtcCloud startLocalPreview:localCameraVideoView];
// Set the preview mode of the local video image: Enable horizontal mirroring and set the fill mode for the video imageliteav::TRTCRenderParams render_params;render_params.mirrorType = liteav::TRTCVideoMirrorType_Enable;render_params.fillMode = TRTCVideoFillMode_Fill;trtc_cloud_->setLocalRenderParams(render_params);// Enable local camera preview (`view` is the control handle used to render the local video image)liteav::TXView local_view = (liteav::TXView)(view);trtc_cloud_->startLocalPreview(local_view);
quality parameter when calling the API to set the capturing mode. A higher quality isn't necessarily better. You need to set an appropriate quality based on your business scenario.SPEECH or MUSIC for better audio communication or music quality.// Enable mic capture and set `quality` to `SPEECH` (it has a high noise suppression and strong immunity to poor network conditions)mCloud.startLocalAudio(TRTCCloudDef.TRTC_AUDIO_QUALITY_SPEECH );// Enable mic capture and set `quality` to `MUSIC` (it captures high fidelity audio with minimum audio quality loss, and is recommended to be used with a professional sound card)mCloud.startLocalAudio(TRTCCloudDef.TRTC_AUDIO_QUALITY_MUSIC);
self.trtcCloud = [TRTCCloud sharedInstance];// Enable mic capture and set `quality` to `SPEECH` (it has a high noise suppression and strong immunity to poor network conditions)[self.trtcCloud startLocalAudio:TRTCAudioQualitySpeech];// Enable mic capture and set `quality` to `MUSIC` (it captures high fidelity audio with minimum audio quality loss, and is recommended to be used with a professional sound card)[self.trtcCloud startLocalAudio:TRTCAudioQualityMusic];
// Enable mic capture and set `quality` to `SPEECH` (it has a high noise suppression and strong immunity to poor network conditions)trtc_cloud_->startLocalAudio(TRTCAudioQualitySpeech);// Enable mic capture and set `quality` to `MUSIC` (it captures high fidelity audio with minimum audio quality loss, and is recommended to be used with a professional sound card)trtc_cloud_->startLocalAudio(TRTCAudioQualityMusic);
enterRoom), but in live streaming scenarios, you need to leave a certain amount of time for the anchor to test the mic and adjust the beauty filters; therefore, it is more common to turn on the camera and mic first and then enter a room.mCloud = TRTCCloud.sharedInstance(getApplicationContext());mCloud.setListener(mTRTCCloudListener);// Assemble TRTC room entry parameters. Replace the field values in `TRTCParams` with your own parameter values// Replace each field in TRTCParams with your own parametersTRTCCloudDef.TRTCParams param = new TRTCCloudDef.TRTCParams();params.sdkAppId = 1400000123; // Replace with your own SDKAppIDparams.userId = "denny"; // Replace with your own user IDparams.roomId = 123321; // Replace with your own room numberparams.userSig = "xxx"; // Replace with your own userSigparams.role = TRTCCloudDef.TRTCRoleAnchor;// If your scenario is live streaming, set the application scenario to `TRTC_APP_SCENE_LIVE`// If your application scenario is a group video call, use "TRTC_APP_SCENE_LIVE"mCloud.enterRoom(param, TRTCCloudDef.TRTC_APP_SCENE_LIVE);
self.trtcCloud = [TRTCCloud sharedInstance];self.trtcCloud.delegate = self;// Assemble TRTC room entry parameters. Replace the field values in `TRTCParams` with your own parameter values// Replace each field in TRTCParams with your own parametersTRTCParams *params = [[TRTCParams alloc] init];params.sdkAppId = 1400000123; // Replace with your own SDKAppIDparams.roomId = 123321; // Replace with your own room numberparams.userId = @"denny"; // Replace with your own useridparams.userSig = @"xxx"; // Replace with your own userSigparams.role = TRTCRoleAnchor;// If your scenario is live streaming, set the application scenario to `TRTC_APP_SCENE_LIVE`// If your application scenario is a group video call, use "TRTC_APP_SCENE_LIVE"[self.trtcCloud enterRoom:params appScene:TRTCAppSceneLIVE];
trtc_cloud_ = getTRTCShareInstance();// Assemble TRTC room entry parameters. Replace the field values in `TRTCParams` with your own parameter values// Replace each field in TRTCParams with your own parametersliteav::TRTCParams params;params.sdkAppId = 1400000123; // Replace with your own SDKAppIDparams.userId = "denny"; // Replace with your own user IDparams.roomId = 123321; // Replace with your own room numberparams.userSig = "xxx"; // Replace with your own userSigparams.role = TRTCCloudDef.TRTCRoleAnchor;// If your scenario is live streaming, set the application scenario to `TRTC_APP_SCENE_LIVE`// If your application scenario is a group video call, use "TRTC_APP_SCENE_LIVE"trtc_cloud_->enterRoom(params, liteav::TRTCAppSceneLIVE);
TRTC_APP_SCENE_VIDEOCALL) and audio call (TRTC_APP_SCENE_AUDIOCALL) scenarios, you don't need to set the role when entering a room, as each user is an anchor by default in these two scenarios.TRTC_APP_SCENE_LIVE) and audio live streaming (TRTC_APP_SCENE_VOICE_CHATROOM) scenarios, each user needs to set their own role to anchor or audience when entering a room.// If your current role is audience, you need to call `switchRole` first to switch to anchor// If your current role is 'audience', you need to call switchRole to switch to 'anchor' firstmCloud.switchRole(TRTCCloudDef.TRTCRoleAnchor);mCloud.startLocalAudio(TRTCCloudDef.TRTC_AUDIO_QUALITY_DEFAULT);mCloud.startLocalPreview(true, cameraVide);// If role switch failed, the error code of the `onSwitchRole` callback is not `0`// If switching operation failed, the error code of the 'onSwitchRole' is not zero@Overridepublic void onSwitchRole(final int errCode, final String errMsg) {if (errCode != 0) {Log.d(TAG, "Switching operation failed...");}}
self.trtcCloud = [TRTCCloud sharedInstance];// If your current role is audience, you need to call `switchRole` first to switch to anchor// If your current role is 'audience', you need to call switchRole to switch to 'anchor' first[self.trtcCloud switchRole:TRTCRoleAnchor];[self.trtcCloud startLocalAudio:TRTCAudioQualityDefault];[self.trtcCloud startLocalPreview:YES view:localCameraVideoView];// If role switch failed, the error code of the `onSwitchRole` callback is not `0`// If switching operation failed, the error code of the 'onSwitchRole' is not zero- (void)onSwitchRole:(TXLiteAVError)errCode errMsg:(nullable NSString *)errMsg {if (errCode != 0) {NSLog(@"Switching operation failed... ");}}
self.trtcCloud = [TRTCCloud sharedInstance];// If your current role is audience, you need to call `switchRole` first to switch to anchor// If your current role is 'audience', you need to call switchRole to switch to 'anchor' first[self.trtcCloud switchRole:TRTCRoleAnchor];[self.trtcCloud startLocalAudio:TRTCAudioQualityDefault];[self.trtcCloud startLocalPreview:localCameraVideoView];// If role switch failed, the error code of the `onSwitchRole` callback is not `0`// If switching operation failed, the error code of the 'onSwitchRole' is not zero- (void)onSwitchRole:(TXLiteAVError)errCode errMsg:(nullable NSString *)errMsg {if (errCode != 0) {NSLog(@"Switching operation failed... ");}}
// If your current role is audience, you need to call `switchRole` first to switch to anchor// If your current role is 'audience', you need to call switchRole to switch to 'anchor' firsttrtc_cloud_->switchRole(liteav::TRTCRoleAnchor);trtc_cloud_->startLocalAudio(TRTCAudioQualityDefault);trtc_cloud_->startLocalPreview(hWnd);// If role switch failed, the error code of the `onSwitchRole` callback is not `ERR_NULL` (i.e., 0)// If switching operation failed, the error code of the 'onSwitchRole' is not zerovoid onSwitchRole(TXLiteAVError errCode, const char* errMsg) {if (errCode != ERR_NULL) {printf("Switching operation failed...");}}
switchRole will fail, and TRTC will notify you of the error code through onSwitchRole. Therefore, if you no longer want to publish audio/video streams, you need to call switchRole again to switch to audience. This process is the so-called "mic-off".switchRole. When they no longer want to publish their audio/video streams (mic off), they need to be switched back to the audience role immediately.Feedback