diff options
Diffstat (limited to 'remoting')
34 files changed, 333 insertions, 139 deletions
diff --git a/remoting/codec/DEPS b/remoting/codec/DEPS index 913ea7d..8c70163 100644 --- a/remoting/codec/DEPS +++ b/remoting/codec/DEPS @@ -1,5 +1,4 @@ include_rules = [ - "+media/video/capture/screen", "+remoting/protocol", "+google/protobuf", diff --git a/remoting/host/DEPS b/remoting/host/DEPS index cadbcd3..ef945f3 100644 --- a/remoting/host/DEPS +++ b/remoting/host/DEPS @@ -1,5 +1,4 @@ include_rules = [ - "+media/video/capture/screen", "+net", "+remoting/codec", "+remoting/protocol", diff --git a/remoting/host/basic_desktop_environment.cc b/remoting/host/basic_desktop_environment.cc index 2a05104..e6e2db3 100644 --- a/remoting/host/basic_desktop_environment.cc +++ b/remoting/host/basic_desktop_environment.cc @@ -7,11 +7,11 @@ #include "base/bind.h" #include "base/logging.h" #include "base/single_thread_task_runner.h" -#include "media/video/capture/screen/screen_capturer.h" #include "remoting/host/audio_capturer.h" #include "remoting/host/client_session_control.h" #include "remoting/host/input_injector.h" #include "remoting/host/screen_controls.h" +#include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" namespace remoting { @@ -44,13 +44,13 @@ std::string BasicDesktopEnvironment::GetCapabilities() const { void BasicDesktopEnvironment::SetCapabilities(const std::string& capabilities) { } -scoped_ptr<media::ScreenCapturer> +scoped_ptr<webrtc::ScreenCapturer> BasicDesktopEnvironment::CreateVideoCapturer() { DCHECK(caller_task_runner_->BelongsToCurrentThread()); // The basic desktop environment does not use X DAMAGE, since it is // broken on many systems - see http://crbug.com/73423. - return media::ScreenCapturer::Create(); + return scoped_ptr<webrtc::ScreenCapturer>(webrtc::ScreenCapturer::Create()); } BasicDesktopEnvironment::BasicDesktopEnvironment( diff --git a/remoting/host/basic_desktop_environment.h b/remoting/host/basic_desktop_environment.h index 6d4a88a..10429d1 100644 --- a/remoting/host/basic_desktop_environment.h +++ b/remoting/host/basic_desktop_environment.h @@ -26,7 +26,7 @@ class BasicDesktopEnvironment : public DesktopEnvironment { virtual scoped_ptr<AudioCapturer> CreateAudioCapturer() OVERRIDE; virtual scoped_ptr<InputInjector> CreateInputInjector() OVERRIDE; virtual scoped_ptr<ScreenControls> CreateScreenControls() OVERRIDE; - virtual scoped_ptr<media::ScreenCapturer> CreateVideoCapturer() OVERRIDE; + virtual scoped_ptr<webrtc::ScreenCapturer> CreateVideoCapturer() OVERRIDE; virtual std::string GetCapabilities() const OVERRIDE; virtual void SetCapabilities(const std::string& capabilities) OVERRIDE; diff --git a/remoting/host/chromoting_host.h b/remoting/host/chromoting_host.h index a0dc3d0..614b466 100644 --- a/remoting/host/chromoting_host.h +++ b/remoting/host/chromoting_host.h @@ -48,7 +48,7 @@ class DesktopEnvironmentFactory; // // 2. We listen for incoming connection using libjingle. We will create // a ConnectionToClient object that wraps around linjingle for transport. -// A VideoScheduler is created with an Encoder and a media::ScreenCapturer. +// A VideoScheduler is created with an Encoder and a webrtc::ScreenCapturer. // A ConnectionToClient is added to the ScreenRecorder for transporting // the screen captures. An InputStub is created and registered with the // ConnectionToClient to receive mouse / keyboard events from the remote diff --git a/remoting/host/chromoting_host_unittest.cc b/remoting/host/chromoting_host_unittest.cc index f7b56e2..e780eda 100644 --- a/remoting/host/chromoting_host_unittest.cc +++ b/remoting/host/chromoting_host_unittest.cc @@ -6,13 +6,13 @@ #include "base/bind_helpers.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop_proxy.h" -#include "media/video/capture/screen/screen_capturer_fake.h" #include "remoting/base/auto_thread_task_runner.h" #include "remoting/host/audio_capturer.h" #include "remoting/host/chromoting_host.h" #include "remoting/host/chromoting_host_context.h" #include "remoting/host/desktop_environment.h" #include "remoting/host/host_mock_objects.h" +#include "remoting/host/screen_capturer_fake.h" #include "remoting/jingle_glue/mock_objects.h" #include "remoting/proto/video.pb.h" #include "remoting/protocol/errors.h" @@ -231,7 +231,7 @@ class ChromotingHostTest : public testing::Test { host_->OnSessionRouteChange(get_client(0), channel_name, route); } - // Creates a DesktopEnvironment with a fake media::ScreenCapturer, to mock + // Creates a DesktopEnvironment with a fake webrtc::ScreenCapturer, to mock // DesktopEnvironmentFactory::Create(). DesktopEnvironment* CreateDesktopEnvironment() { MockDesktopEnvironment* desktop_environment = new MockDesktopEnvironment(); @@ -261,10 +261,10 @@ class ChromotingHostTest : public testing::Test { return input_injector; } - // Creates a fake media::ScreenCapturer, to mock + // Creates a fake webrtc::ScreenCapturer, to mock // DesktopEnvironment::CreateVideoCapturer(). - media::ScreenCapturer* CreateVideoCapturer() { - return new media::ScreenCapturerFake(); + webrtc::ScreenCapturer* CreateVideoCapturer() { + return new ScreenCapturerFake(); } void DisconnectAllClients() { diff --git a/remoting/host/chromoting_messages.h b/remoting/host/chromoting_messages.h index 96ff800..e56b0f3 100644 --- a/remoting/host/chromoting_messages.h +++ b/remoting/host/chromoting_messages.h @@ -6,12 +6,12 @@ #define REMOTING_HOST_CHROMOTING_MESSAGES_H_ #include "ipc/ipc_platform_file.h" -#include "media/video/capture/screen/mouse_cursor_shape.h" #include "net/base/ip_endpoint.h" #include "remoting/host/chromoting_param_traits.h" #include "remoting/host/screen_resolution.h" #include "remoting/protocol/transport.h" #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" +#include "third_party/webrtc/modules/desktop_capture/mouse_cursor_shape.h" #endif // REMOTING_HOST_CHROMOTING_MESSAGES_H_ @@ -138,7 +138,7 @@ IPC_MESSAGE_CONTROL3(ChromotingDesktopNetworkMsg_CreateSharedBuffer, IPC_MESSAGE_CONTROL1(ChromotingDesktopNetworkMsg_ReleaseSharedBuffer, int /* id */) -IPC_STRUCT_TRAITS_BEGIN(media::MouseCursorShape) +IPC_STRUCT_TRAITS_BEGIN(webrtc::MouseCursorShape) IPC_STRUCT_TRAITS_MEMBER(size) IPC_STRUCT_TRAITS_MEMBER(hotspot) IPC_STRUCT_TRAITS_MEMBER(data) @@ -174,7 +174,7 @@ IPC_MESSAGE_CONTROL1(ChromotingDesktopNetworkMsg_CaptureCompleted, // Carries a cursor share update from the desktop session agent to the client. IPC_MESSAGE_CONTROL1(ChromotingDesktopNetworkMsg_CursorShapeChanged, - media::MouseCursorShape /* cursor_shape */ ) + webrtc::MouseCursorShape /* cursor_shape */ ) // Carries a clipboard event from the desktop session agent to the client. // |serialized_event| is a serialized protocol::ClipboardEvent. diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc index f4b72c7..27cd910 100644 --- a/remoting/host/client_session.cc +++ b/remoting/host/client_session.cc @@ -7,7 +7,6 @@ #include <algorithm> #include "base/message_loop_proxy.h" -#include "media/video/capture/screen/screen_capturer.h" #include "remoting/base/capabilities.h" #include "remoting/codec/audio_encoder.h" #include "remoting/codec/audio_encoder_opus.h" @@ -28,6 +27,7 @@ #include "remoting/protocol/client_stub.h" #include "remoting/protocol/clipboard_thread_proxy.h" #include "remoting/protocol/pairing_registry.h" +#include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" // Default DPI to assume for old clients that use notifyClientDimensions. const int kDefaultDPI = 96; diff --git a/remoting/host/client_session_unittest.cc b/remoting/host/client_session_unittest.cc index 4b55caf..99da514 100644 --- a/remoting/host/client_session_unittest.cc +++ b/remoting/host/client_session_unittest.cc @@ -3,17 +3,17 @@ // found in the LICENSE file. #include "base/message_loop.h" -#include "media/video/capture/screen/screen_capturer_fake.h" -#include "media/video/capture/screen/screen_capturer_mock_objects.h" #include "remoting/base/auto_thread_task_runner.h" #include "remoting/base/constants.h" #include "remoting/host/audio_capturer.h" #include "remoting/host/client_session.h" #include "remoting/host/desktop_environment.h" #include "remoting/host/host_mock_objects.h" +#include "remoting/host/screen_capturer_fake.h" #include "remoting/protocol/protocol_mock_objects.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" +#include "third_party/webrtc/modules/desktop_capture/screen_capturer_mock_objects.h" namespace remoting { @@ -69,7 +69,7 @@ class ClientSessionTest : public testing::Test { void StopClientSession(); protected: - // Creates a DesktopEnvironment with a fake media::ScreenCapturer, to mock + // Creates a DesktopEnvironment with a fake webrtc::ScreenCapturer, to mock // DesktopEnvironmentFactory::Create(). DesktopEnvironment* CreateDesktopEnvironment(); @@ -77,9 +77,9 @@ class ClientSessionTest : public testing::Test { // DesktopEnvironment::CreateInputInjector(). InputInjector* CreateInputInjector(); - // Creates a fake media::ScreenCapturer, to mock + // Creates a fake webrtc::ScreenCapturer, to mock // DesktopEnvironment::CreateVideoCapturer(). - media::ScreenCapturer* CreateVideoCapturer(); + webrtc::ScreenCapturer* CreateVideoCapturer(); // Notifies the client session that the client connection has been // authenticated and channels have been connected. This effectively enables @@ -209,8 +209,8 @@ InputInjector* ClientSessionTest::CreateInputInjector() { return input_injector_.release(); } -media::ScreenCapturer* ClientSessionTest::CreateVideoCapturer() { - return new media::ScreenCapturerFake(); +webrtc::ScreenCapturer* ClientSessionTest::CreateVideoCapturer() { + return new ScreenCapturerFake(); } void ClientSessionTest::ConnectClientSession() { @@ -487,9 +487,9 @@ TEST_F(ClientSessionTest, ClampMouseEvents) { Expectation connected = authenticated; int input_x[3] = { -999, 100, 999 }; - int expected_x[3] = { 0, 100, media::ScreenCapturerFake::kWidth - 1 }; + int expected_x[3] = { 0, 100, ScreenCapturerFake::kWidth - 1 }; int input_y[3] = { -999, 50, 999 }; - int expected_y[3] = { 0, 50, media::ScreenCapturerFake::kHeight - 1 }; + int expected_y[3] = { 0, 50, ScreenCapturerFake::kHeight - 1 }; protocol::MouseEvent expected_event; for (int j = 0; j < 3; j++) { diff --git a/remoting/host/desktop_environment.h b/remoting/host/desktop_environment.h index 660744a..1fa9ccd 100644 --- a/remoting/host/desktop_environment.h +++ b/remoting/host/desktop_environment.h @@ -17,9 +17,9 @@ namespace base { class SingleThreadTaskRunner; } // namespace base -namespace media { +namespace webrtc { class ScreenCapturer; -} // namespace media +} // namespace webrtc namespace remoting { @@ -39,7 +39,7 @@ class DesktopEnvironment { virtual scoped_ptr<AudioCapturer> CreateAudioCapturer() = 0; virtual scoped_ptr<InputInjector> CreateInputInjector() = 0; virtual scoped_ptr<ScreenControls> CreateScreenControls() = 0; - virtual scoped_ptr<media::ScreenCapturer> CreateVideoCapturer() = 0; + virtual scoped_ptr<webrtc::ScreenCapturer> CreateVideoCapturer() = 0; // Returns the set of all capabilities supported by |this|. virtual std::string GetCapabilities() const = 0; diff --git a/remoting/host/desktop_process_unittest.cc b/remoting/host/desktop_process_unittest.cc index 6a7623c..71155e7 100644 --- a/remoting/host/desktop_process_unittest.cc +++ b/remoting/host/desktop_process_unittest.cc @@ -15,17 +15,17 @@ #include "ipc/ipc_channel_proxy.h" #include "ipc/ipc_listener.h" #include "ipc/ipc_message.h" -#include "media/video/capture/screen/screen_capturer_fake.h" #include "remoting/base/auto_thread.h" #include "remoting/base/auto_thread_task_runner.h" #include "remoting/host/chromoting_messages.h" #include "remoting/host/desktop_process.h" #include "remoting/host/host_exit_codes.h" #include "remoting/host/host_mock_objects.h" +#include "remoting/host/screen_capturer_fake.h" #include "remoting/host/screen_resolution.h" #include "remoting/protocol/protocol_mock_objects.h" -#include "testing/gmock_mutant.h" #include "testing/gmock/include/gmock/gmock.h" +#include "testing/gmock_mutant.h" #include "testing/gtest/include/gtest/gtest.h" using testing::_; @@ -105,7 +105,7 @@ class DesktopProcessTest : public testing::Test { void ConnectNetworkChannel(IPC::PlatformFileForTransit desktop_process); void OnDesktopAttached(IPC::PlatformFileForTransit desktop_process); - // Creates a DesktopEnvironment with a fake media::ScreenCapturer, to mock + // Creates a DesktopEnvironment with a fake webrtc::ScreenCapturer, to mock // DesktopEnvironmentFactory::Create(). DesktopEnvironment* CreateDesktopEnvironment(); @@ -113,9 +113,9 @@ class DesktopProcessTest : public testing::Test { // DesktopEnvironment::CreateInputInjector(). InputInjector* CreateInputInjector(); - // Creates a fake media::ScreenCapturer, to mock + // Creates a fake webrtc::ScreenCapturer, to mock // DesktopEnvironment::CreateVideoCapturer(). - media::ScreenCapturer* CreateVideoCapturer(); + webrtc::ScreenCapturer* CreateVideoCapturer(); // Disconnects the daemon-to-desktop channel causing the desktop process to // exit. @@ -219,8 +219,8 @@ InputInjector* DesktopProcessTest::CreateInputInjector() { return input_injector; } -media::ScreenCapturer* DesktopProcessTest::CreateVideoCapturer() { - return new media::ScreenCapturerFake(); +webrtc::ScreenCapturer* DesktopProcessTest::CreateVideoCapturer() { + return new ScreenCapturerFake(); } void DesktopProcessTest::DisconnectChannels() { diff --git a/remoting/host/desktop_session_agent.cc b/remoting/host/desktop_session_agent.cc index 490ef90..581f2c1 100644 --- a/remoting/host/desktop_session_agent.cc +++ b/remoting/host/desktop_session_agent.cc @@ -320,9 +320,11 @@ void DesktopSessionAgent::OnCaptureCompleted(webrtc::DesktopFrame* frame) { } void DesktopSessionAgent::OnCursorShapeChanged( - scoped_ptr<media::MouseCursorShape> cursor_shape) { + webrtc::MouseCursorShape* cursor_shape) { DCHECK(video_capture_task_runner_->BelongsToCurrentThread()); + scoped_ptr<webrtc::MouseCursorShape> owned_cursor(cursor_shape); + SendToNetwork(new ChromotingDesktopNetworkMsg_CursorShapeChanged( *cursor_shape)); } @@ -412,11 +414,11 @@ void DesktopSessionAgent::OnCaptureFrame() { return; } - // media::ScreenCapturer supports a very few (currently 2) outstanding capture - // requests. The requests are serialized on |video_capture_task_runner()| task - // runner. If the client issues more requests, pixel data in captured frames - // will likely be corrupted but stability of media::ScreenCapturer will not be - // affected. + // webrtc::ScreenCapturer supports a very few (currently 2) outstanding + // capture requests. The requests are serialized on + // |video_capture_task_runner()| task runner. If the client issues more + // requests, pixel data in captured frames will likely be corrupted but + // stability of webrtc::ScreenCapturer will not be affected. video_capturer_->Capture(webrtc::DesktopRegion()); } diff --git a/remoting/host/desktop_session_agent.h b/remoting/host/desktop_session_agent.h index e121c94..55196db 100644 --- a/remoting/host/desktop_session_agent.h +++ b/remoting/host/desktop_session_agent.h @@ -15,10 +15,10 @@ #include "base/memory/weak_ptr.h" #include "ipc/ipc_listener.h" #include "ipc/ipc_platform_file.h" -#include "media/video/capture/screen/screen_capturer.h" #include "remoting/host/client_session_control.h" #include "remoting/protocol/clipboard_stub.h" #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" +#include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" namespace IPC { class ChannelProxy; @@ -47,7 +47,7 @@ class DesktopSessionAgent : public base::RefCountedThreadSafe<DesktopSessionAgent>, public IPC::Listener, public webrtc::DesktopCapturer::Callback, - public media::ScreenCapturer::MouseShapeObserver, + public webrtc::ScreenCapturer::MouseShapeObserver, public ClientSessionControl { public: class Delegate { @@ -78,9 +78,9 @@ class DesktopSessionAgent virtual webrtc::SharedMemory* CreateSharedMemory(size_t size) OVERRIDE; virtual void OnCaptureCompleted(webrtc::DesktopFrame* frame) OVERRIDE; - // media::ScreenCapturer::MouseShapeObserver implementation. + // webrtc::ScreenCapturer::MouseShapeObserver implementation. virtual void OnCursorShapeChanged( - scoped_ptr<media::MouseCursorShape> cursor_shape) OVERRIDE; + webrtc::MouseCursorShape* cursor_shape) OVERRIDE; // Forwards a local clipboard event though the IPC channel to the network // process. @@ -214,7 +214,7 @@ class DesktopSessionAgent bool started_; // Captures the screen. - scoped_ptr<media::ScreenCapturer> video_capturer_; + scoped_ptr<webrtc::ScreenCapturer> video_capturer_; // Keep reference to the last frame sent to make sure shared buffer is alive // before it's received. diff --git a/remoting/host/desktop_session_proxy.cc b/remoting/host/desktop_session_proxy.cc index 1f2bbc5..c32c2bb 100644 --- a/remoting/host/desktop_session_proxy.cc +++ b/remoting/host/desktop_session_proxy.cc @@ -137,10 +137,10 @@ scoped_ptr<ScreenControls> DesktopSessionProxy::CreateScreenControls() { return scoped_ptr<ScreenControls>(new IpcScreenControls(this)); } -scoped_ptr<media::ScreenCapturer> DesktopSessionProxy::CreateVideoCapturer() { +scoped_ptr<webrtc::ScreenCapturer> DesktopSessionProxy::CreateVideoCapturer() { DCHECK(caller_task_runner_->BelongsToCurrentThread()); - return scoped_ptr<media::ScreenCapturer>(new IpcVideoFrameCapturer(this)); + return scoped_ptr<webrtc::ScreenCapturer>(new IpcVideoFrameCapturer(this)); } std::string DesktopSessionProxy::GetCapabilities() const { @@ -487,10 +487,10 @@ void DesktopSessionProxy::OnCaptureCompleted( } void DesktopSessionProxy::OnCursorShapeChanged( - const media::MouseCursorShape& cursor_shape) { + const webrtc::MouseCursorShape& cursor_shape) { DCHECK(caller_task_runner_->BelongsToCurrentThread()); - PostCursorShape(scoped_ptr<media::MouseCursorShape>( - new media::MouseCursorShape(cursor_shape))); + PostCursorShape(scoped_ptr<webrtc::MouseCursorShape>( + new webrtc::MouseCursorShape(cursor_shape))); } void DesktopSessionProxy::OnInjectClipboardEvent( @@ -519,7 +519,7 @@ void DesktopSessionProxy::PostCaptureCompleted( } void DesktopSessionProxy::PostCursorShape( - scoped_ptr<media::MouseCursorShape> cursor_shape) { + scoped_ptr<webrtc::MouseCursorShape> cursor_shape) { DCHECK(caller_task_runner_->BelongsToCurrentThread()); video_capture_task_runner_->PostTask( diff --git a/remoting/host/desktop_session_proxy.h b/remoting/host/desktop_session_proxy.h index 198bd6f..ae8cc4d 100644 --- a/remoting/host/desktop_session_proxy.h +++ b/remoting/host/desktop_session_proxy.h @@ -15,13 +15,13 @@ #include "base/sequenced_task_runner_helpers.h" #include "ipc/ipc_listener.h" #include "ipc/ipc_platform_file.h" -#include "media/video/capture/screen/screen_capturer.h" #include "remoting/host/audio_capturer.h" #include "remoting/host/desktop_environment.h" #include "remoting/host/screen_resolution.h" #include "remoting/proto/event.pb.h" #include "remoting/protocol/clipboard_stub.h" #include "third_party/skia/include/core/SkRegion.h" +#include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" namespace base { class SingleThreadTaskRunner; @@ -77,7 +77,7 @@ class DesktopSessionProxy scoped_ptr<AudioCapturer> CreateAudioCapturer(); scoped_ptr<InputInjector> CreateInputInjector(); scoped_ptr<ScreenControls> CreateScreenControls(); - scoped_ptr<media::ScreenCapturer> CreateVideoCapturer(); + scoped_ptr<webrtc::ScreenCapturer> CreateVideoCapturer(); std::string GetCapabilities() const; void SetCapabilities(const std::string& capabilities); @@ -101,7 +101,7 @@ class DesktopSessionProxy // on the |audio_capture_task_runner_| thread. void SetAudioCapturer(const base::WeakPtr<IpcAudioCapturer>& audio_capturer); - // APIs used to implement the media::ScreenCapturer interface. These must be + // APIs used to implement the webrtc::ScreenCapturer interface. These must be // called on the |video_capture_task_runner_| thread. void InvalidateRegion(const SkRegion& invalid_region); void CaptureFrame(); @@ -148,7 +148,7 @@ class DesktopSessionProxy void OnCaptureCompleted(const SerializedDesktopFrame& serialized_frame); // Handles CursorShapeChanged notification from the desktop session agent. - void OnCursorShapeChanged(const media::MouseCursorShape& cursor_shape); + void OnCursorShapeChanged(const webrtc::MouseCursorShape& cursor_shape); // Handles InjectClipboardEvent request from the desktop integration process. void OnInjectClipboardEvent(const std::string& serialized_event); @@ -159,7 +159,7 @@ class DesktopSessionProxy // Posts OnCursorShapeChanged() to |video_capturer_| on the video thread, // passing |cursor_shape|. - void PostCursorShape(scoped_ptr<media::MouseCursorShape> cursor_shape); + void PostCursorShape(scoped_ptr<webrtc::MouseCursorShape> cursor_shape); // Sends a message to the desktop session agent. The message is silently // deleted if the channel is broken. diff --git a/remoting/host/host_mock_objects.cc b/remoting/host/host_mock_objects.cc index c4739ee..ea1fabb 100644 --- a/remoting/host/host_mock_objects.cc +++ b/remoting/host/host_mock_objects.cc @@ -6,7 +6,6 @@ #include "base/message_loop_proxy.h" #include "base/single_thread_task_runner.h" -#include "media/video/capture/screen/screen_capturer.h" #include "net/base/ip_endpoint.h" #include "remoting/base/auto_thread_task_runner.h" #include "remoting/codec/audio_encoder.h" @@ -15,6 +14,7 @@ #include "remoting/host/input_injector.h" #include "remoting/proto/event.pb.h" #include "remoting/protocol/transport.h" +#include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" namespace remoting { @@ -34,9 +34,9 @@ scoped_ptr<ScreenControls> MockDesktopEnvironment::CreateScreenControls() { return scoped_ptr<ScreenControls>(CreateScreenControlsPtr()); } -scoped_ptr<media::ScreenCapturer> +scoped_ptr<webrtc::ScreenCapturer> MockDesktopEnvironment::CreateVideoCapturer() { - return scoped_ptr<media::ScreenCapturer>(CreateVideoCapturerPtr()); + return scoped_ptr<webrtc::ScreenCapturer>(CreateVideoCapturerPtr()); } MockDesktopEnvironmentFactory::MockDesktopEnvironmentFactory() {} diff --git a/remoting/host/host_mock_objects.h b/remoting/host/host_mock_objects.h index 15bdc6d..32df6d2 100644 --- a/remoting/host/host_mock_objects.h +++ b/remoting/host/host_mock_objects.h @@ -31,7 +31,7 @@ class MockDesktopEnvironment : public DesktopEnvironment { MOCK_METHOD0(CreateAudioCapturerPtr, AudioCapturer*()); MOCK_METHOD0(CreateInputInjectorPtr, InputInjector*()); MOCK_METHOD0(CreateScreenControlsPtr, ScreenControls*()); - MOCK_METHOD0(CreateVideoCapturerPtr, media::ScreenCapturer*()); + MOCK_METHOD0(CreateVideoCapturerPtr, webrtc::ScreenCapturer*()); MOCK_CONST_METHOD0(GetCapabilities, std::string()); MOCK_METHOD1(SetCapabilities, void(const std::string&)); @@ -39,7 +39,7 @@ class MockDesktopEnvironment : public DesktopEnvironment { virtual scoped_ptr<AudioCapturer> CreateAudioCapturer() OVERRIDE; virtual scoped_ptr<InputInjector> CreateInputInjector() OVERRIDE; virtual scoped_ptr<ScreenControls> CreateScreenControls() OVERRIDE; - virtual scoped_ptr<media::ScreenCapturer> CreateVideoCapturer() OVERRIDE; + virtual scoped_ptr<webrtc::ScreenCapturer> CreateVideoCapturer() OVERRIDE; }; class MockClientSessionControl : public ClientSessionControl { diff --git a/remoting/host/input_injector_mac.cc b/remoting/host/input_injector_mac.cc index 8993e86..0fc0379 100644 --- a/remoting/host/input_injector_mac.cc +++ b/remoting/host/input_injector_mac.cc @@ -15,13 +15,13 @@ #include "base/mac/scoped_cftyperef.h" #include "base/memory/ref_counted.h" #include "base/single_thread_task_runner.h" -#include "media/video/capture/screen/mac/desktop_configuration.h" #include "remoting/host/clipboard.h" #include "remoting/proto/internal.pb.h" #include "remoting/protocol/message_decoder.h" #include "skia/ext/skia_utils_mac.h" #include "third_party/skia/include/core/SkPoint.h" #include "third_party/skia/include/core/SkRect.h" +#include "third_party/webrtc/modules/desktop_capture/mac/desktop_configuration.h" namespace remoting { @@ -191,9 +191,9 @@ void InputInjectorMac::Core::InjectMouseEvent(const MouseEvent& event) { // response to display-changed events. VideoFrameCapturer's VideoFrames // could be augmented to include native cursor coordinates for use by // MouseClampingFilter, removing the need for translation here. - media::MacDesktopConfiguration desktop_config = - media::MacDesktopConfiguration::GetCurrent( - media::MacDesktopConfiguration::TopLeftOrigin); + webrtc::MacDesktopConfiguration desktop_config = + webrtc::MacDesktopConfiguration::GetCurrent( + webrtc::MacDesktopConfiguration::TopLeftOrigin); // Translate the mouse position into desktop coordinates. mouse_pos_ += SkIPoint::Make(desktop_config.pixel_bounds.left(), diff --git a/remoting/host/ipc_desktop_environment.cc b/remoting/host/ipc_desktop_environment.cc index 45de6d9..c0eaec3 100644 --- a/remoting/host/ipc_desktop_environment.cc +++ b/remoting/host/ipc_desktop_environment.cc @@ -11,7 +11,6 @@ #include "base/process_util.h" #include "base/single_thread_task_runner.h" #include "ipc/ipc_sender.h" -#include "media/video/capture/screen/screen_capturer.h" #include "remoting/host/audio_capturer.h" #include "remoting/host/chromoting_messages.h" #include "remoting/host/client_session_control.h" @@ -19,6 +18,7 @@ #include "remoting/host/desktop_session_proxy.h" #include "remoting/host/input_injector.h" #include "remoting/host/screen_controls.h" +#include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" namespace remoting { @@ -56,7 +56,8 @@ scoped_ptr<ScreenControls> IpcDesktopEnvironment::CreateScreenControls() { return desktop_session_proxy_->CreateScreenControls(); } -scoped_ptr<media::ScreenCapturer> IpcDesktopEnvironment::CreateVideoCapturer() { +scoped_ptr<webrtc::ScreenCapturer> +IpcDesktopEnvironment::CreateVideoCapturer() { return desktop_session_proxy_->CreateVideoCapturer(); } diff --git a/remoting/host/ipc_desktop_environment.h b/remoting/host/ipc_desktop_environment.h index f0d11b9..2dee387 100644 --- a/remoting/host/ipc_desktop_environment.h +++ b/remoting/host/ipc_desktop_environment.h @@ -51,7 +51,7 @@ class IpcDesktopEnvironment : public DesktopEnvironment { virtual scoped_ptr<AudioCapturer> CreateAudioCapturer() OVERRIDE; virtual scoped_ptr<InputInjector> CreateInputInjector() OVERRIDE; virtual scoped_ptr<ScreenControls> CreateScreenControls() OVERRIDE; - virtual scoped_ptr<media::ScreenCapturer> CreateVideoCapturer() OVERRIDE; + virtual scoped_ptr<webrtc::ScreenCapturer> CreateVideoCapturer() OVERRIDE; virtual std::string GetCapabilities() const OVERRIDE; virtual void SetCapabilities(const std::string& capabilities) OVERRIDE; diff --git a/remoting/host/ipc_desktop_environment_unittest.cc b/remoting/host/ipc_desktop_environment_unittest.cc index 7c18610..47eb36b 100644 --- a/remoting/host/ipc_desktop_environment_unittest.cc +++ b/remoting/host/ipc_desktop_environment_unittest.cc @@ -16,8 +16,6 @@ #include "ipc/ipc_listener.h" #include "ipc/ipc_message.h" #include "ipc/ipc_platform_file.h" -#include "media/video/capture/screen/screen_capturer_fake.h" -#include "media/video/capture/screen/screen_capturer_mock_objects.h" #include "remoting/base/auto_thread.h" #include "remoting/base/auto_thread_task_runner.h" #include "remoting/base/constants.h" @@ -28,12 +26,14 @@ #include "remoting/host/desktop_session_proxy.h" #include "remoting/host/host_mock_objects.h" #include "remoting/host/ipc_desktop_environment.h" +#include "remoting/host/screen_capturer_fake.h" #include "remoting/protocol/protocol_mock_objects.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkRegion.h" #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" +#include "third_party/webrtc/modules/desktop_capture/screen_capturer_mock_objects.h" using testing::_; using testing::AnyNumber; @@ -130,7 +130,7 @@ class IpcDesktopEnvironmentTest : public testing::Test { bool virtual_terminal); void DisconnectTerminal(int terminal_id); - // Creates a DesktopEnvironment with a fake media::ScreenCapturer, to mock + // Creates a DesktopEnvironment with a fake webrtc::ScreenCapturer, to mock // DesktopEnvironmentFactory::Create(). DesktopEnvironment* CreateDesktopEnvironment(); @@ -138,9 +138,9 @@ class IpcDesktopEnvironmentTest : public testing::Test { // DesktopEnvironment::CreateInputInjector(). InputInjector* CreateInputInjector(); - // Creates a fake media::ScreenCapturer, to mock + // Creates a fake webrtc::ScreenCapturer, to mock // DesktopEnvironment::CreateVideoCapturer(). - media::ScreenCapturer* CreateVideoCapturer(); + webrtc::ScreenCapturer* CreateVideoCapturer(); void DeleteDesktopEnvironment(); @@ -198,7 +198,7 @@ class IpcDesktopEnvironmentTest : public testing::Test { scoped_ptr<ScreenControls> screen_controls_; // The IPC screen capturer. - scoped_ptr<media::ScreenCapturer> video_capturer_; + scoped_ptr<webrtc::ScreenCapturer> video_capturer_; // Represents the desktop process running in a user session. scoped_ptr<DesktopProcess> desktop_process_; @@ -209,7 +209,7 @@ class IpcDesktopEnvironmentTest : public testing::Test { // The last |terminal_id| passed to ConnectTermina(); int terminal_id_; - media::MockScreenCapturerCallback screen_capturer_callback_; + webrtc::MockScreenCapturerCallback screen_capturer_callback_; MockClientSessionControl client_session_control_; base::WeakPtrFactory<ClientSessionControl> client_session_control_factory_; @@ -345,8 +345,8 @@ InputInjector* IpcDesktopEnvironmentTest::CreateInputInjector() { return remote_input_injector_; } -media::ScreenCapturer* IpcDesktopEnvironmentTest::CreateVideoCapturer() { - return new media::ScreenCapturerFake(); +webrtc::ScreenCapturer* IpcDesktopEnvironmentTest::CreateVideoCapturer() { + return new ScreenCapturerFake(); } void IpcDesktopEnvironmentTest::DeleteDesktopEnvironment() { diff --git a/remoting/host/ipc_video_frame_capturer.cc b/remoting/host/ipc_video_frame_capturer.cc index 695bf3c..b4120e1 100644 --- a/remoting/host/ipc_video_frame_capturer.cc +++ b/remoting/host/ipc_video_frame_capturer.cc @@ -4,9 +4,9 @@ #include "remoting/host/ipc_video_frame_capturer.h" -#include "media/video/capture/screen/mouse_cursor_shape.h" #include "remoting/host/desktop_session_proxy.h" #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" +#include "third_party/webrtc/modules/desktop_capture/mouse_cursor_shape.h" namespace remoting { @@ -50,9 +50,9 @@ void IpcVideoFrameCapturer::OnCaptureCompleted( } void IpcVideoFrameCapturer::OnCursorShapeChanged( - scoped_ptr<media::MouseCursorShape> cursor_shape) { + scoped_ptr<webrtc::MouseCursorShape> cursor_shape) { if (mouse_shape_observer_) - mouse_shape_observer_->OnCursorShapeChanged(cursor_shape.Pass()); + mouse_shape_observer_->OnCursorShapeChanged(cursor_shape.release()); } } // namespace remoting diff --git a/remoting/host/ipc_video_frame_capturer.h b/remoting/host/ipc_video_frame_capturer.h index 48ed750..1014604 100644 --- a/remoting/host/ipc_video_frame_capturer.h +++ b/remoting/host/ipc_video_frame_capturer.h @@ -7,7 +7,8 @@ #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" -#include "media/video/capture/screen/screen_capturer.h" +#include "base/memory/scoped_ptr.h" +#include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" namespace IPC { class Message; @@ -21,9 +22,9 @@ namespace remoting { class DesktopSessionProxy; -// Routes media::ScreenCapturer calls though the IPC channel to the desktop +// Routes webrtc::ScreenCapturer calls though the IPC channel to the desktop // session agent running in the desktop integration process. -class IpcVideoFrameCapturer : public media::ScreenCapturer { +class IpcVideoFrameCapturer : public webrtc::ScreenCapturer { public: explicit IpcVideoFrameCapturer( scoped_refptr<DesktopSessionProxy> desktop_session_proxy); @@ -33,7 +34,7 @@ class IpcVideoFrameCapturer : public media::ScreenCapturer { virtual void Start(Callback* callback) OVERRIDE; virtual void Capture(const webrtc::DesktopRegion& region) OVERRIDE; - // media::ScreenCapturer interface. + // webrtc::ScreenCapturer interface. virtual void SetMouseShapeObserver( MouseShapeObserver* mouse_shape_observer) OVERRIDE; @@ -41,11 +42,11 @@ class IpcVideoFrameCapturer : public media::ScreenCapturer { void OnCaptureCompleted(scoped_ptr<webrtc::DesktopFrame> frame); // Called when the cursor shape has changed. - void OnCursorShapeChanged(scoped_ptr<media::MouseCursorShape> cursor_shape); + void OnCursorShapeChanged(scoped_ptr<webrtc::MouseCursorShape> cursor_shape); private: - // Points to the callback passed to media::ScreenCapturer::Start(). - media::ScreenCapturer::Callback* callback_; + // Points to the callback passed to webrtc::ScreenCapturer::Start(). + webrtc::ScreenCapturer::Callback* callback_; MouseShapeObserver* mouse_shape_observer_; diff --git a/remoting/host/me2me_desktop_environment.cc b/remoting/host/me2me_desktop_environment.cc index 9dc6d2f..6f55262 100644 --- a/remoting/host/me2me_desktop_environment.cc +++ b/remoting/host/me2me_desktop_environment.cc @@ -6,7 +6,6 @@ #include "base/logging.h" #include "base/single_thread_task_runner.h" -#include "media/video/capture/screen/screen_capturer.h" #include "remoting/host/client_session_control.h" #include "remoting/host/curtain_mode.h" #include "remoting/host/desktop_resizer.h" @@ -16,6 +15,7 @@ #include "remoting/host/local_input_monitor.h" #include "remoting/host/resizing_host_observer.h" #include "remoting/host/screen_controls.h" +#include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" #if defined(OS_POSIX) #include <sys/types.h> @@ -35,14 +35,15 @@ scoped_ptr<ScreenControls> Me2MeDesktopEnvironment::CreateScreenControls() { new ResizingHostObserver(DesktopResizer::Create())); } -scoped_ptr<media::ScreenCapturer> +scoped_ptr<webrtc::ScreenCapturer> Me2MeDesktopEnvironment::CreateVideoCapturer() { DCHECK(caller_task_runner()->BelongsToCurrentThread()); #if defined(OS_LINUX) - return media::ScreenCapturer::CreateWithXDamage(true); + return scoped_ptr<webrtc::ScreenCapturer>( + webrtc::ScreenCapturer::CreateWithXDamage(true)); #else // !defined(OS_LINUX) - return media::ScreenCapturer::Create(); + return scoped_ptr<webrtc::ScreenCapturer>(webrtc::ScreenCapturer::Create()); #endif // !defined(OS_LINUX) } diff --git a/remoting/host/me2me_desktop_environment.h b/remoting/host/me2me_desktop_environment.h index 316d5c3..1153ec8 100644 --- a/remoting/host/me2me_desktop_environment.h +++ b/remoting/host/me2me_desktop_environment.h @@ -21,7 +21,7 @@ class Me2MeDesktopEnvironment : public BasicDesktopEnvironment { // DesktopEnvironment interface. virtual scoped_ptr<ScreenControls> CreateScreenControls() OVERRIDE; - virtual scoped_ptr<media::ScreenCapturer> CreateVideoCapturer() OVERRIDE; + virtual scoped_ptr<webrtc::ScreenCapturer> CreateVideoCapturer() OVERRIDE; protected: friend class Me2MeDesktopEnvironmentFactory; diff --git a/remoting/host/sas_injector_win.cc b/remoting/host/sas_injector_win.cc index 663c08d..a29d727 100644 --- a/remoting/host/sas_injector_win.cc +++ b/remoting/host/sas_injector_win.cc @@ -14,8 +14,8 @@ #include "base/utf_string_conversions.h" #include "base/win/registry.h" #include "base/win/windows_version.h" -#include "media/video/capture/screen/win/desktop.h" -#include "media/video/capture/screen/win/scoped_thread_desktop.h" +#include "third_party/webrtc/modules/desktop_capture/win/desktop.h" +#include "third_party/webrtc/modules/desktop_capture/win/scoped_thread_desktop.h" namespace remoting { @@ -190,16 +190,16 @@ bool SasInjectorXp::InjectSas() { const wchar_t kSasWindowClassName[] = L"SAS window class"; const wchar_t kSasWindowTitle[] = L"SAS window"; - scoped_ptr<media::Desktop> winlogon_desktop( - media::Desktop::GetDesktop(kWinlogonDesktopName)); + scoped_ptr<webrtc::Desktop> winlogon_desktop( + webrtc::Desktop::GetDesktop(kWinlogonDesktopName)); if (!winlogon_desktop.get()) { LOG_GETLASTERROR(ERROR) << "Failed to open '" << kWinlogonDesktopName << "' desktop"; return false; } - media::ScopedThreadDesktop desktop; - if (!desktop.SetThreadDesktop(winlogon_desktop.Pass())) { + webrtc::ScopedThreadDesktop desktop; + if (!desktop.SetThreadDesktop(winlogon_desktop.release())) { LOG_GETLASTERROR(ERROR) << "Failed to switch to '" << kWinlogonDesktopName << "' desktop"; return false; diff --git a/remoting/host/screen_capturer_fake.cc b/remoting/host/screen_capturer_fake.cc new file mode 100644 index 0000000..0a6707c --- /dev/null +++ b/remoting/host/screen_capturer_fake.cc @@ -0,0 +1,128 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "remoting/host/screen_capturer_fake.h" + +#include "base/logging.h" +#include "base/time.h" +#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" + +namespace remoting { + +// ScreenCapturerFake generates a white picture of size kWidth x kHeight +// with a rectangle of size kBoxWidth x kBoxHeight. The rectangle moves kSpeed +// pixels per frame along both axes, and bounces off the sides of the screen. +static const int kWidth = ScreenCapturerFake::kWidth; +static const int kHeight = ScreenCapturerFake::kHeight; +static const int kBoxWidth = 140; +static const int kBoxHeight = 140; +static const int kSpeed = 20; + +COMPILE_ASSERT(kBoxWidth < kWidth && kBoxHeight < kHeight, bad_box_size); +COMPILE_ASSERT((kBoxWidth % kSpeed == 0) && (kWidth % kSpeed == 0) && + (kBoxHeight % kSpeed == 0) && (kHeight % kSpeed == 0), + sizes_must_be_multiple_of_kSpeed); + +ScreenCapturerFake::ScreenCapturerFake() + : callback_(NULL), + mouse_shape_observer_(NULL), + bytes_per_row_(0), + box_pos_x_(0), + box_pos_y_(0), + box_speed_x_(kSpeed), + box_speed_y_(kSpeed) { + ScreenConfigurationChanged(); +} + +ScreenCapturerFake::~ScreenCapturerFake() { +} + +void ScreenCapturerFake::Start(Callback* callback) { + DCHECK(!callback_); + DCHECK(callback); + callback_ = callback; +} + +void ScreenCapturerFake::Capture(const webrtc::DesktopRegion& region) { + base::Time capture_start_time = base::Time::Now(); + + queue_.MoveToNextFrame(); + + if (!queue_.current_frame()) { + int buffer_size = size_.height() * bytes_per_row_; + webrtc::SharedMemory* shared_memory = + callback_->CreateSharedMemory(buffer_size); + scoped_ptr<webrtc::DesktopFrame> frame; + webrtc::DesktopSize frame_size(size_.width(), size_.height()); + if (shared_memory) { + frame.reset(new webrtc::SharedMemoryDesktopFrame( + frame_size, bytes_per_row_, shared_memory)); + } else { + frame.reset(new webrtc::BasicDesktopFrame(frame_size)); + } + queue_.ReplaceCurrentFrame(frame.release()); + } + + DCHECK(queue_.current_frame()); + GenerateImage(); + + queue_.current_frame()->mutable_updated_region()->SetRect( + webrtc::DesktopRect::MakeSize(size_)); + queue_.current_frame()->set_capture_time_ms( + (base::Time::Now() - capture_start_time).InMillisecondsRoundedUp()); + + callback_->OnCaptureCompleted(queue_.current_frame()->Share()); +} + +void ScreenCapturerFake::SetMouseShapeObserver( + MouseShapeObserver* mouse_shape_observer) { + DCHECK(!mouse_shape_observer_); + DCHECK(mouse_shape_observer); + mouse_shape_observer_ = mouse_shape_observer; +} + +void ScreenCapturerFake::GenerateImage() { + webrtc::DesktopFrame* frame = queue_.current_frame(); + + const int kBytesPerPixel = webrtc::DesktopFrame::kBytesPerPixel; + + memset(frame->data(), 0xff, + size_.width() * size_.height() * kBytesPerPixel); + + uint8* row = frame->data() + + (box_pos_y_ * size_.width() + box_pos_x_) * kBytesPerPixel; + + box_pos_x_ += box_speed_x_; + if (box_pos_x_ + kBoxWidth >= size_.width() || box_pos_x_ == 0) + box_speed_x_ = -box_speed_x_; + + box_pos_y_ += box_speed_y_; + if (box_pos_y_ + kBoxHeight >= size_.height() || box_pos_y_ == 0) + box_speed_y_ = -box_speed_y_; + + // Draw rectangle with the following colors in its corners: + // cyan....yellow + // .............. + // blue.......red + for (int y = 0; y < kBoxHeight; ++y) { + for (int x = 0; x < kBoxWidth; ++x) { + int r = x * 255 / kBoxWidth; + int g = y * 255 / kBoxHeight; + int b = 255 - (x * 255 / kBoxWidth); + row[x * kBytesPerPixel] = r; + row[x * kBytesPerPixel + 1] = g; + row[x * kBytesPerPixel + 2] = b; + row[x * kBytesPerPixel + 3] = 0xff; + } + row += bytes_per_row_; + } +} + +void ScreenCapturerFake::ScreenConfigurationChanged() { + size_.set(kWidth, kHeight); + queue_.Reset(); + bytes_per_row_ = size_.width() * webrtc::DesktopFrame::kBytesPerPixel; +} + +} // namespace remoting diff --git a/remoting/host/screen_capturer_fake.h b/remoting/host/screen_capturer_fake.h new file mode 100644 index 0000000..ab99146 --- /dev/null +++ b/remoting/host/screen_capturer_fake.h @@ -0,0 +1,60 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef REMOTING_HOST_SCREEN_CAPTURER_FAKE_H_ +#define REMOTING_HOST_SCREEN_CAPTURER_FAKE_H_ + +#include "base/memory/scoped_ptr.h" +#include "media/base/media_export.h" +#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" +#include "third_party/webrtc/modules/desktop_capture/screen_capture_frame_queue.h" +#include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" + +namespace remoting { + +// A ScreenCapturerFake generates artificial image for testing purpose. +// +// ScreenCapturerFake is double-buffered as required by ScreenCapturer. +class ScreenCapturerFake : public webrtc::ScreenCapturer { + public: + // ScreenCapturerFake generates a picture of size kWidth x kHeight. + static const int kWidth = 800; + static const int kHeight = 600; + + ScreenCapturerFake(); + virtual ~ScreenCapturerFake(); + + // webrtc::DesktopCapturer interface. + virtual void Start(Callback* callback) OVERRIDE; + virtual void Capture(const webrtc::DesktopRegion& rect) OVERRIDE; + + // ScreenCapturer interface. + virtual void SetMouseShapeObserver( + MouseShapeObserver* mouse_shape_observer) OVERRIDE; + + private: + // Generates an image in the front buffer. + void GenerateImage(); + + // Called when the screen configuration is changed. + void ScreenConfigurationChanged(); + + Callback* callback_; + MouseShapeObserver* mouse_shape_observer_; + + webrtc::DesktopSize size_; + int bytes_per_row_; + int box_pos_x_; + int box_pos_y_; + int box_speed_x_; + int box_speed_y_; + + webrtc::ScreenCaptureFrameQueue queue_; + + DISALLOW_COPY_AND_ASSIGN(ScreenCapturerFake); +}; + +} // namespace remoting + +#endif // REMOTING_HOST_SCREEN_CAPTURER_FAKE_H_ diff --git a/remoting/host/video_scheduler.cc b/remoting/host/video_scheduler.cc index f7db4c2..f051363b 100644 --- a/remoting/host/video_scheduler.cc +++ b/remoting/host/video_scheduler.cc @@ -14,16 +14,16 @@ #include "base/stl_util.h" #include "base/sys_info.h" #include "base/time.h" -#include "media/video/capture/screen/mouse_cursor_shape.h" -#include "media/video/capture/screen/screen_capturer.h" #include "remoting/proto/control.pb.h" #include "remoting/proto/internal.pb.h" #include "remoting/proto/video.pb.h" #include "remoting/protocol/cursor_shape_stub.h" #include "remoting/protocol/message_decoder.h" -#include "remoting/protocol/video_stub.h" #include "remoting/protocol/util.h" +#include "remoting/protocol/video_stub.h" #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" +#include "third_party/webrtc/modules/desktop_capture/mouse_cursor_shape.h" +#include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" namespace remoting { @@ -35,7 +35,7 @@ VideoScheduler::VideoScheduler( scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, - scoped_ptr<media::ScreenCapturer> capturer, + scoped_ptr<webrtc::ScreenCapturer> capturer, scoped_ptr<VideoEncoder> encoder, protocol::CursorShapeStub* cursor_stub, protocol::VideoStub* video_stub) @@ -88,9 +88,11 @@ void VideoScheduler::OnCaptureCompleted(webrtc::DesktopFrame* frame) { } void VideoScheduler::OnCursorShapeChanged( - scoped_ptr<media::MouseCursorShape> cursor_shape) { + webrtc::MouseCursorShape* cursor_shape) { DCHECK(capture_task_runner_->BelongsToCurrentThread()); + scoped_ptr<webrtc::MouseCursorShape> owned_cursor(cursor_shape); + // Do nothing if the scheduler is being stopped. if (!capturer_) return; diff --git a/remoting/host/video_scheduler.h b/remoting/host/video_scheduler.h index 16f6247..aecc207 100644 --- a/remoting/host/video_scheduler.h +++ b/remoting/host/video_scheduler.h @@ -12,11 +12,11 @@ #include "base/memory/scoped_ptr.h" #include "base/time.h" #include "base/timer.h" -#include "media/video/capture/screen/screen_capturer.h" #include "remoting/codec/video_encoder.h" #include "remoting/host/capture_scheduler.h" #include "remoting/proto/video.pb.h" #include "third_party/skia/include/core/SkSize.h" +#include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" namespace base { class SingleThreadTaskRunner; @@ -36,9 +36,10 @@ class CursorShapeStub; class VideoStub; } // namespace protocol -// Class responsible for scheduling frame captures from a media::ScreenCapturer, -// delivering them to a VideoEncoder to encode, and finally passing the encoded -// video packets to the specified VideoStub to send on the network. +// Class responsible for scheduling frame captures from a +// webrtc::ScreenCapturer, delivering them to a VideoEncoder to encode, and +// finally passing the encoded video packets to the specified VideoStub to send +// on the network. // // THREADING // @@ -74,7 +75,7 @@ class VideoStub; class VideoScheduler : public base::RefCountedThreadSafe<VideoScheduler>, public webrtc::DesktopCapturer::Callback, - public media::ScreenCapturer::MouseShapeObserver { + public webrtc::ScreenCapturer::MouseShapeObserver { public: // Creates a VideoScheduler running capture, encode and network tasks on the // supplied TaskRunners. Video and cursor shape updates will be pumped to @@ -84,7 +85,7 @@ class VideoScheduler : public base::RefCountedThreadSafe<VideoScheduler>, scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, - scoped_ptr<media::ScreenCapturer> capturer, + scoped_ptr<webrtc::ScreenCapturer> capturer, scoped_ptr<VideoEncoder> encoder, protocol::CursorShapeStub* cursor_stub, protocol::VideoStub* video_stub); @@ -93,9 +94,9 @@ class VideoScheduler : public base::RefCountedThreadSafe<VideoScheduler>, virtual webrtc::SharedMemory* CreateSharedMemory(size_t size) OVERRIDE; virtual void OnCaptureCompleted(webrtc::DesktopFrame* frame) OVERRIDE; - // media::ScreenCapturer::MouseShapeObserver implementation. + // webrtc::ScreenCapturer::MouseShapeObserver implementation. virtual void OnCursorShapeChanged( - scoped_ptr<media::MouseCursorShape> cursor_shape) OVERRIDE; + webrtc::MouseCursorShape* cursor_shape) OVERRIDE; // Starts scheduling frame captures. void Start(); @@ -160,7 +161,7 @@ class VideoScheduler : public base::RefCountedThreadSafe<VideoScheduler>, scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; // Used to capture frames. Always accessed on the capture thread. - scoped_ptr<media::ScreenCapturer> capturer_; + scoped_ptr<webrtc::ScreenCapturer> capturer_; // Used to encode captured frames. Always accessed on the encode thread. scoped_ptr<VideoEncoder> encoder_; diff --git a/remoting/host/video_scheduler_unittest.cc b/remoting/host/video_scheduler_unittest.cc index 7bf17fc..e949942 100644 --- a/remoting/host/video_scheduler_unittest.cc +++ b/remoting/host/video_scheduler_unittest.cc @@ -7,7 +7,6 @@ #include "base/bind.h" #include "base/message_loop.h" #include "base/run_loop.h" -#include "media/video/capture/screen/screen_capturer_mock_objects.h" #include "remoting/base/auto_thread_task_runner.h" #include "remoting/codec/video_encoder.h" #include "remoting/proto/video.pb.h" @@ -15,6 +14,7 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" +#include "third_party/webrtc/modules/desktop_capture/screen_capturer_mock_objects.h" using ::remoting::protocol::MockClientStub; using ::remoting::protocol::MockVideoStub; @@ -73,11 +73,11 @@ class VideoSchedulerTest : public testing::Test { virtual void SetUp() OVERRIDE; - void StartVideoScheduler(scoped_ptr<media::ScreenCapturer> capturer); + void StartVideoScheduler(scoped_ptr<webrtc::ScreenCapturer> capturer); void StopVideoScheduler(); - // media::ScreenCapturer mocks. - void OnCapturerStart(media::ScreenCapturer::Callback* callback); + // webrtc::ScreenCapturer mocks. + void OnCapturerStart(webrtc::ScreenCapturer::Callback* callback); void OnCaptureFrame(const webrtc::DesktopRegion& region); protected: @@ -94,8 +94,8 @@ class VideoSchedulerTest : public testing::Test { scoped_ptr<webrtc::DesktopFrame> frame_; - // Points to the callback passed to media::ScreenCapturer::Start(). - media::ScreenCapturer::Callback* capturer_callback_; + // Points to the callback passed to webrtc::ScreenCapturer::Start(). + webrtc::ScreenCapturer::Callback* capturer_callback_; private: DISALLOW_COPY_AND_ASSIGN(VideoSchedulerTest); @@ -114,7 +114,7 @@ void VideoSchedulerTest::SetUp() { } void VideoSchedulerTest::StartVideoScheduler( - scoped_ptr<media::ScreenCapturer> capturer) { + scoped_ptr<webrtc::ScreenCapturer> capturer) { scheduler_ = new VideoScheduler( task_runner_, // Capture task_runner_, // Encode @@ -132,7 +132,7 @@ void VideoSchedulerTest::StopVideoScheduler() { } void VideoSchedulerTest::OnCapturerStart( - media::ScreenCapturer::Callback* callback) { + webrtc::ScreenCapturer::Callback* callback) { EXPECT_FALSE(capturer_callback_); EXPECT_TRUE(callback); @@ -150,8 +150,8 @@ void VideoSchedulerTest::OnCaptureFrame(const webrtc::DesktopRegion& region) { // VideoScheduler is instructed to come to a complete stop. We expect the stop // sequence to be executed successfully. TEST_F(VideoSchedulerTest, StartAndStop) { - scoped_ptr<media::MockScreenCapturer> capturer( - new media::MockScreenCapturer()); + scoped_ptr<webrtc::MockScreenCapturer> capturer( + new webrtc::MockScreenCapturer()); Expectation capturer_start = EXPECT_CALL(*capturer, Start(_)) .WillOnce(Invoke(this, &VideoSchedulerTest::OnCapturerStart)); @@ -182,7 +182,7 @@ TEST_F(VideoSchedulerTest, StartAndStop) { .RetiresOnSaturation(); // Start video frame capture. - StartVideoScheduler(capturer.PassAs<media::ScreenCapturer>()); + StartVideoScheduler(capturer.PassAs<webrtc::ScreenCapturer>()); task_runner_ = NULL; run_loop_.Run(); diff --git a/remoting/host/win/session_desktop_environment.cc b/remoting/host/win/session_desktop_environment.cc index 33add388..0f4ffda 100644 --- a/remoting/host/win/session_desktop_environment.cc +++ b/remoting/host/win/session_desktop_environment.cc @@ -6,11 +6,11 @@ #include "base/logging.h" #include "base/single_thread_task_runner.h" -#include "media/video/capture/screen/screen_capturer.h" #include "remoting/host/audio_capturer.h" #include "remoting/host/input_injector.h" #include "remoting/host/screen_controls.h" #include "remoting/host/win/session_input_injector.h" +#include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" namespace remoting { diff --git a/remoting/host/win/session_input_injector.cc b/remoting/host/win/session_input_injector.cc index 4c763ee..8f7a366 100644 --- a/remoting/host/win/session_input_injector.cc +++ b/remoting/host/win/session_input_injector.cc @@ -13,10 +13,10 @@ #include "base/location.h" #include "base/single_thread_task_runner.h" #include "base/win/windows_version.h" -#include "media/video/capture/screen/win/desktop.h" -#include "media/video/capture/screen/win/scoped_thread_desktop.h" #include "remoting/host/sas_injector.h" #include "remoting/proto/event.pb.h" +#include "third_party/webrtc/modules/desktop_capture/win/desktop.h" +#include "third_party/webrtc/modules/desktop_capture/win/scoped_thread_desktop.h" namespace { @@ -80,7 +80,7 @@ class SessionInputInjectorWin::Core scoped_refptr<base::SingleThreadTaskRunner> inject_sas_task_runner_; - media::ScopedThreadDesktop desktop_; + webrtc::ScopedThreadDesktop desktop_; // Used to inject Secure Attention Sequence on Vista+. base::Closure inject_sas_; @@ -182,11 +182,12 @@ SessionInputInjectorWin::Core::~Core() { void SessionInputInjectorWin::Core::SwitchToInputDesktop() { // Switch to the desktop receiving user input if different from the current // one. - scoped_ptr<media::Desktop> input_desktop = media::Desktop::GetInputDesktop(); + scoped_ptr<webrtc::Desktop> input_desktop( + webrtc::Desktop::GetInputDesktop()); if (input_desktop.get() != NULL && !desktop_.IsSame(*input_desktop)) { // If SetThreadDesktop() fails, the thread is still assigned a desktop. // So we can continue capture screen bits, just from a diffected desktop. - desktop_.SetThreadDesktop(input_desktop.Pass()); + desktop_.SetThreadDesktop(input_desktop.release()); } } diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index 1b21b38..aa574957 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -297,7 +297,6 @@ 'remoting_protocol', '../crypto/crypto.gyp:crypto', '../google_apis/google_apis.gyp:google_apis', - '../media/media.gyp:media', '../ipc/ipc.gyp:ipc', '../third_party/webrtc/modules/modules.gyp:desktop_capture', ], @@ -554,8 +553,8 @@ 'dependencies': [ '../base/base.gyp:base', '../base/base.gyp:base_i18n', - '../media/media.gyp:media', '../net/net.gyp:net', + '../third_party/webrtc/modules/modules.gyp:desktop_capture', 'remoting_base', 'remoting_breakpad', 'remoting_host', @@ -840,8 +839,8 @@ 'dependencies': [ '../base/base.gyp:base', '../base/base.gyp:base_i18n', - '../media/media.gyp:media', '../net/net.gyp:net', + '../third_party/webrtc/modules/modules.gyp:desktop_capture', 'remoting_base', 'remoting_breakpad', 'remoting_host', @@ -1427,8 +1426,8 @@ '../base/base.gyp:base_static', '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', '../ipc/ipc.gyp:ipc', - '../media/media.gyp:media', '../net/net.gyp:net', + '../third_party/webrtc/modules/modules.gyp:desktop_capture', 'remoting_base', 'remoting_breakpad', 'remoting_host', @@ -1942,10 +1941,10 @@ 'remoting_base', 'remoting_client', 'remoting_jingle_glue', - '../media/media.gyp:media', '../net/net.gyp:net', '../ppapi/ppapi.gyp:ppapi_cpp_objects', '../skia/skia.gyp:skia', + '../third_party/webrtc/modules/modules.gyp:desktop_capture', ], 'sources': [ 'client/plugin/chromoting_instance.cc', @@ -2115,7 +2114,7 @@ ], 'target_conditions': [ # We cannot currently build the appsv2 version of WebApp on Windows as - # there isn't a version of the "patch" tool available on windows. We + # there isn't a version of the "patch" tool available on windows. We # should remove this condition when we remove the reliance on the 'patch'. # We define this in a 'target_conditions' section because 'plugin_path' @@ -2163,7 +2162,7 @@ '<@(remoting_webapp_locale_files)', '--patches', '<@(remoting_webapp_patch_files)', - ], + ], 'msvs_cygwin_shell': 1, }, ], @@ -2589,8 +2588,6 @@ '../base/base.gyp:base_i18n', '../base/base.gyp:test_support_base', '../ipc/ipc.gyp:ipc', - '../media/media.gyp:media', - '../media/media.gyp:media_test_support', '../net/net.gyp:net_test_support', '../ppapi/ppapi.gyp:ppapi_cpp', '../testing/gmock.gyp:gmock', @@ -2675,6 +2672,8 @@ 'host/register_support_host_request_unittest.cc', 'host/remote_input_filter_unittest.cc', 'host/resizing_host_observer_unittest.cc', + 'host/screen_capturer_fake.cc', + 'host/screen_capturer_fake.h', 'host/screen_resolution_unittest.cc', 'host/server_log_entry_unittest.cc', 'host/setup/native_messaging_host_unittest.cc', |