ObjC: Marshal all VideoTrackSource methods to the signaling thread
This CL makes sure the real VideoTrackSourceInterface implementation is destroyed on the signaling thread and marshals all method calls to the signaling thread. This is done using VideoTrackSourceProxy. Bug: webrtc:7767 Change-Id: Iba3b67bb32a684ba289bc8b9981585ea58084359 Reviewed-on: https://chromium-review.googlesource.com/526634 Commit-Queue: Magnus Jedvert <magjed@webrtc.org> Reviewed-by: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#18476}
This commit is contained in:
committed by
Commit Bot
parent
5390c4814d
commit
9932e255ea
@ -23,6 +23,7 @@
|
||||
|
||||
#include "Video/objcvideotracksource.h"
|
||||
#include "VideoToolbox/videocodecfactory.h"
|
||||
#include "webrtc/api/videosourceproxy.h"
|
||||
|
||||
@implementation RTCPeerConnectionFactory {
|
||||
std::unique_ptr<rtc::Thread> _networkThread;
|
||||
@ -91,7 +92,10 @@
|
||||
- (RTCVideoSource *)videoSource {
|
||||
rtc::scoped_refptr<webrtc::ObjcVideoTrackSource> objcVideoTrackSource(
|
||||
new rtc::RefCountedObject<webrtc::ObjcVideoTrackSource>());
|
||||
return [[RTCVideoSource alloc] initWithNativeVideoSource:objcVideoTrackSource];
|
||||
return [[RTCVideoSource alloc]
|
||||
initWithNativeVideoSource:webrtc::VideoTrackSourceProxy::Create(_signalingThread.get(),
|
||||
_workerThread.get(),
|
||||
objcVideoTrackSource)];
|
||||
}
|
||||
|
||||
- (RTCVideoTrack *)videoTrackWithSource:(RTCVideoSource *)source
|
||||
|
||||
@ -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<webrtc::VideoTrackSourceInterface> nativeSource) {
|
||||
webrtc::VideoTrackSourceProxy *proxy_source =
|
||||
static_cast<webrtc::VideoTrackSourceProxy *>(nativeSource.get());
|
||||
return static_cast<webrtc::ObjcVideoTrackSource *>(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<webrtc::ObjcVideoTrackSource *>(_nativeVideoSource.get())->OnCapturedFrame(frame);
|
||||
getObjcVideoSource(_nativeVideoSource)->OnCapturedFrame(frame);
|
||||
}
|
||||
|
||||
- (void)adaptOutputFormatToWidth:(int)width height:(int)height fps:(int)fps {
|
||||
static_cast<webrtc::ObjcVideoTrackSource *>(_nativeVideoSource.get())
|
||||
->OnOutputFormatRequest(width, height, fps);
|
||||
getObjcVideoSource(_nativeVideoSource)->OnOutputFormatRequest(width, height, fps);
|
||||
}
|
||||
|
||||
#pragma mark - Private
|
||||
|
||||
Reference in New Issue
Block a user