Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1436)

Unified Diff: content/renderer/pepper/pepper_video_capture_host.cc

Issue 242013002: Refactor video capturing code in the render process (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge again and again :( Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 acafcbe4bb23fbd1494206d2cb495bce6af2a967..1141ab0926c788f1e055bb62826df1442237fc65 100644
--- a/content/renderer/pepper/pepper_video_capture_host.cc
+++ b/content/renderer/pepper/pepper_video_capture_host.cc
@@ -73,10 +73,7 @@ int32_t PepperVideoCaptureHost::OnResourceMessageReceived(
return PP_ERROR_FAILED;
}
-void PepperVideoCaptureHost::OnInitialized(media::VideoCapture* capture,
- bool succeeded) {
- DCHECK(capture == platform_video_capture_.get());
-
+void PepperVideoCaptureHost::OnInitialized(bool succeeded) {
if (succeeded) {
open_reply_context_.params.set_result(PP_OK);
} else {
@@ -88,25 +85,22 @@ void PepperVideoCaptureHost::OnInitialized(media::VideoCapture* capture,
PpapiPluginMsg_VideoCapture_OpenReply());
}
-void PepperVideoCaptureHost::OnStarted(media::VideoCapture* capture) {
+void PepperVideoCaptureHost::OnStarted() {
if (SetStatus(PP_VIDEO_CAPTURE_STATUS_STARTED, false))
SendStatus();
}
-void PepperVideoCaptureHost::OnStopped(media::VideoCapture* capture) {
+void PepperVideoCaptureHost::OnStopped() {
if (SetStatus(PP_VIDEO_CAPTURE_STATUS_STOPPED, false))
SendStatus();
}
-void PepperVideoCaptureHost::OnPaused(media::VideoCapture* capture) {
+void PepperVideoCaptureHost::OnPaused() {
if (SetStatus(PP_VIDEO_CAPTURE_STATUS_PAUSED, false))
SendStatus();
}
-void PepperVideoCaptureHost::OnError(media::VideoCapture* capture,
- int error_code) {
- // Today, the media layer only sends "1" as an error.
- DCHECK(error_code == 1);
+void PepperVideoCaptureHost::OnError() {
PostErrorReply();
}
@@ -119,15 +113,13 @@ void PepperVideoCaptureHost::PostErrorReply() {
pp_resource(), PpapiPluginMsg_VideoCapture_OnError(PP_ERROR_FAILED));
}
-void PepperVideoCaptureHost::OnRemoved(media::VideoCapture* capture) {}
-
void PepperVideoCaptureHost::OnFrameReady(
- media::VideoCapture* capture,
- const scoped_refptr<media::VideoFrame>& frame) {
+ const scoped_refptr<media::VideoFrame>& frame,
+ media::VideoCaptureFormat format) {
DCHECK(frame.get());
- if (alloc_size_ != frame->coded_size()) {
- AllocBuffers(frame->coded_size(), capture->CaptureFrameRate());
+ if (alloc_size_ != frame->coded_size() || buffers_.empty()) {
+ AllocBuffers(frame->coded_size(), format.frame_rate);
alloc_size_ = frame->coded_size();
}
@@ -238,7 +230,7 @@ void PepperVideoCaptureHost::AllocBuffers(const gfx::Size& resolution,
// 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(this);
+ platform_video_capture_->StopCapture();
PostErrorReply();
return;
}
@@ -266,8 +258,8 @@ int32_t PepperVideoCaptureHost::OnOpen(
RenderViewImpl* render_view = static_cast<RenderViewImpl*>(
renderer_ppapi_host_->GetRenderViewForInstance(pp_instance()));
- platform_video_capture_ = new PepperPlatformVideoCapture(
- render_view->AsWeakPtr(), device_id, document_url, this);
+ platform_video_capture_.reset(new PepperPlatformVideoCapture(
+ render_view->AsWeakPtr(), device_id, document_url, this));
open_reply_context_ = context->MakeReplyMessageContext();
@@ -284,7 +276,7 @@ int32_t PepperVideoCaptureHost::OnStartCapture(
// It's safe to call this regardless it's capturing or not, because
// PepperPlatformVideoCapture maintains the state.
- platform_video_capture_->StartCapture(this, video_capture_params_);
+ platform_video_capture_->StartCapture(video_capture_params_);
return PP_OK;
}
@@ -316,7 +308,7 @@ int32_t PepperVideoCaptureHost::StopCapture() {
ReleaseBuffers();
// It's safe to call this regardless it's capturing or not, because
// PepperPlatformVideoCapture maintains the state.
- platform_video_capture_->StopCapture(this);
+ platform_video_capture_->StopCapture();
return PP_OK;
}
@@ -362,9 +354,9 @@ void PepperVideoCaptureHost::SetRequestedInfo(
}
void PepperVideoCaptureHost::DetachPlatformVideoCapture() {
- if (platform_video_capture_.get()) {
+ if (platform_video_capture_) {
platform_video_capture_->DetachEventHandler();
- platform_video_capture_ = NULL;
+ platform_video_capture_.reset();
}
}

Powered by Google App Engine
This is Rietveld 408576698