在更新了最新版本的webrtc框架后,我没有得到如何向用户显示本地流的原因方法已更改,该版本在存储库的“iOS”文件夹中没有样本。
旧代码中的......
RTCVideoCapturer *capturer = [RTCVideoCapturer capturerWithDeviceName:cameraID];
RTCMediaConstraints *mediaConstraints = [self defaultMediaStreamConstraints];
RTCVideoSource *videoSource = [_factory videoSourceWithCapturer:capturer constraints:mediaConstraints];
localVideoTrack = [_factory videoTrackWithID:@"ARDAMSv0" source:videoSource];
RTCVideoCapturer对象和RTCVideoSource对象在这里相互链接。
但是在新代码中......
RTCVideoSource *source = [_factory videoSource];
RTCCameraVideoCapturer *capturer = [[RTCCameraVideoCapturer alloc] initWithDelegate:source];
[_delegate appClient:self didCreateLocalCapturer:capturer];
localVideoTrack = [_factory videoTrackWithSource:source
trackId:kARDVideoTrackId];
彼此没有联系。 那么,委托方法做了什么, [_delegate appClient:self didCreateLocalCapturer:capturer]; 我没有得到它。 [需要帮助!]
答案 0 :(得分:3)
在视频通话视图控制器中实现此委托方法....
- (void)appClient:(ARDAppClient *)client didCreateLocalCapturer:(RTCCameraVideoCapturer *)localCapturer{
NSLog(@"%s %@",__PRETTY_FUNCTION__ ,localCapturer);
_captureController = [[ARDCaptureController alloc] initWithCapturer:localCapturer
settings:[[ARDSettingsModel alloc] init]];
[_captureController startCapture];
}
然后....这个方法调用它来创建相同的......
- (RTCVideoTrack *)createLocalVideoTrack {
RTCVideoTrack* localVideoTrack = nil;
// The iOS simulator doesn't provide any sort of camera capture
// trying to open a local stream.
#if !TARGET_IPHONE_SIMULATOR
if (![_settings currentAudioOnlySettingFromStore]) {
RTCVideoSource *source = [_factory videoSource];
RTCCameraVideoCapturer *capturer = [[RTCCameraVideoCapturer alloc] initWithDelegate:source];
[_delegate appClient:self didCreateLocalCapturer:capturer];
localVideoTrack = [_factory videoTrackWithSource:source
trackId:kARDVideoTrackId];
[_delegate appClient:self didReceiveLocalVideoTrack:localVideoTrack];
}
然后致电......
_localVideoTrack = [self createLocalVideoTrack];
你的init方法中的......
- (void)initCall {
NSLog(@"%s",__PRETTY_FUNCTION__);
if (!_isTurnComplete) {
return;
}
self.state = kARDAppClientStateConnected;
_localVideoTrack = [self createLocalVideoTrack];
// Create peer connection.
_constraints = [self defaultPeerConnectionConstraints];
}
这段代码让我能够实现这个目标!