#import "SampleHandler.h"
#import <VolcEngineRTCScreenCapturer/ByteRTCScreenCapturerExt.h>
@interface SampleHandler () <ByteRtcScreenCapturerExtDelegate>
@implementation SampleHandler
- (void)broadcastStartedWithSetupInfo:(NSDictionary<NSString *,NSObject *> *)setupInfo {
// 填写步骤一中创建的 App Group ID
NSString *groupId = @"xxxxxxxxx";
[[ByteRtcScreenCapturerExt shared] startWithDelegate:self groupId:groupId];
- (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 {
// User has requested to finish the broadcast.
[[ByteRtcScreenCapturerExt shared] stop];
- (void)processSampleBuffer:(CMSampleBufferRef)sampleBuffer withType:(RPSampleBufferType)sampleBufferType {
switch (sampleBufferType) {
case RPSampleBufferTypeVideo:// 采集到的屏幕视频流
case RPSampleBufferTypeAudioApp:// 采集到的设备音频流
[[ByteRtcScreenCapturerExt shared] processSampleBuffer:sampleBuffer withType:sampleBufferType];
case RPSampleBufferTypeAudioMic:
#pragma mark - ByteRtcScreenCapturerExtDelegate
// 通知 Broadcast Upload Extension 停止采集屏幕并退出。
NSLocalizedFailureReasonErrorKey : @"您停止了屏幕共享"};
NSError *error = [NSError errorWithDomain:RPRecordingErrorDomain
code:RPRecordingErrorUserDeclined
[self finishBroadcastWithError:error];