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/pepper/pepper_media_stream_video_track_host.h" | 5 #include "content/renderer/pepper/pepper_media_stream_video_track_host.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "content/renderer/media/media_stream_video_track.h" | 14 #include "content/renderer/media/media_stream_video_track.h" |
15 #include "media/base/bind_to_current_loop.h" | 15 #include "media/base/bind_to_current_loop.h" |
| 16 #include "media/base/video_util.h" |
16 #include "media/base/yuv_convert.h" | 17 #include "media/base/yuv_convert.h" |
17 #include "ppapi/c/pp_errors.h" | 18 #include "ppapi/c/pp_errors.h" |
18 #include "ppapi/c/ppb_media_stream_video_track.h" | 19 #include "ppapi/c/ppb_media_stream_video_track.h" |
19 #include "ppapi/c/ppb_video_frame.h" | 20 #include "ppapi/c/ppb_video_frame.h" |
20 #include "ppapi/host/dispatch_host_message.h" | 21 #include "ppapi/host/dispatch_host_message.h" |
21 #include "ppapi/host/host_message_context.h" | 22 #include "ppapi/host/host_message_context.h" |
22 #include "ppapi/proxy/ppapi_messages.h" | 23 #include "ppapi/proxy/ppapi_messages.h" |
23 #include "ppapi/shared_impl/media_stream_buffer.h" | 24 #include "ppapi/shared_impl/media_stream_buffer.h" |
24 #include "third_party/libyuv/include/libyuv.h" | 25 #include "third_party/libyuv/include/libyuv.h" |
25 | 26 |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 | 364 |
364 frame_deliverer_->DeliverVideoFrame(frame); | 365 frame_deliverer_->DeliverVideoFrame(frame); |
365 } | 366 } |
366 | 367 |
367 // Makes the frame available again for plugin. | 368 // Makes the frame available again for plugin. |
368 SendEnqueueBufferMessageToPlugin(index); | 369 SendEnqueueBufferMessageToPlugin(index); |
369 return PP_OK; | 370 return PP_OK; |
370 } | 371 } |
371 | 372 |
372 void PepperMediaStreamVideoTrackHost::OnVideoFrame( | 373 void PepperMediaStreamVideoTrackHost::OnVideoFrame( |
373 const scoped_refptr<VideoFrame>& frame, | 374 const scoped_refptr<VideoFrame>& video_frame, |
374 base::TimeTicks estimated_capture_time) { | 375 base::TimeTicks estimated_capture_time) { |
375 DCHECK(frame.get()); | 376 DCHECK(video_frame.get()); |
376 // TODO(penghuang): Check |frame->end_of_stream()| and close the track. | 377 // TODO(penghuang): Check |frame->end_of_stream()| and close the track. |
| 378 scoped_refptr<media::VideoFrame> frame = video_frame; |
| 379 // Drop alpha channel since we do not support it yet. |
| 380 if (frame->format() == media::PIXEL_FORMAT_YV12A) |
| 381 frame = media::WrapAsI420VideoFrame(video_frame); |
377 PP_VideoFrame_Format ppformat = ToPpapiFormat(frame->format()); | 382 PP_VideoFrame_Format ppformat = ToPpapiFormat(frame->format()); |
378 if (ppformat == PP_VIDEOFRAME_FORMAT_UNKNOWN) | 383 if (ppformat == PP_VIDEOFRAME_FORMAT_UNKNOWN) |
379 return; | 384 return; |
380 | 385 |
381 if (source_frame_size_.IsEmpty()) { | 386 if (source_frame_size_.IsEmpty()) { |
382 source_frame_size_ = frame->visible_rect().size(); | 387 source_frame_size_ = frame->visible_rect().size(); |
383 source_frame_format_ = ppformat; | 388 source_frame_format_ = ppformat; |
384 InitBuffers(); | 389 InitBuffers(); |
385 } | 390 } |
386 | 391 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 } | 532 } |
528 | 533 |
529 void PepperMediaStreamVideoTrackHost::OnTrackStarted( | 534 void PepperMediaStreamVideoTrackHost::OnTrackStarted( |
530 MediaStreamSource* source, | 535 MediaStreamSource* source, |
531 MediaStreamRequestResult result, | 536 MediaStreamRequestResult result, |
532 const blink::WebString& result_name) { | 537 const blink::WebString& result_name) { |
533 DVLOG(3) << "OnTrackStarted result: " << result; | 538 DVLOG(3) << "OnTrackStarted result: " << result; |
534 } | 539 } |
535 | 540 |
536 } // namespace content | 541 } // namespace content |
OLD | NEW |