OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h" | 5 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/aligned_memory.h" | 8 #include "base/memory/aligned_memory.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "content/renderer/media/webrtc/webrtc_video_frame_adapter.h" | 10 #include "content/renderer/media/webrtc/webrtc_video_frame_adapter.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 best_format->height = desired.height; | 212 best_format->height = desired.height; |
213 best_format->fourcc = cricket::FOURCC_I420; | 213 best_format->fourcc = cricket::FOURCC_I420; |
214 best_format->interval = desired.interval; | 214 best_format->interval = desired.interval; |
215 return true; | 215 return true; |
216 } | 216 } |
217 | 217 |
218 void WebRtcVideoCapturerAdapter::OnFrameCaptured( | 218 void WebRtcVideoCapturerAdapter::OnFrameCaptured( |
219 const scoped_refptr<media::VideoFrame>& frame) { | 219 const scoped_refptr<media::VideoFrame>& frame) { |
220 DCHECK(thread_checker_.CalledOnValidThread()); | 220 DCHECK(thread_checker_.CalledOnValidThread()); |
221 TRACE_EVENT0("video", "WebRtcVideoCapturerAdapter::OnFrameCaptured"); | 221 TRACE_EVENT0("video", "WebRtcVideoCapturerAdapter::OnFrameCaptured"); |
222 if (!(frame->IsMappable() && (frame->format() == media::PIXEL_FORMAT_I420 || | 222 if (!(frame->IsMappable() && |
223 frame->format() == media::PIXEL_FORMAT_YV12))) { | 223 (frame->format() == media::PIXEL_FORMAT_I420 || |
| 224 frame->format() == media::PIXEL_FORMAT_YV12 || |
| 225 frame->format() == media::PIXEL_FORMAT_YV12A))) { |
224 // Since connecting sources and sinks do not check the format, we need to | 226 // Since connecting sources and sinks do not check the format, we need to |
225 // just ignore formats that we can not handle. | 227 // just ignore formats that we can not handle. |
226 NOTREACHED(); | 228 NOTREACHED(); |
227 return; | 229 return; |
228 } | 230 } |
229 | 231 |
| 232 // Drop alpha channel since we do not support it yet. |
| 233 if (frame->format() == media::PIXEL_FORMAT_YV12A) |
| 234 frame->DropYV12AAlphaChannel(); |
| 235 |
230 // Inject the frame via the VideoFrameFactory of base class. | 236 // Inject the frame via the VideoFrameFactory of base class. |
231 MediaVideoFrameFactory* media_video_frame_factory = | 237 MediaVideoFrameFactory* media_video_frame_factory = |
232 reinterpret_cast<MediaVideoFrameFactory*>(frame_factory()); | 238 reinterpret_cast<MediaVideoFrameFactory*>(frame_factory()); |
233 media_video_frame_factory->SetFrame(frame); | 239 media_video_frame_factory->SetFrame(frame); |
234 | 240 |
235 // This signals to libJingle that a new VideoFrame is available. | 241 // This signals to libJingle that a new VideoFrame is available. |
236 SignalFrameCaptured(this, media_video_frame_factory->GetCapturedFrame()); | 242 SignalFrameCaptured(this, media_video_frame_factory->GetCapturedFrame()); |
237 | 243 |
238 media_video_frame_factory->ReleaseFrame(); // Release the frame ASAP. | 244 media_video_frame_factory->ReleaseFrame(); // Release the frame ASAP. |
239 } | 245 } |
240 | 246 |
241 } // namespace content | 247 } // namespace content |
OLD | NEW |