Commit a4b93b7a authored by Xiangjun Zhang's avatar Xiangjun Zhang Committed by Commit Bot

Move video_capture.mojom out of content.

This is a prerequisite for the coming mirroring service CLs to not
depend on content. Moved the interfaces to media/capture/mojo/. No
functional change.

Bug: 734672
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel
Change-Id: Ie7a1d618920860cba08f1708f6cd9486db0b4956
Reviewed-on: https://chromium-review.googlesource.com/872101Reviewed-by: default avatarNasko Oskov <nasko@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarYuri Wiitala <miu@chromium.org>
Reviewed-by: default avatarChristian Fremerey <chfremer@chromium.org>
Commit-Queue: Xiangjun Zhang <xjz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#531379}
parent 862205e2
......@@ -99,7 +99,6 @@ jumbo_source_set("browser") {
"//media",
"//media:media_features",
"//media/capture",
"//media/capture/mojo:image_capture",
"//media/midi",
"//media/midi:mojo",
"//media/mojo:features",
......
......@@ -19,10 +19,10 @@
#include "components/viz/common/gl_helper.h"
#include "content/browser/renderer_host/media/media_stream_manager.h"
#include "content/browser/renderer_host/media/video_capture_manager.h"
#include "content/common/video_capture.mojom.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/content_switches.h"
#include "media/base/video_frame.h"
#include "media/capture/mojo/video_capture_types.mojom.h"
#include "media/capture/video/video_capture_buffer_pool.h"
#include "media/capture/video/video_capture_buffer_tracker_factory_impl.h"
#include "media/capture/video/video_capture_device_client.h"
......
......@@ -9,7 +9,7 @@
#include "base/memory/shared_memory.h"
#include "content/common/content_export.h"
#include "content/common/video_capture.mojom.h"
#include "media/capture/mojo/video_capture_types.mojom.h"
#include "mojo/public/cpp/system/buffer.h"
#include "ui/gfx/geometry/size.h"
......
......@@ -75,7 +75,7 @@ VideoCaptureHost::VideoCaptureHost(
// static
void VideoCaptureHost::Create(uint32_t render_process_id,
MediaStreamManager* media_stream_manager,
mojom::VideoCaptureHostRequest request) {
media::mojom::VideoCaptureHostRequest request) {
DVLOG(1) << __func__;
DCHECK_CURRENTLY_ON(BrowserThread::IO);
mojo::MakeStrongBinding(std::make_unique<VideoCaptureHost>(
......@@ -170,7 +170,7 @@ void VideoCaptureHost::OnStarted(VideoCaptureControllerID controller_id) {
if (base::ContainsKey(device_id_to_observer_map_, controller_id)) {
device_id_to_observer_map_[controller_id]->OnStateChanged(
mojom::VideoCaptureState::STARTED);
media::mojom::VideoCaptureState::STARTED);
NotifyStreamAdded();
}
}
......@@ -180,7 +180,7 @@ void VideoCaptureHost::OnStartedUsingGpuDecode(VideoCaptureControllerID id) {}
void VideoCaptureHost::Start(int32_t device_id,
int32_t session_id,
const media::VideoCaptureParams& params,
mojom::VideoCaptureObserverPtr observer) {
media::mojom::VideoCaptureObserverPtr observer) {
DVLOG(1) << __func__ << " session_id=" << session_id
<< ", device_id=" << device_id << ", format="
<< media::VideoCaptureFormat::ToString(params.requested_format);
......@@ -192,7 +192,7 @@ void VideoCaptureHost::Start(int32_t device_id,
const VideoCaptureControllerID controller_id(device_id);
if (controllers_.find(controller_id) != controllers_.end()) {
device_id_to_observer_map_[device_id]->OnStateChanged(
mojom::VideoCaptureState::STARTED);
media::mojom::VideoCaptureState::STARTED);
NotifyStreamAdded();
return;
}
......@@ -212,7 +212,7 @@ void VideoCaptureHost::Stop(int32_t device_id) {
if (base::ContainsKey(device_id_to_observer_map_, device_id)) {
device_id_to_observer_map_[device_id]->OnStateChanged(
mojom::VideoCaptureState::STOPPED);
media::mojom::VideoCaptureState::STOPPED);
}
device_id_to_observer_map_.erase(controller_id);
......@@ -233,7 +233,7 @@ void VideoCaptureHost::Pause(int32_t device_id) {
it->second.get(), controller_id, this);
if (base::ContainsKey(device_id_to_observer_map_, device_id)) {
device_id_to_observer_map_[device_id]->OnStateChanged(
mojom::VideoCaptureState::PAUSED);
media::mojom::VideoCaptureState::PAUSED);
}
}
......@@ -252,7 +252,7 @@ void VideoCaptureHost::Resume(int32_t device_id,
session_id, params, it->second.get(), controller_id, this);
if (base::ContainsKey(device_id_to_observer_map_, device_id)) {
device_id_to_observer_map_[device_id]->OnStateChanged(
mojom::VideoCaptureState::RESUMED);
media::mojom::VideoCaptureState::RESUMED);
}
}
......@@ -324,7 +324,7 @@ void VideoCaptureHost::DoError(VideoCaptureControllerID controller_id) {
if (base::ContainsKey(device_id_to_observer_map_, controller_id)) {
device_id_to_observer_map_[controller_id]->OnStateChanged(
mojom::VideoCaptureState::FAILED);
media::mojom::VideoCaptureState::FAILED);
}
DeleteVideoCaptureController(controller_id, true);
......@@ -339,7 +339,7 @@ void VideoCaptureHost::DoEnded(VideoCaptureControllerID controller_id) {
if (base::ContainsKey(device_id_to_observer_map_, controller_id)) {
device_id_to_observer_map_[controller_id]->OnStateChanged(
mojom::VideoCaptureState::ENDED);
media::mojom::VideoCaptureState::ENDED);
}
DeleteVideoCaptureController(controller_id, false);
......@@ -363,7 +363,7 @@ void VideoCaptureHost::OnControllerAdded(
if (!controller) {
if (base::ContainsKey(device_id_to_observer_map_, controller_id)) {
device_id_to_observer_map_[device_id]->OnStateChanged(
mojom::VideoCaptureState::FAILED);
media::mojom::VideoCaptureState::FAILED);
}
controllers_.erase(controller_id);
return;
......
......@@ -14,7 +14,7 @@
#include "content/browser/renderer_host/media/video_capture_controller.h"
#include "content/browser/renderer_host/media/video_capture_controller_event_handler.h"
#include "content/common/content_export.h"
#include "content/common/video_capture.mojom.h"
#include "media/capture/mojo/video_capture.mojom.h"
namespace content {
class MediaStreamManager;
......@@ -26,7 +26,7 @@ class MediaStreamManager;
// unique |device_id|, and is paired with a single VideoCaptureController.
class CONTENT_EXPORT VideoCaptureHost
: public VideoCaptureControllerEventHandler,
public mojom::VideoCaptureHost {
public media::mojom::VideoCaptureHost {
public:
VideoCaptureHost(uint32_t render_process_id,
MediaStreamManager* media_stream_manager);
......@@ -37,7 +37,7 @@ class CONTENT_EXPORT VideoCaptureHost
static void Create(uint32_t render_process_id,
MediaStreamManager* media_stream_manager,
mojom::VideoCaptureHostRequest request);
media::mojom::VideoCaptureHostRequest request);
// Interface for notifying RenderProcessHost instance about active video
// capture stream changes.
......@@ -68,11 +68,11 @@ class CONTENT_EXPORT VideoCaptureHost
void OnStarted(VideoCaptureControllerID id) override;
void OnStartedUsingGpuDecode(VideoCaptureControllerID id) override;
// mojom::VideoCaptureHost implementation
// media::mojom::VideoCaptureHost implementation
void Start(int32_t device_id,
int32_t session_id,
const media::VideoCaptureParams& params,
mojom::VideoCaptureObserverPtr observer) override;
media::mojom::VideoCaptureObserverPtr observer) override;
void Stop(int32_t device_id) override;
void Pause(int32_t device_id) override;
void Resume(int32_t device_id,
......@@ -122,7 +122,8 @@ class CONTENT_EXPORT VideoCaptureHost
// VideoCaptureObservers map, each one is used and should be valid between
// Start() and the corresponding Stop().
std::map<int32_t, mojom::VideoCaptureObserverPtr> device_id_to_observer_map_;
std::map<int32_t, media::mojom::VideoCaptureObserverPtr>
device_id_to_observer_map_;
base::WeakPtrFactory<VideoCaptureHost> weak_factory_;
......
......@@ -86,7 +86,7 @@ class MockRenderProcessHostDelegate
// MediaStreamManager, VideoCaptureManager, VideoCaptureController, and
// VideoCaptureDevice.
class VideoCaptureTest : public testing::Test,
public mojom::VideoCaptureObserver {
public media::mojom::VideoCaptureObserver {
public:
VideoCaptureTest()
: thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
......@@ -175,8 +175,8 @@ class VideoCaptureTest : public testing::Test,
}
protected:
// mojom::VideoCaptureObserver implementation.
MOCK_METHOD1(OnStateChanged, void(mojom::VideoCaptureState));
// media::mojom::VideoCaptureObserver implementation.
MOCK_METHOD1(OnStateChanged, void(media::mojom::VideoCaptureState));
void OnBufferCreated(int32_t buffer_id,
mojo::ScopedSharedBufferHandle handle) override {
DoOnBufferCreated(buffer_id);
......@@ -195,7 +195,8 @@ class VideoCaptureTest : public testing::Test,
params.requested_format = media::VideoCaptureFormat(
gfx::Size(352, 288), 30, media::PIXEL_FORMAT_I420);
EXPECT_CALL(*this, OnStateChanged(mojom::VideoCaptureState::STARTED));
EXPECT_CALL(*this,
OnStateChanged(media::mojom::VideoCaptureState::STARTED));
EXPECT_CALL(*this, DoOnBufferCreated(_))
.Times(AnyNumber())
.WillRepeatedly(Return());
......@@ -203,7 +204,7 @@ class VideoCaptureTest : public testing::Test,
.Times(AnyNumber())
.WillRepeatedly(ExitMessageLoop(task_runner_, run_loop.QuitClosure()));
mojom::VideoCaptureObserverPtr observer;
media::mojom::VideoCaptureObserverPtr observer;
observer_binding_.Bind(mojo::MakeRequest(&observer));
host_->Start(kDeviceId, opened_session_id_, params, std::move(observer));
......@@ -222,13 +223,14 @@ class VideoCaptureTest : public testing::Test,
// |STARTED| is reported asynchronously, which may not be received if
// capture is stopped immediately.
EXPECT_CALL(*this, OnStateChanged(mojom::VideoCaptureState::STARTED))
EXPECT_CALL(*this, OnStateChanged(media::mojom::VideoCaptureState::STARTED))
.Times(AtMost(1));
mojom::VideoCaptureObserverPtr observer;
media::mojom::VideoCaptureObserverPtr observer;
observer_binding_.Bind(mojo::MakeRequest(&observer));
host_->Start(kDeviceId, opened_session_id_, params, std::move(observer));
EXPECT_CALL(*this, OnStateChanged(mojom::VideoCaptureState::STOPPED));
EXPECT_CALL(*this,
OnStateChanged(media::mojom::VideoCaptureState::STOPPED));
host_->Stop(kDeviceId);
run_loop.RunUntilIdle();
}
......@@ -237,14 +239,15 @@ class VideoCaptureTest : public testing::Test,
InSequence s;
base::RunLoop run_loop;
EXPECT_CALL(*this, OnStateChanged(mojom::VideoCaptureState::PAUSED));
EXPECT_CALL(*this, OnStateChanged(media::mojom::VideoCaptureState::PAUSED));
host_->Pause(kDeviceId);
media::VideoCaptureParams params;
params.requested_format = media::VideoCaptureFormat(
gfx::Size(352, 288), 30, media::PIXEL_FORMAT_I420);
EXPECT_CALL(*this, OnStateChanged(mojom::VideoCaptureState::RESUMED));
EXPECT_CALL(*this,
OnStateChanged(media::mojom::VideoCaptureState::RESUMED));
host_->Resume(kDeviceId, opened_session_id_, params);
run_loop.RunUntilIdle();
}
......@@ -252,7 +255,7 @@ class VideoCaptureTest : public testing::Test,
void StopCapture() {
base::RunLoop run_loop;
EXPECT_CALL(*this, OnStateChanged(mojom::VideoCaptureState::STOPPED))
EXPECT_CALL(*this, OnStateChanged(media::mojom::VideoCaptureState::STOPPED))
.WillOnce(ExitMessageLoop(task_runner_, run_loop.QuitClosure()));
host_->Stop(kDeviceId);
......@@ -272,7 +275,7 @@ class VideoCaptureTest : public testing::Test,
}
void SimulateError() {
EXPECT_CALL(*this, OnStateChanged(mojom::VideoCaptureState::FAILED));
EXPECT_CALL(*this, OnStateChanged(media::mojom::VideoCaptureState::FAILED));
VideoCaptureControllerID id(kDeviceId);
host_->OnError(id);
base::RunLoop().RunUntilIdle();
......@@ -308,7 +311,7 @@ class VideoCaptureTest : public testing::Test,
std::string opened_device_label_;
std::unique_ptr<VideoCaptureHost> host_;
mojo::Binding<mojom::VideoCaptureObserver> observer_binding_;
mojo::Binding<media::mojom::VideoCaptureObserver> observer_binding_;
DISALLOW_COPY_AND_ASSIGN(VideoCaptureTest);
};
......@@ -334,7 +337,7 @@ TEST_F(VideoCaptureTest, StartAndErrorAndStop) {
}
TEST_F(VideoCaptureTest, StartAndCaptureAndError) {
EXPECT_CALL(*this, OnStateChanged(mojom::VideoCaptureState::STOPPED))
EXPECT_CALL(*this, OnStateChanged(media::mojom::VideoCaptureState::STOPPED))
.Times(0);
StartCapture();
WaitForOneCapturedBuffer();
......@@ -353,7 +356,7 @@ TEST_F(VideoCaptureTest, CloseSessionWithoutStopping) {
// When the session is closed via the stream without stopping capture, the
// ENDED event is sent.
EXPECT_CALL(*this, OnStateChanged(mojom::VideoCaptureState::ENDED));
EXPECT_CALL(*this, OnStateChanged(media::mojom::VideoCaptureState::ENDED));
CloseSession();
base::RunLoop().RunUntilIdle();
}
......
......@@ -576,7 +576,6 @@ mojom("mojo_bindings") {
"shared_worker/shared_worker_info.mojom",
"storage_partition_service.mojom",
"url_loader_factory_bundle.mojom",
"video_capture.mojom",
"widget.mojom",
]
......@@ -593,7 +592,6 @@ mojom("mojo_bindings") {
"//components/leveldb/public/interfaces",
"//content/public/common:interfaces",
"//ipc:mojom_constants",
"//media/capture/mojo:capture_types",
"//media/mojo/interfaces",
"//mojo/common:common_custom_types",
"//services/network/public/interfaces",
......
......@@ -49,13 +49,13 @@
"content::mojom::ReportingServiceProxy",
"content::mojom::ServiceWorkerDispatcherHost",
"content::mojom::StoragePartitionService",
"content::mojom::VideoCaptureHost",
"content::mojom::WorkerURLLoaderFactoryProvider",
"device::mojom::BatteryMonitor",
"device::mojom::GamepadHapticsManager",
"device::mojom::GamepadMonitor",
"discardable_memory::mojom::DiscardableSharedMemoryManager",
"media::mojom::KeySystemSupport",
"media::mojom::VideoCaptureHost",
"media::mojom::VideoDecodePerfHistory",
"memory_coordinator::mojom::MemoryCoordinatorHandle",
"metrics::mojom::SingleSampleMetricsProvider",
......
......@@ -75,7 +75,7 @@ VideoCaptureImpl::VideoCaptureImpl(media::VideoCaptureSessionId session_id)
io_thread_checker_.DetachFromThread();
if (ChildThread::Get()) { // This will be null in unit tests.
mojom::VideoCaptureHostPtr temp_video_capture_host;
media::mojom::VideoCaptureHostPtr temp_video_capture_host;
ChildThread::Get()->GetConnector()->BindInterface(
mojom::kBrowserServiceName,
mojo::MakeRequest(&temp_video_capture_host));
......@@ -189,12 +189,12 @@ void VideoCaptureImpl::GetDeviceFormatsInUse(
weak_factory_.GetWeakPtr(), callback));
}
void VideoCaptureImpl::OnStateChanged(mojom::VideoCaptureState state) {
void VideoCaptureImpl::OnStateChanged(media::mojom::VideoCaptureState state) {
DVLOG(1) << __func__ << " state: " << state;
DCHECK(io_thread_checker_.CalledOnValidThread());
switch (state) {
case mojom::VideoCaptureState::STARTED:
case media::mojom::VideoCaptureState::STARTED:
state_ = VIDEO_CAPTURE_STATE_STARTED;
for (const auto& client : clients_)
client.second.state_update_cb.Run(VIDEO_CAPTURE_STATE_STARTED);
......@@ -203,28 +203,28 @@ void VideoCaptureImpl::OnStateChanged(mojom::VideoCaptureState state) {
// Capture device will make a decision if it should refresh a frame.
RequestRefreshFrame();
break;
case mojom::VideoCaptureState::STOPPED:
case media::mojom::VideoCaptureState::STOPPED:
state_ = VIDEO_CAPTURE_STATE_STOPPED;
client_buffers_.clear();
weak_factory_.InvalidateWeakPtrs();
if (!clients_.empty() || !clients_pending_on_restart_.empty())
RestartCapture();
break;
case mojom::VideoCaptureState::PAUSED:
case media::mojom::VideoCaptureState::PAUSED:
for (const auto& client : clients_)
client.second.state_update_cb.Run(VIDEO_CAPTURE_STATE_PAUSED);
break;
case mojom::VideoCaptureState::RESUMED:
case media::mojom::VideoCaptureState::RESUMED:
for (const auto& client : clients_)
client.second.state_update_cb.Run(VIDEO_CAPTURE_STATE_RESUMED);
break;
case mojom::VideoCaptureState::FAILED:
case media::mojom::VideoCaptureState::FAILED:
for (const auto& client : clients_)
client.second.state_update_cb.Run(VIDEO_CAPTURE_STATE_ERROR);
clients_.clear();
state_ = VIDEO_CAPTURE_STATE_ERROR;
break;
case mojom::VideoCaptureState::ENDED:
case media::mojom::VideoCaptureState::ENDED:
// We'll only notify the client that the stream has stopped.
for (const auto& client : clients_)
client.second.state_update_cb.Run(VIDEO_CAPTURE_STATE_STOPPED);
......@@ -414,7 +414,7 @@ void VideoCaptureImpl::StartCaptureInternal() {
DCHECK(io_thread_checker_.CalledOnValidThread());
state_ = VIDEO_CAPTURE_STATE_STARTING;
mojom::VideoCaptureObserverPtr observer;
media::mojom::VideoCaptureObserverPtr observer;
observer_binding_.Bind(mojo::MakeRequest(&observer));
GetVideoCaptureHost()->Start(device_id_, session_id_, params_,
std::move(observer));
......@@ -446,7 +446,7 @@ bool VideoCaptureImpl::RemoveClient(int client_id, ClientInfoMap* clients) {
return true;
}
mojom::VideoCaptureHost* VideoCaptureImpl::GetVideoCaptureHost() {
media::mojom::VideoCaptureHost* VideoCaptureImpl::GetVideoCaptureHost() {
DCHECK(io_thread_checker_.CalledOnValidThread());
if (video_capture_host_for_testing_)
return video_capture_host_for_testing_;
......
......@@ -15,8 +15,8 @@
#include "base/threading/thread_checker.h"
#include "content/common/content_export.h"
#include "content/common/media/video_capture.h"
#include "content/common/video_capture.mojom.h"
#include "media/base/video_frame.h"
#include "media/capture/mojo/video_capture.mojom.h"
#include "media/capture/video_capture_types.h"
#include "mojo/public/cpp/bindings/binding.h"
......@@ -27,7 +27,8 @@ namespace content {
// communicates back to these clients e.g. the capture state or incoming
// captured VideoFrames. VideoCaptureImpl is created in the main Renderer thread
// but otherwise operates on |io_task_runner_|, which is usually the IO thread.
class CONTENT_EXPORT VideoCaptureImpl : public mojom::VideoCaptureObserver {
class CONTENT_EXPORT VideoCaptureImpl
: public media::mojom::VideoCaptureObserver {
public:
explicit VideoCaptureImpl(media::VideoCaptureSessionId session_id);
~VideoCaptureImpl() override;
......@@ -62,12 +63,12 @@ class CONTENT_EXPORT VideoCaptureImpl : public mojom::VideoCaptureObserver {
media::VideoCaptureSessionId session_id() const { return session_id_; }
void SetVideoCaptureHostForTesting(mojom::VideoCaptureHost* service) {
void SetVideoCaptureHostForTesting(media::mojom::VideoCaptureHost* service) {
video_capture_host_for_testing_ = service;
}
// mojom::VideoCaptureObserver implementation.
void OnStateChanged(mojom::VideoCaptureState state) override;
// media::mojom::VideoCaptureObserver implementation.
void OnStateChanged(media::mojom::VideoCaptureState state) override;
void OnBufferCreated(int32_t buffer_id,
mojo::ScopedSharedBufferHandle handle) override;
void OnBufferReady(int32_t buffer_id,
......@@ -110,7 +111,7 @@ class CONTENT_EXPORT VideoCaptureImpl : public mojom::VideoCaptureObserver {
// Tries to remove |client_id| from |clients|, returning false if not found.
bool RemoveClient(int client_id, ClientInfoMap* clients);
mojom::VideoCaptureHost* GetVideoCaptureHost();
media::mojom::VideoCaptureHost* GetVideoCaptureHost();
// Called (by an unknown thread) when all consumers are done with a VideoFrame
// and its ref-count has gone to zero. This helper function grabs the
......@@ -128,11 +129,11 @@ class CONTENT_EXPORT VideoCaptureImpl : public mojom::VideoCaptureObserver {
// |video_capture_host_| is an IO-thread InterfacePtr to a remote service
// implementation and is created by binding |video_capture_host_info_|,
// unless a |video_capture_host_for_testing_| has been injected.
mojom::VideoCaptureHostPtrInfo video_capture_host_info_;
mojom::VideoCaptureHostPtr video_capture_host_;
mojom::VideoCaptureHost* video_capture_host_for_testing_;
media::mojom::VideoCaptureHostPtrInfo video_capture_host_info_;
media::mojom::VideoCaptureHostPtr video_capture_host_;
media::mojom::VideoCaptureHost* video_capture_host_for_testing_;
mojo::Binding<mojom::VideoCaptureObserver> observer_binding_;
mojo::Binding<media::mojom::VideoCaptureObserver> observer_binding_;
// Buffers available for sending to the client.
using ClientBufferMap = std::map<int32_t, scoped_refptr<ClientBuffer>>;
......
......@@ -12,10 +12,10 @@
#include "base/run_loop.h"
#include "base/test/scoped_task_environment.h"
#include "content/child/child_process.h"
#include "content/common/video_capture.mojom.h"
#include "content/renderer/media/video_capture_impl.h"
#include "content/renderer/media/video_capture_impl_manager.h"
#include "media/base/bind_to_current_loop.h"
#include "media/capture/mojo/video_capture.mojom.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -46,7 +46,7 @@ class PauseResumeCallback {
};
class MockVideoCaptureImpl : public VideoCaptureImpl,
public mojom::VideoCaptureHost {
public media::mojom::VideoCaptureHost {
public:
MockVideoCaptureImpl(media::VideoCaptureSessionId session_id,
PauseResumeCallback* pause_callback,
......@@ -61,11 +61,11 @@ class MockVideoCaptureImpl : public VideoCaptureImpl,
void Start(int32_t device_id,
int32_t session_id,
const media::VideoCaptureParams& params,
mojom::VideoCaptureObserverPtr observer) override {
media::mojom::VideoCaptureObserverPtr observer) override {
// For every Start(), expect a corresponding Stop() call.
EXPECT_CALL(*this, Stop(_));
// Simulate device started.
OnStateChanged(mojom::VideoCaptureState::STARTED);
OnStateChanged(media::mojom::VideoCaptureState::STARTED);
}
MOCK_METHOD1(Stop, void(int32_t));
......
......@@ -8,8 +8,8 @@
#include "base/memory/shared_memory.h"
#include "base/test/scoped_task_environment.h"
#include "content/child/child_process.h"
#include "content/common/video_capture.mojom.h"
#include "content/renderer/media/video_capture_impl.h"
#include "media/capture/mojo/video_capture.mojom.h"
#include "mojo/public/cpp/system/platform_handle.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -26,7 +26,8 @@ namespace content {
const int kSessionId = 11;
void RunEmptyFormatsCallback(
mojom::VideoCaptureHost::GetDeviceSupportedFormatsCallback& callback) {
media::mojom::VideoCaptureHost::GetDeviceSupportedFormatsCallback&
callback) {
media::VideoCaptureFormats formats;
std::move(callback).Run(formats);
}
......@@ -34,7 +35,7 @@ void RunEmptyFormatsCallback(
ACTION(DoNothing) {}
// Mock implementation of the Mojo Host service.
class MockMojoVideoCaptureHost : public mojom::VideoCaptureHost {
class MockMojoVideoCaptureHost : public media::mojom::VideoCaptureHost {
public:
MockMojoVideoCaptureHost() : released_buffer_count_(0) {
ON_CALL(*this, GetDeviceSupportedFormatsMock(_, _, _))
......@@ -50,7 +51,7 @@ class MockMojoVideoCaptureHost : public mojom::VideoCaptureHost {
void Start(int32_t device_id,
int32_t session_id,
const media::VideoCaptureParams& params,
mojom::VideoCaptureObserverPtr observer) override {
media::mojom::VideoCaptureObserverPtr observer) override {
DoStart(device_id, session_id, params);
}
MOCK_METHOD3(DoStart,
......@@ -108,7 +109,7 @@ class VideoCaptureImplTest : public ::testing::Test {
ON_CALL(mock_video_capture_host_, DoStart(_, _, _))
.WillByDefault(InvokeWithoutArgs([this]() {
video_capture_impl_->OnStateChanged(
mojom::VideoCaptureState::STARTED);
media::mojom::VideoCaptureState::STARTED);
}));
}
......@@ -188,7 +189,7 @@ class VideoCaptureImplTest : public ::testing::Test {
video_capture_impl_->GetDeviceFormatsInUse(callback);
}
void OnStateChanged(mojom::VideoCaptureState state) {
void OnStateChanged(media::mojom::VideoCaptureState state) {
video_capture_impl_->OnStateChanged(state);
}
......@@ -338,7 +339,7 @@ TEST_F(VideoCaptureImplTest, AlreadyStarted) {
EXPECT_CALL(mock_video_capture_host_, DoStart(_, kSessionId, params_small_))
.WillOnce(DoAll(InvokeWithoutArgs([this]() {
video_capture_impl_->OnStateChanged(
mojom::VideoCaptureState::STARTED);
media::mojom::VideoCaptureState::STARTED);
}),
SaveArg<2>(&params)));
EXPECT_CALL(mock_video_capture_host_, Stop(_));
......@@ -357,7 +358,7 @@ TEST_F(VideoCaptureImplTest, EndedBeforeStop) {
StartCapture(0, params_small_);
OnStateChanged(mojom::VideoCaptureState::ENDED);
OnStateChanged(media::mojom::VideoCaptureState::ENDED);
StopCapture(0);
}
......@@ -369,7 +370,7 @@ TEST_F(VideoCaptureImplTest, ErrorBeforeStop) {
StartCapture(0, params_small_);
OnStateChanged(mojom::VideoCaptureState::FAILED);
OnStateChanged(media::mojom::VideoCaptureState::FAILED);
StopCapture(0);
}
......@@ -392,12 +393,12 @@ TEST_F(VideoCaptureImplTest, BufferReceivedBeforeOnStarted) {
EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED));
EXPECT_CALL(mock_video_capture_host_, RequestRefreshFrame(_));
video_capture_impl_->OnStateChanged(mojom::VideoCaptureState::STARTED);
video_capture_impl_->OnStateChanged(media::mojom::VideoCaptureState::STARTED);
// Additional STARTED will cause RequestRefreshFrame a second time.
EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED));
EXPECT_CALL(mock_video_capture_host_, RequestRefreshFrame(_));
video_capture_impl_->OnStateChanged(mojom::VideoCaptureState::STARTED);
video_capture_impl_->OnStateChanged(media::mojom::VideoCaptureState::STARTED);
EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED));
EXPECT_CALL(mock_video_capture_host_, Stop(_));
......
......@@ -1693,7 +1693,6 @@ test("content_unittests") {
"//media:test_support",
"//media/blink",
"//media/capture",
"//media/capture/mojo:capture_types",
"//media/midi:midi",
"//media/midi:mojo",
"//mojo/edk/system",
......
......@@ -9,12 +9,13 @@ import("//testing/test.gni")
group("capture") {
public_deps = [
":capture_lib",
"//media/capture/mojo:capture_types",
"//media/capture/mojo:image_capture",
"//media/capture/mojo:video_capture",
"//services/service_manager/public/cpp",
]
}
# Things needed by //media/capture/mojo:capture_types.
# Things needed by //media/capture/mojo/video_capture_types.mojom.
component("capture_base") {
defines = [ "CAPTURE_IMPLEMENTATION" ]
sources = [
......@@ -160,8 +161,8 @@ component("capture_lib") {
"//base",
"//base:i18n",
"//media",
"//media/capture/mojo:capture_types",
"//media/capture/mojo:image_capture",
"//media/capture/mojo:video_capture",
"//media/mojo/interfaces:interfaces",
"//services/service_manager/public/cpp",
"//third_party/libyuv",
......
......@@ -4,8 +4,9 @@
import("//mojo/public/tools/bindings/mojom.gni")
mojom("capture_types") {
mojom("video_capture") {
sources = [
"video_capture.mojom",
"video_capture_types.mojom",
]
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module content.mojom;
module media.mojom;
import "media/mojo/interfaces/media_types.mojom";
import "media/capture/mojo/video_capture_types.mojom";
......@@ -69,7 +69,7 @@ interface VideoCaptureObserver {
// |buffer_id| has video capture data with |info| containing the associated
// VideoFrame constituent parts.
OnBufferReady(int32 buffer_id, media.mojom.VideoFrameInfo info);
OnBufferReady(int32 buffer_id, VideoFrameInfo info);
// |buffer_id| has been released by VideoCaptureHost and must not be used.
OnBufferDestroyed(int32 buffer_id);
......@@ -79,7 +79,7 @@ interface VideoCaptureHost {
// Start the |session_id| session with |params|. The video capture will be
// identified as |device_id|, a new id picked by the renderer process.
// |observer| will be used for notifications.
Start(int32 device_id, int32 session_id, media.mojom.VideoCaptureParams params,
Start(int32 device_id, int32 session_id, VideoCaptureParams params,
VideoCaptureObserver observer);
// Closes the video capture specified by |device_id|.
......@@ -89,7 +89,7 @@ interface VideoCaptureHost {
Pause(int32 device_id);
// Resume |device_id| video capture, in |session_id| and with |params|.
Resume(int32 device_id, int32 session_id, media.mojom.VideoCaptureParams params);
Resume(int32 device_id, int32 session_id, VideoCaptureParams params);
// Requests that the video capturer send a frame "soon" (e.g., to resolve
// picture loss or quality issues).
......@@ -101,9 +101,9 @@ interface VideoCaptureHost {
// Get the formats supported by a device referenced by |session_id|.
GetDeviceSupportedFormats(int32 device_id, int32 session_id)
=> (array<media.mojom.VideoCaptureFormat> formats_supported);
=> (array<VideoCaptureFormat> formats_supported);
// Get the format(s) in use by a device referenced by |session_id|.
GetDeviceFormatsInUse(int32 device_id, int32 session_id)
=> (array<media.mojom.VideoCaptureFormat> formats_in_use);
=> (array<VideoCaptureFormat> formats_in_use);
};
......@@ -92,7 +92,7 @@ source_set("tests") {
":lib",
":video_capture",
"//base/test:test_support",
"//media/capture/mojo:capture_types",
"//media/capture/mojo:video_capture",
"//services/service_manager/public/cpp",
"//services/service_manager/public/cpp:service_test_support",
"//services/service_manager/public/cpp/test:test_support",
......
......@@ -16,8 +16,8 @@ mojom("interfaces") {
]
deps = [
"//media/capture/mojo:capture_types",
"//media/capture/mojo:image_capture",
"//media/capture/mojo:video_capture",
"//media/mojo/interfaces",
"//ui/gfx/geometry/mojo",
]
......
......@@ -26,7 +26,7 @@ source_set("unit_tests") {
deps = [
"//base/test:test_support",
"//components/viz/common:common",
"//media/capture/mojo:capture_types",
"//media/capture/mojo:video_capture",
"//services/service_manager/public/cpp",
"//services/service_manager/public/cpp:service_test_support",
"//services/viz/privileged/interfaces/compositing",
......
......@@ -15,7 +15,7 @@ mojom("compositing") {
public_deps = [
"//gpu/ipc/common:interfaces",
"//media/capture/mojo:capture_types",
"//media/capture/mojo:video_capture",
"//media/mojo/interfaces:interfaces",
"//mojo/common:common_custom_types",
"//services/viz/public/interfaces",
......
......@@ -14,7 +14,7 @@ source_set("tests") {
"//components/viz/common:common",
"//components/viz/test:test_support",
"//gpu/ipc/common:struct_traits",
"//media/capture/mojo:capture_types",
"//media/capture/mojo:video_capture",
"//services/service_manager/public/cpp",
"//services/service_manager/public/cpp:service_test_support",
"//services/viz/public/interfaces",
......
......@@ -859,7 +859,7 @@ mojom("media_devices_mojo_bindings") {
]
public_deps = [
"//media/capture/mojo:capture_types",
"//media/capture/mojo:video_capture",
"//media/mojo/interfaces",
"//ui/gfx/geometry/mojo",
]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment