Line data Source code
1 : /*
2 : * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 : *
4 : * Use of this source code is governed by a BSD-style license
5 : * that can be found in the LICENSE file in the root of the source
6 : * tree. An additional intellectual property rights grant can be found
7 : * in the file PATENTS. All contributing project authors may
8 : * be found in the AUTHORS file in the root of the source tree.
9 : */
10 : #include "webrtc/common_video/include/video_frame_buffer.h"
11 :
12 : #include <string.h>
13 :
14 : #include <algorithm>
15 :
16 : #include "webrtc/base/checks.h"
17 : #include "webrtc/base/keep_ref_until_done.h"
18 : #include "libyuv/convert.h"
19 : #include "libyuv/planar_functions.h"
20 : #include "libyuv/scale.h"
21 :
22 : namespace webrtc {
23 :
24 0 : NativeHandleBuffer::NativeHandleBuffer(void* native_handle,
25 : int width,
26 0 : int height)
27 0 : : native_handle_(native_handle), width_(width), height_(height) {
28 0 : RTC_DCHECK(native_handle != nullptr);
29 0 : RTC_DCHECK_GT(width, 0);
30 0 : RTC_DCHECK_GT(height, 0);
31 0 : }
32 :
33 0 : int NativeHandleBuffer::width() const {
34 0 : return width_;
35 : }
36 :
37 0 : int NativeHandleBuffer::height() const {
38 0 : return height_;
39 : }
40 :
41 0 : const uint8_t* NativeHandleBuffer::DataY() const {
42 0 : RTC_NOTREACHED(); // Should not be called.
43 0 : return nullptr;
44 : }
45 0 : const uint8_t* NativeHandleBuffer::DataU() const {
46 0 : RTC_NOTREACHED(); // Should not be called.
47 0 : return nullptr;
48 : }
49 0 : const uint8_t* NativeHandleBuffer::DataV() const {
50 0 : RTC_NOTREACHED(); // Should not be called.
51 0 : return nullptr;
52 : }
53 :
54 0 : int NativeHandleBuffer::StrideY() const {
55 0 : RTC_NOTREACHED(); // Should not be called.
56 0 : return 0;
57 : }
58 0 : int NativeHandleBuffer::StrideU() const {
59 0 : RTC_NOTREACHED(); // Should not be called.
60 0 : return 0;
61 : }
62 0 : int NativeHandleBuffer::StrideV() const {
63 0 : RTC_NOTREACHED(); // Should not be called.
64 0 : return 0;
65 : }
66 :
67 0 : void* NativeHandleBuffer::native_handle() const {
68 0 : return native_handle_;
69 : }
70 :
71 0 : WrappedI420Buffer::WrappedI420Buffer(int width,
72 : int height,
73 : const uint8_t* y_plane,
74 : int y_stride,
75 : const uint8_t* u_plane,
76 : int u_stride,
77 : const uint8_t* v_plane,
78 : int v_stride,
79 0 : const rtc::Callback0<void>& no_longer_used)
80 : : width_(width),
81 : height_(height),
82 : y_plane_(y_plane),
83 : u_plane_(u_plane),
84 : v_plane_(v_plane),
85 : y_stride_(y_stride),
86 : u_stride_(u_stride),
87 : v_stride_(v_stride),
88 0 : no_longer_used_cb_(no_longer_used) {
89 0 : }
90 :
91 0 : WrappedI420Buffer::~WrappedI420Buffer() {
92 0 : no_longer_used_cb_();
93 0 : }
94 :
95 0 : int WrappedI420Buffer::width() const {
96 0 : return width_;
97 : }
98 :
99 0 : int WrappedI420Buffer::height() const {
100 0 : return height_;
101 : }
102 :
103 0 : const uint8_t* WrappedI420Buffer::DataY() const {
104 0 : return y_plane_;
105 : }
106 0 : const uint8_t* WrappedI420Buffer::DataU() const {
107 0 : return u_plane_;
108 : }
109 0 : const uint8_t* WrappedI420Buffer::DataV() const {
110 0 : return v_plane_;
111 : }
112 :
113 0 : int WrappedI420Buffer::StrideY() const {
114 0 : return y_stride_;
115 : }
116 0 : int WrappedI420Buffer::StrideU() const {
117 0 : return u_stride_;
118 : }
119 0 : int WrappedI420Buffer::StrideV() const {
120 0 : return v_stride_;
121 : }
122 :
123 0 : void* WrappedI420Buffer::native_handle() const {
124 0 : return nullptr;
125 : }
126 :
127 0 : rtc::scoped_refptr<VideoFrameBuffer> WrappedI420Buffer::NativeToI420Buffer() {
128 0 : RTC_NOTREACHED();
129 0 : return nullptr;
130 : }
131 :
132 : } // namespace webrtc
|