OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 int64_t time_stamp_ns) | 62 int64_t time_stamp_ns) |
63 : video_frame_buffer_(buffer), | 63 : video_frame_buffer_(buffer), |
64 pixel_width_(1), | 64 pixel_width_(1), |
65 pixel_height_(1), | 65 pixel_height_(1), |
66 time_stamp_ns_(time_stamp_ns), | 66 time_stamp_ns_(time_stamp_ns), |
67 rotation_(webrtc::kVideoRotation_0) { | 67 rotation_(webrtc::kVideoRotation_0) { |
68 } | 68 } |
69 | 69 |
70 WebRtcVideoFrame::~WebRtcVideoFrame() {} | 70 WebRtcVideoFrame::~WebRtcVideoFrame() {} |
71 | 71 |
72 bool WebRtcVideoFrame::Init(uint32 format, | 72 bool WebRtcVideoFrame::Init(uint32_t format, |
73 int w, | 73 int w, |
74 int h, | 74 int h, |
75 int dw, | 75 int dw, |
76 int dh, | 76 int dh, |
77 uint8* sample, | 77 uint8_t* sample, |
78 size_t sample_size, | 78 size_t sample_size, |
79 size_t pixel_width, | 79 size_t pixel_width, |
80 size_t pixel_height, | 80 size_t pixel_height, |
81 int64_t time_stamp_ns, | 81 int64_t time_stamp_ns, |
82 webrtc::VideoRotation rotation) { | 82 webrtc::VideoRotation rotation) { |
83 return Reset(format, w, h, dw, dh, sample, sample_size, pixel_width, | 83 return Reset(format, w, h, dw, dh, sample, sample_size, pixel_width, |
84 pixel_height, time_stamp_ns, rotation, | 84 pixel_height, time_stamp_ns, rotation, |
85 true /*apply_rotation*/); | 85 true /*apply_rotation*/); |
86 } | 86 } |
87 | 87 |
88 bool WebRtcVideoFrame::Init(const CapturedFrame* frame, int dw, int dh, | 88 bool WebRtcVideoFrame::Init(const CapturedFrame* frame, int dw, int dh, |
89 bool apply_rotation) { | 89 bool apply_rotation) { |
90 return Reset(frame->fourcc, frame->width, frame->height, dw, dh, | 90 return Reset(frame->fourcc, frame->width, frame->height, dw, dh, |
91 static_cast<uint8*>(frame->data), frame->data_size, | 91 static_cast<uint8_t*>(frame->data), frame->data_size, |
92 frame->pixel_width, frame->pixel_height, | 92 frame->pixel_width, frame->pixel_height, frame->time_stamp, |
93 frame->time_stamp, | 93 frame->GetRotation(), apply_rotation); |
94 frame->GetRotation(), | |
95 apply_rotation); | |
96 } | 94 } |
97 | 95 |
98 bool WebRtcVideoFrame::InitToBlack(int w, int h, size_t pixel_width, | 96 bool WebRtcVideoFrame::InitToBlack(int w, int h, size_t pixel_width, |
99 size_t pixel_height, int64_t, | 97 size_t pixel_height, int64_t, |
100 int64_t time_stamp_ns) { | 98 int64_t time_stamp_ns) { |
101 return InitToBlack(w, h, pixel_width, pixel_height, time_stamp_ns); | 99 return InitToBlack(w, h, pixel_width, pixel_height, time_stamp_ns); |
102 } | 100 } |
103 | 101 |
104 bool WebRtcVideoFrame::InitToBlack(int w, int h, size_t pixel_width, | 102 bool WebRtcVideoFrame::InitToBlack(int w, int h, size_t pixel_width, |
105 size_t pixel_height, int64_t time_stamp_ns) { | 103 size_t pixel_height, int64_t time_stamp_ns) { |
106 InitToEmptyBuffer(w, h, pixel_width, pixel_height, time_stamp_ns); | 104 InitToEmptyBuffer(w, h, pixel_width, pixel_height, time_stamp_ns); |
107 return SetToBlack(); | 105 return SetToBlack(); |
108 } | 106 } |
109 | 107 |
110 size_t WebRtcVideoFrame::GetWidth() const { | 108 size_t WebRtcVideoFrame::GetWidth() const { |
111 return video_frame_buffer_ ? video_frame_buffer_->width() : 0; | 109 return video_frame_buffer_ ? video_frame_buffer_->width() : 0; |
112 } | 110 } |
113 | 111 |
114 size_t WebRtcVideoFrame::GetHeight() const { | 112 size_t WebRtcVideoFrame::GetHeight() const { |
115 return video_frame_buffer_ ? video_frame_buffer_->height() : 0; | 113 return video_frame_buffer_ ? video_frame_buffer_->height() : 0; |
116 } | 114 } |
117 | 115 |
118 const uint8* WebRtcVideoFrame::GetYPlane() const { | 116 const uint8_t* WebRtcVideoFrame::GetYPlane() const { |
119 return video_frame_buffer_ ? video_frame_buffer_->data(kYPlane) : nullptr; | 117 return video_frame_buffer_ ? video_frame_buffer_->data(kYPlane) : nullptr; |
120 } | 118 } |
121 | 119 |
122 const uint8* WebRtcVideoFrame::GetUPlane() const { | 120 const uint8_t* WebRtcVideoFrame::GetUPlane() const { |
123 return video_frame_buffer_ ? video_frame_buffer_->data(kUPlane) : nullptr; | 121 return video_frame_buffer_ ? video_frame_buffer_->data(kUPlane) : nullptr; |
124 } | 122 } |
125 | 123 |
126 const uint8* WebRtcVideoFrame::GetVPlane() const { | 124 const uint8_t* WebRtcVideoFrame::GetVPlane() const { |
127 return video_frame_buffer_ ? video_frame_buffer_->data(kVPlane) : nullptr; | 125 return video_frame_buffer_ ? video_frame_buffer_->data(kVPlane) : nullptr; |
128 } | 126 } |
129 | 127 |
130 uint8* WebRtcVideoFrame::GetYPlane() { | 128 uint8_t* WebRtcVideoFrame::GetYPlane() { |
131 return video_frame_buffer_ ? video_frame_buffer_->MutableData(kYPlane) | 129 return video_frame_buffer_ ? video_frame_buffer_->MutableData(kYPlane) |
132 : nullptr; | 130 : nullptr; |
133 } | 131 } |
134 | 132 |
135 uint8* WebRtcVideoFrame::GetUPlane() { | 133 uint8_t* WebRtcVideoFrame::GetUPlane() { |
136 return video_frame_buffer_ ? video_frame_buffer_->MutableData(kUPlane) | 134 return video_frame_buffer_ ? video_frame_buffer_->MutableData(kUPlane) |
137 : nullptr; | 135 : nullptr; |
138 } | 136 } |
139 | 137 |
140 uint8* WebRtcVideoFrame::GetVPlane() { | 138 uint8_t* WebRtcVideoFrame::GetVPlane() { |
141 return video_frame_buffer_ ? video_frame_buffer_->MutableData(kVPlane) | 139 return video_frame_buffer_ ? video_frame_buffer_->MutableData(kVPlane) |
142 : nullptr; | 140 : nullptr; |
143 } | 141 } |
144 | 142 |
145 int32 WebRtcVideoFrame::GetYPitch() const { | 143 int32_t WebRtcVideoFrame::GetYPitch() const { |
146 return video_frame_buffer_ ? video_frame_buffer_->stride(kYPlane) : 0; | 144 return video_frame_buffer_ ? video_frame_buffer_->stride(kYPlane) : 0; |
147 } | 145 } |
148 | 146 |
149 int32 WebRtcVideoFrame::GetUPitch() const { | 147 int32_t WebRtcVideoFrame::GetUPitch() const { |
150 return video_frame_buffer_ ? video_frame_buffer_->stride(kUPlane) : 0; | 148 return video_frame_buffer_ ? video_frame_buffer_->stride(kUPlane) : 0; |
151 } | 149 } |
152 | 150 |
153 int32 WebRtcVideoFrame::GetVPitch() const { | 151 int32_t WebRtcVideoFrame::GetVPitch() const { |
154 return video_frame_buffer_ ? video_frame_buffer_->stride(kVPlane) : 0; | 152 return video_frame_buffer_ ? video_frame_buffer_->stride(kVPlane) : 0; |
155 } | 153 } |
156 | 154 |
157 bool WebRtcVideoFrame::IsExclusive() const { | 155 bool WebRtcVideoFrame::IsExclusive() const { |
158 return video_frame_buffer_->HasOneRef(); | 156 return video_frame_buffer_->HasOneRef(); |
159 } | 157 } |
160 | 158 |
161 void* WebRtcVideoFrame::GetNativeHandle() const { | 159 void* WebRtcVideoFrame::GetNativeHandle() const { |
162 return video_frame_buffer_ ? video_frame_buffer_->native_handle() : nullptr; | 160 return video_frame_buffer_ ? video_frame_buffer_->native_handle() : nullptr; |
163 } | 161 } |
(...skipping 28 matching lines...) Expand all Loading... |
192 new_buffer->MutableData(kYPlane), new_buffer->MutableData(kUPlane), | 190 new_buffer->MutableData(kYPlane), new_buffer->MutableData(kUPlane), |
193 new_buffer->MutableData(kVPlane), new_buffer->stride(kYPlane), | 191 new_buffer->MutableData(kVPlane), new_buffer->stride(kYPlane), |
194 new_buffer->stride(kUPlane), new_buffer->stride(kVPlane))) { | 192 new_buffer->stride(kUPlane), new_buffer->stride(kVPlane))) { |
195 return false; | 193 return false; |
196 } | 194 } |
197 | 195 |
198 video_frame_buffer_ = new_buffer; | 196 video_frame_buffer_ = new_buffer; |
199 return true; | 197 return true; |
200 } | 198 } |
201 | 199 |
202 size_t WebRtcVideoFrame::ConvertToRgbBuffer(uint32 to_fourcc, uint8* buffer, | 200 size_t WebRtcVideoFrame::ConvertToRgbBuffer(uint32_t to_fourcc, |
203 size_t size, int stride_rgb) const { | 201 uint8_t* buffer, |
| 202 size_t size, |
| 203 int stride_rgb) const { |
204 RTC_CHECK(video_frame_buffer_); | 204 RTC_CHECK(video_frame_buffer_); |
205 RTC_CHECK(video_frame_buffer_->native_handle() == nullptr); | 205 RTC_CHECK(video_frame_buffer_->native_handle() == nullptr); |
206 return VideoFrame::ConvertToRgbBuffer(to_fourcc, buffer, size, stride_rgb); | 206 return VideoFrame::ConvertToRgbBuffer(to_fourcc, buffer, size, stride_rgb); |
207 } | 207 } |
208 | 208 |
209 bool WebRtcVideoFrame::Reset(uint32 format, | 209 bool WebRtcVideoFrame::Reset(uint32_t format, |
210 int w, | 210 int w, |
211 int h, | 211 int h, |
212 int dw, | 212 int dw, |
213 int dh, | 213 int dh, |
214 uint8* sample, | 214 uint8_t* sample, |
215 size_t sample_size, | 215 size_t sample_size, |
216 size_t pixel_width, | 216 size_t pixel_width, |
217 size_t pixel_height, | 217 size_t pixel_height, |
218 int64_t time_stamp_ns, | 218 int64_t time_stamp_ns, |
219 webrtc::VideoRotation rotation, | 219 webrtc::VideoRotation rotation, |
220 bool apply_rotation) { | 220 bool apply_rotation) { |
221 if (!Validate(format, w, h, sample, sample_size)) { | 221 if (!Validate(format, w, h, sample, sample_size)) { |
222 return false; | 222 return false; |
223 } | 223 } |
224 // Translate aliases to standard enums (e.g., IYUV -> I420). | 224 // Translate aliases to standard enums (e.g., IYUV -> I420). |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 rotated_frame_->GetUPlane(), rotated_frame_->GetUPitch(), | 320 rotated_frame_->GetUPlane(), rotated_frame_->GetUPitch(), |
321 rotated_frame_->GetVPlane(), rotated_frame_->GetVPitch(), width, height, | 321 rotated_frame_->GetVPlane(), rotated_frame_->GetVPitch(), width, height, |
322 static_cast<libyuv::RotationMode>(GetVideoRotation())); | 322 static_cast<libyuv::RotationMode>(GetVideoRotation())); |
323 if (ret == 0) { | 323 if (ret == 0) { |
324 return rotated_frame_.get(); | 324 return rotated_frame_.get(); |
325 } | 325 } |
326 return nullptr; | 326 return nullptr; |
327 } | 327 } |
328 | 328 |
329 } // namespace cricket | 329 } // namespace cricket |
OLD | NEW |