blob: d8be8ceed14e1aa85b2ca9e95e44ba00b0bea66f [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
2 * libjingle
jlmiller@webrtc.org5f93d0a2015-01-20 21:36:13 +00003 * Copyright 2013 Google Inc.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00004 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#import "RTCI420Frame.h"
29
kwiberg84cc9182016-03-11 22:12:57 -080030#include <memory>
31
kjellandera96e2d72016-02-04 23:52:28 -080032#include "webrtc/media/base/videoframe.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000033
tkchin@webrtc.org1732a592014-05-19 23:26:01 +000034@implementation RTCI420Frame {
kwiberg84cc9182016-03-11 22:12:57 -080035 std::unique_ptr<cricket::VideoFrame> _videoFrame;
tkchin@webrtc.org1732a592014-05-19 23:26:01 +000036}
37
38- (NSUInteger)width {
39 return _videoFrame->GetWidth();
40}
41
42- (NSUInteger)height {
43 return _videoFrame->GetHeight();
44}
45
46- (NSUInteger)chromaWidth {
47 return _videoFrame->GetChromaWidth();
48}
49
50- (NSUInteger)chromaHeight {
51 return _videoFrame->GetChromaHeight();
52}
53
54- (NSUInteger)chromaSize {
55 return _videoFrame->GetChromaSize();
56}
57
58- (const uint8_t*)yPlane {
magjed@webrtc.orgf09e7b82015-02-25 14:49:48 +000059 const cricket::VideoFrame* const_frame = _videoFrame.get();
60 return const_frame->GetYPlane();
tkchin@webrtc.org1732a592014-05-19 23:26:01 +000061}
62
63- (const uint8_t*)uPlane {
magjed@webrtc.orgf09e7b82015-02-25 14:49:48 +000064 const cricket::VideoFrame* const_frame = _videoFrame.get();
65 return const_frame->GetUPlane();
tkchin@webrtc.org1732a592014-05-19 23:26:01 +000066}
67
68- (const uint8_t*)vPlane {
magjed@webrtc.orgf09e7b82015-02-25 14:49:48 +000069 const cricket::VideoFrame* const_frame = _videoFrame.get();
70 return const_frame->GetVPlane();
tkchin@webrtc.org1732a592014-05-19 23:26:01 +000071}
72
73- (NSInteger)yPitch {
74 return _videoFrame->GetYPitch();
75}
76
77- (NSInteger)uPitch {
78 return _videoFrame->GetUPitch();
79}
80
81- (NSInteger)vPitch {
82 return _videoFrame->GetVPitch();
83}
84
tkchin@webrtc.org81257442014-11-04 23:06:15 +000085- (BOOL)makeExclusive {
86 return _videoFrame->MakeExclusive();
87}
88
tkchin@webrtc.org1732a592014-05-19 23:26:01 +000089@end
90
91@implementation RTCI420Frame (Internal)
92
93- (instancetype)initWithVideoFrame:(cricket::VideoFrame*)videoFrame {
94 if (self = [super init]) {
95 // Keep a shallow copy of the video frame. The underlying frame buffer is
96 // not copied.
97 _videoFrame.reset(videoFrame->Copy());
98 }
99 return self;
100}
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000101
102@end