Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / libjingle / source / talk / app / webrtc / objc / RTCI420Frame.mm
index df84fc1..0b50691 100644 (file)
 
 #import "RTCI420Frame.h"
 
-@implementation RTCI420Frame
+#include "talk/media/base/videoframe.h"
+#include "webrtc/base/scoped_ptr.h"
 
-// TODO(hughv): Should this just be a cricket::VideoFrame wrapper object?
+@implementation RTCI420Frame {
+  rtc::scoped_ptr<cricket::VideoFrame> _videoFrame;
+}
+
+- (NSUInteger)width {
+  return _videoFrame->GetWidth();
+}
+
+- (NSUInteger)height {
+  return _videoFrame->GetHeight();
+}
+
+- (NSUInteger)chromaWidth {
+  return _videoFrame->GetChromaWidth();
+}
+
+- (NSUInteger)chromaHeight {
+  return _videoFrame->GetChromaHeight();
+}
+
+- (NSUInteger)chromaSize {
+  return _videoFrame->GetChromaSize();
+}
+
+- (const uint8_t*)yPlane {
+  return _videoFrame->GetYPlane();
+}
+
+- (const uint8_t*)uPlane {
+  return _videoFrame->GetUPlane();
+}
+
+- (const uint8_t*)vPlane {
+  return _videoFrame->GetVPlane();
+}
+
+- (NSInteger)yPitch {
+  return _videoFrame->GetYPitch();
+}
+
+- (NSInteger)uPitch {
+  return _videoFrame->GetUPitch();
+}
+
+- (NSInteger)vPitch {
+  return _videoFrame->GetVPitch();
+}
+
+@end
+
+@implementation RTCI420Frame (Internal)
+
+- (instancetype)initWithVideoFrame:(cricket::VideoFrame*)videoFrame {
+  if (self = [super init]) {
+    // Keep a shallow copy of the video frame. The underlying frame buffer is
+    // not copied.
+    _videoFrame.reset(videoFrame->Copy());
+  }
+  return self;
+}
 
 @end