| 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. |
| 377 PP_VideoFrame_Format ppformat = ToPpapiFormat(frame->format()); | 378 PP_VideoFrame_Format ppformat = ToPpapiFormat(video_frame->format()); |
| 379 scoped_refptr<media::VideoFrame> frame = video_frame; |
| 380 // Drop alpha channel since we do not support it yet. |
| 381 if (frame->format() == media::PIXEL_FORMAT_YV12A) |
| 382 frame = media::WrapAsI420VideoFrame(video_frame); |
| 383 |
| 378 if (ppformat == PP_VIDEOFRAME_FORMAT_UNKNOWN) | 384 if (ppformat == PP_VIDEOFRAME_FORMAT_UNKNOWN) |
| 379 return; | 385 return; |
| 380 | 386 |
| 381 if (source_frame_size_.IsEmpty()) { | 387 if (source_frame_size_.IsEmpty()) { |
| 382 source_frame_size_ = frame->visible_rect().size(); | 388 source_frame_size_ = frame->visible_rect().size(); |
| 383 source_frame_format_ = ppformat; | 389 source_frame_format_ = ppformat; |
| 384 InitBuffers(); | 390 InitBuffers(); |
| 385 } | 391 } |
| 386 | 392 |
| 387 int32_t index = buffer_manager()->DequeueBuffer(); | 393 int32_t index = buffer_manager()->DequeueBuffer(); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 } | 533 } |
| 528 | 534 |
| 529 void PepperMediaStreamVideoTrackHost::OnTrackStarted( | 535 void PepperMediaStreamVideoTrackHost::OnTrackStarted( |
| 530 MediaStreamSource* source, | 536 MediaStreamSource* source, |
| 531 MediaStreamRequestResult result, | 537 MediaStreamRequestResult result, |
| 532 const blink::WebString& result_name) { | 538 const blink::WebString& result_name) { |
| 533 DVLOG(3) << "OnTrackStarted result: " << result; | 539 DVLOG(3) << "OnTrackStarted result: " << result; |
| 534 } | 540 } |
| 535 | 541 |
| 536 } // namespace content | 542 } // namespace content |
| OLD | NEW |