| Index: content/renderer/pepper/pepper_video_capture_host.cc
|
| diff --git a/content/renderer/pepper/pepper_video_capture_host.cc b/content/renderer/pepper/pepper_video_capture_host.cc
|
| index 871b94d4eaf16521c3c8c641c459bb6a77efb6ef..acafcbe4bb23fbd1494206d2cb495bce6af2a967 100644
|
| --- a/content/renderer/pepper/pepper_video_capture_host.cc
|
| +++ b/content/renderer/pepper/pepper_video_capture_host.cc
|
| @@ -45,12 +45,9 @@
|
| PepperMediaDeviceManager::GetForRenderView(
|
| host->GetRenderViewForInstance(pp_instance())),
|
| PP_DEVICETYPE_DEV_VIDEOCAPTURE,
|
| - host->GetDocumentURL(instance)) {
|
| -}
|
| -
|
| -PepperVideoCaptureHost::~PepperVideoCaptureHost() {
|
| - Close();
|
| -}
|
| + host->GetDocumentURL(instance)) {}
|
| +
|
| +PepperVideoCaptureHost::~PepperVideoCaptureHost() { Close(); }
|
|
|
| bool PepperVideoCaptureHost::Init() {
|
| return !!renderer_ppapi_host_->GetPluginInstance(pp_instance());
|
| @@ -76,7 +73,10 @@
|
| return PP_ERROR_FAILED;
|
| }
|
|
|
| -void PepperVideoCaptureHost::OnInitialized(bool succeeded) {
|
| +void PepperVideoCaptureHost::OnInitialized(media::VideoCapture* capture,
|
| + bool succeeded) {
|
| + DCHECK(capture == platform_video_capture_.get());
|
| +
|
| if (succeeded) {
|
| open_reply_context_.params.set_result(PP_OK);
|
| } else {
|
| @@ -88,22 +88,25 @@
|
| PpapiPluginMsg_VideoCapture_OpenReply());
|
| }
|
|
|
| -void PepperVideoCaptureHost::OnStarted() {
|
| +void PepperVideoCaptureHost::OnStarted(media::VideoCapture* capture) {
|
| if (SetStatus(PP_VIDEO_CAPTURE_STATUS_STARTED, false))
|
| SendStatus();
|
| }
|
|
|
| -void PepperVideoCaptureHost::OnStopped() {
|
| +void PepperVideoCaptureHost::OnStopped(media::VideoCapture* capture) {
|
| if (SetStatus(PP_VIDEO_CAPTURE_STATUS_STOPPED, false))
|
| SendStatus();
|
| }
|
|
|
| -void PepperVideoCaptureHost::OnPaused() {
|
| +void PepperVideoCaptureHost::OnPaused(media::VideoCapture* capture) {
|
| if (SetStatus(PP_VIDEO_CAPTURE_STATUS_PAUSED, false))
|
| SendStatus();
|
| }
|
|
|
| -void PepperVideoCaptureHost::OnError() {
|
| +void PepperVideoCaptureHost::OnError(media::VideoCapture* capture,
|
| + int error_code) {
|
| + // Today, the media layer only sends "1" as an error.
|
| + DCHECK(error_code == 1);
|
| PostErrorReply();
|
| }
|
|
|
| @@ -116,13 +119,15 @@
|
| pp_resource(), PpapiPluginMsg_VideoCapture_OnError(PP_ERROR_FAILED));
|
| }
|
|
|
| +void PepperVideoCaptureHost::OnRemoved(media::VideoCapture* capture) {}
|
| +
|
| void PepperVideoCaptureHost::OnFrameReady(
|
| - const scoped_refptr<media::VideoFrame>& frame,
|
| - media::VideoCaptureFormat format) {
|
| + media::VideoCapture* capture,
|
| + const scoped_refptr<media::VideoFrame>& frame) {
|
| DCHECK(frame.get());
|
|
|
| - if (alloc_size_ != frame->coded_size() || buffers_.empty()) {
|
| - AllocBuffers(frame->coded_size(), format.frame_rate);
|
| + if (alloc_size_ != frame->coded_size()) {
|
| + AllocBuffers(frame->coded_size(), capture->CaptureFrameRate());
|
| alloc_size_ = frame->coded_size();
|
| }
|
|
|
| @@ -233,7 +238,7 @@
|
| // We couldn't allocate/map buffers at all. Send an error and stop the
|
| // capture.
|
| SetStatus(PP_VIDEO_CAPTURE_STATUS_STOPPING, true);
|
| - platform_video_capture_->StopCapture();
|
| + platform_video_capture_->StopCapture(this);
|
| PostErrorReply();
|
| return;
|
| }
|
| @@ -261,8 +266,8 @@
|
| RenderViewImpl* render_view = static_cast<RenderViewImpl*>(
|
| renderer_ppapi_host_->GetRenderViewForInstance(pp_instance()));
|
|
|
| - platform_video_capture_.reset(new PepperPlatformVideoCapture(
|
| - render_view->AsWeakPtr(), device_id, document_url, this));
|
| + platform_video_capture_ = new PepperPlatformVideoCapture(
|
| + render_view->AsWeakPtr(), device_id, document_url, this);
|
|
|
| open_reply_context_ = context->MakeReplyMessageContext();
|
|
|
| @@ -279,7 +284,7 @@
|
|
|
| // It's safe to call this regardless it's capturing or not, because
|
| // PepperPlatformVideoCapture maintains the state.
|
| - platform_video_capture_->StartCapture(video_capture_params_);
|
| + platform_video_capture_->StartCapture(this, video_capture_params_);
|
| return PP_OK;
|
| }
|
|
|
| @@ -311,7 +316,7 @@
|
| ReleaseBuffers();
|
| // It's safe to call this regardless it's capturing or not, because
|
| // PepperPlatformVideoCapture maintains the state.
|
| - platform_video_capture_->StopCapture();
|
| + platform_video_capture_->StopCapture(this);
|
| return PP_OK;
|
| }
|
|
|
| @@ -357,9 +362,9 @@
|
| }
|
|
|
| void PepperVideoCaptureHost::DetachPlatformVideoCapture() {
|
| - if (platform_video_capture_) {
|
| + if (platform_video_capture_.get()) {
|
| platform_video_capture_->DetachEventHandler();
|
| - platform_video_capture_.reset();
|
| + platform_video_capture_ = NULL;
|
| }
|
| }
|
|
|
| @@ -411,10 +416,8 @@
|
| }
|
|
|
| PepperVideoCaptureHost::BufferInfo::BufferInfo()
|
| - : in_use(false), data(NULL), buffer() {
|
| -}
|
| -
|
| -PepperVideoCaptureHost::BufferInfo::~BufferInfo() {
|
| -}
|
| + : in_use(false), data(NULL), buffer() {}
|
| +
|
| +PepperVideoCaptureHost::BufferInfo::~BufferInfo() {}
|
|
|
| } // namespace content
|
|
|