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}
This commit is contained in:
committed by
Commit Bot
parent
a2d89fc9f5
commit
9823ee47d3
@ -8,23 +8,10 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#import "RTCVideoFrame+Private.h"
|
||||
|
||||
#import "WebRTC/RTCVideoFrame.h"
|
||||
|
||||
#import "WebRTC/RTCVideoFrameBuffer.h"
|
||||
|
||||
#include "api/video/video_frame.h"
|
||||
#include "rtc_base/timeutils.h"
|
||||
#include "sdk/objc/Framework/Native/api/video_frame_buffer.h"
|
||||
#include "sdk/objc/Framework/Native/src/objc_frame_buffer.h"
|
||||
|
||||
id<RTCVideoFrameBuffer> nativeToRtcFrameBuffer(
|
||||
const rtc::scoped_refptr<webrtc::VideoFrameBuffer> &buffer) {
|
||||
return buffer->type() == webrtc::VideoFrameBuffer::Type::kNative ?
|
||||
static_cast<webrtc::ObjCFrameBuffer *>(buffer.get())->wrapped_frame_buffer() :
|
||||
[[RTCI420Buffer alloc] initWithFrameBuffer:buffer->ToI420()];
|
||||
}
|
||||
|
||||
@implementation RTCVideoFrame {
|
||||
RTCVideoRotation _rotation;
|
||||
int64_t _timeStampNs;
|
||||
@ -94,24 +81,4 @@ id<RTCVideoFrameBuffer> nativeToRtcFrameBuffer(
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithNativeVideoFrame:(const webrtc::VideoFrame &)frame {
|
||||
if (self = [self initWithBuffer:nativeToRtcFrameBuffer(frame.video_frame_buffer())
|
||||
rotation:RTCVideoRotation(frame.rotation())
|
||||
timeStampNs:frame.timestamp_us() * rtc::kNumNanosecsPerMicrosec]) {
|
||||
self.timeStamp = frame.timestamp();
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (webrtc::VideoFrame)nativeVideoFrame {
|
||||
rtc::scoped_refptr<webrtc::VideoFrameBuffer> frameBuffer =
|
||||
webrtc::ObjCToNativeVideoFrameBuffer(self.buffer);
|
||||
webrtc::VideoFrame videoFrame(frameBuffer,
|
||||
(webrtc::VideoRotation)self.rotation,
|
||||
self.timeStampNs / rtc::kNumNanosecsPerMicrosec);
|
||||
videoFrame.set_timestamp(self.timeStamp);
|
||||
return videoFrame;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user