diff --git a/webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory.mm b/webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory.mm index 72a97ea48c..a883587af2 100644 --- a/webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory.mm +++ b/webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory.mm @@ -23,6 +23,7 @@ #include "Video/objcvideotracksource.h" #include "VideoToolbox/videocodecfactory.h" +#include "webrtc/api/videosourceproxy.h" @implementation RTCPeerConnectionFactory { std::unique_ptr _networkThread; @@ -91,7 +92,10 @@ - (RTCVideoSource *)videoSource { rtc::scoped_refptr objcVideoTrackSource( new rtc::RefCountedObject()); - return [[RTCVideoSource alloc] initWithNativeVideoSource:objcVideoTrackSource]; + return [[RTCVideoSource alloc] + initWithNativeVideoSource:webrtc::VideoTrackSourceProxy::Create(_signalingThread.get(), + _workerThread.get(), + objcVideoTrackSource)]; } - (RTCVideoTrack *)videoTrackWithSource:(RTCVideoSource *)source diff --git a/webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCVideoSource.mm b/webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCVideoSource.mm index ef95e65ce1..cdc77b343b 100644 --- a/webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCVideoSource.mm +++ b/webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCVideoSource.mm @@ -10,9 +10,17 @@ #import "RTCVideoSource+Private.h" +#include "webrtc/api/videosourceproxy.h" #include "webrtc/base/checks.h" #include "webrtc/sdk/objc/Framework/Classes/Video/objcvideotracksource.h" +static webrtc::ObjcVideoTrackSource *getObjcVideoSource( + const rtc::scoped_refptr nativeSource) { + webrtc::VideoTrackSourceProxy *proxy_source = + static_cast(nativeSource.get()); + return static_cast(proxy_source->internal()); +} + // TODO(magjed): Refactor this class and target ObjcVideoTrackSource only once // RTCAVFoundationVideoSource is gone. See http://crbug/webrtc/7177 for more // info. @@ -43,12 +51,11 @@ } - (void)capturer:(RTCVideoCapturer *)capturer didCaptureVideoFrame:(RTCVideoFrame *)frame { - static_cast(_nativeVideoSource.get())->OnCapturedFrame(frame); + getObjcVideoSource(_nativeVideoSource)->OnCapturedFrame(frame); } - (void)adaptOutputFormatToWidth:(int)width height:(int)height fps:(int)fps { - static_cast(_nativeVideoSource.get()) - ->OnOutputFormatRequest(width, height, fps); + getObjcVideoSource(_nativeVideoSource)->OnOutputFormatRequest(width, height, fps); } #pragma mark - Private