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

Unified Diff: media/capture/media_video_capture_device_core.cc

Issue 1162863003: Move ContentVideoCaptureDeviceCore from src/content to src/media (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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: media/capture/media_video_capture_device_core.cc
diff --git a/content/browser/media/capture/content_video_capture_device_core.cc b/media/capture/media_video_capture_device_core.cc
similarity index 74%
rename from content/browser/media/capture/content_video_capture_device_core.cc
rename to media/capture/media_video_capture_device_core.cc
index 051aec103485388a28bfb905e14e0c96d87848c4..9576c44c1cc8ffec2296dac6e2fe721f804f5278 100644
--- a/content/browser/media/capture/content_video_capture_device_core.cc
+++ b/media/capture/media_video_capture_device_core.cc
@@ -1,8 +1,8 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
+// Copyright 2015 The Chromium Authors. All rights reserved.
miu 2015/06/05 01:13:36 nit: Please don't update the year here, since the
jiajia.qin 2015/06/08 04:58:23 Done.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/browser/media/capture/content_video_capture_device_core.h"
+#include "media/capture/media_video_capture_device_core.h"
#include "base/basictypes.h"
#include "base/bind.h"
@@ -21,7 +21,6 @@
#include "base/threading/thread_checker.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
-#include "content/public/browser/browser_thread.h"
#include "media/base/bind_to_current_loop.h"
#include "media/base/video_capture_types.h"
#include "media/base/video_frame.h"
@@ -29,22 +28,20 @@
#include "media/base/video_util.h"
#include "ui/gfx/geometry/rect.h"
-namespace content {
+namespace media {
namespace {
-void DeleteCaptureMachineOnUIThread(
+void DeleteCaptureMachine(
scoped_ptr<VideoCaptureMachine> capture_machine) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
-
capture_machine.reset();
}
} // namespace
ThreadSafeCaptureOracle::ThreadSafeCaptureOracle(
- scoped_ptr<media::VideoCaptureDevice::Client> client,
- const media::VideoCaptureParams& params)
+ scoped_ptr<VideoCaptureDevice::Client> client,
+ const VideoCaptureParams& params)
: client_(client.Pass()),
oracle_(base::TimeDelta::FromMicroseconds(
static_cast<int64>(1000000.0 / params.requested_format.frame_rate +
@@ -59,7 +56,7 @@ bool ThreadSafeCaptureOracle::ObserveEventAndDecideCapture(
VideoCaptureOracle::Event event,
const gfx::Rect& damage_rect,
base::TimeTicks event_time,
- scoped_refptr<media::VideoFrame>* storage,
+ scoped_refptr<VideoFrame>* storage,
CaptureFrameCallback* callback) {
// Grab the current time before waiting to acquire the |lock_|.
const base::TimeTicks capture_begin_time = base::TimeTicks::Now();
@@ -75,7 +72,7 @@ bool ThreadSafeCaptureOracle::ObserveEventAndDecideCapture(
const gfx::Size coded_size((visible_size.width() + 15) & ~15,
(visible_size.height() + 15) & ~15);
- scoped_ptr<media::VideoCaptureDevice::Client::Buffer> output_buffer(
+ scoped_ptr<VideoCaptureDevice::Client::Buffer> output_buffer(
client_->ReserveOutputBuffer(params_.requested_format.pixel_format,
coded_size));
const bool should_capture =
@@ -117,9 +114,9 @@ bool ThreadSafeCaptureOracle::ObserveEventAndDecideCapture(
"trigger", event_name);
// NATIVE_TEXTURE frames wrap a texture mailbox, which we don't have at the
// moment. We do not construct those frames.
- if (params_.requested_format.pixel_format != media::PIXEL_FORMAT_TEXTURE) {
- *storage = media::VideoFrame::WrapExternalData(
- media::VideoFrame::I420,
+ if (params_.requested_format.pixel_format != PIXEL_FORMAT_TEXTURE) {
+ *storage = VideoFrame::WrapExternalData(
+ VideoFrame::I420,
coded_size,
gfx::Rect(visible_size),
visible_size,
@@ -163,10 +160,10 @@ void ThreadSafeCaptureOracle::ReportError(const std::string& reason) {
void ThreadSafeCaptureOracle::DidCaptureFrame(
int frame_number,
- scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer,
+ scoped_ptr<VideoCaptureDevice::Client::Buffer> buffer,
base::TimeTicks capture_begin_time,
base::TimeDelta estimated_frame_duration,
- const scoped_refptr<media::VideoFrame>& frame,
+ const scoped_refptr<VideoFrame>& frame,
base::TimeTicks timestamp,
bool success) {
base::AutoLock guard(lock_);
@@ -181,21 +178,21 @@ void ThreadSafeCaptureOracle::DidCaptureFrame(
if (!client_)
return; // Capture is stopped.
- frame->metadata()->SetDouble(media::VideoFrameMetadata::FRAME_RATE,
+ frame->metadata()->SetDouble(VideoFrameMetadata::FRAME_RATE,
params_.requested_format.frame_rate);
frame->metadata()->SetTimeTicks(
- media::VideoFrameMetadata::CAPTURE_BEGIN_TIME, capture_begin_time);
+ VideoFrameMetadata::CAPTURE_BEGIN_TIME, capture_begin_time);
frame->metadata()->SetTimeTicks(
- media::VideoFrameMetadata::CAPTURE_END_TIME, base::TimeTicks::Now());
- frame->metadata()->SetTimeDelta(media::VideoFrameMetadata::FRAME_DURATION,
+ VideoFrameMetadata::CAPTURE_END_TIME, base::TimeTicks::Now());
+ frame->metadata()->SetTimeDelta(VideoFrameMetadata::FRAME_DURATION,
estimated_frame_duration);
client_->OnIncomingCapturedVideoFrame(buffer.Pass(), frame, timestamp);
}
}
-void ContentVideoCaptureDeviceCore::AllocateAndStart(
- const media::VideoCaptureParams& params,
- scoped_ptr<media::VideoCaptureDevice::Client> client) {
+void MediaVideoCaptureDeviceCore::AllocateAndStart(
+ const VideoCaptureParams& params,
+ scoped_ptr<VideoCaptureDevice::Client> client) {
DCHECK(thread_checker_.CalledOnValidThread());
if (state_ != kIdle) {
@@ -211,8 +208,8 @@ void ContentVideoCaptureDeviceCore::AllocateAndStart(
return;
}
- if (params.requested_format.pixel_format != media::PIXEL_FORMAT_I420 &&
- params.requested_format.pixel_format != media::PIXEL_FORMAT_TEXTURE) {
+ if (params.requested_format.pixel_format != PIXEL_FORMAT_I420 &&
+ params.requested_format.pixel_format != PIXEL_FORMAT_TEXTURE) {
std::string error_msg = base::StringPrintf(
"unsupported format: %d", params.requested_format.pixel_format);
DVLOG(1) << error_msg;
@@ -230,20 +227,15 @@ void ContentVideoCaptureDeviceCore::AllocateAndStart(
oracle_proxy_ = new ThreadSafeCaptureOracle(client.Pass(), params);
- // Starts the capture machine asynchronously.
- BrowserThread::PostTaskAndReplyWithResult(
- BrowserThread::UI,
- FROM_HERE,
- base::Bind(&VideoCaptureMachine::Start,
- base::Unretained(capture_machine_.get()),
- oracle_proxy_,
- params),
- base::Bind(&ContentVideoCaptureDeviceCore::CaptureStarted, AsWeakPtr()));
+ capture_machine_->Start(
+ oracle_proxy_,
+ params,
+ base::Bind(&MediaVideoCaptureDeviceCore::CaptureStarted, AsWeakPtr()));
TransitionStateTo(kCapturing);
}
-void ContentVideoCaptureDeviceCore::StopAndDeAllocate() {
+void MediaVideoCaptureDeviceCore::StopAndDeAllocate() {
DCHECK(thread_checker_.CalledOnValidThread());
if (state_ != kCapturing)
@@ -254,15 +246,10 @@ void ContentVideoCaptureDeviceCore::StopAndDeAllocate() {
TransitionStateTo(kIdle);
- // Stops the capture machine asynchronously.
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE, base::Bind(
- &VideoCaptureMachine::Stop,
- base::Unretained(capture_machine_.get()),
- base::Bind(&base::DoNothing)));
+ capture_machine_->Stop(base::Bind(&base::DoNothing));
}
-void ContentVideoCaptureDeviceCore::CaptureStarted(bool success) {
+void MediaVideoCaptureDeviceCore::CaptureStarted(bool success) {
DCHECK(thread_checker_.CalledOnValidThread());
if (!success) {
std::string reason("Failed to start capture machine.");
@@ -271,31 +258,26 @@ void ContentVideoCaptureDeviceCore::CaptureStarted(bool success) {
}
}
-ContentVideoCaptureDeviceCore::ContentVideoCaptureDeviceCore(
+MediaVideoCaptureDeviceCore::MediaVideoCaptureDeviceCore(
scoped_ptr<VideoCaptureMachine> capture_machine)
: state_(kIdle),
capture_machine_(capture_machine.Pass()) {
DCHECK(capture_machine_.get());
}
-ContentVideoCaptureDeviceCore::~ContentVideoCaptureDeviceCore() {
+MediaVideoCaptureDeviceCore::~MediaVideoCaptureDeviceCore() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_NE(state_, kCapturing);
// If capture_machine is not NULL, then we need to return to the UI thread to
miu 2015/06/05 01:13:36 Please remove this comment, since the posting of t
jiajia.qin 2015/06/08 04:58:24 Done.
// safely stop the capture machine.
if (capture_machine_) {
- VideoCaptureMachine* capture_machine_ptr = capture_machine_.get();
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&VideoCaptureMachine::Stop,
- base::Unretained(capture_machine_ptr),
- base::Bind(&DeleteCaptureMachineOnUIThread,
- base::Passed(&capture_machine_))));
+ capture_machine_->Stop(base::Bind(&DeleteCaptureMachine,
+ base::Passed(&capture_machine_)));
}
- DVLOG(1) << "ContentVideoCaptureDeviceCore@" << this << " destroying.";
+ DVLOG(1) << "MediaVideoCaptureDeviceCore@" << this << " destroying.";
}
-void ContentVideoCaptureDeviceCore::TransitionStateTo(State next_state) {
+void MediaVideoCaptureDeviceCore::TransitionStateTo(State next_state) {
DCHECK(thread_checker_.CalledOnValidThread());
#ifndef NDEBUG
@@ -309,7 +291,7 @@ void ContentVideoCaptureDeviceCore::TransitionStateTo(State next_state) {
state_ = next_state;
}
-void ContentVideoCaptureDeviceCore::Error(const std::string& reason) {
+void MediaVideoCaptureDeviceCore::Error(const std::string& reason) {
DCHECK(thread_checker_.CalledOnValidThread());
if (state_ == kIdle)
@@ -322,4 +304,4 @@ void ContentVideoCaptureDeviceCore::Error(const std::string& reason) {
TransitionStateTo(kError);
}
-} // namespace content
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698