Fix native api in preparation for native_api example.
Add native api conversions for video frames and video renderer. This
also requires some changes to sdk/BUILD to avoid cyclic dependencies.
Bug: webrtc:8832
Change-Id: Ibf21e63bdcae195dcb61d63f9262e6a8dc4fa790
Reviewed-on: https://webrtc-review.googlesource.com/57142
Commit-Queue: Anders Carlsson <andersc@webrtc.org>
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22340}
diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCVideoSource.mm b/sdk/objc/Framework/Classes/PeerConnection/RTCVideoSource.mm
index fccf92e..f380af4 100644
--- a/sdk/objc/Framework/Classes/PeerConnection/RTCVideoSource.mm
+++ b/sdk/objc/Framework/Classes/PeerConnection/RTCVideoSource.mm
@@ -12,16 +12,16 @@
#include "api/videosourceproxy.h"
#include "rtc_base/checks.h"
-#include "sdk/objc/Framework/Classes/Video/objcvideotracksource.h"
+#include "sdk/objc/Framework/Native/src/objc_video_track_source.h"
-static webrtc::ObjcVideoTrackSource *getObjcVideoSource(
+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());
+ return static_cast<webrtc::ObjCVideoTrackSource *>(proxy_source->internal());
}
-// TODO(magjed): Refactor this class and target ObjcVideoTrackSource only once
+// TODO(magjed): Refactor this class and target ObjCVideoTrackSource only once
// RTCAVFoundationVideoSource is gone. See http://crbug/webrtc/7177 for more
// info.
@implementation RTCVideoSource {
@@ -45,17 +45,26 @@
return nil;
}
+- (instancetype)initWithSignalingThread:(rtc::Thread *)signalingThread
+ workerThread:(rtc::Thread *)workerThread {
+ rtc::scoped_refptr<webrtc::ObjCVideoTrackSource> objCVideoTrackSource(
+ new rtc::RefCountedObject<webrtc::ObjCVideoTrackSource>());
+
+ return [self initWithNativeVideoSource:webrtc::VideoTrackSourceProxy::Create(
+ signalingThread, workerThread, objCVideoTrackSource)];
+}
+
- (NSString *)description {
NSString *stateString = [[self class] stringForState:self.state];
return [NSString stringWithFormat:@"RTCVideoSource( %p ): %@", self, stateString];
}
- (void)capturer:(RTCVideoCapturer *)capturer didCaptureVideoFrame:(RTCVideoFrame *)frame {
- getObjcVideoSource(_nativeVideoSource)->OnCapturedFrame(frame);
+ getObjCVideoSource(_nativeVideoSource)->OnCapturedFrame(frame);
}
- (void)adaptOutputFormatToWidth:(int)width height:(int)height fps:(int)fps {
- getObjcVideoSource(_nativeVideoSource)->OnOutputFormatRequest(width, height, fps);
+ getObjCVideoSource(_nativeVideoSource)->OnOutputFormatRequest(width, height, fps);
}
#pragma mark - Private