iOS | Android | macOS | Windows | Electron | Chrome |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
TRTCVideoEncParam
. If TRTCVideoEncParam
is set to nil
, the SDK will use the encoding parameters set previously.Item | Parameter | Recommended Value for Regular Scenarios | Recommended Value for Text-based Teaching |
Resolution | videoResolution | 1280 × 720 | 1920 × 1080 |
Frame rate | videoFps | 10 fps | 8 fps |
Highest bitrate | videoBitrate | 1600 Kbps | 2000 Kbps |
Resolution adaption | enableAdjustRes | NO | NO |
videoBitrate
) refers to the highest output bitrate when a shared screen changes dramatically. If the shared content does not change a lot, the actual encoding bitrate will be lower.TXLiteAVSDK_ReplayKitExt.framework
from the SDK package.nil
to the API), you can still enable screen sharing, but its stability will be compromised. We suggest you configure an App Group as described below.AppGroup
value passed in to the API. Click Continue.
TXLiteAVSDK_ReplayKitExt.framework
in the SDK package into the project and select the target created.target name.entitlements
will appear in the file list as shown below. Select it, click +, and enter the App Group created earlier.
SampleHandler.h
. Replace the file content with the following code. You need to change APPGROUP
in the code to the App Group Identifier created earlier.#import "SampleHandler.h"@import TXLiteAVSDK_ReplayKitExt;#define APPGROUP @"group.com.tencent.liteav.RPLiveStreamShare"@interface SampleHandler() <TXReplayKitExtDelegate>@end@implementation SampleHandler// Note: Replace `APPGROUP` with the ID of the App Group created earlier.- (void)broadcastStartedWithSetupInfo:(NSDictionary<NSString *,NSObject *> *)setupInfo {[[TXReplayKitExt sharedInstance] setupWithAppGroup:APPGROUP delegate:self];}- (void)broadcastPaused {// User has requested to pause the broadcast. Samples will stop being delivered.}- (void)broadcastResumed {// User has requested to resume the broadcast. Samples delivery will resume.}- (void)broadcastFinished {[[TXReplayKitExt sharedInstance] finishBroadcast];// User has requested to finish the broadcast.}#pragma mark - TXReplayKitExtDelegate- (void)broadcastFinished:(TXReplayKitExt *)broadcast reason:(TXReplayKitExtReason)reason{NSString *tip = @"";switch (reason) {case TXReplayKitExtReasonRequestedByMain:tip = @"Screen sharing ended";break;case TXReplayKitExtReasonDisconnected:tip = @"Application disconnected";break;case TXReplayKitExtReasonVersionMismatch:tip = @"Integration error (SDK version mismatch)";break;}NSError *error = [NSError errorWithDomain:NSStringFromClass(self.class)code:0userInfo:@{NSLocalizedFailureReasonErrorKey:tip}];[self finishBroadcastWithError:error];}- (void)processSampleBuffer:(CMSampleBufferRef)sampleBuffer withType:(RPSampleBufferType)sampleBufferType {switch (sampleBufferType) {case RPSampleBufferTypeVideo:[[TXReplayKitExt sharedInstance] sendVideoSampleBuffer:sampleBuffer];break;case RPSampleBufferTypeAudioApp:// Handle audio sample buffer for app audiobreak;case RPSampleBufferTypeAudioMic:// Handle audio sample buffer for mic audiobreak;default:break;}}@end
TRTCCloud
; if not, call stopLocalPreview to disable it.AppGroup
set in step 1 to put the SDK on standby.// Start screen sharing. You need to replace `APPGROUP` with the ID of the App Group created earlier.- (void)startScreenCapture {TRTCVideoEncParam *videoEncConfig = [[TRTCVideoEncParam alloc] init];videoEncConfig.videoResolution = TRTCVideoResolution_1280_720;videoEncConfig.videoFps = 10;videoEncConfig.videoBitrate = 2000;// You need to replace `APPGROUP` with the App Group Identifier created earlier.[[TRTCCloud sharedInstance] startScreenCaptureByReplaykit:videoEncConfigappGroup:APPGROUP];}// Stop screen sharing- (void)stopScreenCapture {[[TRTCCloud sharedInstance] stopScreenCapture];}// Event notification for the start of screen sharing, which can be received through `TRTCCloudDelegate`- (void)onScreenCaptureStarted[self showTip:@"Screen sharing started"];}
launch
function of TRTCBroadcastExtensionLauncher
in the response function of the button to trigger screen sharing.// Customize a response for button tapping- (IBAction)onScreenButtonTapped:(id)sender {[TRTCBroadcastExtensionLauncher launch];}
RPSystemBroadcastPickerView
to iOS 12.0, which can show a picker view in apps for users to select whether to start screen sharing. Currently, RPSystemBroadcastPickerView
does not support custom UI, and Apple does not provide an official triggering method.TRTCBroadcastExtensionLauncher
works by going through the subviews of RPSystemBroadcastPickerView
, finding the UI button, and triggering its tapping event.TRTCCloudDelegate
.
Users who want to watch the shared screen can start rendering the substream of the remote user by calling the startRemoteSubStreamView API.TRTCCloudDelegate
.
Users who want to watch the shared screen can start rendering the primary stream of the remote user by calling the startRemoteView API.
Was this page helpful?