| 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" | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 24 #include "ppapi/proxy/ppapi_messages.h" | 24 #include "ppapi/proxy/ppapi_messages.h" | 
| 25 #include "ppapi/shared_impl/media_stream_buffer.h" | 25 #include "ppapi/shared_impl/media_stream_buffer.h" | 
| 26 #include "third_party/libyuv/include/libyuv.h" | 26 #include "third_party/libyuv/include/libyuv.h" | 
| 27 | 27 | 
| 28 using media::VideoFrame; | 28 using media::VideoFrame; | 
| 29 using ppapi::host::HostMessageContext; | 29 using ppapi::host::HostMessageContext; | 
| 30 using ppapi::MediaStreamVideoTrackShared; | 30 using ppapi::MediaStreamVideoTrackShared; | 
| 31 | 31 | 
| 32 namespace { | 32 namespace { | 
| 33 | 33 | 
| 34 const int32_t kDefaultNumberOfBuffers = 4; | 34 const int32_t kVideoDefaultNumberOfBuffers = 4; | 
| 35 const int32_t kMaxNumberOfBuffers = 8; | 35 const int32_t kVideoMaxNumberOfBuffers = 8; | 
| 36 // Filter mode for scaling frames. | 36 // Filter mode for scaling frames. | 
| 37 const libyuv::FilterMode kFilterMode = libyuv::kFilterBox; | 37 const libyuv::FilterMode kFilterMode = libyuv::kFilterBox; | 
| 38 | 38 | 
| 39 const char kPepperVideoSourceName[] = "PepperVideoSourceName"; | 39 const char kPepperVideoSourceName[] = "PepperVideoSourceName"; | 
| 40 | 40 | 
| 41 // Default config for output mode. | 41 // Default config for output mode. | 
| 42 const int kDefaultOutputFrameRate = 30; | 42 const int kDefaultOutputFrameRate = 30; | 
| 43 | 43 | 
| 44 media::VideoPixelFormat ToPixelFormat(PP_VideoFrame_Format format) { | 44 media::VideoPixelFormat ToPixelFormat(PP_VideoFrame_Format format) { | 
| 45   switch (format) { | 45   switch (format) { | 
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 221   new_frame_callback_.Run(frame, base::TimeTicks()); | 221   new_frame_callback_.Run(frame, base::TimeTicks()); | 
| 222 } | 222 } | 
| 223 | 223 | 
| 224 PepperMediaStreamVideoTrackHost::PepperMediaStreamVideoTrackHost( | 224 PepperMediaStreamVideoTrackHost::PepperMediaStreamVideoTrackHost( | 
| 225     RendererPpapiHost* host, | 225     RendererPpapiHost* host, | 
| 226     PP_Instance instance, | 226     PP_Instance instance, | 
| 227     PP_Resource resource, | 227     PP_Resource resource, | 
| 228     const blink::WebMediaStreamTrack& track) | 228     const blink::WebMediaStreamTrack& track) | 
| 229     : PepperMediaStreamTrackHostBase(host, instance, resource), | 229     : PepperMediaStreamTrackHostBase(host, instance, resource), | 
| 230       track_(track), | 230       track_(track), | 
| 231       number_of_buffers_(kDefaultNumberOfBuffers), | 231       number_of_buffers_(kVideoDefaultNumberOfBuffers), | 
| 232       source_frame_format_(PP_VIDEOFRAME_FORMAT_UNKNOWN), | 232       source_frame_format_(PP_VIDEOFRAME_FORMAT_UNKNOWN), | 
| 233       plugin_frame_format_(PP_VIDEOFRAME_FORMAT_UNKNOWN), | 233       plugin_frame_format_(PP_VIDEOFRAME_FORMAT_UNKNOWN), | 
| 234       frame_data_size_(0), | 234       frame_data_size_(0), | 
| 235       type_(kRead), | 235       type_(kRead), | 
| 236       weak_factory_(this) { | 236       weak_factory_(this) { | 
| 237   DCHECK(!track_.IsNull()); | 237   DCHECK(!track_.IsNull()); | 
| 238 } | 238 } | 
| 239 | 239 | 
| 240 PepperMediaStreamVideoTrackHost::PepperMediaStreamVideoTrackHost( | 240 PepperMediaStreamVideoTrackHost::PepperMediaStreamVideoTrackHost( | 
| 241     RendererPpapiHost* host, | 241     RendererPpapiHost* host, | 
| 242     PP_Instance instance, | 242     PP_Instance instance, | 
| 243     PP_Resource resource) | 243     PP_Resource resource) | 
| 244     : PepperMediaStreamTrackHostBase(host, instance, resource), | 244     : PepperMediaStreamTrackHostBase(host, instance, resource), | 
| 245       number_of_buffers_(kDefaultNumberOfBuffers), | 245       number_of_buffers_(kVideoDefaultNumberOfBuffers), | 
| 246       source_frame_format_(PP_VIDEOFRAME_FORMAT_UNKNOWN), | 246       source_frame_format_(PP_VIDEOFRAME_FORMAT_UNKNOWN), | 
| 247       plugin_frame_format_(PP_VIDEOFRAME_FORMAT_UNKNOWN), | 247       plugin_frame_format_(PP_VIDEOFRAME_FORMAT_UNKNOWN), | 
| 248       frame_data_size_(0), | 248       frame_data_size_(0), | 
| 249       type_(kWrite), | 249       type_(kWrite), | 
| 250       weak_factory_(this) { | 250       weak_factory_(this) { | 
| 251   InitBlinkTrack(); | 251   InitBlinkTrack(); | 
| 252   DCHECK(!track_.IsNull()); | 252   DCHECK(!track_.IsNull()); | 
| 253 } | 253 } | 
| 254 | 254 | 
| 255 PepperMediaStreamVideoTrackHost::~PepperMediaStreamVideoTrackHost() { | 255 PepperMediaStreamVideoTrackHost::~PepperMediaStreamVideoTrackHost() { | 
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 472 | 472 | 
| 473   bool changed = false; | 473   bool changed = false; | 
| 474   gfx::Size new_size(attributes.width, attributes.height); | 474   gfx::Size new_size(attributes.width, attributes.height); | 
| 475   if (GetTargetSize(source_frame_size_, plugin_frame_size_) != | 475   if (GetTargetSize(source_frame_size_, plugin_frame_size_) != | 
| 476       GetTargetSize(source_frame_size_, new_size)) { | 476       GetTargetSize(source_frame_size_, new_size)) { | 
| 477     changed = true; | 477     changed = true; | 
| 478   } | 478   } | 
| 479   plugin_frame_size_ = new_size; | 479   plugin_frame_size_ = new_size; | 
| 480 | 480 | 
| 481   int32_t buffers = attributes.buffers | 481   int32_t buffers = attributes.buffers | 
| 482                         ? std::min(kMaxNumberOfBuffers, attributes.buffers) | 482                         ? std::min(kVideoMaxNumberOfBuffers, attributes.buffers) | 
| 483                         : kDefaultNumberOfBuffers; | 483                         : kVideoDefaultNumberOfBuffers; | 
| 484   if (buffers != number_of_buffers_) | 484   if (buffers != number_of_buffers_) | 
| 485     changed = true; | 485     changed = true; | 
| 486   number_of_buffers_ = buffers; | 486   number_of_buffers_ = buffers; | 
| 487 | 487 | 
| 488   if (GetTargetFormat(source_frame_format_, plugin_frame_format_) != | 488   if (GetTargetFormat(source_frame_format_, plugin_frame_format_) != | 
| 489       GetTargetFormat(source_frame_format_, attributes.format)) { | 489       GetTargetFormat(source_frame_format_, attributes.format)) { | 
| 490     changed = true; | 490     changed = true; | 
| 491   } | 491   } | 
| 492   plugin_frame_format_ = attributes.format; | 492   plugin_frame_format_ = attributes.format; | 
| 493 | 493 | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 528 } | 528 } | 
| 529 | 529 | 
| 530 void PepperMediaStreamVideoTrackHost::OnTrackStarted( | 530 void PepperMediaStreamVideoTrackHost::OnTrackStarted( | 
| 531     MediaStreamSource* source, | 531     MediaStreamSource* source, | 
| 532     MediaStreamRequestResult result, | 532     MediaStreamRequestResult result, | 
| 533     const blink::WebString& result_name) { | 533     const blink::WebString& result_name) { | 
| 534   DVLOG(3) << "OnTrackStarted result: " << result; | 534   DVLOG(3) << "OnTrackStarted result: " << result; | 
| 535 } | 535 } | 
| 536 | 536 | 
| 537 }  // namespace content | 537 }  // namespace content | 
| OLD | NEW | 
|---|