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> |
| 8 |
7 #include "base/base64.h" | 9 #include "base/base64.h" |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/macros.h" |
9 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
11 #include "content/renderer/media/media_stream_video_track.h" | 14 #include "content/renderer/media/media_stream_video_track.h" |
12 #include "media/base/bind_to_current_loop.h" | 15 #include "media/base/bind_to_current_loop.h" |
13 #include "media/base/yuv_convert.h" | 16 #include "media/base/yuv_convert.h" |
14 #include "ppapi/c/pp_errors.h" | 17 #include "ppapi/c/pp_errors.h" |
15 #include "ppapi/c/ppb_media_stream_video_track.h" | 18 #include "ppapi/c/ppb_media_stream_video_track.h" |
16 #include "ppapi/c/ppb_video_frame.h" | 19 #include "ppapi/c/ppb_video_frame.h" |
17 #include "ppapi/host/dispatch_host_message.h" | 20 #include "ppapi/host/dispatch_host_message.h" |
18 #include "ppapi/host/host_message_context.h" | 21 #include "ppapi/host/host_message_context.h" |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 } | 324 } |
322 | 325 |
323 int32_t PepperMediaStreamVideoTrackHost::SendFrameToTrack(int32_t index) { | 326 int32_t PepperMediaStreamVideoTrackHost::SendFrameToTrack(int32_t index) { |
324 DCHECK_EQ(type_, kWrite); | 327 DCHECK_EQ(type_, kWrite); |
325 | 328 |
326 if (output_started_) { | 329 if (output_started_) { |
327 // Sends the frame to blink video track. | 330 // Sends the frame to blink video track. |
328 ppapi::MediaStreamBuffer::Video* pp_frame = | 331 ppapi::MediaStreamBuffer::Video* pp_frame = |
329 &(buffer_manager()->GetBufferPointer(index)->video); | 332 &(buffer_manager()->GetBufferPointer(index)->video); |
330 | 333 |
331 int32 y_stride = plugin_frame_size_.width(); | 334 int32_t y_stride = plugin_frame_size_.width(); |
332 int32 uv_stride = (plugin_frame_size_.width() + 1) / 2; | 335 int32_t uv_stride = (plugin_frame_size_.width() + 1) / 2; |
333 uint8* y_data = static_cast<uint8*>(pp_frame->data); | 336 uint8_t* y_data = static_cast<uint8_t*>(pp_frame->data); |
334 // Default to I420 | 337 // Default to I420 |
335 uint8* u_data = y_data + plugin_frame_size_.GetArea(); | 338 uint8_t* u_data = y_data + plugin_frame_size_.GetArea(); |
336 uint8* v_data = y_data + (plugin_frame_size_.GetArea() * 5 / 4); | 339 uint8_t* v_data = y_data + (plugin_frame_size_.GetArea() * 5 / 4); |
337 if (plugin_frame_format_ == PP_VIDEOFRAME_FORMAT_YV12) { | 340 if (plugin_frame_format_ == PP_VIDEOFRAME_FORMAT_YV12) { |
338 // Swap u and v for YV12. | 341 // Swap u and v for YV12. |
339 uint8* tmp = u_data; | 342 uint8_t* tmp = u_data; |
340 u_data = v_data; | 343 u_data = v_data; |
341 v_data = tmp; | 344 v_data = tmp; |
342 } | 345 } |
343 | 346 |
344 int64 ts_ms = static_cast<int64>(pp_frame->timestamp * | 347 int64_t ts_ms = static_cast<int64_t>(pp_frame->timestamp * |
345 base::Time::kMillisecondsPerSecond); | 348 base::Time::kMillisecondsPerSecond); |
346 scoped_refptr<VideoFrame> frame = media::VideoFrame::WrapExternalYuvData( | 349 scoped_refptr<VideoFrame> frame = media::VideoFrame::WrapExternalYuvData( |
347 FromPpapiFormat(plugin_frame_format_), | 350 FromPpapiFormat(plugin_frame_format_), |
348 plugin_frame_size_, | 351 plugin_frame_size_, |
349 gfx::Rect(plugin_frame_size_), | 352 gfx::Rect(plugin_frame_size_), |
350 plugin_frame_size_, | 353 plugin_frame_size_, |
351 y_stride, | 354 y_stride, |
352 uv_stride, | 355 uv_stride, |
353 uv_stride, | 356 uv_stride, |
354 y_data, | 357 y_data, |
355 u_data, | 358 u_data, |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 } | 525 } |
523 | 526 |
524 void PepperMediaStreamVideoTrackHost::OnTrackStarted( | 527 void PepperMediaStreamVideoTrackHost::OnTrackStarted( |
525 MediaStreamSource* source, | 528 MediaStreamSource* source, |
526 MediaStreamRequestResult result, | 529 MediaStreamRequestResult result, |
527 const blink::WebString& result_name) { | 530 const blink::WebString& result_name) { |
528 DVLOG(3) << "OnTrackStarted result: " << result; | 531 DVLOG(3) << "OnTrackStarted result: " << result; |
529 } | 532 } |
530 | 533 |
531 } // namespace content | 534 } // namespace content |
OLD | NEW |