diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-28 23:54:03 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-28 23:54:03 +0000 |
commit | 497d8a9857e7383f979b89694aff8dd403c176fe (patch) | |
tree | 2f07bb42d4a7a8e94e959c90dacbfa62eed1debd | |
parent | bac4ae80a786d68bfc18ca46f0adfcc4a1c43b0f (diff) | |
download | chromium_src-497d8a9857e7383f979b89694aff8dd403c176fe.zip chromium_src-497d8a9857e7383f979b89694aff8dd403c176fe.tar.gz chromium_src-497d8a9857e7383f979b89694aff8dd403c176fe.tar.bz2 |
Move screen capturers from remoting/capturer to media/video/capturer/screen
Screen capturers will be used in content, and so they have to be moved to
avoid dependency on remoting/capturer in content.
Beside moving the files this CL also renames classes as follows:
remoting::VideoFrameCapturer -> media::ScreenCapturer
remoting::VideoFrame -> media::ScreenCaptureFrame
remoting::CaptureData -> media::ScreenCaptureData
BUG=134249
Review URL: https://codereview.chromium.org/12047101
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179218 0039d316-1c4b-4281-b951-d872f2087c98
86 files changed, 969 insertions, 917 deletions
diff --git a/media/media.gyp b/media/media.gyp index 8b33bd8..1a90391 100644 --- a/media/media.gyp +++ b/media/media.gyp @@ -19,6 +19,12 @@ 'use_ffmpeg%': 1, 'use_libvpx%': 1, }], + # Screen capturer works only on Windows, OSX and Linux. + ['OS=="win" or OS=="mac" or OS=="linux"', { + 'screen_capture_supported%': 1, + }, { + 'screen_capture_supported%': 0, + }], ], }, 'targets': [ @@ -326,6 +332,39 @@ 'video/capture/mac/video_capture_device_mac.mm', 'video/capture/mac/video_capture_device_qtkit_mac.h', 'video/capture/mac/video_capture_device_qtkit_mac.mm', + 'video/capture/screen/differ.cc', + 'video/capture/screen/differ.h', + 'video/capture/screen/differ_block.cc', + 'video/capture/screen/differ_block.h', + 'video/capture/screen/linux/x_server_pixel_buffer.cc', + 'video/capture/screen/linux/x_server_pixel_buffer.h', + 'video/capture/screen/mac/desktop_configuration.mm', + 'video/capture/screen/mac/desktop_configuration.h', + 'video/capture/screen/mac/scoped_pixel_buffer_object.cc', + 'video/capture/screen/mac/scoped_pixel_buffer_object.h', + 'video/capture/screen/mouse_cursor_shape.cc', + 'video/capture/screen/mouse_cursor_shape.h', + 'video/capture/screen/screen_capture_data.cc', + 'video/capture/screen/screen_capture_data.h', + 'video/capture/screen/screen_capture_frame.cc', + 'video/capture/screen/screen_capture_frame.h', + 'video/capture/screen/screen_capture_frame_queue.cc', + 'video/capture/screen/screen_capture_frame_queue.h', + 'video/capture/screen/screen_capturer.h', + 'video/capture/screen/screen_capturer_fake.cc', + 'video/capture/screen/screen_capturer_fake.h', + 'video/capture/screen/screen_capturer_helper.cc', + 'video/capture/screen/screen_capturer_helper.h', + 'video/capture/screen/screen_capturer_linux.cc', + 'video/capture/screen/screen_capturer_mac.mm', + 'video/capture/screen/screen_capturer_win.cc', + 'video/capture/screen/shared_buffer.cc', + 'video/capture/screen/shared_buffer.h', + 'video/capture/screen/shared_buffer_factory.h', + 'video/capture/screen/win/desktop.cc', + 'video/capture/screen/win/desktop.h', + 'video/capture/screen/win/scoped_thread_desktop.cc', + 'video/capture/screen/win/scoped_thread_desktop.h', 'video/capture/video_capture.h', 'video/capture/video_capture_device.h', 'video/capture/video_capture_device_dummy.cc', @@ -521,6 +560,14 @@ }], ], }, + 'link_settings': { + 'libraries': [ + '-lX11', + '-lXdamage', + '-lXext', + '-lXfixes', + ], + }, 'conditions': [ ['use_cras == 1', { 'cflags': [ @@ -576,10 +623,11 @@ ['OS=="mac"', { 'link_settings': { 'libraries': [ - '$(SDKROOT)/System/Library/Frameworks/AudioUnit.framework', '$(SDKROOT)/System/Library/Frameworks/AudioToolbox.framework', + '$(SDKROOT)/System/Library/Frameworks/AudioUnit.framework', '$(SDKROOT)/System/Library/Frameworks/CoreAudio.framework', '$(SDKROOT)/System/Library/Frameworks/CoreVideo.framework', + '$(SDKROOT)/System/Library/Frameworks/OpenGL.framework', '$(SDKROOT)/System/Library/Frameworks/QTKit.framework', ], }, @@ -644,6 +692,21 @@ 'mp4/track_run_iterator.h', ], }], + [ 'screen_capture_supported==0', { + 'sources/': [ + ['exclude', '^video/capture/screen/'], + ], + }], + [ 'screen_capture_supported==1 and (target_arch=="ia32" or target_arch=="x64")', { + 'dependencies': [ + 'differ_block_sse2', + ], + }], + ['toolkit_uses_gtk==1', { + 'dependencies': [ + '../build/linux/system.gyp:gtk', + ], + }], ], 'target_conditions': [ ['OS == "ios"', { @@ -705,13 +768,13 @@ 'base/audio_renderer_mixer_unittest.cc', 'base/audio_splicer_unittest.cc', 'base/audio_timestamp_helper_unittest.cc', - 'base/bit_reader_unittest.cc', 'base/bind_to_loop_unittest.cc', + 'base/bit_reader_unittest.cc', 'base/channel_mixer_unittest.cc', 'base/clock_unittest.cc', 'base/data_buffer_unittest.cc', - 'base/decoder_buffer_unittest.cc', 'base/decoder_buffer_queue_unittest.cc', + 'base/decoder_buffer_unittest.cc', 'base/djb2_unittest.cc', 'base/filter_collection_unittest.cc', 'base/gmock_callback_support_unittest.cc', @@ -752,6 +815,12 @@ 'filters/source_buffer_stream_unittest.cc', 'filters/video_decoder_selector_unittest.cc', 'filters/video_renderer_base_unittest.cc', + 'video/capture/screen/differ_block_unittest.cc', + 'video/capture/screen/differ_unittest.cc', + 'video/capture/screen/shared_buffer_unittest.cc', + 'video/capture/screen/screen_capturer_helper_unittest.cc', + 'video/capture/screen/screen_capturer_mac_unittest.cc', + 'video/capture/screen/screen_capturer_unittest.cc', 'video/capture/video_capture_device_unittest.cc', 'webm/cluster_builder.cc', 'webm/cluster_builder.h', @@ -841,6 +910,11 @@ 'base/simd/convert_rgb_to_yuv_unittest.cc', ], }], + [ 'screen_capture_supported == 0', { + 'sources/': [ + ['exclude', '^video/capture/screen/'], + ], + }], ['proprietary_codecs==1 or branding=="Chrome"', { 'sources': [ 'mp4/aac_unittest.cc', @@ -860,6 +934,7 @@ 'dependencies': [ 'media', '../base/base.gyp:base', + '../skia/skia.gyp:skia', '../testing/gmock.gyp:gmock', '../testing/gtest.gyp:gtest', ], @@ -881,6 +956,15 @@ 'base/mock_filters.h', 'base/test_helpers.cc', 'base/test_helpers.h', + 'video/capture/screen/screen_capturer_mock_objects.cc', + 'video/capture/screen/screen_capturer_mock_objects.h', + ], + 'conditions': [ + [ 'screen_capture_supported == 0', { + 'sources/': [ + ['exclude', '^video/capture/screen/'], + ], + }], ], }, ], @@ -1346,6 +1430,28 @@ ], }, ], - }] + }], + [ 'screen_capture_supported==1 and (target_arch=="ia32" or target_arch=="x64")', { + 'targets': [ + { + 'target_name': 'differ_block_sse2', + 'type': 'static_library', + 'conditions': [ + [ 'os_posix == 1 and OS != "mac"', { + 'cflags': [ + '-msse2', + ], + }], + ], + 'include_dirs': [ + '..', + ], + 'sources': [ + 'video/capture/screen/differ_block_sse2.cc', + 'video/capture/screen/differ_block_sse2.h', + ], + }, # end of target differ_block_sse2 + ], + }], ], } diff --git a/remoting/capturer/DEPS b/media/video/capture/screen/DEPS index 6b0cdaa6..2a3980b 100644 --- a/remoting/capturer/DEPS +++ b/media/video/capture/screen/DEPS @@ -1,3 +1,3 @@ include_rules = [ - "-remoting/base", + "+skia", ] diff --git a/media/video/capture/screen/OWNERS b/media/video/capture/screen/OWNERS new file mode 100644 index 0000000..3276530 --- /dev/null +++ b/media/video/capture/screen/OWNERS @@ -0,0 +1,3 @@ +alexeypa@chromium.org +sergeyu@chromium.org +wez@chromium.org diff --git a/remoting/capturer/differ.cc b/media/video/capture/screen/differ.cc index 07421cf..3296903 100644 --- a/remoting/capturer/differ.cc +++ b/media/video/capture/screen/differ.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/capturer/differ.h" +#include "media/video/capture/screen/differ.h" #include "base/logging.h" -#include "remoting/capturer/differ_block.h" +#include "media/video/capture/screen/differ_block.h" -namespace remoting { +namespace media { Differ::Differ(int width, int height, int bpp, int stride) { // Dimensions of screen. @@ -208,4 +208,4 @@ void Differ::MergeBlocks(SkRegion* region) { } } -} // namespace remoting +} // namespace media diff --git a/remoting/capturer/differ.h b/media/video/capture/screen/differ.h index 469384c..898c27d 100644 --- a/remoting/capturer/differ.h +++ b/media/video/capture/screen/differ.h @@ -2,16 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef REMOTING_CAPTURER_DIFFER_H_ -#define REMOTING_CAPTURER_DIFFER_H_ +#ifndef MEDIA_VIDEO_CAPTURE_SCREEN_DIFFER_H_ +#define MEDIA_VIDEO_CAPTURE_SCREEN_DIFFER_H_ #include <vector> #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" +#include "media/base/media_export.h" #include "third_party/skia/include/core/SkRegion.h" -namespace remoting { +namespace media { typedef uint8 DiffInfo; @@ -20,8 +21,8 @@ typedef uint8 DiffInfo; // the region that we are calculating. // http://crbug.com/92379 // TODO(sergeyu): Rename this class to something more sensible, e.g. -// VideoFrameDifferencer. -class Differ { +// ScreenCaptureFrameDifferencer. +class MEDIA_EXPORT Differ { public: // Create a differ that operates on bitmaps with the specified width, height // and bytes_per_pixel. @@ -79,6 +80,6 @@ class Differ { DISALLOW_COPY_AND_ASSIGN(Differ); }; -} // namespace remoting +} // namespace media -#endif // REMOTING_CAPTURER_DIFFER_H_ +#endif // MEDIA_VIDEO_CAPTURE_SCREEN_DIFFER_H_ diff --git a/remoting/capturer/differ_block.cc b/media/video/capture/screen/differ_block.cc index 1386ba7..4a1b44d 100644 --- a/remoting/capturer/differ_block.cc +++ b/media/video/capture/screen/differ_block.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/capturer/differ_block.h" +#include "media/video/capture/screen/differ_block.h" #include "base/cpu.h" #include "build/build_config.h" -#include "remoting/capturer/differ_block_sse2.h" +#include "media/video/capture/screen/differ_block_sse2.h" -namespace remoting { +namespace media { int BlockDifference_C(const uint8* image1, const uint8* image2, int stride) { int width_bytes = kBlockSize * kBytesPerPixel; @@ -46,4 +46,4 @@ int BlockDifference(const uint8* image1, const uint8* image2, int stride) { return diff_proc(image1, image2, stride); } -} // namespace remoting +} // namespace media diff --git a/media/video/capture/screen/differ_block.h b/media/video/capture/screen/differ_block.h new file mode 100644 index 0000000..8b211e2 --- /dev/null +++ b/media/video/capture/screen/differ_block.h @@ -0,0 +1,28 @@ +// Copyright (c) 2011 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 MEDIA_VIDEO_CAPTURE_SCREEN_DIFFER_BLOCK_H_ +#define MEDIA_VIDEO_CAPTURE_SCREEN_DIFFER_BLOCK_H_ + +#include "base/basictypes.h" +#include "media/base/media_export.h" + +namespace media { + +// Size (in pixels) of each square block used for diffing. This must be a +// multiple of sizeof(uint64)/8. +const int kBlockSize = 32; + +// Format: BGRA 32 bit. +const int kBytesPerPixel = 4; + +// Low level functions to compare 2 blocks of pixels. Zero means the blocks +// are identical. One - the blocks are different. +MEDIA_EXPORT int BlockDifference(const uint8* image1, + const uint8* image2, + int stride); + +} // namespace media + +#endif // MEDIA_VIDEO_CAPTURE_SCREEN_DIFFER_BLOCK_H_ diff --git a/remoting/capturer/differ_block_sse2.cc b/media/video/capture/screen/differ_block_sse2.cc index 9078a42..abe7ced 100644 --- a/remoting/capturer/differ_block_sse2.cc +++ b/media/video/capture/screen/differ_block_sse2.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/capturer/differ_block_sse2.h" +#include "media/video/capture/screen/differ_block_sse2.h" #if defined(_MSC_VER) #include <intrin.h> @@ -11,9 +11,9 @@ #include <emmintrin.h> #endif -#include "remoting/capturer/differ_block.h" +#include "media/video/capture/screen/differ_block.h" -namespace remoting { +namespace media { extern int BlockDifference_SSE2_W16(const uint8* image1, const uint8* image2, int stride) { @@ -109,4 +109,4 @@ extern int BlockDifference_SSE2_W32(const uint8* image1, const uint8* image2, return 0; } -} // namespace remoting +} // namespace media diff --git a/remoting/capturer/differ_block_sse2.h b/media/video/capture/screen/differ_block_sse2.h index 2148f28..08d4d47 100644 --- a/remoting/capturer/differ_block_sse2.h +++ b/media/video/capture/screen/differ_block_sse2.h @@ -5,12 +5,12 @@ // This header file is used only differ_block.h. It defines the SSE2 rountines // for finding block difference. -#ifndef REMOTING_HOST_DIFFER_BLOCK_SSE2_H_ -#define REMOTING_HOST_DIFFER_BLOCK_SSE2_H_ +#ifndef MEDIA_VIDEO_CAPTURE_SCREEN_DIFFER_BLOCK_SSE2_H_ +#define MEDIA_VIDEO_CAPTURE_SCREEN_DIFFER_BLOCK_SSE2_H_ #include "base/basictypes.h" -namespace remoting { +namespace media { // Find block difference of dimension 16x16. extern int BlockDifference_SSE2_W16(const uint8* image1, const uint8* image2, @@ -20,6 +20,6 @@ extern int BlockDifference_SSE2_W16(const uint8* image1, const uint8* image2, extern int BlockDifference_SSE2_W32(const uint8* image1, const uint8* image2, int stride); -} // namespace remoting +} // namespace media -#endif // REMOTING_HOST_DIFFER_BLOCK_SSE2_H_ +#endif // MEDIA_VIDEO_CAPTURE_SCREEN_DIFFER_BLOCK_SSE2_H_ diff --git a/remoting/capturer/differ_block_unittest.cc b/media/video/capture/screen/differ_block_unittest.cc index d7bb62a..45694a0 100644 --- a/remoting/capturer/differ_block_unittest.cc +++ b/media/video/capture/screen/differ_block_unittest.cc @@ -3,10 +3,10 @@ // found in the LICENSE file. #include "base/memory/ref_counted.h" -#include "remoting/capturer/differ_block.h" +#include "media/video/capture/screen/differ_block.h" #include "testing/gmock/include/gmock/gmock.h" -namespace remoting { +namespace media { // Run 900 times to mimic 1280x720. // TODO(fbarchard): Remove benchmark once performance is non-issue. @@ -78,4 +78,4 @@ TEST(BlockDifferenceTestFirst, BlockDifference) { } } -} // namespace remoting +} // namespace media diff --git a/remoting/capturer/differ_unittest.cc b/media/video/capture/screen/differ_unittest.cc index 9d932cc..9b9b20f 100644 --- a/remoting/capturer/differ_unittest.cc +++ b/media/video/capture/screen/differ_unittest.cc @@ -3,11 +3,11 @@ // found in the LICENSE file. #include "base/memory/scoped_ptr.h" -#include "remoting/capturer/differ.h" -#include "remoting/capturer/differ_block.h" +#include "media/video/capture/screen/differ.h" +#include "media/video/capture/screen/differ_block.h" #include "testing/gmock/include/gmock/gmock.h" -namespace remoting { +namespace media { // 96x96 screen gives a 4x4 grid of blocks. const int kScreenWidth= 96; @@ -636,4 +636,4 @@ TEST_F(DifferTest, MergeBlocks_MultiRect) { ASSERT_TRUE(CheckDirtyRegionContainsRect(dirty, 1, 2, 1, 1)); } -} // namespace remoting +} // namespace media diff --git a/remoting/capturer/linux/x_server_pixel_buffer.cc b/media/video/capture/screen/linux/x_server_pixel_buffer.cc index c495cbc..99d454c 100644 --- a/remoting/capturer/linux/x_server_pixel_buffer.cc +++ b/media/video/capture/screen/linux/x_server_pixel_buffer.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/capturer/linux/x_server_pixel_buffer.h" +#include "media/video/capture/screen/linux/x_server_pixel_buffer.h" #include <sys/shm.h> @@ -56,7 +56,7 @@ int GetLastXServerError() { } // namespace -namespace remoting { +namespace media { XServerPixelBuffer::XServerPixelBuffer() : display_(NULL), root_window_(0), @@ -272,4 +272,4 @@ bool XServerPixelBuffer::IsRgb() const { return GetRedShift() == 16 && GetGreenShift() == 8 && GetBlueShift() == 0; } -} // namespace remoting +} // namespace media diff --git a/remoting/capturer/linux/x_server_pixel_buffer.h b/media/video/capture/screen/linux/x_server_pixel_buffer.h index afd96b0..e4d2f4b 100644 --- a/remoting/capturer/linux/x_server_pixel_buffer.h +++ b/media/video/capture/screen/linux/x_server_pixel_buffer.h @@ -4,8 +4,8 @@ // Don't include this file in any .h files because it pulls in some X headers. -#ifndef REMOTING_CAPTURER_LINUX_X_SERVER_PIXEL_BUFFER_H_ -#define REMOTING_CAPTURER_LINUX_X_SERVER_PIXEL_BUFFER_H_ +#ifndef MEDIA_VIDEO_CAPTURE_SCREEN_LINUX_X_SERVER_PIXEL_BUFFER_H_ +#define MEDIA_VIDEO_CAPTURE_SCREEN_LINUX_X_SERVER_PIXEL_BUFFER_H_ #include "base/basictypes.h" #include "third_party/skia/include/core/SkRect.h" @@ -13,7 +13,7 @@ #include <X11/Xutil.h> #include <X11/extensions/XShm.h> -namespace remoting { +namespace media { // A class to allow the X server's pixel buffer to be accessed as efficiently // as possible. @@ -77,6 +77,6 @@ class XServerPixelBuffer { DISALLOW_COPY_AND_ASSIGN(XServerPixelBuffer); }; -} // namespace remoting +} // namespace media -#endif // REMOTING_CAPTURER_LINUX_X_SERVER_PIXEL_BUFFER_H_ +#endif // MEDIA_VIDEO_CAPTURE_SCREEN_LINUX_X_SERVER_PIXEL_BUFFER_H_ diff --git a/remoting/capturer/mac/desktop_configuration.h b/media/video/capture/screen/mac/desktop_configuration.h index 7157d75..998f918 100644 --- a/remoting/capturer/mac/desktop_configuration.h +++ b/media/video/capture/screen/mac/desktop_configuration.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef REMOTING_CAPTURER_MAC_DESKTOP_CONFIGURATION_H_ -#define REMOTING_CAPTURER_MAC_DESKTOP_CONFIGURATION_H_ +#ifndef MEDIA_VIDEO_CAPTURE_SCREEN_MAC_DESKTOP_CONFIGURATION_H_ +#define MEDIA_VIDEO_CAPTURE_SCREEN_MAC_DESKTOP_CONFIGURATION_H_ #include <ApplicationServices/ApplicationServices.h> #include <Carbon/Carbon.h> @@ -13,7 +13,7 @@ #include "third_party/skia/include/core/SkPoint.h" #include "third_party/skia/include/core/SkRect.h" -namespace remoting { +namespace media { // Describes the configuration of a specific display. struct MacDisplayConfiguration { @@ -58,6 +58,6 @@ struct MacDesktopConfiguration { MacDisplayConfigurations displays; }; -} // namespace remoting +} // namespace media -#endif // REMOTING_CAPTURER_MAC_DESKTOP_CONFIGURATION_H_ +#endif // MEDIA_VIDEO_CAPTURE_SCREEN_MAC_DESKTOP_CONFIGURATION_H_ diff --git a/remoting/capturer/mac/desktop_configuration.mm b/media/video/capture/screen/mac/desktop_configuration.mm index f14e3e4..064c4ef 100644 --- a/remoting/capturer/mac/desktop_configuration.mm +++ b/media/video/capture/screen/mac/desktop_configuration.mm @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/capturer/mac/desktop_configuration.h" +#include "media/video/capture/screen/mac/desktop_configuration.h" #include <Cocoa/Cocoa.h> @@ -19,7 +19,7 @@ #endif // 10.7 -namespace remoting { +namespace media { MacDisplayConfiguration::MacDisplayConfiguration() : id(0), @@ -103,4 +103,4 @@ MacDesktopConfiguration MacDesktopConfiguration::GetCurrent() { return desktop_config; } -} // namespace remoting +} // namespace media diff --git a/remoting/capturer/mac/scoped_pixel_buffer_object.cc b/media/video/capture/screen/mac/scoped_pixel_buffer_object.cc index 39afc3e..29adf6f 100644 --- a/remoting/capturer/mac/scoped_pixel_buffer_object.cc +++ b/media/video/capture/screen/mac/scoped_pixel_buffer_object.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/capturer/mac/scoped_pixel_buffer_object.h" +#include "media/video/capture/screen/mac/scoped_pixel_buffer_object.h" -namespace remoting { +namespace media { ScopedPixelBufferObject::ScopedPixelBufferObject() : cgl_context_(NULL), @@ -44,4 +44,4 @@ void ScopedPixelBufferObject::Release() { } } -} // namespace remoting +} // namespace media diff --git a/remoting/capturer/mac/scoped_pixel_buffer_object.h b/media/video/capture/screen/mac/scoped_pixel_buffer_object.h index f928ab5..0c06278 100644 --- a/remoting/capturer/mac/scoped_pixel_buffer_object.h +++ b/media/video/capture/screen/mac/scoped_pixel_buffer_object.h @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef REMOTING_CAPTURER_SCOPED_PIXEL_BUFFER_OBJECT_H_ -#define REMOTING_CAPTURER_SCOPED_PIXEL_BUFFER_OBJECT_H_ +#ifndef MEDIA_VIDEO_CAPTURE_SCREEN_SCOPED_PIXEL_BUFFER_OBJECT_H_ +#define MEDIA_VIDEO_CAPTURE_SCREEN_SCOPED_PIXEL_BUFFER_OBJECT_H_ #include <OpenGL/CGLMacro.h> #include <OpenGL/OpenGL.h> #include "base/basictypes.h" -namespace remoting { +namespace media { class ScopedPixelBufferObject { public: @@ -28,6 +28,6 @@ class ScopedPixelBufferObject { DISALLOW_COPY_AND_ASSIGN(ScopedPixelBufferObject); }; -} // namespace remoting +} // namespace media -#endif // REMOTING_CAPTURER_SCOPED_PIXEL_BUFFER_OBJECT_H_ +#endif // MEDIA_VIDEO_CAPTURE_SCREEN_SCOPED_PIXEL_BUFFER_OBJECT_H_ diff --git a/remoting/capturer/mouse_cursor_shape.cc b/media/video/capture/screen/mouse_cursor_shape.cc index 7381a2b0..f57f7fb 100644 --- a/remoting/capturer/mouse_cursor_shape.cc +++ b/media/video/capture/screen/mouse_cursor_shape.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/capturer/mouse_cursor_shape.h" +#include "media/video/capture/screen/mouse_cursor_shape.h" -namespace remoting { +namespace media { MouseCursorShape::MouseCursorShape() : size(SkISize::Make(0, 0)), @@ -14,4 +14,4 @@ MouseCursorShape::MouseCursorShape() MouseCursorShape::~MouseCursorShape() { } -} // namespace remoting +} // namespace media diff --git a/remoting/capturer/mouse_cursor_shape.h b/media/video/capture/screen/mouse_cursor_shape.h index 136728a..e2d57f1 100644 --- a/remoting/capturer/mouse_cursor_shape.h +++ b/media/video/capture/screen/mouse_cursor_shape.h @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef REMOTING_CAPTURER_MOUSE_CURSOR_SHAPE_H_ -#define REMOTING_CAPTURER_MOUSE_CURSOR_SHAPE_H_ +#ifndef MEDIA_VIDEO_CAPTURE_SCREEN_MOUSE_CURSOR_SHAPE_H_ +#define MEDIA_VIDEO_CAPTURE_SCREEN_MOUSE_CURSOR_SHAPE_H_ #include <string> +#include "media/base/media_export.h" #include "third_party/skia/include/core/SkPoint.h" -#include "third_party/skia/include/core/SkRect.h" #include "third_party/skia/include/core/SkSize.h" -namespace remoting { +namespace media { // Type used to return mouse cursor shape from video capturers. -struct MouseCursorShape { +struct MEDIA_EXPORT MouseCursorShape { MouseCursorShape(); ~MouseCursorShape(); @@ -28,6 +28,6 @@ struct MouseCursorShape { std::string data; }; -} // namespace remoting +} // namespace media -#endif // REMOTING_CAPTURER_MOUSE_CURSOR_SHAPE_H_ +#endif // MEDIA_VIDEO_CAPTURE_SCREEN_MOUSE_CURSOR_SHAPE_H_ diff --git a/remoting/capturer/capture_data.cc b/media/video/capture/screen/screen_capture_data.cc index 49511da..2869401 100644 --- a/remoting/capturer/capture_data.cc +++ b/media/video/capture/screen/screen_capture_data.cc @@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/capturer/capture_data.h" +#include "media/video/capture/screen/screen_capture_data.h" -namespace remoting { +namespace media { -CaptureData::CaptureData(uint8* data, int stride, const SkISize& size) +ScreenCaptureData::ScreenCaptureData(uint8* data, + int stride, + const SkISize& size) : data_(data), stride_(stride), size_(size), @@ -15,6 +17,6 @@ CaptureData::CaptureData(uint8* data, int stride, const SkISize& size) dpi_(SkIPoint::Make(0, 0)) { } -CaptureData::~CaptureData() {} +ScreenCaptureData::~ScreenCaptureData() {} -} // namespace remoting +} // namespace media diff --git a/remoting/capturer/capture_data.h b/media/video/capture/screen/screen_capture_data.h index a68ebe8..c5e4a09 100644 --- a/remoting/capturer/capture_data.h +++ b/media/video/capture/screen/screen_capture_data.h @@ -2,28 +2,30 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef REMOTING_CAPTURER_CAPTURE_DATA_H_ -#define REMOTING_CAPTURER_CAPTURE_DATA_H_ +#ifndef MEDIA_VIDEO_CAPTURE_SCREEN_CAPTURE_DATA_H_ +#define MEDIA_VIDEO_CAPTURE_SCREEN_CAPTURE_DATA_H_ #include <vector> #include "base/basictypes.h" #include "base/memory/ref_counted.h" -#include "remoting/capturer/shared_buffer.h" +#include "media/base/media_export.h" +#include "media/video/capture/screen/shared_buffer.h" #include "third_party/skia/include/core/SkRegion.h" -namespace remoting { +namespace media { class SharedBuffer; // Stores the data and information of a capture to pass off to the // encoding thread. -class CaptureData : public base::RefCountedThreadSafe<CaptureData> { +class MEDIA_EXPORT ScreenCaptureData + : public base::RefCountedThreadSafe<ScreenCaptureData> { public: // 32 bit RGB is 4 bytes per pixel. static const int kBytesPerPixel = 4; - CaptureData(uint8* data, int stride, const SkISize& size); + ScreenCaptureData(uint8* data, int stride, const SkISize& size); // Data buffer. uint8* data() const { return data_; } @@ -66,8 +68,8 @@ class CaptureData : public base::RefCountedThreadSafe<CaptureData> { } private: - friend class base::RefCountedThreadSafe<CaptureData>; - virtual ~CaptureData(); + friend class base::RefCountedThreadSafe<ScreenCaptureData>; + virtual ~ScreenCaptureData(); uint8* data_; int stride_; @@ -86,6 +88,6 @@ class CaptureData : public base::RefCountedThreadSafe<CaptureData> { scoped_refptr<SharedBuffer> shared_buffer_; }; -} // namespace remoting +} // namespace media -#endif // REMOTING_CAPTURER_CAPTURE_DATA_H_ +#endif // MEDIA_VIDEO_CAPTURE_SCREEN_CAPTURE_DATA_H_ diff --git a/remoting/capturer/video_frame.cc b/media/video/capture/screen/screen_capture_frame.cc index b9d7278..4da28eb 100644 --- a/remoting/capturer/video_frame.cc +++ b/media/video/capture/screen/screen_capture_frame.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/capturer/video_frame.h" +#include "media/video/capture/screen/screen_capture_frame.h" -namespace remoting { +namespace media { -VideoFrame::~VideoFrame() { +ScreenCaptureFrame::~ScreenCaptureFrame() { } -VideoFrame::VideoFrame() +ScreenCaptureFrame::ScreenCaptureFrame() : bytes_per_row_(0), dimensions_(SkISize::Make(0, 0)), pixels_(NULL) { } -} // namespace remoting +} // namespace media diff --git a/remoting/capturer/video_frame.h b/media/video/capture/screen/screen_capture_frame.h index 77105b7..090501e 100644 --- a/remoting/capturer/video_frame.h +++ b/media/video/capture/screen/screen_capture_frame.h @@ -2,22 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef REMOTING_CAPTURER_VIDEO_FRAME_H_ -#define REMOTING_CAPTURER_VIDEO_FRAME_H_ +#ifndef MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURE_FRAME_H_ +#define MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURE_FRAME_H_ #include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" -#include "remoting/capturer/shared_buffer.h" +#include "media/base/media_export.h" +#include "media/video/capture/screen/shared_buffer.h" #include "third_party/skia/include/core/SkSize.h" #include "third_party/skia/include/core/SkTypes.h" -namespace remoting { +namespace media { // Represents a video frame. -class VideoFrame { +class MEDIA_EXPORT ScreenCaptureFrame { public: - virtual ~VideoFrame(); + virtual ~ScreenCaptureFrame(); int bytes_per_row() const { return bytes_per_row_; } const SkISize& dimensions() const { return dimensions_; } @@ -30,7 +31,7 @@ class VideoFrame { // Initializes an empty video frame. Derived classes are expected to allocate // memory for the frame in a platform-specific way and set the properties of // the allocated frame. - VideoFrame(); + ScreenCaptureFrame(); void set_bytes_per_row(int bytes_per_row) { bytes_per_row_ = bytes_per_row; @@ -55,9 +56,9 @@ class VideoFrame { // Points to an optional shared memory buffer that backs up |pixels_| buffer. scoped_refptr<SharedBuffer> shared_buffer_; - DISALLOW_COPY_AND_ASSIGN(VideoFrame); + DISALLOW_COPY_AND_ASSIGN(ScreenCaptureFrame); }; -} // namespace remoting +} // namespace media -#endif // REMOTING_CAPTURER_VIDEO_FRAME_H_ +#endif // MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURE_FRAME_H_ diff --git a/remoting/capturer/video_frame_queue.cc b/media/video/capture/screen/screen_capture_frame_queue.cc index 1d23f4e..610a062 100644 --- a/remoting/capturer/video_frame_queue.cc +++ b/media/video/capture/screen/screen_capture_frame_queue.cc @@ -2,37 +2,38 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/capturer/video_frame_queue.h" +#include "media/video/capture/screen/screen_capture_frame_queue.h" #include <algorithm> #include "base/basictypes.h" -#include "remoting/capturer/video_frame.h" +#include "media/video/capture/screen/screen_capture_frame.h" -namespace remoting { +namespace media { -VideoFrameQueue::VideoFrameQueue() +ScreenCaptureFrameQueue::ScreenCaptureFrameQueue() : current_(0), previous_(NULL) { SetAllFramesNeedUpdate(); } -VideoFrameQueue::~VideoFrameQueue() { +ScreenCaptureFrameQueue::~ScreenCaptureFrameQueue() { } -void VideoFrameQueue::DoneWithCurrentFrame() { +void ScreenCaptureFrameQueue::DoneWithCurrentFrame() { previous_ = current_frame(); current_ = (current_ + 1) % kQueueLength; } -void VideoFrameQueue::ReplaceCurrentFrame(scoped_ptr<VideoFrame> frame) { +void ScreenCaptureFrameQueue::ReplaceCurrentFrame( + scoped_ptr<ScreenCaptureFrame> frame) { frames_[current_] = frame.Pass(); needs_update_[current_] = false; } -void VideoFrameQueue::SetAllFramesNeedUpdate() { +void ScreenCaptureFrameQueue::SetAllFramesNeedUpdate() { std::fill(needs_update_, needs_update_ + arraysize(needs_update_), true); previous_ = NULL; } -} // namespace remoting +} // namespace media diff --git a/remoting/capturer/video_frame_queue.h b/media/video/capture/screen/screen_capture_frame_queue.h index 44aee7c..d36f15a 100644 --- a/remoting/capturer/video_frame_queue.h +++ b/media/video/capture/screen/screen_capture_frame_queue.h @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef REMOTING_CAPTURER_VIDEO_FRAME_QUEUE_H_ -#define REMOTING_CAPTURER_VIDEO_FRAME_QUEUE_H_ +#ifndef MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURE_FRAME_QUEUE_H_ +#define MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURE_FRAME_QUEUE_H_ #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" -namespace remoting { +namespace media { -class VideoFrame; +class ScreenCaptureFrame; // Represents a queue of reusable video frames. Provides access to the 'current' // frame - the frame that the caller is working with at the moment, and to @@ -21,10 +21,10 @@ class VideoFrame; // is set. The caller can mark all frames in the queue for reallocation (when, // say, frame dimensions change). The queue records which frames need updating // which the caller can query. -class VideoFrameQueue { +class ScreenCaptureFrameQueue { public: - VideoFrameQueue(); - ~VideoFrameQueue(); + ScreenCaptureFrameQueue(); + ~ScreenCaptureFrameQueue(); // Moves to the next frame in the queue, moving the 'current' frame to become // the 'previous' one. @@ -32,13 +32,13 @@ class VideoFrameQueue { // Replaces the current frame with a new one allocated by the caller. // The existing frame (if any) is destroyed. - void ReplaceCurrentFrame(scoped_ptr<VideoFrame> frame); + void ReplaceCurrentFrame(scoped_ptr<ScreenCaptureFrame> frame); // Marks all frames obsolete and resets the previous frame pointer. No // frames are freed though as the caller can still access them. void SetAllFramesNeedUpdate(); - VideoFrame* current_frame() const { + ScreenCaptureFrame* current_frame() const { return frames_[current_].get(); } @@ -46,24 +46,24 @@ class VideoFrameQueue { return !current_frame() || needs_update_[current_]; } - VideoFrame* previous_frame() const { return previous_; } + ScreenCaptureFrame* previous_frame() const { return previous_; } private: // Index of the current frame. int current_; static const int kQueueLength = 2; - scoped_ptr<VideoFrame> frames_[kQueueLength]; + scoped_ptr<ScreenCaptureFrame> frames_[kQueueLength]; // True if the corresponding frame needs to be re-allocated. bool needs_update_[kQueueLength]; // Points to the previous frame if any. - VideoFrame* previous_; + ScreenCaptureFrame* previous_; - DISALLOW_COPY_AND_ASSIGN(VideoFrameQueue); + DISALLOW_COPY_AND_ASSIGN(ScreenCaptureFrameQueue); }; -} // namespace remoting +} // namespace media -#endif // REMOTING_CAPTURER_VIDEO_FRAME_QUEUE_H_ +#endif // MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURE_FRAME_QUEUE_H_ diff --git a/remoting/capturer/video_frame_capturer.h b/media/video/capture/screen/screen_capturer.h index 2b6c803..0d34871 100644 --- a/remoting/capturer/video_frame_capturer.h +++ b/media/video/capture/screen/screen_capturer.h @@ -2,17 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef REMOTING_CAPTURER_VIDEO_FRAME_CAPTURER_H_ -#define REMOTING_CAPTURER_VIDEO_FRAME_CAPTURER_H_ +#ifndef MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_H_ +#define MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_H_ #include "base/basictypes.h" #include "base/callback.h" #include "base/shared_memory.h" +#include "media/base/media_export.h" #include "third_party/skia/include/core/SkRegion.h" -namespace remoting { +namespace media { -class CaptureData; +class ScreenCaptureData; struct MouseCursorShape; class SharedBufferFactory; @@ -46,7 +47,7 @@ class SharedBufferFactory; // Implementation has to ensure the following guarantees: // 1. Double buffering // Since data can be read while another capture action is happening. -class VideoFrameCapturer { +class MEDIA_EXPORT ScreenCapturer { public: // Provides callbacks used by the capturer to pass captured video frames and // mouse cursor shapes to the processing pipeline. @@ -55,7 +56,7 @@ class VideoFrameCapturer { // Called when a video frame has been captured. |capture_data| describes // a captured frame. virtual void OnCaptureCompleted( - scoped_refptr<CaptureData> capture_data) = 0; + scoped_refptr<ScreenCaptureData> capture_data) = 0; // Called when the cursor shape has changed. // TODO(sergeyu): Move cursor shape capturing to a separate class. @@ -66,26 +67,26 @@ class VideoFrameCapturer { virtual ~Delegate() {} }; - virtual ~VideoFrameCapturer() {} + virtual ~ScreenCapturer() {} // Create platform-specific capturer. - static scoped_ptr<VideoFrameCapturer> Create(); + static scoped_ptr<ScreenCapturer> Create(); // Create platform-specific capturer that uses shared memory buffers. - static scoped_ptr<VideoFrameCapturer> CreateWithFactory( + static scoped_ptr<ScreenCapturer> CreateWithFactory( SharedBufferFactory* shared_buffer_factory); #if defined(OS_LINUX) - // Set whether the VideoFrameCapturer should try to use X DAMAGE support if it - // is available. This needs to be called before the VideoFrameCapturer is + // Set whether the ScreenCapturer should try to use X DAMAGE support if it + // is available. This needs to be called before the ScreenCapturer is // created. // This is used by the Virtual Me2Me host, since the XDamage extension is // known to work reliably in this case. // TODO(lambroslambrou): This currently sets a global flag, referenced during - // VideoFrameCapturer::Create(). This is a temporary solution, until the + // ScreenCapturer::Create(). This is a temporary solution, until the // DesktopEnvironment class is refactored to allow applications to control - // the creation of various stubs (including the VideoFrameCapturer) - see + // the creation of various stubs (including the ScreenCapturer) - see // http://crbug.com/104544 static void EnableXDamage(bool enable); #endif // defined(OS_LINUX) @@ -110,6 +111,6 @@ class VideoFrameCapturer { virtual void CaptureFrame() = 0; }; -} // namespace remoting +} // namespace media -#endif // REMOTING_CAPTURER_VIDEO_FRAME_CAPTURER_H_ +#endif // MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_H_ diff --git a/remoting/capturer/video_frame_capturer_fake.cc b/media/video/capture/screen/screen_capturer_fake.cc index 8cdff43..d069d54 100644 --- a/remoting/capturer/video_frame_capturer_fake.cc +++ b/media/video/capture/screen/screen_capturer_fake.cc @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/capturer/video_frame_capturer_fake.h" +#include "media/video/capture/screen/screen_capturer_fake.h" #include "base/time.h" -#include "remoting/capturer/capture_data.h" +#include "media/video/capture/screen/screen_capture_data.h" -namespace remoting { +namespace media { -// VideoFrameCapturerFake generates a white picture of size kWidth x kHeight +// 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 = VideoFrameCapturerFake::kWidth; -static const int kHeight = VideoFrameCapturerFake::kHeight; +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; @@ -23,7 +23,7 @@ COMPILE_ASSERT((kBoxWidth % kSpeed == 0) && (kWidth % kSpeed == 0) && (kBoxHeight % kSpeed == 0) && (kHeight % kSpeed == 0), sizes_must_be_multiple_of_kSpeed); -VideoFrameCapturerFake::VideoFrameCapturerFake() +ScreenCapturerFake::ScreenCapturerFake() : size_(SkISize::Make(0, 0)), bytes_per_row_(0), box_pos_x_(0), @@ -34,21 +34,21 @@ VideoFrameCapturerFake::VideoFrameCapturerFake() ScreenConfigurationChanged(); } -VideoFrameCapturerFake::~VideoFrameCapturerFake() { +ScreenCapturerFake::~ScreenCapturerFake() { } -void VideoFrameCapturerFake::Start(Delegate* delegate) { +void ScreenCapturerFake::Start(Delegate* delegate) { delegate_ = delegate; } -void VideoFrameCapturerFake::Stop() { +void ScreenCapturerFake::Stop() { } -void VideoFrameCapturerFake::InvalidateRegion(const SkRegion& invalid_region) { +void ScreenCapturerFake::InvalidateRegion(const SkRegion& invalid_region) { helper_.InvalidateRegion(invalid_region); } -void VideoFrameCapturerFake::CaptureFrame() { +void ScreenCapturerFake::CaptureFrame() { base::Time capture_start_time = base::Time::Now(); GenerateImage(); @@ -59,7 +59,7 @@ void VideoFrameCapturerFake::CaptureFrame() { current_buffer_ = (current_buffer_ + 1) % kNumBuffers; - scoped_refptr<CaptureData> capture_data(new CaptureData( + scoped_refptr<ScreenCaptureData> capture_data(new ScreenCaptureData( buffers_[current_buffer_].get(), bytes_per_row_, size_)); capture_data->mutable_dirty_region() = invalid_region; @@ -70,12 +70,13 @@ void VideoFrameCapturerFake::CaptureFrame() { delegate_->OnCaptureCompleted(capture_data); } -void VideoFrameCapturerFake::GenerateImage() { +void ScreenCapturerFake::GenerateImage() { memset(buffers_[current_buffer_].get(), 0xff, - size_.width() * size_.height() * CaptureData::kBytesPerPixel); + size_.width() * size_.height() * ScreenCaptureData::kBytesPerPixel); uint8* row = buffers_[current_buffer_].get() + - (box_pos_y_ * size_.width() + box_pos_x_) * CaptureData::kBytesPerPixel; + (box_pos_y_ * size_.width() + box_pos_x_) * + ScreenCaptureData::kBytesPerPixel; box_pos_x_ += box_speed_x_; if (box_pos_x_ + kBoxWidth >= size_.width() || box_pos_x_ == 0) @@ -94,18 +95,18 @@ void VideoFrameCapturerFake::GenerateImage() { int r = x * 255 / kBoxWidth; int g = y * 255 / kBoxHeight; int b = 255 - (x * 255 / kBoxWidth); - row[x * CaptureData::kBytesPerPixel] = r; - row[x * CaptureData::kBytesPerPixel + 1] = g; - row[x * CaptureData::kBytesPerPixel + 2] = b; - row[x * CaptureData::kBytesPerPixel + 3] = 0xff; + row[x * ScreenCaptureData::kBytesPerPixel] = r; + row[x * ScreenCaptureData::kBytesPerPixel + 1] = g; + row[x * ScreenCaptureData::kBytesPerPixel + 2] = b; + row[x * ScreenCaptureData::kBytesPerPixel + 3] = 0xff; } row += bytes_per_row_; } } -void VideoFrameCapturerFake::ScreenConfigurationChanged() { +void ScreenCapturerFake::ScreenConfigurationChanged() { size_ = SkISize::Make(kWidth, kHeight); - bytes_per_row_ = size_.width() * CaptureData::kBytesPerPixel; + bytes_per_row_ = size_.width() * ScreenCaptureData::kBytesPerPixel; // Create memory for the buffers. int buffer_size = size_.height() * bytes_per_row_; @@ -114,4 +115,4 @@ void VideoFrameCapturerFake::ScreenConfigurationChanged() { } } -} // namespace remoting +} // namespace media diff --git a/remoting/capturer/video_frame_capturer_fake.h b/media/video/capture/screen/screen_capturer_fake.h index b116967..11daad4 100644 --- a/remoting/capturer/video_frame_capturer_fake.h +++ b/media/video/capture/screen/screen_capturer_fake.h @@ -2,29 +2,29 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef REMOTING_CAPTURER_VIDEO_FRAME_CAPTURER_FAKE_H_ -#define REMOTING_CAPTURER_VIDEO_FRAME_CAPTURER_FAKE_H_ +#ifndef MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_FAKE_H_ +#define MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_FAKE_H_ #include "base/memory/scoped_ptr.h" -#include "remoting/capturer/video_frame_capturer.h" -#include "remoting/capturer/video_frame_capturer_helper.h" +#include "media/base/media_export.h" +#include "media/video/capture/screen/screen_capturer.h" +#include "media/video/capture/screen/screen_capturer_helper.h" -namespace remoting { +namespace media { -// A VideoFrameCapturerFake generates artificial image for testing purpose. +// A ScreenCapturerFake generates artificial image for testing purpose. // -// VideoFrameCapturerFake is double-buffered as required by VideoFrameCapturer. -// See remoting/host/video_frame_capturer.h. -class VideoFrameCapturerFake : public VideoFrameCapturer { +// ScreenCapturerFake is double-buffered as required by ScreenCapturer. +class MEDIA_EXPORT ScreenCapturerFake : public ScreenCapturer { public: - // VideoFrameCapturerFake generates a picture of size kWidth x kHeight. + // ScreenCapturerFake generates a picture of size kWidth x kHeight. static const int kWidth = 800; static const int kHeight = 600; - VideoFrameCapturerFake(); - virtual ~VideoFrameCapturerFake(); + ScreenCapturerFake(); + virtual ~ScreenCapturerFake(); - // Overridden from VideoFrameCapturer: + // Overridden from ScreenCapturer: virtual void Start(Delegate* delegate) OVERRIDE; virtual void Stop() OVERRIDE; virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; @@ -46,7 +46,7 @@ class VideoFrameCapturerFake : public VideoFrameCapturer { int box_speed_x_; int box_speed_y_; - VideoFrameCapturerHelper helper_; + ScreenCapturerHelper helper_; // We have two buffers for the screen images as required by Capturer. static const int kNumBuffers = 2; @@ -55,9 +55,9 @@ class VideoFrameCapturerFake : public VideoFrameCapturer { // The current buffer with valid data for reading. int current_buffer_; - DISALLOW_COPY_AND_ASSIGN(VideoFrameCapturerFake); + DISALLOW_COPY_AND_ASSIGN(ScreenCapturerFake); }; -} // namespace remoting +} // namespace media -#endif // REMOTING_CAPTURER_VIDEO_FRAME_CAPTURER_FAKE_H_ +#endif // MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_FAKE_H_ diff --git a/remoting/capturer/video_frame_capturer_helper.cc b/media/video/capture/screen/screen_capturer_helper.cc index 7f05548..afc8208 100644 --- a/remoting/capturer/video_frame_capturer_helper.cc +++ b/media/video/capture/screen/screen_capturer_helper.cc @@ -2,46 +2,46 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/capturer/video_frame_capturer_helper.h" +#include "media/video/capture/screen/screen_capturer_helper.h" #include <algorithm> #include "base/logging.h" #include "base/memory/scoped_ptr.h" -namespace remoting { +namespace media { -VideoFrameCapturerHelper::VideoFrameCapturerHelper() : +ScreenCapturerHelper::ScreenCapturerHelper() : size_most_recent_(SkISize::Make(0, 0)), log_grid_size_(0) { } -VideoFrameCapturerHelper::~VideoFrameCapturerHelper() { +ScreenCapturerHelper::~ScreenCapturerHelper() { } -void VideoFrameCapturerHelper::ClearInvalidRegion() { +void ScreenCapturerHelper::ClearInvalidRegion() { base::AutoLock auto_invalid_region_lock(invalid_region_lock_); invalid_region_.setEmpty(); } -void VideoFrameCapturerHelper::InvalidateRegion( +void ScreenCapturerHelper::InvalidateRegion( const SkRegion& invalid_region) { base::AutoLock auto_invalid_region_lock(invalid_region_lock_); invalid_region_.op(invalid_region, SkRegion::kUnion_Op); } -void VideoFrameCapturerHelper::InvalidateScreen(const SkISize& size) { +void ScreenCapturerHelper::InvalidateScreen(const SkISize& size) { base::AutoLock auto_invalid_region_lock(invalid_region_lock_); invalid_region_.op(SkIRect::MakeWH(size.width(), size.height()), SkRegion::kUnion_Op); } -void VideoFrameCapturerHelper::InvalidateFullScreen() { +void ScreenCapturerHelper::InvalidateFullScreen() { if (!size_most_recent_.isZero()) InvalidateScreen(size_most_recent_); } -void VideoFrameCapturerHelper::SwapInvalidRegion(SkRegion* invalid_region) { +void ScreenCapturerHelper::SwapInvalidRegion(SkRegion* invalid_region) { { base::AutoLock auto_invalid_region_lock(invalid_region_lock_); invalid_region->swap(invalid_region_); @@ -55,15 +55,15 @@ void VideoFrameCapturerHelper::SwapInvalidRegion(SkRegion* invalid_region) { } } -void VideoFrameCapturerHelper::SetLogGridSize(int log_grid_size) { +void ScreenCapturerHelper::SetLogGridSize(int log_grid_size) { log_grid_size_ = log_grid_size; } -const SkISize& VideoFrameCapturerHelper::size_most_recent() const { +const SkISize& ScreenCapturerHelper::size_most_recent() const { return size_most_recent_; } -void VideoFrameCapturerHelper::set_size_most_recent(const SkISize& size) { +void ScreenCapturerHelper::set_size_most_recent(const SkISize& size) { size_most_recent_ = size; } @@ -79,7 +79,7 @@ static int UpToMultiple(int x, int n, int nMask) { return ((x + n - 1) & nMask); } -scoped_ptr<SkRegion> VideoFrameCapturerHelper::ExpandToGrid( +scoped_ptr<SkRegion> ScreenCapturerHelper::ExpandToGrid( const SkRegion& region, int log_grid_size) { DCHECK(log_grid_size >= 1); @@ -115,4 +115,4 @@ scoped_ptr<SkRegion> VideoFrameCapturerHelper::ExpandToGrid( return regionNew.Pass(); } -} // namespace remoting +} // namespace media diff --git a/remoting/capturer/video_frame_capturer_helper.h b/media/video/capture/screen/screen_capturer_helper.h index 79a4750..7b5e27e 100644 --- a/remoting/capturer/video_frame_capturer_helper.h +++ b/media/video/capture/screen/screen_capturer_helper.h @@ -2,23 +2,24 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef REMOTING_CAPTURER_VIDEO_FRAME_CAPTURER_HELPER_H_ -#define REMOTING_CAPTURER_VIDEO_FRAME_CAPTURER_HELPER_H_ +#ifndef MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_HELPER_H_ +#define MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_HELPER_H_ #include "base/memory/scoped_ptr.h" #include "base/synchronization/lock.h" +#include "media/base/media_export.h" #include "third_party/skia/include/core/SkRegion.h" -namespace remoting { +namespace media { -// VideoFrameCapturerHelper is intended to be used by an implementation of the -// VideoFrameCapturer interface. It maintains a thread-safe invalid region, and +// ScreenCapturerHelper is intended to be used by an implementation of the +// ScreenCapturer interface. It maintains a thread-safe invalid region, and // the size of the most recently captured screen, on behalf of the -// VideoFrameCapturer that owns it. -class VideoFrameCapturerHelper { +// ScreenCapturer that owns it. +class MEDIA_EXPORT ScreenCapturerHelper { public: - VideoFrameCapturerHelper(); - ~VideoFrameCapturerHelper(); + ScreenCapturerHelper(); + ~ScreenCapturerHelper(); // Clear out the invalid region. void ClearInvalidRegion(); @@ -75,9 +76,9 @@ class VideoFrameCapturerHelper { // If the value is <= 0, then the invalid region is not expanded to a grid. int log_grid_size_; - DISALLOW_COPY_AND_ASSIGN(VideoFrameCapturerHelper); + DISALLOW_COPY_AND_ASSIGN(ScreenCapturerHelper); }; -} // namespace remoting +} // namespace media -#endif // REMOTING_CAPTURER_VIDEO_FRAME_CAPTURER_HELPER_H_ +#endif // MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_HELPER_H_ diff --git a/remoting/capturer/video_frame_capturer_helper_unittest.cc b/media/video/capture/screen/screen_capturer_helper_unittest.cc index a362c34..dc22231 100644 --- a/remoting/capturer/video_frame_capturer_helper_unittest.cc +++ b/media/video/capture/screen/screen_capturer_helper_unittest.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/capturer/video_frame_capturer_helper.h" +#include "media/video/capture/screen/screen_capturer_helper.h" #include "base/memory/scoped_ptr.h" #include "testing/gtest/include/gtest/gtest.h" -namespace remoting { +namespace media { -class VideoFrameCapturerHelperTest : public testing::Test { +class ScreenCapturerHelperTest : public testing::Test { protected: - VideoFrameCapturerHelper capturer_helper_; + ScreenCapturerHelper capturer_helper_; }; bool Equals(const SkRegion& region1, const SkRegion& region2) { @@ -35,7 +35,7 @@ bool Equals(const SkRegion& region1, const SkRegion& region2) { return true; } -TEST_F(VideoFrameCapturerHelperTest, ClearInvalidRegion) { +TEST_F(ScreenCapturerHelperTest, ClearInvalidRegion) { SkRegion region; capturer_helper_.InvalidateRegion(SkRegion(SkIRect::MakeXYWH(1, 2, 3, 4))); capturer_helper_.ClearInvalidRegion(); @@ -43,7 +43,7 @@ TEST_F(VideoFrameCapturerHelperTest, ClearInvalidRegion) { ASSERT_TRUE(region.isEmpty()); } -TEST_F(VideoFrameCapturerHelperTest, InvalidateRegion) { +TEST_F(ScreenCapturerHelperTest, InvalidateRegion) { SkRegion region; capturer_helper_.SwapInvalidRegion(®ion); ASSERT_TRUE(Equals(SkRegion(SkIRect::MakeEmpty()), region)); @@ -60,14 +60,14 @@ TEST_F(VideoFrameCapturerHelperTest, InvalidateRegion) { ASSERT_TRUE(Equals(SkRegion(SkIRect::MakeXYWH(1, 2, 6, 4)), region)); } -TEST_F(VideoFrameCapturerHelperTest, InvalidateScreen) { +TEST_F(ScreenCapturerHelperTest, InvalidateScreen) { SkRegion region; capturer_helper_.InvalidateScreen(SkISize::Make(12, 34)); capturer_helper_.SwapInvalidRegion(®ion); ASSERT_TRUE(Equals(SkRegion(SkIRect::MakeWH(12, 34)), region)); } -TEST_F(VideoFrameCapturerHelperTest, InvalidateFullScreen) { +TEST_F(ScreenCapturerHelperTest, InvalidateFullScreen) { SkRegion region; capturer_helper_.set_size_most_recent(SkISize::Make(12, 34)); capturer_helper_.InvalidateFullScreen(); @@ -75,13 +75,13 @@ TEST_F(VideoFrameCapturerHelperTest, InvalidateFullScreen) { ASSERT_TRUE(Equals(SkRegion(SkIRect::MakeWH(12, 34)), region)); } -TEST_F(VideoFrameCapturerHelperTest, SizeMostRecent) { +TEST_F(ScreenCapturerHelperTest, SizeMostRecent) { ASSERT_EQ(SkISize::Make(0, 0), capturer_helper_.size_most_recent()); capturer_helper_.set_size_most_recent(SkISize::Make(12, 34)); ASSERT_EQ(SkISize::Make(12, 34), capturer_helper_.size_most_recent()); } -TEST_F(VideoFrameCapturerHelperTest, SetLogGridSize) { +TEST_F(ScreenCapturerHelperTest, SetLogGridSize) { capturer_helper_.set_size_most_recent(SkISize::Make(10, 10)); SkRegion region; @@ -127,10 +127,10 @@ TEST_F(VideoFrameCapturerHelperTest, SetLogGridSize) { void TestExpandRegionToGrid(const SkRegion& region, int log_grid_size, const SkRegion& expandedRegionExpected) { scoped_ptr<SkRegion> expandedRegion1( - VideoFrameCapturerHelper::ExpandToGrid(region, log_grid_size)); + ScreenCapturerHelper::ExpandToGrid(region, log_grid_size)); ASSERT_TRUE(Equals(expandedRegionExpected, *expandedRegion1)); scoped_ptr<SkRegion> expandedRegion2( - VideoFrameCapturerHelper::ExpandToGrid(*expandedRegion1, log_grid_size)); + ScreenCapturerHelper::ExpandToGrid(*expandedRegion1, log_grid_size)); ASSERT_TRUE(Equals(*expandedRegion1, *expandedRegion2)); } @@ -142,7 +142,7 @@ void TestExpandRectToGrid(int l, int t, int r, int b, int log_grid_size, rExpanded, bExpanded))); } -TEST_F(VideoFrameCapturerHelperTest, ExpandToGrid) { +TEST_F(ScreenCapturerHelperTest, ExpandToGrid) { const int LOG_GRID_SIZE = 4; const int GRID_SIZE = 1 << LOG_GRID_SIZE; for (int i = -2; i <= 2; i++) { @@ -212,4 +212,4 @@ TEST_F(VideoFrameCapturerHelperTest, ExpandToGrid) { } } -} // namespace remoting +} // namespace media diff --git a/remoting/capturer/video_frame_capturer_linux.cc b/media/video/capture/screen/screen_capturer_linux.cc index edfa1a4..774d62e 100644 --- a/remoting/capturer/video_frame_capturer_linux.cc +++ b/media/video/capture/screen/screen_capturer_linux.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/capturer/video_frame_capturer.h" +#include "media/video/capture/screen/screen_capturer.h" #include <X11/Xlib.h> #include <X11/Xutil.h> @@ -16,15 +16,15 @@ #include "base/memory/scoped_ptr.h" #include "base/stl_util.h" #include "base/time.h" -#include "remoting/capturer/capture_data.h" -#include "remoting/capturer/differ.h" -#include "remoting/capturer/linux/x_server_pixel_buffer.h" -#include "remoting/capturer/mouse_cursor_shape.h" -#include "remoting/capturer/video_frame.h" -#include "remoting/capturer/video_frame_capturer_helper.h" -#include "remoting/capturer/video_frame_queue.h" +#include "media/video/capture/screen/differ.h" +#include "media/video/capture/screen/linux/x_server_pixel_buffer.h" +#include "media/video/capture/screen/mouse_cursor_shape.h" +#include "media/video/capture/screen/screen_capture_data.h" +#include "media/video/capture/screen/screen_capture_frame.h" +#include "media/video/capture/screen/screen_capture_frame_queue.h" +#include "media/video/capture/screen/screen_capturer_helper.h" -namespace remoting { +namespace media { namespace { @@ -37,23 +37,23 @@ static bool ShouldUseXDamage() { } // A class representing a full-frame pixel buffer. -class VideoFrameLinux : public VideoFrame { +class ScreenCaptureFrameLinux : public ScreenCaptureFrame { public: - explicit VideoFrameLinux(const SkISize& window_size); - virtual ~VideoFrameLinux(); + explicit ScreenCaptureFrameLinux(const SkISize& window_size); + virtual ~ScreenCaptureFrameLinux(); private: // Allocated pixel buffer. scoped_array<uint8> data_; - DISALLOW_COPY_AND_ASSIGN(VideoFrameLinux); + DISALLOW_COPY_AND_ASSIGN(ScreenCaptureFrameLinux); }; // A class to perform video frame capturing for Linux. -class VideoFrameCapturerLinux : public VideoFrameCapturer { +class ScreenCapturerLinux : public ScreenCapturer { public: - VideoFrameCapturerLinux(); - virtual ~VideoFrameCapturerLinux(); + ScreenCapturerLinux(); + virtual ~ScreenCapturerLinux(); bool Init(); // TODO(ajwong): Do we really want this to be synchronous? @@ -68,7 +68,7 @@ class VideoFrameCapturerLinux : public VideoFrameCapturer { // Read and handle all currently-pending XEvents. // In the DAMAGE case, process the XDamage events and store the resulting - // damage rectangles in the VideoFrameCapturerHelper. + // damage rectangles in the ScreenCapturerHelper. // In all cases, call ScreenConfigurationChanged() in response to any // ConfigNotify events. void ProcessPendingXEvents(); @@ -76,14 +76,13 @@ class VideoFrameCapturerLinux : public VideoFrameCapturer { // Capture the cursor image and notify the delegate if it was captured. void CaptureCursor(); - // Capture screen pixels, and return the data in a new CaptureData object, - // to be freed by the caller. - // In the DAMAGE case, the VideoFrameCapturerHelper already holds the list of - // invalid rectangles from ProcessPendingXEvents(). - // In the non-DAMAGE case, this captures the whole screen, then calculates - // some invalid rectangles that include any differences between this and the - // previous capture. - scoped_refptr<CaptureData> CaptureScreen(); + // Capture screen pixels, and return the data in a new ScreenCaptureData + // object, to be freed by the caller. In the DAMAGE case, the + // ScreenCapturerHelper already holds the list of invalid rectangles from + // ProcessPendingXEvents(). In the non-DAMAGE case, this captures the whole + // screen, then calculates some invalid rectangles that include any + // differences between this and the previous capture. + scoped_refptr<ScreenCaptureData> CaptureScreen(); // Called when the screen configuration is changed. |root_window_size| // specifies the most recent size of the root window. @@ -100,12 +99,16 @@ class VideoFrameCapturerLinux : public VideoFrameCapturer { // Capture a rectangle from |x_server_pixel_buffer_|, and copy the data into // |capture_data|. - void CaptureRect(const SkIRect& rect, CaptureData* capture_data); + void CaptureRect(const SkIRect& rect, ScreenCaptureData* capture_data); // We expose two forms of blitting to handle variations in the pixel format. // In FastBlit, the operation is effectively a memcpy. - void FastBlit(uint8* image, const SkIRect& rect, CaptureData* capture_data); - void SlowBlit(uint8* image, const SkIRect& rect, CaptureData* capture_data); + void FastBlit(uint8* image, + const SkIRect& rect, + ScreenCaptureData* capture_data); + void SlowBlit(uint8* image, + const SkIRect& rect, + ScreenCaptureData* capture_data); Delegate* delegate_; @@ -134,10 +137,10 @@ class VideoFrameCapturerLinux : public VideoFrameCapturer { // A thread-safe list of invalid rectangles, and the size of the most // recently captured screen. - VideoFrameCapturerHelper helper_; + ScreenCapturerHelper helper_; // Queue of the frames buffers. - VideoFrameQueue queue_; + ScreenCaptureFrameQueue queue_; // Invalid region from the previous capture. This is used to synchronize the // current with the last buffer used. @@ -146,11 +149,11 @@ class VideoFrameCapturerLinux : public VideoFrameCapturer { // |Differ| for use when polling for changes. scoped_ptr<Differ> differ_; - DISALLOW_COPY_AND_ASSIGN(VideoFrameCapturerLinux); + DISALLOW_COPY_AND_ASSIGN(ScreenCapturerLinux); }; -VideoFrameLinux::VideoFrameLinux(const SkISize& window_size) { - set_bytes_per_row(window_size.width() * CaptureData::kBytesPerPixel); +ScreenCaptureFrameLinux::ScreenCaptureFrameLinux(const SkISize& window_size) { + set_bytes_per_row(window_size.width() * ScreenCaptureData::kBytesPerPixel); set_dimensions(window_size); size_t buffer_size = bytes_per_row() * window_size.height(); @@ -158,10 +161,10 @@ VideoFrameLinux::VideoFrameLinux(const SkISize& window_size) { set_pixels(data_.get()); } -VideoFrameLinux::~VideoFrameLinux() { +ScreenCaptureFrameLinux::~ScreenCaptureFrameLinux() { } -VideoFrameCapturerLinux::VideoFrameCapturerLinux() +ScreenCapturerLinux::ScreenCapturerLinux() : delegate_(NULL), display_(NULL), gc_(NULL), @@ -178,11 +181,11 @@ VideoFrameCapturerLinux::VideoFrameCapturerLinux() helper_.SetLogGridSize(4); } -VideoFrameCapturerLinux::~VideoFrameCapturerLinux() { +ScreenCapturerLinux::~ScreenCapturerLinux() { DeinitXlib(); } -bool VideoFrameCapturerLinux::Init() { +bool ScreenCapturerLinux::Init() { // TODO(ajwong): We should specify the display string we are attaching to // in the constructor. display_ = XOpenDisplay(NULL); @@ -233,7 +236,7 @@ bool VideoFrameCapturerLinux::Init() { return true; } -void VideoFrameCapturerLinux::InitXDamage() { +void ScreenCapturerLinux::InitXDamage() { // Our use of XDamage requires XFixes. if (!has_xfixes_) { return; @@ -271,20 +274,20 @@ void VideoFrameCapturerLinux::InitXDamage() { LOG(INFO) << "Using XDamage extension."; } -void VideoFrameCapturerLinux::Start(Delegate* delegate) { +void ScreenCapturerLinux::Start(Delegate* delegate) { DCHECK(delegate_ == NULL); delegate_ = delegate; } -void VideoFrameCapturerLinux::Stop() { +void ScreenCapturerLinux::Stop() { } -void VideoFrameCapturerLinux::InvalidateRegion(const SkRegion& invalid_region) { +void ScreenCapturerLinux::InvalidateRegion(const SkRegion& invalid_region) { helper_.InvalidateRegion(invalid_region); } -void VideoFrameCapturerLinux::CaptureFrame() { +void ScreenCapturerLinux::CaptureFrame() { base::Time capture_start_time = base::Time::Now(); // Process XEvents for XDamage and cursor shape tracking. @@ -294,13 +297,13 @@ void VideoFrameCapturerLinux::CaptureFrame() { // Note that we can't reallocate other buffers at this point, since the caller // may still be reading from them. if (queue_.current_frame_needs_update()) { - scoped_ptr<VideoFrameLinux> buffer(new VideoFrameLinux( + scoped_ptr<ScreenCaptureFrameLinux> buffer(new ScreenCaptureFrameLinux( root_window_size_)); - queue_.ReplaceCurrentFrame(buffer.PassAs<VideoFrame>()); + queue_.ReplaceCurrentFrame(buffer.PassAs<ScreenCaptureFrame>()); } // Refresh the Differ helper used by CaptureFrame(), if needed. - const VideoFrame* current_buffer = queue_.current_frame(); + const ScreenCaptureFrame* current_buffer = queue_.current_frame(); if (!use_damage_ && ( !differ_.get() || (differ_->width() != current_buffer->dimensions().width()) || @@ -308,11 +311,11 @@ void VideoFrameCapturerLinux::CaptureFrame() { (differ_->bytes_per_row() != current_buffer->bytes_per_row()))) { differ_.reset(new Differ(current_buffer->dimensions().width(), current_buffer->dimensions().height(), - CaptureData::kBytesPerPixel, + ScreenCaptureData::kBytesPerPixel, current_buffer->bytes_per_row())); } - scoped_refptr<CaptureData> capture_data(CaptureScreen()); + scoped_refptr<ScreenCaptureData> capture_data(CaptureScreen()); // Swap the current & previous buffers ready for the next capture. last_invalid_region_ = capture_data->dirty_region(); @@ -324,7 +327,7 @@ void VideoFrameCapturerLinux::CaptureFrame() { delegate_->OnCaptureCompleted(capture_data); } -void VideoFrameCapturerLinux::ProcessPendingXEvents() { +void ScreenCapturerLinux::ProcessPendingXEvents() { // Find the number of events that are outstanding "now." We don't just loop // on XPending because we want to guarantee this terminates. int events_to_process = XPending(display_); @@ -351,7 +354,7 @@ void VideoFrameCapturerLinux::ProcessPendingXEvents() { } } -void VideoFrameCapturerLinux::CaptureCursor() { +void ScreenCapturerLinux::CaptureCursor() { DCHECK(has_xfixes_); XFixesCursorImage* img = XFixesGetCursorImage(display_); @@ -364,7 +367,7 @@ void VideoFrameCapturerLinux::CaptureCursor() { cursor->hotspot.set(img->xhot, img->yhot); int total_bytes = cursor->size.width() * cursor->size.height() * - CaptureData::kBytesPerPixel; + ScreenCaptureData::kBytesPerPixel; cursor->data.resize(total_bytes); // Xlib stores 32-bit data in longs, even if longs are 64-bits long. @@ -379,9 +382,9 @@ void VideoFrameCapturerLinux::CaptureCursor() { delegate_->OnCursorShapeChanged(cursor.Pass()); } -scoped_refptr<CaptureData> VideoFrameCapturerLinux::CaptureScreen() { - VideoFrame* frame = queue_.current_frame(); - scoped_refptr<CaptureData> capture_data(new CaptureData( +scoped_refptr<ScreenCaptureData> ScreenCapturerLinux::CaptureScreen() { + ScreenCaptureFrame* frame = queue_.current_frame(); + scoped_refptr<ScreenCaptureData> capture_data(new ScreenCaptureData( frame->pixels(), frame->bytes_per_row(), frame->dimensions())); // Pass the screen size to the helper, so it can clip the invalid region if it @@ -450,7 +453,7 @@ scoped_refptr<CaptureData> VideoFrameCapturerLinux::CaptureScreen() { return capture_data; } -void VideoFrameCapturerLinux::ScreenConfigurationChanged( +void ScreenCapturerLinux::ScreenConfigurationChanged( const SkISize& root_window_size) { root_window_size_ = root_window_size; @@ -461,7 +464,7 @@ void VideoFrameCapturerLinux::ScreenConfigurationChanged( x_server_pixel_buffer_.Init(display_, root_window_size_); } -void VideoFrameCapturerLinux::SynchronizeFrame() { +void ScreenCapturerLinux::SynchronizeFrame() { // Synchronize the current buffer with the previous one since we do not // capture the entire desktop. Note that encoder may be reading from the // previous buffer at this time so thread access complaints are false @@ -472,22 +475,23 @@ void VideoFrameCapturerLinux::SynchronizeFrame() { // http://crbug.com/92354 DCHECK(queue_.previous_frame()); - VideoFrame* current = queue_.current_frame(); - VideoFrame* last = queue_.previous_frame(); + ScreenCaptureFrame* current = queue_.current_frame(); + ScreenCaptureFrame* last = queue_.previous_frame(); DCHECK_NE(current, last); for (SkRegion::Iterator it(last_invalid_region_); !it.done(); it.next()) { const SkIRect& r = it.rect(); int offset = r.fTop * current->bytes_per_row() + - r.fLeft * CaptureData::kBytesPerPixel; + r.fLeft * ScreenCaptureData::kBytesPerPixel; for (int i = 0; i < r.height(); ++i) { memcpy(current->pixels() + offset, last->pixels() + offset, - r.width() * CaptureData::kBytesPerPixel); - offset += current->dimensions().width() * CaptureData::kBytesPerPixel; + r.width() * ScreenCaptureData::kBytesPerPixel); + offset += current->dimensions().width() * + ScreenCaptureData::kBytesPerPixel; } } } -void VideoFrameCapturerLinux::DeinitXlib() { +void ScreenCapturerLinux::DeinitXlib() { if (gc_) { XFreeGC(display_, gc_); gc_ = NULL; @@ -507,8 +511,8 @@ void VideoFrameCapturerLinux::DeinitXlib() { } } -void VideoFrameCapturerLinux::CaptureRect(const SkIRect& rect, - CaptureData* capture_data) { +void ScreenCapturerLinux::CaptureRect(const SkIRect& rect, + ScreenCaptureData* capture_data) { uint8* image = x_server_pixel_buffer_.CaptureRect(rect); int depth = x_server_pixel_buffer_.GetDepth(); int bpp = x_server_pixel_buffer_.GetBitsPerPixel(); @@ -522,17 +526,17 @@ void VideoFrameCapturerLinux::CaptureRect(const SkIRect& rect, } } -void VideoFrameCapturerLinux::FastBlit(uint8* image, const SkIRect& rect, - CaptureData* capture_data) { +void ScreenCapturerLinux::FastBlit(uint8* image, const SkIRect& rect, + ScreenCaptureData* capture_data) { uint8* src_pos = image; int src_stride = x_server_pixel_buffer_.GetStride(); int dst_x = rect.fLeft, dst_y = rect.fTop; uint8* dst_pos = capture_data->data() + capture_data->stride() * dst_y; - dst_pos += dst_x * CaptureData::kBytesPerPixel; + dst_pos += dst_x * ScreenCaptureData::kBytesPerPixel; int height = rect.height(); - int row_bytes = rect.width() * CaptureData::kBytesPerPixel; + int row_bytes = rect.width() * ScreenCaptureData::kBytesPerPixel; for (int y = 0; y < height; ++y) { memcpy(dst_pos, src_pos, row_bytes); src_pos += src_stride; @@ -540,8 +544,8 @@ void VideoFrameCapturerLinux::FastBlit(uint8* image, const SkIRect& rect, } } -void VideoFrameCapturerLinux::SlowBlit(uint8* image, const SkIRect& rect, - CaptureData* capture_data) { +void ScreenCapturerLinux::SlowBlit(uint8* image, const SkIRect& rect, + ScreenCaptureData* capture_data) { int src_stride = x_server_pixel_buffer_.GetStride(); int dst_x = rect.fLeft, dst_y = rect.fTop; int width = rect.width(), height = rect.height(); @@ -561,7 +565,7 @@ void VideoFrameCapturerLinux::SlowBlit(uint8* image, const SkIRect& rect, uint8* dst_pos = capture_data->data() + capture_data->stride() * dst_y; uint8* src_pos = image; - dst_pos += dst_x * CaptureData::kBytesPerPixel; + dst_pos += dst_x * ScreenCaptureData::kBytesPerPixel; // TODO(hclam): Optimize, perhaps using MMX code or by converting to // YUV directly for (int y = 0; y < height; y++) { @@ -591,23 +595,23 @@ void VideoFrameCapturerLinux::SlowBlit(uint8* image, const SkIRect& rect, } // namespace // static -scoped_ptr<VideoFrameCapturer> VideoFrameCapturer::Create() { - scoped_ptr<VideoFrameCapturerLinux> capturer(new VideoFrameCapturerLinux()); +scoped_ptr<ScreenCapturer> ScreenCapturer::Create() { + scoped_ptr<ScreenCapturerLinux> capturer(new ScreenCapturerLinux()); if (!capturer->Init()) capturer.reset(); - return capturer.PassAs<VideoFrameCapturer>(); + return capturer.PassAs<ScreenCapturer>(); } // static -scoped_ptr<VideoFrameCapturer> VideoFrameCapturer::CreateWithFactory( +scoped_ptr<ScreenCapturer> ScreenCapturer::CreateWithFactory( SharedBufferFactory* shared_buffer_factory) { NOTIMPLEMENTED(); - return scoped_ptr<VideoFrameCapturer>(); + return scoped_ptr<ScreenCapturer>(); } // static -void VideoFrameCapturer::EnableXDamage(bool enable) { +void ScreenCapturer::EnableXDamage(bool enable) { g_should_use_x_damage = enable; } -} // namespace remoting +} // namespace media diff --git a/remoting/capturer/video_frame_capturer_mac.mm b/media/video/capture/screen/screen_capturer_mac.mm index d77dd15..1baa090 100644 --- a/remoting/capturer/video_frame_capturer_mac.mm +++ b/media/video/capture/screen/screen_capturer_mac.mm @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/capturer/video_frame_capturer.h" +#include "media/video/capture/screen/screen_capturer.h" #include <ApplicationServices/ApplicationServices.h> #include <Cocoa/Cocoa.h> @@ -21,16 +21,16 @@ #include "base/scoped_native_library.h" #include "base/synchronization/waitable_event.h" #include "base/time.h" -#include "remoting/capturer/capture_data.h" -#include "remoting/capturer/mac/desktop_configuration.h" -#include "remoting/capturer/mac/scoped_pixel_buffer_object.h" -#include "remoting/capturer/mouse_cursor_shape.h" -#include "remoting/capturer/video_frame.h" -#include "remoting/capturer/video_frame_capturer_helper.h" -#include "remoting/capturer/video_frame_queue.h" +#include "media/video/capture/screen/mac/desktop_configuration.h" +#include "media/video/capture/screen/mac/scoped_pixel_buffer_object.h" +#include "media/video/capture/screen/mouse_cursor_shape.h" +#include "media/video/capture/screen/screen_capture_data.h" +#include "media/video/capture/screen/screen_capture_frame.h" +#include "media/video/capture/screen/screen_capture_frame_queue.h" +#include "media/video/capture/screen/screen_capturer_helper.h" #include "skia/ext/skia_utils_mac.h" -namespace remoting { +namespace media { namespace { @@ -92,10 +92,10 @@ void CopyRect(const uint8* src_plane, const int64 kDisplayConfigurationEventTimeoutInSeconds = 10; // A class representing a full-frame pixel buffer. -class VideoFrameMac : public VideoFrame { +class ScreenCaptureFrameMac : public ScreenCaptureFrame { public: - explicit VideoFrameMac(const MacDesktopConfiguration& desktop_config); - virtual ~VideoFrameMac(); + explicit ScreenCaptureFrameMac(const MacDesktopConfiguration& desktop_config); + virtual ~ScreenCaptureFrameMac(); const SkIPoint& dpi() const { return dpi_; } @@ -106,18 +106,18 @@ class VideoFrameMac : public VideoFrame { // DPI settings for this buffer. SkIPoint dpi_; - DISALLOW_COPY_AND_ASSIGN(VideoFrameMac); + DISALLOW_COPY_AND_ASSIGN(ScreenCaptureFrameMac); }; // A class to perform video frame capturing for mac. -class VideoFrameCapturerMac : public VideoFrameCapturer { +class ScreenCapturerMac : public ScreenCapturer { public: - VideoFrameCapturerMac(); - virtual ~VideoFrameCapturerMac(); + ScreenCapturerMac(); + virtual ~ScreenCapturerMac(); bool Init(); - // Overridden from VideoFrameCapturer: + // Overridden from ScreenCapturer: virtual void Start(Delegate* delegate) OVERRIDE; virtual void Stop() OVERRIDE; virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; @@ -126,10 +126,10 @@ class VideoFrameCapturerMac : public VideoFrameCapturer { private: void CaptureCursor(); - void GlBlitFast(const VideoFrame& buffer, const SkRegion& region); - void GlBlitSlow(const VideoFrame& buffer); - void CgBlitPreLion(const VideoFrame& buffer, const SkRegion& region); - void CgBlitPostLion(const VideoFrame& buffer, const SkRegion& region); + void GlBlitFast(const ScreenCaptureFrame& buffer, const SkRegion& region); + void GlBlitSlow(const ScreenCaptureFrame& buffer); + void CgBlitPreLion(const ScreenCaptureFrame& buffer, const SkRegion& region); + void CgBlitPostLion(const ScreenCaptureFrame& buffer, const SkRegion& region); // Called when the screen configuration is changed. void ScreenConfigurationChanged(); @@ -159,14 +159,14 @@ class VideoFrameCapturerMac : public VideoFrameCapturer { ScopedPixelBufferObject pixel_buffer_object_; // Queue of the frames buffers. - VideoFrameQueue queue_; + ScreenCaptureFrameQueue queue_; // Current display configuration. MacDesktopConfiguration desktop_config_; // A thread-safe list of invalid rectangles, and the size of the most // recently captured screen. - VideoFrameCapturerHelper helper_; + ScreenCapturerHelper helper_; // Image of the last cursor that we sent to the client. base::mac::ScopedCFTypeRef<CGImageRef> current_cursor_; @@ -196,10 +196,11 @@ class VideoFrameCapturerMac : public VideoFrameCapturer { base::ScopedNativeLibrary opengl_library_; CGLSetFullScreenFunc cgl_set_full_screen_; - DISALLOW_COPY_AND_ASSIGN(VideoFrameCapturerMac); + DISALLOW_COPY_AND_ASSIGN(ScreenCapturerMac); }; -VideoFrameMac::VideoFrameMac(const MacDesktopConfiguration& desktop_config) { +ScreenCaptureFrameMac::ScreenCaptureFrameMac( + const MacDesktopConfiguration& desktop_config) { SkISize size = SkISize::Make(desktop_config.pixel_bounds.width(), desktop_config.pixel_bounds.height()); set_bytes_per_row(size.width() * sizeof(uint32_t)); @@ -213,10 +214,10 @@ VideoFrameMac::VideoFrameMac(const MacDesktopConfiguration& desktop_config) { kStandardDPI * desktop_config.dip_to_pixel_scale); } -VideoFrameMac::~VideoFrameMac() { +ScreenCaptureFrameMac::~ScreenCaptureFrameMac() { } -VideoFrameCapturerMac::VideoFrameCapturerMac() +ScreenCapturerMac::ScreenCapturerMac() : delegate_(NULL), cgl_context_(NULL), display_configuration_capture_event_(false, true), @@ -229,35 +230,35 @@ VideoFrameCapturerMac::VideoFrameCapturerMac() { } -VideoFrameCapturerMac::~VideoFrameCapturerMac() { +ScreenCapturerMac::~ScreenCapturerMac() { ReleaseBuffers(); CGUnregisterScreenRefreshCallback( - VideoFrameCapturerMac::ScreenRefreshCallback, this); + ScreenCapturerMac::ScreenRefreshCallback, this); CGScreenUnregisterMoveCallback( - VideoFrameCapturerMac::ScreenUpdateMoveCallback, this); + ScreenCapturerMac::ScreenUpdateMoveCallback, this); CGError err = CGDisplayRemoveReconfigurationCallback( - VideoFrameCapturerMac::DisplaysReconfiguredCallback, this); + ScreenCapturerMac::DisplaysReconfiguredCallback, this); if (err != kCGErrorSuccess) { LOG(ERROR) << "CGDisplayRemoveReconfigurationCallback " << err; } } -bool VideoFrameCapturerMac::Init() { +bool ScreenCapturerMac::Init() { CGError err = CGRegisterScreenRefreshCallback( - VideoFrameCapturerMac::ScreenRefreshCallback, this); + ScreenCapturerMac::ScreenRefreshCallback, this); if (err != kCGErrorSuccess) { LOG(ERROR) << "CGRegisterScreenRefreshCallback " << err; return false; } err = CGScreenRegisterMoveCallback( - VideoFrameCapturerMac::ScreenUpdateMoveCallback, this); + ScreenCapturerMac::ScreenUpdateMoveCallback, this); if (err != kCGErrorSuccess) { LOG(ERROR) << "CGScreenRegisterMoveCallback " << err; return false; } err = CGDisplayRegisterReconfigurationCallback( - VideoFrameCapturerMac::DisplaysReconfiguredCallback, this); + ScreenCapturerMac::DisplaysReconfiguredCallback, this); if (err != kCGErrorSuccess) { LOG(ERROR) << "CGDisplayRegisterReconfigurationCallback " << err; return false; @@ -267,7 +268,7 @@ bool VideoFrameCapturerMac::Init() { return true; } -void VideoFrameCapturerMac::ReleaseBuffers() { +void ScreenCapturerMac::ReleaseBuffers() { if (cgl_context_) { pixel_buffer_object_.Release(); CGLDestroyContext(cgl_context_); @@ -279,7 +280,7 @@ void VideoFrameCapturerMac::ReleaseBuffers() { queue_.SetAllFramesNeedUpdate(); } -void VideoFrameCapturerMac::Start(Delegate* delegate) { +void ScreenCapturerMac::Start(Delegate* delegate) { DCHECK(delegate_ == NULL); delegate_ = delegate; @@ -300,7 +301,7 @@ void VideoFrameCapturerMac::Start(Delegate* delegate) { &power_assertion_id_user_); } -void VideoFrameCapturerMac::Stop() { +void ScreenCapturerMac::Stop() { if (power_assertion_id_display_ != kIOPMNullAssertionID) { IOPMAssertionRelease(power_assertion_id_display_); power_assertion_id_display_ = kIOPMNullAssertionID; @@ -311,13 +312,13 @@ void VideoFrameCapturerMac::Stop() { } } -void VideoFrameCapturerMac::InvalidateRegion(const SkRegion& invalid_region) { +void ScreenCapturerMac::InvalidateRegion(const SkRegion& invalid_region) { helper_.InvalidateRegion(invalid_region); } -void VideoFrameCapturerMac::CaptureFrame() { +void ScreenCapturerMac::CaptureFrame() { // Only allow captures when the display configuration is not occurring. - scoped_refptr<CaptureData> data; + scoped_refptr<ScreenCaptureData> data; base::Time capture_start_time = base::Time::Now(); @@ -336,11 +337,12 @@ void VideoFrameCapturerMac::CaptureFrame() { // Note that we can't reallocate other buffers at this point, since the caller // may still be reading from them. if (queue_.current_frame_needs_update()) { - scoped_ptr<VideoFrameMac> buffer(new VideoFrameMac(desktop_config_)); - queue_.ReplaceCurrentFrame(buffer.PassAs<VideoFrame>()); + scoped_ptr<ScreenCaptureFrameMac> buffer( + new ScreenCaptureFrameMac(desktop_config_)); + queue_.ReplaceCurrentFrame(buffer.PassAs<ScreenCaptureFrame>()); } - VideoFrame* current_buffer = queue_.current_frame(); + ScreenCaptureFrame* current_buffer = queue_.current_frame(); bool flip = false; // GL capturers need flipping. if (base::mac::IsOSLionOrLater()) { @@ -368,8 +370,8 @@ void VideoFrameCapturerMac::CaptureFrame() { current_buffer->bytes_per_row(); } - data = new CaptureData(buffer, stride, current_buffer->dimensions()); - data->set_dpi(static_cast<VideoFrameMac*>(current_buffer)->dpi()); + data = new ScreenCaptureData(buffer, stride, current_buffer->dimensions()); + data->set_dpi(static_cast<ScreenCaptureFrameMac*>(current_buffer)->dpi()); data->mutable_dirty_region() = region; helper_.set_size_most_recent(data->size()); @@ -389,7 +391,7 @@ void VideoFrameCapturerMac::CaptureFrame() { delegate_->OnCaptureCompleted(data); } -void VideoFrameCapturerMac::CaptureCursor() { +void ScreenCapturerMac::CaptureCursor() { NSCursor* cursor = [NSCursor currentSystemCursor]; if (cursor == nil) { return; @@ -465,7 +467,7 @@ void VideoFrameCapturerMac::CaptureCursor() { delegate_->OnCursorShapeChanged(cursor_shape.Pass()); } -void VideoFrameCapturerMac::GlBlitFast(const VideoFrame& buffer, +void ScreenCapturerMac::GlBlitFast(const ScreenCaptureFrame& buffer, const SkRegion& region) { const int buffer_height = buffer.dimensions().height(); const int buffer_width = buffer.dimensions().width(); @@ -532,7 +534,7 @@ void VideoFrameCapturerMac::GlBlitFast(const VideoFrame& buffer, glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); } -void VideoFrameCapturerMac::GlBlitSlow(const VideoFrame& buffer) { +void ScreenCapturerMac::GlBlitSlow(const ScreenCaptureFrame& buffer) { CGLContextObj CGL_MACRO_CONTEXT = cgl_context_; glReadBuffer(GL_FRONT); glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); @@ -546,7 +548,7 @@ void VideoFrameCapturerMac::GlBlitSlow(const VideoFrame& buffer) { glPopClientAttrib(); } -void VideoFrameCapturerMac::CgBlitPreLion(const VideoFrame& buffer, +void ScreenCapturerMac::CgBlitPreLion(const ScreenCaptureFrame& buffer, const SkRegion& region) { const int buffer_height = buffer.dimensions().height(); @@ -603,7 +605,7 @@ void VideoFrameCapturerMac::CgBlitPreLion(const VideoFrame& buffer, } } -void VideoFrameCapturerMac::CgBlitPostLion(const VideoFrame& buffer, +void ScreenCapturerMac::CgBlitPostLion(const ScreenCaptureFrame& buffer, const SkRegion& region) { const int buffer_height = buffer.dimensions().height(); @@ -667,7 +669,7 @@ void VideoFrameCapturerMac::CgBlitPostLion(const VideoFrame& buffer, } } -void VideoFrameCapturerMac::ScreenConfigurationChanged() { +void ScreenCapturerMac::ScreenConfigurationChanged() { // Release existing buffers, which will be of the wrong size. ReleaseBuffers(); @@ -756,7 +758,7 @@ void VideoFrameCapturerMac::ScreenConfigurationChanged() { pixel_buffer_object_.Init(cgl_context_, buffer_size); } -void VideoFrameCapturerMac::ScreenRefresh(CGRectCount count, +void ScreenCapturerMac::ScreenRefresh(CGRectCount count, const CGRect* rect_array) { if (desktop_config_.pixel_bounds.isEmpty()) { return; @@ -780,7 +782,7 @@ void VideoFrameCapturerMac::ScreenRefresh(CGRectCount count, InvalidateRegion(region); } -void VideoFrameCapturerMac::ScreenUpdateMove(CGScreenUpdateMoveDelta delta, +void ScreenCapturerMac::ScreenUpdateMove(CGScreenUpdateMoveDelta delta, size_t count, const CGRect* rect_array) { // Translate |rect_array| to identify the move's destination. @@ -793,7 +795,7 @@ void VideoFrameCapturerMac::ScreenUpdateMove(CGScreenUpdateMoveDelta delta, ScreenRefresh(count, refresh_rects); } -void VideoFrameCapturerMac::DisplaysReconfigured( +void ScreenCapturerMac::DisplaysReconfigured( CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags) { if (flags & kCGDisplayBeginConfigurationFlag) { @@ -819,10 +821,10 @@ void VideoFrameCapturerMac::DisplaysReconfigured( } } -void VideoFrameCapturerMac::ScreenRefreshCallback(CGRectCount count, +void ScreenCapturerMac::ScreenRefreshCallback(CGRectCount count, const CGRect* rect_array, void* user_parameter) { - VideoFrameCapturerMac* capturer = reinterpret_cast<VideoFrameCapturerMac*>( + ScreenCapturerMac* capturer = reinterpret_cast<ScreenCapturerMac*>( user_parameter); if (capturer->desktop_config_.pixel_bounds.isEmpty()) { capturer->ScreenConfigurationChanged(); @@ -830,21 +832,21 @@ void VideoFrameCapturerMac::ScreenRefreshCallback(CGRectCount count, capturer->ScreenRefresh(count, rect_array); } -void VideoFrameCapturerMac::ScreenUpdateMoveCallback( +void ScreenCapturerMac::ScreenUpdateMoveCallback( CGScreenUpdateMoveDelta delta, size_t count, const CGRect* rect_array, void* user_parameter) { - VideoFrameCapturerMac* capturer = reinterpret_cast<VideoFrameCapturerMac*>( + ScreenCapturerMac* capturer = reinterpret_cast<ScreenCapturerMac*>( user_parameter); capturer->ScreenUpdateMove(delta, count, rect_array); } -void VideoFrameCapturerMac::DisplaysReconfiguredCallback( +void ScreenCapturerMac::DisplaysReconfiguredCallback( CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, void* user_parameter) { - VideoFrameCapturerMac* capturer = reinterpret_cast<VideoFrameCapturerMac*>( + ScreenCapturerMac* capturer = reinterpret_cast<ScreenCapturerMac*>( user_parameter); capturer->DisplaysReconfigured(display, flags); } @@ -852,18 +854,18 @@ void VideoFrameCapturerMac::DisplaysReconfiguredCallback( } // namespace // static -scoped_ptr<VideoFrameCapturer> VideoFrameCapturer::Create() { - scoped_ptr<VideoFrameCapturerMac> capturer(new VideoFrameCapturerMac()); +scoped_ptr<ScreenCapturer> ScreenCapturer::Create() { + scoped_ptr<ScreenCapturerMac> capturer(new ScreenCapturerMac()); if (!capturer->Init()) capturer.reset(); - return capturer.PassAs<VideoFrameCapturer>(); + return capturer.PassAs<ScreenCapturer>(); } // static -scoped_ptr<VideoFrameCapturer> VideoFrameCapturer::CreateWithFactory( +scoped_ptr<ScreenCapturer> ScreenCapturer::CreateWithFactory( SharedBufferFactory* shared_buffer_factory) { NOTIMPLEMENTED(); - return scoped_ptr<VideoFrameCapturer>(); + return scoped_ptr<ScreenCapturer>(); } -} // namespace remoting +} // namespace media diff --git a/remoting/capturer/video_frame_capturer_mac_unittest.cc b/media/video/capture/screen/screen_capturer_mac_unittest.cc index 12435b3..a62d40b 100644 --- a/remoting/capturer/video_frame_capturer_mac_unittest.cc +++ b/media/video/capture/screen/screen_capturer_mac_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/capturer/video_frame_capturer.h" +#include "media/video/capture/screen/screen_capturer.h" #include <ApplicationServices/ApplicationServices.h> @@ -11,14 +11,14 @@ #include "base/bind.h" #include "base/callback.h" #include "base/memory/scoped_ptr.h" -#include "remoting/capturer/capture_data.h" -#include "remoting/capturer/video_capturer_mock_objects.h" +#include "media/video/capture/screen/screen_capture_data.h" +#include "media/video/capture/screen/screen_capturer_mock_objects.h" #include "testing/gtest/include/gtest/gtest.h" using ::testing::_; using ::testing::AnyNumber; -namespace remoting { +namespace media { // Verify that the OS is at least Snow Leopard (10.6). // Chromoting doesn't support 10.5 or earlier. @@ -29,18 +29,18 @@ bool CheckSnowLeopard() { return majorVersion == 10 && minorVersion > 5; } -class VideoFrameCapturerMacTest : public testing::Test { +class ScreenCapturerMacTest : public testing::Test { public: // Verifies that the whole screen is initially dirty. - void CaptureDoneCallback1(scoped_refptr<CaptureData> capture_data); + void CaptureDoneCallback1(scoped_refptr<ScreenCaptureData> capture_data); // Verifies that a rectangle explicitly marked as dirty is propagated // correctly. - void CaptureDoneCallback2(scoped_refptr<CaptureData> capture_data); + void CaptureDoneCallback2(scoped_refptr<ScreenCaptureData> capture_data); protected: virtual void SetUp() OVERRIDE { - capturer_ = VideoFrameCapturer::Create(); + capturer_ = ScreenCapturer::Create(); } void AddDirtyRect() { @@ -48,13 +48,13 @@ class VideoFrameCapturerMacTest : public testing::Test { region_.op(rect, SkRegion::kUnion_Op); } - scoped_ptr<VideoFrameCapturer> capturer_; - MockVideoFrameCapturerDelegate delegate_; + scoped_ptr<ScreenCapturer> capturer_; + MockScreenCapturerDelegate delegate_; SkRegion region_; }; -void VideoFrameCapturerMacTest::CaptureDoneCallback1( - scoped_refptr<CaptureData> capture_data) { +void ScreenCapturerMacTest::CaptureDoneCallback1( + scoped_refptr<ScreenCaptureData> capture_data) { CGDirectDisplayID mainDevice = CGMainDisplayID(); int width = CGDisplayPixelsWide(mainDevice); int height = CGDisplayPixelsHigh(mainDevice); @@ -62,8 +62,8 @@ void VideoFrameCapturerMacTest::CaptureDoneCallback1( EXPECT_EQ(initial_region, capture_data->dirty_region()); } -void VideoFrameCapturerMacTest::CaptureDoneCallback2( - scoped_refptr<CaptureData> capture_data) { +void ScreenCapturerMacTest::CaptureDoneCallback2( + scoped_refptr<ScreenCaptureData> capture_data) { CGDirectDisplayID mainDevice = CGMainDisplayID(); int width = CGDisplayPixelsWide(mainDevice); int height = CGDisplayPixelsHigh(mainDevice); @@ -78,15 +78,15 @@ void VideoFrameCapturerMacTest::CaptureDoneCallback2( abs(capture_data->stride())); } -TEST_F(VideoFrameCapturerMacTest, Capture) { +TEST_F(ScreenCapturerMacTest, Capture) { if (!CheckSnowLeopard()) { return; } EXPECT_CALL(delegate_, OnCaptureCompleted(_)) .Times(2) - .WillOnce(Invoke(this, &VideoFrameCapturerMacTest::CaptureDoneCallback1)) - .WillOnce(Invoke(this, &VideoFrameCapturerMacTest::CaptureDoneCallback2)); + .WillOnce(Invoke(this, &ScreenCapturerMacTest::CaptureDoneCallback1)) + .WillOnce(Invoke(this, &ScreenCapturerMacTest::CaptureDoneCallback2)); EXPECT_CALL(delegate_, OnCursorShapeChangedPtr(_)) .Times(AnyNumber()); @@ -103,7 +103,7 @@ TEST_F(VideoFrameCapturerMacTest, Capture) { capturer_->Stop(); } -} // namespace remoting +} // namespace media namespace gfx { diff --git a/media/video/capture/screen/screen_capturer_mock_objects.cc b/media/video/capture/screen/screen_capturer_mock_objects.cc new file mode 100644 index 0000000..e4fa7fb --- /dev/null +++ b/media/video/capture/screen/screen_capturer_mock_objects.cc @@ -0,0 +1,30 @@ +// Copyright (c) 2012 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 "media/video/capture/screen/screen_capturer_mock_objects.h" + +#include "media/video/capture/screen/screen_capturer.h" +#include "testing/gmock/include/gmock/gmock.h" + +namespace media { + +MockScreenCapturer::MockScreenCapturer() { +} + +MockScreenCapturer::~MockScreenCapturer() { +} + +MockScreenCapturerDelegate::MockScreenCapturerDelegate() { +} + +MockScreenCapturerDelegate::~MockScreenCapturerDelegate() { +} + +void MockScreenCapturerDelegate::OnCursorShapeChanged( + scoped_ptr<MouseCursorShape> cursor_shape) { + // Notify the mock method. + OnCursorShapeChangedPtr(cursor_shape.get()); +} + +} // namespace media diff --git a/media/video/capture/screen/screen_capturer_mock_objects.h b/media/video/capture/screen/screen_capturer_mock_objects.h new file mode 100644 index 0000000..36bf3fb --- /dev/null +++ b/media/video/capture/screen/screen_capturer_mock_objects.h @@ -0,0 +1,46 @@ +// Copyright (c) 2012 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 MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_MOCK_OBJECTS_H_ +#define MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_MOCK_OBJECTS_H_ + +#include "media/video/capture/screen/mouse_cursor_shape.h" +#include "media/video/capture/screen/screen_capture_data.h" +#include "media/video/capture/screen/screen_capturer.h" +#include "testing/gmock/include/gmock/gmock.h" + +namespace media { + +class MockScreenCapturer : public ScreenCapturer { + public: + MockScreenCapturer(); + virtual ~MockScreenCapturer(); + + MOCK_METHOD1(Start, void(Delegate* delegate)); + MOCK_METHOD0(Stop, void()); + MOCK_METHOD1(InvalidateRegion, void(const SkRegion& invalid_region)); + MOCK_METHOD0(CaptureFrame, void()); + + private: + DISALLOW_COPY_AND_ASSIGN(MockScreenCapturer); +}; + +class MockScreenCapturerDelegate : public ScreenCapturer::Delegate { + public: + MockScreenCapturerDelegate(); + virtual ~MockScreenCapturerDelegate(); + + void OnCursorShapeChanged(scoped_ptr<MouseCursorShape> cursor_shape) OVERRIDE; + + MOCK_METHOD1(OnCaptureCompleted, void(scoped_refptr<ScreenCaptureData>)); + MOCK_METHOD1(OnCursorShapeChangedPtr, + void(MouseCursorShape* cursor_shape)); + + private: + DISALLOW_COPY_AND_ASSIGN(MockScreenCapturerDelegate); +}; + +} // namespace media + +#endif // MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_MOCK_OBJECTS_H_ diff --git a/remoting/capturer/video_frame_capturer_unittest.cc b/media/video/capture/screen/screen_capturer_unittest.cc index 11f71f5..be08749 100644 --- a/remoting/capturer/video_frame_capturer_unittest.cc +++ b/media/video/capture/screen/screen_capturer_unittest.cc @@ -2,22 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/capturer/video_frame_capturer.h" +#include "media/video/capture/screen/screen_capturer.h" #include "base/bind.h" #if defined(OS_MACOSX) #include "base/mac/mac_util.h" #endif // defined(OS_MACOSX) -#include "remoting/capturer/capture_data.h" -#include "remoting/capturer/shared_buffer_factory.h" -#include "remoting/capturer/video_capturer_mock_objects.h" +#include "media/video/capture/screen/screen_capture_data.h" +#include "media/video/capture/screen/screen_capturer_mock_objects.h" +#include "media/video/capture/screen/shared_buffer_factory.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" using ::testing::_; using ::testing::AnyNumber; -namespace remoting { +namespace media { class MockSharedBufferFactory : public SharedBufferFactory { public: @@ -40,23 +40,23 @@ MATCHER(DirtyRegionIsNonEmptyRect, "") { return dirty_region == SkRegion(dirty_region_bounds); } -class VideoFrameCapturerTest : public testing::Test { +class ScreenCapturerTest : public testing::Test { public: scoped_refptr<SharedBuffer> CreateSharedBuffer(uint32 size); protected: - scoped_ptr<VideoFrameCapturer> capturer_; + scoped_ptr<ScreenCapturer> capturer_; MockSharedBufferFactory shared_buffer_factory_; - MockVideoFrameCapturerDelegate delegate_; + MockScreenCapturerDelegate delegate_; }; -scoped_refptr<SharedBuffer> VideoFrameCapturerTest::CreateSharedBuffer( +scoped_refptr<SharedBuffer> ScreenCapturerTest::CreateSharedBuffer( uint32 size) { return scoped_refptr<SharedBuffer>(new SharedBuffer(size)); } -TEST_F(VideoFrameCapturerTest, StartCapturer) { - capturer_ = VideoFrameCapturer::Create(); +TEST_F(ScreenCapturerTest, StartCapturer) { + capturer_ = ScreenCapturer::Create(); capturer_->Start(&delegate_); capturer_->Stop(); } @@ -67,14 +67,14 @@ TEST_F(VideoFrameCapturerTest, StartCapturer) { #else #define MAYBE_Capture Capture #endif -TEST_F(VideoFrameCapturerTest, MAYBE_Capture) { +TEST_F(ScreenCapturerTest, MAYBE_Capture) { // Assume that Start() treats the screen as invalid initially. EXPECT_CALL(delegate_, OnCaptureCompleted(DirtyRegionIsNonEmptyRect())); EXPECT_CALL(delegate_, OnCursorShapeChangedPtr(_)) .Times(AnyNumber()); - capturer_ = VideoFrameCapturer::Create(); + capturer_ = ScreenCapturer::Create(); capturer_->Start(&delegate_); capturer_->CaptureFrame(); capturer_->Stop(); @@ -82,7 +82,7 @@ TEST_F(VideoFrameCapturerTest, MAYBE_Capture) { #if defined(OS_WIN) -TEST_F(VideoFrameCapturerTest, UseSharedBuffers) { +TEST_F(ScreenCapturerTest, UseSharedBuffers) { EXPECT_CALL(delegate_, OnCaptureCompleted(DirtyRegionIsNonEmptyRect())); EXPECT_CALL(delegate_, OnCursorShapeChangedPtr(_)) @@ -90,11 +90,11 @@ TEST_F(VideoFrameCapturerTest, UseSharedBuffers) { EXPECT_CALL(shared_buffer_factory_, CreateSharedBuffer(_)) .Times(1) - .WillOnce(Invoke(this, &VideoFrameCapturerTest::CreateSharedBuffer)); + .WillOnce(Invoke(this, &ScreenCapturerTest::CreateSharedBuffer)); EXPECT_CALL(shared_buffer_factory_, ReleaseSharedBuffer(_)) .Times(1); - capturer_ = VideoFrameCapturer::CreateWithFactory(&shared_buffer_factory_); + capturer_ = ScreenCapturer::CreateWithFactory(&shared_buffer_factory_); capturer_->Start(&delegate_); capturer_->CaptureFrame(); capturer_->Stop(); @@ -103,4 +103,4 @@ TEST_F(VideoFrameCapturerTest, UseSharedBuffers) { #endif // defined(OS_WIN) -} // namespace remoting +} // namespace media diff --git a/remoting/capturer/video_frame_capturer_win.cc b/media/video/capture/screen/screen_capturer_win.cc index 59e978c..bf6bfae 100644 --- a/remoting/capturer/video_frame_capturer_win.cc +++ b/media/video/capture/screen/screen_capturer_win.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/capturer/video_frame_capturer.h" +#include "media/video/capture/screen/screen_capturer.h" #include <windows.h> @@ -17,18 +17,18 @@ #include "base/utf_string_conversions.h" #include "base/win/scoped_gdi_object.h" #include "base/win/scoped_hdc.h" -#include "remoting/capturer/capture_data.h" -#include "remoting/capturer/differ.h" -#include "remoting/capturer/mouse_cursor_shape.h" -#include "remoting/capturer/shared_buffer_factory.h" -#include "remoting/capturer/video_frame.h" -#include "remoting/capturer/video_frame_capturer_helper.h" -#include "remoting/capturer/video_frame_queue.h" -#include "remoting/capturer/win/desktop.h" -#include "remoting/capturer/win/scoped_thread_desktop.h" +#include "media/video/capture/screen/differ.h" +#include "media/video/capture/screen/mouse_cursor_shape.h" +#include "media/video/capture/screen/screen_capture_data.h" +#include "media/video/capture/screen/screen_capture_frame.h" +#include "media/video/capture/screen/screen_capture_frame_queue.h" +#include "media/video/capture/screen/screen_capturer_helper.h" +#include "media/video/capture/screen/shared_buffer_factory.h" +#include "media/video/capture/screen/win/desktop.h" +#include "media/video/capture/screen/win/scoped_thread_desktop.h" #include "third_party/skia/include/core/SkColorPriv.h" -namespace remoting { +namespace media { namespace { @@ -46,11 +46,11 @@ const uint32 kPixelBgraWhite = 0xffffffff; const uint32 kPixelBgraTransparent = 0x00000000; // A class representing a full-frame pixel buffer. -class VideoFrameWin : public VideoFrame { +class ScreenCaptureFrameWin : public ScreenCaptureFrame { public: - VideoFrameWin(HDC desktop_dc, const SkISize& size, + ScreenCaptureFrameWin(HDC desktop_dc, const SkISize& size, SharedBufferFactory* shared_buffer_factory); - virtual ~VideoFrameWin(); + virtual ~ScreenCaptureFrameWin(); // Returns handle of the device independent bitmap representing this frame // buffer to GDI. @@ -68,20 +68,19 @@ class VideoFrameWin : public VideoFrame { // Used to allocate shared memory buffers if set. SharedBufferFactory* shared_buffer_factory_; - DISALLOW_COPY_AND_ASSIGN(VideoFrameWin); + DISALLOW_COPY_AND_ASSIGN(ScreenCaptureFrameWin); }; -// VideoFrameCapturerWin captures 32bit RGB using GDI. +// ScreenCapturerWin captures 32bit RGB using GDI. // -// VideoFrameCapturerWin is double-buffered as required by VideoFrameCapturer. -// See remoting/host/video_frame_capturer.h. -class VideoFrameCapturerWin : public VideoFrameCapturer { +// ScreenCapturerWin is double-buffered as required by ScreenCapturer. +class ScreenCapturerWin : public ScreenCapturer { public: - VideoFrameCapturerWin(); - explicit VideoFrameCapturerWin(SharedBufferFactory* shared_buffer_factory); - virtual ~VideoFrameCapturerWin(); + ScreenCapturerWin(); + explicit ScreenCapturerWin(SharedBufferFactory* shared_buffer_factory); + virtual ~ScreenCapturerWin(); - // Overridden from VideoFrameCapturer: + // Overridden from ScreenCapturer: virtual void Start(Delegate* delegate) OVERRIDE; virtual void Stop() OVERRIDE; virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; @@ -91,7 +90,7 @@ class VideoFrameCapturerWin : public VideoFrameCapturer { // Make sure that the device contexts match the screen configuration. void PrepareCaptureResources(); - // Creates a CaptureData instance wrapping the current framebuffer and + // Creates a ScreenCaptureData instance wrapping the current framebuffer and // notifies |delegate_|. void CaptureRegion(const SkRegion& region, const base::Time& capture_start_time); @@ -113,7 +112,7 @@ class VideoFrameCapturerWin : public VideoFrameCapturer { // A thread-safe list of invalid rectangles, and the size of the most // recently captured screen. - VideoFrameCapturerHelper helper_; + ScreenCapturerHelper helper_; // Snapshot of the last cursor bitmap we sent to the client. This is used // to diff against the current cursor so we only send a cursor-change @@ -127,7 +126,7 @@ class VideoFrameCapturerWin : public VideoFrameCapturer { base::win::ScopedCreateDC memory_dc_; // Queue of the frames buffers. - VideoFrameQueue queue_; + ScreenCaptureFrameQueue queue_; // Rectangle describing the bounds of the desktop device context. SkIRect desktop_dc_rect_; @@ -138,20 +137,20 @@ class VideoFrameCapturerWin : public VideoFrameCapturer { base::ScopedNativeLibrary dwmapi_library_; DwmEnableCompositionFunc composition_func_; - DISALLOW_COPY_AND_ASSIGN(VideoFrameCapturerWin); + DISALLOW_COPY_AND_ASSIGN(ScreenCapturerWin); }; // 3780 pixels per meter is equivalent to 96 DPI, typical on desktop monitors. static const int kPixelsPerMeter = 3780; -VideoFrameWin::VideoFrameWin( +ScreenCaptureFrameWin::ScreenCaptureFrameWin( HDC desktop_dc, const SkISize& size, SharedBufferFactory* shared_buffer_factory) : shared_buffer_factory_(shared_buffer_factory) { // Allocate a shared memory buffer. uint32 buffer_size = - size.width() * size.height() * CaptureData::kBytesPerPixel; + size.width() * size.height() * ScreenCaptureData::kBytesPerPixel; if (shared_buffer_factory_) { scoped_refptr<SharedBuffer> shared_buffer = shared_buffer_factory_->CreateSharedBuffer(buffer_size); @@ -162,17 +161,18 @@ VideoFrameWin::VideoFrameWin( AllocateBitmap(desktop_dc, size); } -VideoFrameWin::~VideoFrameWin() { +ScreenCaptureFrameWin::~ScreenCaptureFrameWin() { if (shared_buffer()) shared_buffer_factory_->ReleaseSharedBuffer(shared_buffer()); } -HBITMAP VideoFrameWin::GetBitmap() { +HBITMAP ScreenCaptureFrameWin::GetBitmap() { return bitmap_; } -void VideoFrameWin::AllocateBitmap(HDC desktop_dc, const SkISize& size) { - int bytes_per_row = size.width() * CaptureData::kBytesPerPixel; +void ScreenCaptureFrameWin::AllocateBitmap(HDC desktop_dc, + const SkISize& size) { + int bytes_per_row = size.width() * ScreenCaptureData::kBytesPerPixel; // Describe a device independent bitmap (DIB) that is the size of the desktop. BITMAPINFO bmi; @@ -180,7 +180,7 @@ void VideoFrameWin::AllocateBitmap(HDC desktop_dc, const SkISize& size) { bmi.bmiHeader.biHeight = -size.height(); bmi.bmiHeader.biWidth = size.width(); bmi.bmiHeader.biPlanes = 1; - bmi.bmiHeader.biBitCount = CaptureData::kBytesPerPixel * 8; + bmi.bmiHeader.biBitCount = ScreenCaptureData::kBytesPerPixel * 8; bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader); bmi.bmiHeader.biSizeImage = bytes_per_row * size.height(); bmi.bmiHeader.biXPelsPerMeter = kPixelsPerMeter; @@ -205,14 +205,14 @@ void VideoFrameWin::AllocateBitmap(HDC desktop_dc, const SkISize& size) { bmi.bmiHeader.biSizeImage / std::abs(bmi.bmiHeader.biHeight)); } -VideoFrameCapturerWin::VideoFrameCapturerWin() +ScreenCapturerWin::ScreenCapturerWin() : shared_buffer_factory_(NULL), delegate_(NULL), desktop_dc_rect_(SkIRect::MakeEmpty()), composition_func_(NULL) { } -VideoFrameCapturerWin::VideoFrameCapturerWin( +ScreenCapturerWin::ScreenCapturerWin( SharedBufferFactory* shared_buffer_factory) : shared_buffer_factory_(shared_buffer_factory), delegate_(NULL), @@ -220,14 +220,14 @@ VideoFrameCapturerWin::VideoFrameCapturerWin( composition_func_(NULL) { } -VideoFrameCapturerWin::~VideoFrameCapturerWin() { +ScreenCapturerWin::~ScreenCapturerWin() { } -void VideoFrameCapturerWin::InvalidateRegion(const SkRegion& invalid_region) { +void ScreenCapturerWin::InvalidateRegion(const SkRegion& invalid_region) { helper_.InvalidateRegion(invalid_region); } -void VideoFrameCapturerWin::CaptureFrame() { +void ScreenCapturerWin::CaptureFrame() { base::Time capture_start_time = base::Time::Now(); // Force the system to power-up display hardware, if it has been suspended. @@ -239,8 +239,8 @@ void VideoFrameCapturerWin::CaptureFrame() { // Copy screen bits to the current buffer. CaptureImage(); - const VideoFrame* current_buffer = queue_.current_frame(); - const VideoFrame* last_buffer = queue_.previous_frame(); + const ScreenCaptureFrame* current_buffer = queue_.current_frame(); + const ScreenCaptureFrame* last_buffer = queue_.previous_frame(); if (last_buffer) { // Make sure the differencer is set up correctly for these previous and // current screens. @@ -250,7 +250,7 @@ void VideoFrameCapturerWin::CaptureFrame() { (differ_->bytes_per_row() != current_buffer->bytes_per_row())) { differ_.reset(new Differ(current_buffer->dimensions().width(), current_buffer->dimensions().height(), - CaptureData::kBytesPerPixel, + ScreenCaptureData::kBytesPerPixel, current_buffer->bytes_per_row())); } @@ -264,7 +264,7 @@ void VideoFrameCapturerWin::CaptureFrame() { helper_.InvalidateScreen(current_buffer->dimensions()); } - // Wrap the captured frame into CaptureData structure and invoke + // Wrap the captured frame into ScreenCaptureData structure and invoke // the completion callback. SkRegion invalid_region; helper_.SwapInvalidRegion(&invalid_region); @@ -274,7 +274,7 @@ void VideoFrameCapturerWin::CaptureFrame() { CaptureCursor(); } -void VideoFrameCapturerWin::Start(Delegate* delegate) { +void ScreenCapturerWin::Start(Delegate* delegate) { DCHECK(delegate_ == NULL); delegate_ = delegate; @@ -298,7 +298,7 @@ void VideoFrameCapturerWin::Start(Delegate* delegate) { } } -void VideoFrameCapturerWin::Stop() { +void ScreenCapturerWin::Stop() { // Restore Aero. if (composition_func_ != NULL) { (*composition_func_)(DWM_EC_ENABLECOMPOSITION); @@ -307,7 +307,7 @@ void VideoFrameCapturerWin::Stop() { delegate_ = NULL; } -void VideoFrameCapturerWin::PrepareCaptureResources() { +void ScreenCapturerWin::PrepareCaptureResources() { // Switch to the desktop receiving user input if different from the current // one. scoped_ptr<Desktop> input_desktop = Desktop::GetInputDesktop(); @@ -349,14 +349,14 @@ void VideoFrameCapturerWin::PrepareCaptureResources() { } } -void VideoFrameCapturerWin::CaptureRegion( +void ScreenCapturerWin::CaptureRegion( const SkRegion& region, const base::Time& capture_start_time) { - const VideoFrame* current_buffer = queue_.current_frame(); + const ScreenCaptureFrame* current_buffer = queue_.current_frame(); - scoped_refptr<CaptureData> data( - new CaptureData(current_buffer->pixels(), current_buffer->bytes_per_row(), - current_buffer->dimensions())); + scoped_refptr<ScreenCaptureData> data(new ScreenCaptureData( + current_buffer->pixels(), current_buffer->bytes_per_row(), + current_buffer->dimensions())); data->mutable_dirty_region() = region; data->set_shared_buffer(current_buffer->shared_buffer()); @@ -369,7 +369,7 @@ void VideoFrameCapturerWin::CaptureRegion( delegate_->OnCaptureCompleted(data); } -void VideoFrameCapturerWin::CaptureImage() { +void ScreenCapturerWin::CaptureImage() { // If the current buffer is from an older generation then allocate a new one. // Note that we can't reallocate other buffers at this point, since the caller // may still be reading from them. @@ -379,14 +379,15 @@ void VideoFrameCapturerWin::CaptureImage() { SkISize size = SkISize::Make(desktop_dc_rect_.width(), desktop_dc_rect_.height()); - scoped_ptr<VideoFrameWin> buffer( - new VideoFrameWin(*desktop_dc_, size, shared_buffer_factory_)); - queue_.ReplaceCurrentFrame(buffer.PassAs<VideoFrame>()); + scoped_ptr<ScreenCaptureFrameWin> buffer( + new ScreenCaptureFrameWin(*desktop_dc_, size, shared_buffer_factory_)); + queue_.ReplaceCurrentFrame(buffer.PassAs<ScreenCaptureFrame>()); } // Select the target bitmap into the memory dc and copy the rect from desktop // to memory. - VideoFrameWin* current = static_cast<VideoFrameWin*>(queue_.current_frame()); + ScreenCaptureFrameWin* current = static_cast<ScreenCaptureFrameWin*>( + queue_.current_frame()); HGDIOBJ previous_object = SelectObject(memory_dc_, current->GetBitmap()); if (previous_object != NULL) { BitBlt(memory_dc_, @@ -401,9 +402,9 @@ void VideoFrameCapturerWin::CaptureImage() { } } -void VideoFrameCapturerWin::AddCursorOutline(int width, - int height, - uint32* dst) { +void ScreenCapturerWin::AddCursorOutline(int width, + int height, + uint32* dst) { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { // If this is a transparent pixel (bgr == 0 and alpha = 0), check the @@ -423,7 +424,7 @@ void VideoFrameCapturerWin::AddCursorOutline(int width, } } -void VideoFrameCapturerWin::CaptureCursor() { +void ScreenCapturerWin::CaptureCursor() { CURSORINFO cursor_info; cursor_info.cbSize = sizeof(CURSORINFO); if (!GetCursorInfo(&cursor_info)) { @@ -478,7 +479,7 @@ void VideoFrameCapturerWin::CaptureCursor() { if (!color_bitmap) { height /= 2; } - int data_size = height * width * CaptureData::kBytesPerPixel; + int data_size = height * width * ScreenCaptureData::kBytesPerPixel; scoped_ptr<MouseCursorShape> cursor(new MouseCursorShape()); cursor->data.resize(data_size); @@ -506,10 +507,10 @@ void VideoFrameCapturerWin::CaptureCursor() { dst[1] = SkAlphaMul(src[1], src[3]); dst[2] = SkAlphaMul(src[2], src[3]); dst[3] = src[3]; - dst += CaptureData::kBytesPerPixel; - src += CaptureData::kBytesPerPixel; + dst += ScreenCaptureData::kBytesPerPixel; + src += ScreenCaptureData::kBytesPerPixel; } - src -= row_bytes + (width * CaptureData::kBytesPerPixel); + src -= row_bytes + (width * ScreenCaptureData::kBytesPerPixel); } } else { if (bitmap.bmPlanes != 1 || bitmap.bmBitsPixel != 1) { @@ -583,16 +584,16 @@ void VideoFrameCapturerWin::CaptureCursor() { } // namespace // static -scoped_ptr<VideoFrameCapturer> VideoFrameCapturer::Create() { - return scoped_ptr<VideoFrameCapturer>(new VideoFrameCapturerWin()); +scoped_ptr<ScreenCapturer> ScreenCapturer::Create() { + return scoped_ptr<ScreenCapturer>(new ScreenCapturerWin()); } // static -scoped_ptr<VideoFrameCapturer> VideoFrameCapturer::CreateWithFactory( +scoped_ptr<ScreenCapturer> ScreenCapturer::CreateWithFactory( SharedBufferFactory* shared_buffer_factory) { - scoped_ptr<VideoFrameCapturerWin> capturer( - new VideoFrameCapturerWin(shared_buffer_factory)); - return capturer.PassAs<VideoFrameCapturer>(); + scoped_ptr<ScreenCapturerWin> capturer( + new ScreenCapturerWin(shared_buffer_factory)); + return capturer.PassAs<ScreenCapturer>(); } -} // namespace remoting +} // namespace media diff --git a/remoting/capturer/shared_buffer.cc b/media/video/capture/screen/shared_buffer.cc index 8268299..33eb5c3 100644 --- a/remoting/capturer/shared_buffer.cc +++ b/media/video/capture/screen/shared_buffer.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/capturer/shared_buffer.h" +#include "media/video/capture/screen/shared_buffer.h" const bool kReadOnly = true; -namespace remoting { +namespace media { SharedBuffer::SharedBuffer(uint32 size) : id_(0), @@ -34,4 +34,9 @@ SharedBuffer::SharedBuffer( SharedBuffer::~SharedBuffer() { } -} // namespace remoting +bool SharedBuffer::ShareToProcess(base::ProcessHandle process, + base::SharedMemoryHandle* new_handle) { + return shared_memory_.ShareToProcess(process, new_handle); +} + +} // namespace media diff --git a/remoting/capturer/shared_buffer.h b/media/video/capture/screen/shared_buffer.h index 16429b9..4c77b6a0 100644 --- a/remoting/capturer/shared_buffer.h +++ b/media/video/capture/screen/shared_buffer.h @@ -2,20 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef REMOTING_CAPTURER_SHARED_BUFFER_H_ -#define REMOTING_CAPTURER_SHARED_BUFFER_H_ +#ifndef MEDIA_VIDEO_CAPTURE_SCREEN_SHARED_BUFFER_H_ +#define MEDIA_VIDEO_CAPTURE_SCREEN_SHARED_BUFFER_H_ #include "base/basictypes.h" #include "base/memory/ref_counted.h" #include "base/process.h" #include "base/shared_memory.h" +#include "media/base/media_export.h" -namespace remoting { +namespace media { // Represents a memory buffer that can be shared between multiple processes. // It is more or less a convenience wrapper around base::SharedMemory providing // ref-counted lifetime management and unique buffer identifiers. -class SharedBuffer +class MEDIA_EXPORT SharedBuffer : public base::RefCountedThreadSafe<SharedBuffer> { public: // Creates a new shared memory buffer of the given size and maps it to @@ -43,6 +44,11 @@ class SharedBuffer // data buffer. base::SharedMemoryHandle handle() const { return shared_memory_.handle(); } + // Calls SharedMemory::ShareToProcess to share the handle with a different + // process. + bool ShareToProcess(base::ProcessHandle process, + base::SharedMemoryHandle* new_handle); + int id() const { return id_; } uint32 size() const { return size_; } @@ -64,6 +70,6 @@ class SharedBuffer DISALLOW_COPY_AND_ASSIGN(SharedBuffer); }; -} // namespace remoting +} // namespace media -#endif // REMOTING_CAPTURER_SHARED_BUFFER_H_ +#endif // MEDIA_VIDEO_CAPTURE_SCREEN_SHARED_BUFFER_H_ diff --git a/remoting/capturer/shared_buffer_factory.h b/media/video/capture/screen/shared_buffer_factory.h index 008714b..f5bafc6 100644 --- a/remoting/capturer/shared_buffer_factory.h +++ b/media/video/capture/screen/shared_buffer_factory.h @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef REMOTING_CAPTURER_SHARED_BUFFER_FACTORY_H_ -#define REMOTING_CAPTURER_SHARED_BUFFER_FACTORY_H_ +#ifndef MEDIA_VIDEO_CAPTURE_SCREEN_SHARED_BUFFER_FACTORY_H_ +#define MEDIA_VIDEO_CAPTURE_SCREEN_SHARED_BUFFER_FACTORY_H_ -namespace remoting { +namespace media { class SharedBuffer; @@ -24,6 +24,6 @@ class SharedBufferFactory { virtual ~SharedBufferFactory() {} }; -} // namespace remoting +} // namespace media -#endif // REMOTING_CAPTURER_SHARED_BUFFER_FACTORY_H_ +#endif // MEDIA_VIDEO_CAPTURE_SCREEN_SHARED_BUFFER_FACTORY_H_ diff --git a/remoting/capturer/shared_buffer_unittest.cc b/media/video/capture/screen/shared_buffer_unittest.cc index b065f5c..1efc798 100644 --- a/remoting/capturer/shared_buffer_unittest.cc +++ b/media/video/capture/screen/shared_buffer_unittest.cc @@ -3,8 +3,7 @@ // found in the LICENSE file. #include "base/process_util.h" -#include "ipc/ipc_platform_file.h" -#include "remoting/capturer/shared_buffer.h" +#include "media/video/capture/screen/shared_buffer.h" #include "testing/gtest/include/gtest/gtest.h" const uint32 kBufferSize = 4096; @@ -13,7 +12,7 @@ const int kPattern = 0x12345678; const int kIdZero = 0; const int kIdOne = 1; -namespace remoting { +namespace media { TEST(SharedBufferTest, Basic) { scoped_refptr<SharedBuffer> source(new SharedBuffer(kBufferSize)); @@ -28,15 +27,9 @@ TEST(SharedBufferTest, Basic) { source->set_id(kIdOne); EXPECT_EQ(source->id(), kIdOne); -#if defined(OS_POSIX) - base::PlatformFile source_handle = source->handle().fd; -#else // !defined(OS_POSIX) - base::PlatformFile source_handle = source->handle(); -#endif // !defined(OS_POSIX) - - // Duplicate the source handle. - IPC::PlatformFileForTransit copied_handle = IPC::GetFileHandleForProcess( - source_handle, base::GetCurrentProcessHandle(), false); + base::SharedMemoryHandle copied_handle; + EXPECT_TRUE(source->ShareToProcess( + base::GetCurrentProcessHandle(), &copied_handle)); scoped_refptr<SharedBuffer> dest( new SharedBuffer(kIdZero, copied_handle, kBufferSize)); @@ -59,4 +52,4 @@ TEST(SharedBufferTest, Basic) { EXPECT_EQ(0x12345678, *dest_ptr); } -} // namespace remoting +} // namespace media diff --git a/remoting/capturer/win/desktop.cc b/media/video/capture/screen/win/desktop.cc index e7dbe4d..2b6cbb7 100644 --- a/remoting/capturer/win/desktop.cc +++ b/media/video/capture/screen/win/desktop.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/capturer/win/desktop.h" +#include "media/video/capture/screen/win/desktop.h" #include <vector> #include "base/logging.h" -namespace remoting { +namespace media { Desktop::Desktop(HDESK desktop, bool own) : desktop_(desktop), own_(own) { } @@ -101,4 +101,4 @@ scoped_ptr<Desktop> Desktop::GetThreadDesktop() { return scoped_ptr<Desktop>(new Desktop(desktop, false)); } -} // namespace remoting +} // namespace media diff --git a/remoting/capturer/win/desktop.h b/media/video/capture/screen/win/desktop.h index f50a047..69c83b4 100644 --- a/remoting/capturer/win/desktop.h +++ b/media/video/capture/screen/win/desktop.h @@ -2,18 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef REMOTING_CAPTURER_WIN_DESKTOP_H_ -#define REMOTING_CAPTURER_WIN_DESKTOP_H_ +#ifndef MEDIA_VIDEO_CAPTURE_SCREEN_WIN_DESKTOP_H_ +#define MEDIA_VIDEO_CAPTURE_SCREEN_WIN_DESKTOP_H_ #include <windows.h> #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "base/string16.h" +#include "media/base/media_export.h" -namespace remoting { +namespace media { -class Desktop { +class MEDIA_EXPORT Desktop { public: ~Desktop(); @@ -53,6 +54,6 @@ class Desktop { DISALLOW_COPY_AND_ASSIGN(Desktop); }; -} // namespace remoting +} // namespace media -#endif // REMOTING_CAPTURER_WIN_DESKTOP_H_ +#endif // MEDIA_VIDEO_CAPTURE_SCREEN_WIN_DESKTOP_H_ diff --git a/remoting/capturer/win/scoped_thread_desktop.cc b/media/video/capture/screen/win/scoped_thread_desktop.cc index bbde520..8e9a80a 100644 --- a/remoting/capturer/win/scoped_thread_desktop.cc +++ b/media/video/capture/screen/win/scoped_thread_desktop.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/capturer/win/scoped_thread_desktop.h" +#include "media/video/capture/screen/win/scoped_thread_desktop.h" #include "base/logging.h" -#include "remoting/capturer/win/desktop.h" +#include "media/video/capture/screen/win/desktop.h" -namespace remoting { +namespace media { ScopedThreadDesktop::ScopedThreadDesktop() : initial_(Desktop::GetThreadDesktop()) { @@ -46,4 +46,4 @@ bool ScopedThreadDesktop::SetThreadDesktop(scoped_ptr<Desktop> desktop) { return true; } -} // namespace remoting +} // namespace media diff --git a/remoting/capturer/win/scoped_thread_desktop.h b/media/video/capture/screen/win/scoped_thread_desktop.h index 5f2378b..1a9259f 100644 --- a/remoting/capturer/win/scoped_thread_desktop.h +++ b/media/video/capture/screen/win/scoped_thread_desktop.h @@ -2,19 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef REMOTING_CAPTURER_WIN_SCOPED_THREAD_DESKTOP_H_ -#define REMOTING_CAPTURER_WIN_SCOPED_THREAD_DESKTOP_H_ +#ifndef MEDIA_VIDEO_CAPTURE_SCREEN_WIN_SCOPED_THREAD_DESKTOP_H_ +#define MEDIA_VIDEO_CAPTURE_SCREEN_WIN_SCOPED_THREAD_DESKTOP_H_ #include <windows.h> #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" +#include "media/base/media_export.h" -namespace remoting { +namespace media { class Desktop; -class ScopedThreadDesktop { +class MEDIA_EXPORT ScopedThreadDesktop { public: ScopedThreadDesktop(); ~ScopedThreadDesktop(); @@ -42,6 +43,6 @@ class ScopedThreadDesktop { DISALLOW_COPY_AND_ASSIGN(ScopedThreadDesktop); }; -} // namespace remoting +} // namespace media -#endif // REMOTING_CAPTURER_WIN_SCOPED_THREAD_DESKTOP_H_ +#endif // MEDIA_VIDEO_CAPTURE_SCREEN_WIN_SCOPED_THREAD_DESKTOP_H_ diff --git a/remoting/capturer/differ_block.h b/remoting/capturer/differ_block.h deleted file mode 100644 index 4f78960..0000000 --- a/remoting/capturer/differ_block.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2011 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_DIFFER_BLOCK_H_ -#define REMOTING_HOST_DIFFER_BLOCK_H_ - -#include "base/basictypes.h" - -namespace remoting { - -// Size (in pixels) of each square block used for diffing. -// This must be a multiple of sizeof(uint64)/8. -static const int kBlockSize = 32; - -// Format: BGRA 32 bit. -static const int kBytesPerPixel = 4; - -// Low level functions to compare 2 blocks of pixels. -// zero means the blocks are identical. -// one means the blocks are different. -int BlockDifference(const uint8* image1, const uint8* image2, int stride); - -} // namespace remoting - -#endif // REMOTING_HOST_DIFFER_BLOCK_H_ diff --git a/remoting/capturer/video_capturer_mock_objects.cc b/remoting/capturer/video_capturer_mock_objects.cc deleted file mode 100644 index 22a79f6..0000000 --- a/remoting/capturer/video_capturer_mock_objects.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2012 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/capturer/video_capturer_mock_objects.h" - -#include "remoting/capturer/video_frame_capturer.h" -#include "testing/gmock/include/gmock/gmock.h" - -namespace remoting { - -MockVideoFrameCapturer::MockVideoFrameCapturer() {} - -MockVideoFrameCapturer::~MockVideoFrameCapturer() {} - -MockVideoFrameCapturerDelegate::MockVideoFrameCapturerDelegate() { -} - -MockVideoFrameCapturerDelegate::~MockVideoFrameCapturerDelegate() { -} - -void MockVideoFrameCapturerDelegate::OnCursorShapeChanged( - scoped_ptr<MouseCursorShape> cursor_shape) { - // Notify the mock method. - OnCursorShapeChangedPtr(cursor_shape.get()); -} - -} // namespace remoting diff --git a/remoting/capturer/video_capturer_mock_objects.h b/remoting/capturer/video_capturer_mock_objects.h deleted file mode 100644 index f460c1f..0000000 --- a/remoting/capturer/video_capturer_mock_objects.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) 2012 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_CAPTURER_VIDEO_CAPTURER_MOCK_OBJECTS_H_ -#define REMOTING_CAPTURER_VIDEO_CAPTURER_MOCK_OBJECTS_H_ - -#include "remoting/capturer/capture_data.h" -#include "remoting/capturer/mouse_cursor_shape.h" -#include "remoting/capturer/video_frame_capturer.h" -#include "testing/gmock/include/gmock/gmock.h" - -namespace remoting { - -class MockVideoFrameCapturer : public VideoFrameCapturer { - public: - MockVideoFrameCapturer(); - virtual ~MockVideoFrameCapturer(); - - MOCK_METHOD1(Start, void(Delegate* delegate)); - MOCK_METHOD0(Stop, void()); - MOCK_METHOD1(InvalidateRegion, void(const SkRegion& invalid_region)); - MOCK_METHOD0(CaptureFrame, void()); - - private: - DISALLOW_COPY_AND_ASSIGN(MockVideoFrameCapturer); -}; - -class MockVideoFrameCapturerDelegate : public VideoFrameCapturer::Delegate { - public: - MockVideoFrameCapturerDelegate(); - virtual ~MockVideoFrameCapturerDelegate(); - - void OnCursorShapeChanged(scoped_ptr<MouseCursorShape> cursor_shape) OVERRIDE; - - MOCK_METHOD1(OnCaptureCompleted, void(scoped_refptr<CaptureData>)); - MOCK_METHOD1(OnCursorShapeChangedPtr, - void(MouseCursorShape* cursor_shape)); - - private: - DISALLOW_COPY_AND_ASSIGN(MockVideoFrameCapturerDelegate); -}; - -} // namespace remoting - -#endif // REMOTING_CAPTURER_VIDEO_CAPTURER_MOCK_OBJECTS_H_ diff --git a/remoting/codec/DEPS b/remoting/codec/DEPS index 7f88e41..61e5c26 100644 --- a/remoting/codec/DEPS +++ b/remoting/codec/DEPS @@ -1,5 +1,5 @@ include_rules = [ - "+remoting/capturer", + "+media/video/capture/screen", "+remoting/protocol", "+google/protobuf", diff --git a/remoting/codec/codec_test.cc b/remoting/codec/codec_test.cc index 7f45828..7c87307 100644 --- a/remoting/codec/codec_test.cc +++ b/remoting/codec/codec_test.cc @@ -180,7 +180,7 @@ class VideoDecoderTester { strict_ = strict; } - void set_capture_data(scoped_refptr<CaptureData> data) { + void set_capture_data(scoped_refptr<media::ScreenCaptureData> data) { capture_data_ = data; } @@ -272,7 +272,7 @@ class VideoDecoderTester { SkRegion update_region_; VideoDecoder* decoder_; scoped_array<uint8> image_data_; - scoped_refptr<CaptureData> capture_data_; + scoped_refptr<media::ScreenCaptureData> capture_data_; DISALLOW_COPY_AND_ASSIGN(VideoDecoderTester); }; @@ -317,8 +317,9 @@ class VideoEncoderTester { DISALLOW_COPY_AND_ASSIGN(VideoEncoderTester); }; -scoped_refptr<CaptureData> PrepareEncodeData(const SkISize& size, - scoped_array<uint8>* memory) { +scoped_refptr<media::ScreenCaptureData> PrepareEncodeData( + const SkISize& size, + scoped_array<uint8>* memory) { int memory_size = size.width() * size.height() * kBytesPerPixel; memory->reset(new uint8[memory_size]); @@ -328,14 +329,14 @@ scoped_refptr<CaptureData> PrepareEncodeData(const SkISize& size, (*memory)[i] = rand() % 256; } - scoped_refptr<CaptureData> data = - new CaptureData(memory->get(), size.width() * kBytesPerPixel, size); + scoped_refptr<media::ScreenCaptureData> data = new media::ScreenCaptureData( + memory->get(), size.width() * kBytesPerPixel, size); return data; } static void TestEncodingRects(VideoEncoder* encoder, VideoEncoderTester* tester, - scoped_refptr<CaptureData> data, + scoped_refptr<media::ScreenCaptureData> data, const SkIRect* rects, int count) { data->mutable_dirty_region().setEmpty(); for (int i = 0; i < count; ++i) { @@ -360,7 +361,7 @@ void TestVideoEncoder(VideoEncoder* encoder, bool strict) { for (size_t xi = 0; xi < arraysize(kSizes); ++xi) { for (size_t yi = 0; yi < arraysize(kSizes); ++yi) { SkISize size = SkISize::Make(kSizes[xi], kSizes[yi]); - scoped_refptr<CaptureData> data = + scoped_refptr<media::ScreenCaptureData> data = PrepareEncodeData(size, &memory); std::vector<std::vector<SkIRect> > test_rect_lists = MakeTestRectLists(size); @@ -376,7 +377,7 @@ void TestVideoEncoder(VideoEncoder* encoder, bool strict) { static void TestEncodeDecodeRects(VideoEncoder* encoder, VideoEncoderTester* encoder_tester, VideoDecoderTester* decoder_tester, - scoped_refptr<CaptureData> data, + scoped_refptr<media::ScreenCaptureData> data, const SkIRect* rects, int count) { data->mutable_dirty_region().setRects(rects, count); encoder_tester->AddRects(rects, count); @@ -413,7 +414,8 @@ void TestVideoEncoderDecoder( VideoEncoderTester encoder_tester(&message_tester); scoped_array<uint8> memory; - scoped_refptr<CaptureData> data = PrepareEncodeData(kSize, &memory); + scoped_refptr<media::ScreenCaptureData> data = + PrepareEncodeData(kSize, &memory); VideoDecoderTester decoder_tester(decoder, kSize, kSize); decoder_tester.set_strict(strict); @@ -458,9 +460,9 @@ void TestVideoEncoderDecoderGradient(VideoEncoder* encoder, view_size.width() * view_size.height() * kBytesPerPixel]); FillWithGradient(expected_view_data.get(), view_size, view_rect); - scoped_refptr<CaptureData> capture_data = - new CaptureData(screen_data.get(), screen_size.width() * kBytesPerPixel, - screen_size); + scoped_refptr<media::ScreenCaptureData> capture_data = + new media::ScreenCaptureData( + screen_data.get(), screen_size.width() * kBytesPerPixel, screen_size); capture_data->mutable_dirty_region().op(screen_rect, SkRegion::kUnion_Op); VideoDecoderTester decoder_tester(decoder, screen_size, view_size); diff --git a/remoting/codec/codec_test.h b/remoting/codec/codec_test.h index 86c52f2..d2bda83 100644 --- a/remoting/codec/codec_test.h +++ b/remoting/codec/codec_test.h @@ -7,7 +7,7 @@ #include "base/memory/ref_counted.h" #include "media/base/video_frame.h" -#include "remoting/capturer/capture_data.h" +#include "media/video/capture/screen/screen_capture_data.h" namespace remoting { diff --git a/remoting/codec/video_encoder.h b/remoting/codec/video_encoder.h index 5cc4c10..81179c4 100644 --- a/remoting/codec/video_encoder.h +++ b/remoting/codec/video_encoder.h @@ -10,12 +10,11 @@ #include "media/base/data_buffer.h" namespace media { - class DataBuffer; -} +class ScreenCaptureData; +} // namespace media namespace remoting { -class CaptureData; class VideoPacket; // A class to perform the task of encoding a continous stream of @@ -37,7 +36,7 @@ class VideoEncoder { // // When encoded data is available, partial or full |data_available_callback| // is called. - virtual void Encode(scoped_refptr<CaptureData> capture_data, + virtual void Encode(scoped_refptr<media::ScreenCaptureData> capture_data, bool key_frame, const DataAvailableCallback& data_available_callback) = 0; }; diff --git a/remoting/codec/video_encoder_verbatim.cc b/remoting/codec/video_encoder_verbatim.cc index 0633ac2..2e7f6d0 100644 --- a/remoting/codec/video_encoder_verbatim.cc +++ b/remoting/codec/video_encoder_verbatim.cc @@ -5,8 +5,8 @@ #include "remoting/codec/video_encoder_verbatim.h" #include "base/logging.h" +#include "media/video/capture/screen/screen_capture_data.h" #include "remoting/base/util.h" -#include "remoting/capturer/capture_data.h" #include "remoting/proto/video.pb.h" namespace remoting { @@ -26,7 +26,7 @@ VideoEncoderVerbatim::~VideoEncoderVerbatim() { } void VideoEncoderVerbatim::Encode( - scoped_refptr<CaptureData> capture_data, + scoped_refptr<media::ScreenCaptureData> capture_data, bool key_frame, const DataAvailableCallback& data_available_callback) { capture_data_ = capture_data; diff --git a/remoting/codec/video_encoder_verbatim.h b/remoting/codec/video_encoder_verbatim.h index 6477b2a..2b6250b 100644 --- a/remoting/codec/video_encoder_verbatim.h +++ b/remoting/codec/video_encoder_verbatim.h @@ -24,7 +24,7 @@ class VideoEncoderVerbatim : public VideoEncoder { // VideoEncoder interface. virtual void Encode( - scoped_refptr<CaptureData> capture_data, + scoped_refptr<media::ScreenCaptureData> capture_data, bool key_frame, const DataAvailableCallback& data_available_callback) OVERRIDE; @@ -43,7 +43,7 @@ class VideoEncoderVerbatim : public VideoEncoder { // Submit |packet| to |callback_|. void SubmitMessage(VideoPacket* packet, size_t rect_index); - scoped_refptr<CaptureData> capture_data_; + scoped_refptr<media::ScreenCaptureData> capture_data_; DataAvailableCallback callback_; base::Time encode_start_time_; diff --git a/remoting/codec/video_encoder_vp8.cc b/remoting/codec/video_encoder_vp8.cc index ace549b..a4e4d1a 100644 --- a/remoting/codec/video_encoder_vp8.cc +++ b/remoting/codec/video_encoder_vp8.cc @@ -8,8 +8,8 @@ #include "base/sys_info.h" #include "base/time.h" #include "media/base/yuv_convert.h" +#include "media/video/capture/screen/screen_capture_data.h" #include "remoting/base/util.h" -#include "remoting/capturer/capture_data.h" #include "remoting/proto/video.pb.h" extern "C" { @@ -146,8 +146,9 @@ bool VideoEncoderVp8::Init(const SkISize& size) { return true; } -void VideoEncoderVp8::PrepareImage(scoped_refptr<CaptureData> capture_data, - SkRegion* updated_region) { +void VideoEncoderVp8::PrepareImage( + scoped_refptr<media::ScreenCaptureData> capture_data, + SkRegion* updated_region) { const SkRegion& region = capture_data->dirty_region(); if (region.isEmpty()) { updated_region->setEmpty(); @@ -212,7 +213,7 @@ void VideoEncoderVp8::PrepareActiveMap(const SkRegion& updated_region) { } void VideoEncoderVp8::Encode( - scoped_refptr<CaptureData> capture_data, + scoped_refptr<media::ScreenCaptureData> capture_data, bool key_frame, const DataAvailableCallback& data_available_callback) { DCHECK_LE(32, capture_data->size().width()); diff --git a/remoting/codec/video_encoder_vp8.h b/remoting/codec/video_encoder_vp8.h index 83559e1..4b3f903 100644 --- a/remoting/codec/video_encoder_vp8.h +++ b/remoting/codec/video_encoder_vp8.h @@ -21,7 +21,7 @@ class VideoEncoderVp8 : public VideoEncoder { virtual ~VideoEncoderVp8(); virtual void Encode( - scoped_refptr<CaptureData> capture_data, + scoped_refptr<media::ScreenCaptureData> capture_data, bool key_frame, const DataAvailableCallback& data_available_callback) OVERRIDE; @@ -36,7 +36,7 @@ class VideoEncoderVp8 : public VideoEncoder { // Prepare |image_| for encoding. Write updated rectangles into // |updated_region|. - void PrepareImage(scoped_refptr<CaptureData> capture_data, + void PrepareImage(scoped_refptr<media::ScreenCaptureData> capture_data, SkRegion* updated_region); // Update the active map according to |updated_region|. Active map is then diff --git a/remoting/codec/video_encoder_vp8_unittest.cc b/remoting/codec/video_encoder_vp8_unittest.cc index 11d5ded..9a32fe2 100644 --- a/remoting/codec/video_encoder_vp8_unittest.cc +++ b/remoting/codec/video_encoder_vp8_unittest.cc @@ -10,7 +10,7 @@ #include "base/bind.h" #include "base/callback.h" #include "base/memory/scoped_ptr.h" -#include "remoting/capturer/capture_data.h" +#include "media/video/capture/screen/screen_capture_data.h" #include "remoting/codec/codec_test.h" #include "remoting/proto/video.pb.h" #include "testing/gtest/include/gtest/gtest.h" @@ -34,8 +34,8 @@ class VideoEncoderCallback { } }; -// Test that calling Encode with a differently-sized CaptureData does not -// leak memory. +// Test that calling Encode with a differently-sized media::ScreenCaptureData +// does not leak memory. TEST(VideoEncoderVp8Test, TestSizeChangeNoLeak) { int height = 1000; int width = 1000; @@ -45,14 +45,15 @@ TEST(VideoEncoderVp8Test, TestSizeChangeNoLeak) { VideoEncoderCallback callback; std::vector<uint8> buffer(width * height * kBytesPerPixel); - scoped_refptr<CaptureData> capture_data(new CaptureData( - &buffer.front(), width * kBytesPerPixel, SkISize::Make(width, height))); + scoped_refptr<media::ScreenCaptureData> capture_data( + new media::ScreenCaptureData(&buffer.front(), width * kBytesPerPixel, + SkISize::Make(width, height))); encoder.Encode(capture_data, false, base::Bind(&VideoEncoderCallback::DataAvailable, base::Unretained(&callback))); height /= 2; - capture_data = new CaptureData( + capture_data = new media::ScreenCaptureData( &buffer.front(), width * kBytesPerPixel, SkISize::Make(width, height)); encoder.Encode(capture_data, false, base::Bind(&VideoEncoderCallback::DataAvailable, @@ -67,8 +68,8 @@ class VideoEncoderDpiCallback { } }; -// Test that the DPI information is correctly propagated from the CaptureData -// to the VideoPacket. +// Test that the DPI information is correctly propagated from the +// media::ScreenCaptureData to the VideoPacket. TEST(VideoEncoderVp8Test, TestDpiPropagation) { int height = 32; int width = 32; @@ -78,8 +79,9 @@ TEST(VideoEncoderVp8Test, TestDpiPropagation) { VideoEncoderDpiCallback callback; std::vector<uint8> buffer(width * height * kBytesPerPixel); - scoped_refptr<CaptureData> capture_data(new CaptureData( - &buffer.front(), width * kBytesPerPixel, SkISize::Make(width, height))); + scoped_refptr<media::ScreenCaptureData> capture_data( + new media::ScreenCaptureData(&buffer.front(), width * kBytesPerPixel, + SkISize::Make(width, height))); capture_data->set_dpi(SkIPoint::Make(96, 97)); encoder.Encode(capture_data, false, base::Bind(&VideoEncoderDpiCallback::DataAvailable, diff --git a/remoting/host/DEPS b/remoting/host/DEPS index 9936357..5cfd1e5 100644 --- a/remoting/host/DEPS +++ b/remoting/host/DEPS @@ -1,4 +1,5 @@ include_rules = [ + "+media/video/capture/screen", "+net/base", "+net/ftp", "+net/http", @@ -10,7 +11,6 @@ include_rules = [ # at process start. "+net/socket", - "+remoting/capturer", "+remoting/codec", "+remoting/protocol", "+remoting/jingle_glue", diff --git a/remoting/host/basic_desktop_environment.cc b/remoting/host/basic_desktop_environment.cc index 040fe88..5c41ef1 100644 --- a/remoting/host/basic_desktop_environment.cc +++ b/remoting/host/basic_desktop_environment.cc @@ -5,7 +5,7 @@ #include "remoting/host/basic_desktop_environment.h" #include "base/logging.h" -#include "remoting/capturer/video_frame_capturer.h" +#include "media/video/capture/screen/screen_capturer.h" #include "remoting/host/audio_capturer.h" #include "remoting/host/event_executor.h" @@ -33,12 +33,12 @@ scoped_ptr<EventExecutor> BasicDesktopEnvironment::CreateEventExecutor( return EventExecutor::Create(input_task_runner, ui_task_runner); } -scoped_ptr<VideoFrameCapturer> BasicDesktopEnvironment::CreateVideoCapturer( +scoped_ptr<media::ScreenCapturer> BasicDesktopEnvironment::CreateVideoCapturer( scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner) { DCHECK(CalledOnValidThread()); - return VideoFrameCapturer::Create(); + return media::ScreenCapturer::Create(); } BasicDesktopEnvironmentFactory::BasicDesktopEnvironmentFactory() { diff --git a/remoting/host/basic_desktop_environment.h b/remoting/host/basic_desktop_environment.h index 4d0c08e..e3ac2bf 100644 --- a/remoting/host/basic_desktop_environment.h +++ b/remoting/host/basic_desktop_environment.h @@ -29,7 +29,7 @@ class BasicDesktopEnvironment virtual scoped_ptr<EventExecutor> CreateEventExecutor( scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) OVERRIDE; - virtual scoped_ptr<VideoFrameCapturer> CreateVideoCapturer( + virtual scoped_ptr<media::ScreenCapturer> CreateVideoCapturer( scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner) OVERRIDE; diff --git a/remoting/host/chromoting_host.h b/remoting/host/chromoting_host.h index 31b8bba..7e1a935 100644 --- a/remoting/host/chromoting_host.h +++ b/remoting/host/chromoting_host.h @@ -46,7 +46,7 @@ class DesktopEnvironmentFactory; // // 2. We listen for incoming connection using libjingle. We will create // a ConnectionToClient object that wraps around linjingle for transport. -// A ScreenRecorder is created with an Encoder and a VideoFrameCapturer. +// A VideoScheduler is created with an Encoder and a media::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 4d1f00d..97c490a 100644 --- a/remoting/host/chromoting_host_unittest.cc +++ b/remoting/host/chromoting_host_unittest.cc @@ -6,8 +6,8 @@ #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/capturer/video_frame_capturer_fake.h" #include "remoting/host/audio_capturer.h" #include "remoting/host/chromoting_host.h" #include "remoting/host/chromoting_host_context.h" @@ -19,8 +19,8 @@ #include "remoting/protocol/errors.h" #include "remoting/protocol/protocol_mock_objects.h" #include "remoting/protocol/session_config.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 ::remoting::protocol::MockClientStub; @@ -285,7 +285,7 @@ class ChromotingHostTest : public testing::Test { host_->OnSessionRouteChange(get_client(0), channel_name, route); } - // Creates a DesktopEnvironment with a fake VideoFrameCapturer, to mock + // Creates a DesktopEnvironment with a fake media::ScreenCapturer, to mock // DesktopEnvironmentFactory::Create(). DesktopEnvironment* CreateDesktopEnvironment() { MockDesktopEnvironment* desktop_environment = new MockDesktopEnvironment(); @@ -311,12 +311,12 @@ class ChromotingHostTest : public testing::Test { return event_executor; } - // Creates a fake VideoFrameCapturer, to mock + // Creates a fake media::ScreenCapturer, to mock // DesktopEnvironment::CreateVideoCapturer(). - VideoFrameCapturer* CreateVideoCapturer( + media::ScreenCapturer* CreateVideoCapturer( scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner) { - return new VideoFrameCapturerFake(); + return new media::ScreenCapturerFake(); } void DisconnectAllClients() { diff --git a/remoting/host/chromoting_messages.h b/remoting/host/chromoting_messages.h index 4407f49..f62bfbb 100644 --- a/remoting/host/chromoting_messages.h +++ b/remoting/host/chromoting_messages.h @@ -6,7 +6,7 @@ #define REMOTING_HOST_CHROMOTING_MESSAGES_H_ #include "ipc/ipc_platform_file.h" -#include "remoting/capturer/mouse_cursor_shape.h" +#include "media/video/capture/screen/mouse_cursor_shape.h" #include "third_party/skia/include/core/SkPoint.h" #include "third_party/skia/include/core/SkRect.h" #include "third_party/skia/include/core/SkSize.h" @@ -128,13 +128,13 @@ IPC_STRUCT_TRAITS_BEGIN(SkISize) IPC_STRUCT_TRAITS_MEMBER(fHeight) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(remoting::MouseCursorShape) +IPC_STRUCT_TRAITS_BEGIN(media::MouseCursorShape) IPC_STRUCT_TRAITS_MEMBER(size) IPC_STRUCT_TRAITS_MEMBER(hotspot) IPC_STRUCT_TRAITS_MEMBER(data) IPC_STRUCT_TRAITS_END() -// Serialized CaptureData structure. +// Serialized media::ScreenCaptureData structure. IPC_STRUCT_BEGIN(SerializedCapturedData) // ID of the shared memory buffer containing the pixels. IPC_STRUCT_MEMBER(int, shared_buffer_id) @@ -164,7 +164,7 @@ IPC_MESSAGE_CONTROL1(ChromotingDesktopNetworkMsg_CaptureCompleted, // Carries a cursor share update from the desktop session agent to the client. IPC_MESSAGE_CONTROL1(ChromotingDesktopNetworkMsg_CursorShapeChanged, - remoting::MouseCursorShape /* cursor_shape */ ) + media::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 1e27128..b62b2e4 100644 --- a/remoting/host/client_session.cc +++ b/remoting/host/client_session.cc @@ -7,7 +7,7 @@ #include <algorithm> #include "base/message_loop_proxy.h" -#include "remoting/capturer/video_frame_capturer.h" +#include "media/video/capture/screen/screen_capturer.h" #include "remoting/codec/audio_encoder.h" #include "remoting/codec/audio_encoder_opus.h" #include "remoting/codec/audio_encoder_speex.h" diff --git a/remoting/host/client_session_unittest.cc b/remoting/host/client_session_unittest.cc index 1720382..abe7eee 100644 --- a/remoting/host/client_session_unittest.cc +++ b/remoting/host/client_session_unittest.cc @@ -3,10 +3,10 @@ // 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/capturer/video_capturer_mock_objects.h" -#include "remoting/capturer/video_frame_capturer_fake.h" #include "remoting/host/audio_capturer.h" #include "remoting/host/client_session.h" #include "remoting/host/desktop_environment.h" @@ -67,7 +67,7 @@ class ClientSessionTest : public testing::Test { void StopClientSession(); protected: - // Creates a DesktopEnvironment with a fake VideoFrameCapturer, to mock + // Creates a DesktopEnvironment with a fake media::ScreenCapturer, to mock // DesktopEnvironmentFactory::Create(). DesktopEnvironment* CreateDesktopEnvironment(); @@ -77,9 +77,9 @@ class ClientSessionTest : public testing::Test { scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); - // Creates a fake VideoFrameCapturer, to mock + // Creates a fake media::ScreenCapturer, to mock // DesktopEnvironment::CreateVideoCapturer(). - VideoFrameCapturer* CreateVideoCapturer( + media::ScreenCapturer* CreateVideoCapturer( scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner); @@ -208,10 +208,10 @@ EventExecutor* ClientSessionTest::CreateEventExecutor( return event_executor_.release(); } -VideoFrameCapturer* ClientSessionTest::CreateVideoCapturer( +media::ScreenCapturer* ClientSessionTest::CreateVideoCapturer( scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner) { - return new VideoFrameCapturerFake(); + return new media::ScreenCapturerFake(); } void ClientSessionTest::ConnectClientSession() { @@ -437,9 +437,9 @@ TEST_F(ClientSessionTest, ClampMouseEvents) { EXPECT_CALL(session_event_handler_, OnSessionClosed(_)); int input_x[3] = { -999, 100, 999 }; - int expected_x[3] = { 0, 100, VideoFrameCapturerFake::kWidth - 1 }; + int expected_x[3] = { 0, 100, media::ScreenCapturerFake::kWidth - 1 }; int input_y[3] = { -999, 50, 999 }; - int expected_y[3] = { 0, 50, VideoFrameCapturerFake::kHeight - 1 }; + int expected_y[3] = { 0, 50, media::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 06b0b373..f91fb85 100644 --- a/remoting/host/desktop_environment.h +++ b/remoting/host/desktop_environment.h @@ -16,11 +16,14 @@ namespace base { class SingleThreadTaskRunner; } // namespace base +namespace media { +class ScreenCapturer; +} // namespace media + namespace remoting { class AudioCapturer; class EventExecutor; -class VideoFrameCapturer; // Provides factory methods for creation of audio/video capturers and event // executor for a given desktop environment. @@ -35,7 +38,7 @@ class DesktopEnvironment { virtual scoped_ptr<EventExecutor> CreateEventExecutor( scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) = 0; - virtual scoped_ptr<VideoFrameCapturer> CreateVideoCapturer( + virtual scoped_ptr<media::ScreenCapturer> CreateVideoCapturer( scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner) = 0; }; diff --git a/remoting/host/desktop_session_agent.cc b/remoting/host/desktop_session_agent.cc index 39a2aec..878ae4f 100644 --- a/remoting/host/desktop_session_agent.cc +++ b/remoting/host/desktop_session_agent.cc @@ -8,10 +8,10 @@ #include "ipc/ipc_channel_proxy.h" #include "ipc/ipc_message.h" #include "ipc/ipc_message_macros.h" +#include "media/video/capture/screen/screen_capture_data.h" #include "remoting/base/auto_thread_task_runner.h" #include "remoting/base/constants.h" #include "remoting/base/util.h" -#include "remoting/capturer/capture_data.h" #include "remoting/host/audio_capturer.h" #include "remoting/host/chromoting_messages.h" #include "remoting/host/disconnect_window.h" @@ -137,11 +137,11 @@ void DesktopSessionAgent::OnLocalMouseMoved(const SkIPoint& new_pos) { remote_input_filter_->LocalMouseMoved(new_pos); } -scoped_refptr<SharedBuffer> DesktopSessionAgent::CreateSharedBuffer( +scoped_refptr<media::SharedBuffer> DesktopSessionAgent::CreateSharedBuffer( uint32 size) { DCHECK(video_capture_task_runner()->BelongsToCurrentThread()); - scoped_refptr<SharedBuffer> buffer = new SharedBuffer(size); + scoped_refptr<media::SharedBuffer> buffer = new media::SharedBuffer(size); if (buffer->ptr() != NULL) { buffer->set_id(next_shared_buffer_id_); shared_buffers_.push_back(buffer); @@ -164,7 +164,7 @@ scoped_refptr<SharedBuffer> DesktopSessionAgent::CreateSharedBuffer( } void DesktopSessionAgent::ReleaseSharedBuffer( - scoped_refptr<SharedBuffer> buffer) { + scoped_refptr<media::SharedBuffer> buffer) { DCHECK(video_capture_task_runner()->BelongsToCurrentThread()); DCHECK(buffer->id() != 0); @@ -214,12 +214,12 @@ void DesktopSessionAgent::OnStartSessionAgent( } void DesktopSessionAgent::OnCaptureCompleted( - scoped_refptr<CaptureData> capture_data) { + scoped_refptr<media::ScreenCaptureData> capture_data) { DCHECK(video_capture_task_runner()->BelongsToCurrentThread()); current_size_ = capture_data->size(); - // Serialize CaptureData + // Serialize media::ScreenCaptureData SerializedCapturedData serialized_data; serialized_data.shared_buffer_id = capture_data->shared_buffer()->id(); serialized_data.bytes_per_row = capture_data->stride(); @@ -236,7 +236,7 @@ void DesktopSessionAgent::OnCaptureCompleted( } void DesktopSessionAgent::OnCursorShapeChanged( - scoped_ptr<MouseCursorShape> cursor_shape) { + scoped_ptr<media::MouseCursorShape> cursor_shape) { DCHECK(video_capture_task_runner()->BelongsToCurrentThread()); SendToNetwork(new ChromotingDesktopNetworkMsg_CursorShapeChanged( @@ -325,10 +325,10 @@ void DesktopSessionAgent::OnCaptureFrame() { return; } - // VideoFrameCapturer supports a very few (currently 2) outstanding capture + // 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 VideoFrameCapturer will not be + // will likely be corrupted but stability of media::ScreenCapturer will not be // affected. video_capturer_->CaptureFrame(); } @@ -486,7 +486,7 @@ void DesktopSessionAgent::StopAudioCapturer() { void DesktopSessionAgent::StartVideoCapturer() { DCHECK(video_capture_task_runner()->BelongsToCurrentThread()); - video_capturer_ = VideoFrameCapturer::CreateWithFactory(this); + video_capturer_ = media::ScreenCapturer::CreateWithFactory(this); if (video_capturer_) video_capturer_->Start(this); } diff --git a/remoting/host/desktop_session_agent.h b/remoting/host/desktop_session_agent.h index b5e6556..b315b50 100644 --- a/remoting/host/desktop_session_agent.h +++ b/remoting/host/desktop_session_agent.h @@ -15,9 +15,9 @@ #include "base/memory/weak_ptr.h" #include "ipc/ipc_listener.h" #include "ipc/ipc_platform_file.h" -#include "remoting/capturer/shared_buffer.h" -#include "remoting/capturer/shared_buffer_factory.h" -#include "remoting/capturer/video_frame_capturer.h" +#include "media/video/capture/screen/screen_capturer.h" +#include "media/video/capture/screen/shared_buffer.h" +#include "media/video/capture/screen/shared_buffer_factory.h" #include "remoting/host/mouse_move_observer.h" #include "remoting/host/ui_strings.h" #include "remoting/protocol/clipboard_stub.h" @@ -49,8 +49,8 @@ class DesktopSessionAgent : public base::RefCountedThreadSafe<DesktopSessionAgent>, public IPC::Listener, public MouseMoveObserver, - public SharedBufferFactory, - public VideoFrameCapturer::Delegate { + public media::SharedBufferFactory, + public media::ScreenCapturer::Delegate { public: class Delegate { public: @@ -80,14 +80,16 @@ class DesktopSessionAgent virtual void OnLocalMouseMoved(const SkIPoint& new_pos) OVERRIDE; // SharedBufferFactory implementation. - virtual scoped_refptr<SharedBuffer> CreateSharedBuffer(uint32 size) OVERRIDE; - virtual void ReleaseSharedBuffer(scoped_refptr<SharedBuffer> buffer) OVERRIDE; + virtual scoped_refptr<media::SharedBuffer> CreateSharedBuffer( + uint32 size) OVERRIDE; + virtual void ReleaseSharedBuffer( + scoped_refptr<media::SharedBuffer> buffer) OVERRIDE; - // VideoFrameCapturer::Delegate implementation. + // media::ScreenCapturer::Delegate implementation. virtual void OnCaptureCompleted( - scoped_refptr<CaptureData> capture_data) OVERRIDE; + scoped_refptr<media::ScreenCaptureData> capture_data) OVERRIDE; virtual void OnCursorShapeChanged( - scoped_ptr<MouseCursorShape> cursor_shape) OVERRIDE; + scoped_ptr<media::MouseCursorShape> cursor_shape) OVERRIDE; // Forwards a local clipboard event though the IPC channel to the network // process. @@ -233,14 +235,14 @@ class DesktopSessionAgent int next_shared_buffer_id_; // List of the shared buffers registered via |SharedBufferFactory| interface. - typedef std::list<scoped_refptr<SharedBuffer> > SharedBuffers; + typedef std::list<scoped_refptr<media::SharedBuffer> > SharedBuffers; SharedBuffers shared_buffers_; // True if the desktop session agent has been started. bool started_; // Captures the screen. - scoped_ptr<VideoFrameCapturer> video_capturer_; + scoped_ptr<media::ScreenCapturer> video_capturer_; UiStrings ui_strings_; diff --git a/remoting/host/desktop_session_proxy.cc b/remoting/host/desktop_session_proxy.cc index 48e1547..c557853 100644 --- a/remoting/host/desktop_session_proxy.cc +++ b/remoting/host/desktop_session_proxy.cc @@ -10,7 +10,7 @@ #include "base/single_thread_task_runner.h" #include "ipc/ipc_channel_proxy.h" #include "ipc/ipc_message_macros.h" -#include "remoting/capturer/capture_data.h" +#include "media/video/capture/screen/screen_capture_data.h" #include "remoting/host/audio_capturer.h" #include "remoting/host/chromoting_messages.h" #include "remoting/host/client_session.h" @@ -59,14 +59,14 @@ scoped_ptr<EventExecutor> DesktopSessionProxy::CreateEventExecutor( return scoped_ptr<EventExecutor>(new IpcEventExecutor(this)); } -scoped_ptr<VideoFrameCapturer> DesktopSessionProxy::CreateVideoCapturer( +scoped_ptr<media::ScreenCapturer> DesktopSessionProxy::CreateVideoCapturer( scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner) { DCHECK(caller_task_runner_->BelongsToCurrentThread()); DCHECK(!video_capture_task_runner_.get()); video_capture_task_runner_ = capture_task_runner; - return scoped_ptr<VideoFrameCapturer>(new IpcVideoFrameCapturer(this)); + return scoped_ptr<media::ScreenCapturer>(new IpcVideoFrameCapturer(this)); } bool DesktopSessionProxy::OnMessageReceived(const IPC::Message& message) { @@ -169,7 +169,7 @@ void DesktopSessionProxy::DetachFromDesktop() { // Generate fake responses to keep the video capturer in sync. while (pending_capture_frame_requests_) { --pending_capture_frame_requests_; - PostCaptureCompleted(scoped_refptr<CaptureData>()); + PostCaptureCompleted(scoped_refptr<media::ScreenCaptureData>()); } } @@ -284,7 +284,8 @@ void DesktopSessionProxy::StartEventExecutor( DesktopSessionProxy::~DesktopSessionProxy() { } -scoped_refptr<SharedBuffer> DesktopSessionProxy::GetSharedBuffer(int id) { +scoped_refptr<media::SharedBuffer> DesktopSessionProxy::GetSharedBuffer( + int id) { DCHECK(caller_task_runner_->BelongsToCurrentThread()); SharedBuffers::const_iterator i = shared_buffers_.find(id); @@ -292,7 +293,7 @@ scoped_refptr<SharedBuffer> DesktopSessionProxy::GetSharedBuffer(int id) { return i->second; } else { LOG(ERROR) << "Failed to find the shared buffer " << id; - return scoped_refptr<SharedBuffer>(); + return scoped_refptr<media::SharedBuffer>(); } } @@ -316,12 +317,12 @@ void DesktopSessionProxy::OnCreateSharedBuffer( uint32 size) { DCHECK(caller_task_runner_->BelongsToCurrentThread()); - scoped_refptr<SharedBuffer> shared_buffer; + scoped_refptr<media::SharedBuffer> shared_buffer; #if defined(OS_WIN) - shared_buffer = new SharedBuffer(id, handle, desktop_process_, size); + shared_buffer = new media::SharedBuffer(id, handle, desktop_process_, size); #elif defined(OS_POSIX) - shared_buffer = new SharedBuffer(id, handle, size); + shared_buffer = new media::SharedBuffer(id, handle, size); #else #error Unsupported platform. #endif @@ -363,14 +364,15 @@ void DesktopSessionProxy::OnCaptureCompleted( // Assume that |serialized_data| is well formed because it was received from // a more privileged process. - scoped_refptr<CaptureData> capture_data; - scoped_refptr<SharedBuffer> shared_buffer = + scoped_refptr<media::ScreenCaptureData> capture_data; + scoped_refptr<media::SharedBuffer> shared_buffer = GetSharedBuffer(serialized_data.shared_buffer_id); CHECK(shared_buffer); - capture_data = new CaptureData(reinterpret_cast<uint8*>(shared_buffer->ptr()), - serialized_data.bytes_per_row, - serialized_data.dimensions); + capture_data = new media::ScreenCaptureData( + reinterpret_cast<uint8*>(shared_buffer->ptr()), + serialized_data.bytes_per_row, + serialized_data.dimensions); capture_data->set_capture_time_ms(serialized_data.capture_time_ms); capture_data->set_client_sequence_number( serialized_data.client_sequence_number); @@ -388,10 +390,10 @@ void DesktopSessionProxy::OnCaptureCompleted( } void DesktopSessionProxy::OnCursorShapeChanged( - const MouseCursorShape& cursor_shape) { + const media::MouseCursorShape& cursor_shape) { DCHECK(caller_task_runner_->BelongsToCurrentThread()); - PostCursorShape( - scoped_ptr<MouseCursorShape>(new MouseCursorShape(cursor_shape))); + PostCursorShape(scoped_ptr<media::MouseCursorShape>( + new media::MouseCursorShape(cursor_shape))); } void DesktopSessionProxy::OnInjectClipboardEvent( @@ -422,7 +424,7 @@ void DesktopSessionProxy::PostAudioPacket(scoped_ptr<AudioPacket> packet) { } void DesktopSessionProxy::PostCaptureCompleted( - scoped_refptr<CaptureData> capture_data) { + scoped_refptr<media::ScreenCaptureData> capture_data) { if (!video_capture_task_runner_->BelongsToCurrentThread()) { video_capture_task_runner_->PostTask( FROM_HERE, base::Bind(&DesktopSessionProxy::PostCaptureCompleted, @@ -435,7 +437,7 @@ void DesktopSessionProxy::PostCaptureCompleted( } void DesktopSessionProxy::PostCursorShape( - scoped_ptr<MouseCursorShape> cursor_shape) { + scoped_ptr<media::MouseCursorShape> cursor_shape) { if (!video_capture_task_runner_->BelongsToCurrentThread()) { video_capture_task_runner_->PostTask( FROM_HERE, base::Bind(&DesktopSessionProxy::PostCursorShape, diff --git a/remoting/host/desktop_session_proxy.h b/remoting/host/desktop_session_proxy.h index db4f26b..7988ce6 100644 --- a/remoting/host/desktop_session_proxy.h +++ b/remoting/host/desktop_session_proxy.h @@ -13,8 +13,8 @@ #include "base/memory/weak_ptr.h" #include "ipc/ipc_listener.h" #include "ipc/ipc_platform_file.h" -#include "remoting/capturer/shared_buffer.h" -#include "remoting/capturer/video_frame_capturer.h" +#include "media/video/capture/screen/screen_capturer.h" +#include "media/video/capture/screen/shared_buffer.h" #include "remoting/host/desktop_environment.h" #include "remoting/proto/event.pb.h" #include "remoting/protocol/clipboard_stub.h" @@ -60,7 +60,7 @@ class DesktopSessionProxy scoped_ptr<EventExecutor> CreateEventExecutor( scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); - scoped_ptr<VideoFrameCapturer> CreateVideoCapturer( + scoped_ptr<media::ScreenCapturer> CreateVideoCapturer( scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner); @@ -88,7 +88,7 @@ class DesktopSessionProxy // StopAudioCapturer() has been called will be silently dropped. void StopAudioCapturer(); - // APIs used to implement the VideoFrameCapturer interface. These must be + // APIs used to implement the media::ScreenCapturer interface. These must be // called on |video_capture_task_runner_|. void InvalidateRegion(const SkRegion& invalid_region); void CaptureFrame(); @@ -112,7 +112,7 @@ class DesktopSessionProxy virtual ~DesktopSessionProxy(); // Returns a shared buffer from the list of known buffers. - scoped_refptr<SharedBuffer> GetSharedBuffer(int id); + scoped_refptr<media::SharedBuffer> GetSharedBuffer(int id); // Handles AudioPacket notification from the desktop session agent. void OnAudioPacket(const std::string& serialized_packet); @@ -129,7 +129,7 @@ class DesktopSessionProxy void OnCaptureCompleted(const SerializedCapturedData& serialized_data); // Handles CursorShapeChanged notification from the desktop session agent. - void OnCursorShapeChanged(const MouseCursorShape& cursor_shape); + void OnCursorShapeChanged(const media::MouseCursorShape& cursor_shape); // Handles InjectClipboardEvent request from the desktop integration process. void OnInjectClipboardEvent(const std::string& serialized_event); @@ -140,11 +140,12 @@ class DesktopSessionProxy // Posted to |video_capture_task_runner_| to pass a captured video frame back // to |video_capturer_|. - void PostCaptureCompleted(scoped_refptr<CaptureData> capture_data); + void PostCaptureCompleted( + scoped_refptr<media::ScreenCaptureData> capture_data); // Posted to |video_capture_task_runner_| to pass |cursor_shape| back to // |video_capturer_|. - void PostCursorShape(scoped_ptr<MouseCursorShape> cursor_shape); + void PostCursorShape(scoped_ptr<media::MouseCursorShape> cursor_shape); // Sends a message to the desktop session agent. The message is silently // deleted if the channel is broken. @@ -182,7 +183,7 @@ class DesktopSessionProxy int pending_capture_frame_requests_; - typedef std::map<int, scoped_refptr<SharedBuffer> > SharedBuffers; + typedef std::map<int, scoped_refptr<media::SharedBuffer> > SharedBuffers; SharedBuffers shared_buffers_; // Points to the video capturer receiving captured video frames. diff --git a/remoting/host/event_executor_mac.cc b/remoting/host/event_executor_mac.cc index 6eca1f6..b917ecc 100644 --- a/remoting/host/event_executor_mac.cc +++ b/remoting/host/event_executor_mac.cc @@ -14,7 +14,7 @@ #include "base/mac/scoped_cftyperef.h" #include "base/memory/ref_counted.h" #include "base/single_thread_task_runner.h" -#include "remoting/capturer/mac/desktop_configuration.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" @@ -192,8 +192,8 @@ void EventExecutorMac::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. - MacDesktopConfiguration desktop_config - = MacDesktopConfiguration::GetCurrent(); + media::MacDesktopConfiguration desktop_config = + media::MacDesktopConfiguration::GetCurrent(); // Translate the mouse position into desktop coordinates. mouse_pos_ += SkIPoint::Make(desktop_config.pixel_bounds.left(), diff --git a/remoting/host/host_mock_objects.cc b/remoting/host/host_mock_objects.cc index 881683d..f8f1062 100644 --- a/remoting/host/host_mock_objects.cc +++ b/remoting/host/host_mock_objects.cc @@ -6,9 +6,9 @@ #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/capturer/video_frame_capturer.h" #include "remoting/codec/audio_encoder.h" #include "remoting/codec/video_encoder.h" #include "remoting/host/audio_capturer.h" @@ -34,10 +34,10 @@ scoped_ptr<EventExecutor> MockDesktopEnvironment::CreateEventExecutor( ui_task_runner)); } -scoped_ptr<VideoFrameCapturer> MockDesktopEnvironment::CreateVideoCapturer( +scoped_ptr<media::ScreenCapturer> MockDesktopEnvironment::CreateVideoCapturer( scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner) { - return scoped_ptr<VideoFrameCapturer>(CreateVideoCapturerPtr( + return scoped_ptr<media::ScreenCapturer>(CreateVideoCapturerPtr( capture_task_runner, encode_task_runner)); } diff --git a/remoting/host/host_mock_objects.h b/remoting/host/host_mock_objects.h index 4ca939d..1c32dab 100644 --- a/remoting/host/host_mock_objects.h +++ b/remoting/host/host_mock_objects.h @@ -35,7 +35,7 @@ class MockDesktopEnvironment : public DesktopEnvironment { scoped_refptr<base::SingleThreadTaskRunner>)); MOCK_METHOD2( CreateVideoCapturerPtr, - VideoFrameCapturer*(scoped_refptr<base::SingleThreadTaskRunner>, + media::ScreenCapturer*(scoped_refptr<base::SingleThreadTaskRunner>, scoped_refptr<base::SingleThreadTaskRunner>)); // DesktopEnvironment implementation. @@ -44,7 +44,7 @@ class MockDesktopEnvironment : public DesktopEnvironment { virtual scoped_ptr<EventExecutor> CreateEventExecutor( scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) OVERRIDE; - virtual scoped_ptr<VideoFrameCapturer> CreateVideoCapturer( + virtual scoped_ptr<media::ScreenCapturer> CreateVideoCapturer( scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner) OVERRIDE; }; diff --git a/remoting/host/ipc_desktop_environment.cc b/remoting/host/ipc_desktop_environment.cc index bc657a5..d94a381 100644 --- a/remoting/host/ipc_desktop_environment.cc +++ b/remoting/host/ipc_desktop_environment.cc @@ -11,7 +11,7 @@ #include "base/logging.h" #include "base/single_thread_task_runner.h" #include "ipc/ipc_channel_proxy.h" -#include "remoting/capturer/video_frame_capturer.h" +#include "media/video/capture/screen/screen_capturer.h" #include "remoting/host/audio_capturer.h" #include "remoting/host/chromoting_messages.h" #include "remoting/host/desktop_session_proxy.h" @@ -58,7 +58,7 @@ scoped_ptr<EventExecutor> IpcDesktopEnvironment::CreateEventExecutor( ui_task_runner); } -scoped_ptr<VideoFrameCapturer> IpcDesktopEnvironment::CreateVideoCapturer( +scoped_ptr<media::ScreenCapturer> IpcDesktopEnvironment::CreateVideoCapturer( scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner) { DCHECK(caller_task_runner_->BelongsToCurrentThread()); diff --git a/remoting/host/ipc_desktop_environment.h b/remoting/host/ipc_desktop_environment.h index c851221..10268c1 100644 --- a/remoting/host/ipc_desktop_environment.h +++ b/remoting/host/ipc_desktop_environment.h @@ -48,7 +48,7 @@ class IpcDesktopEnvironment : public DesktopEnvironment { virtual scoped_ptr<EventExecutor> CreateEventExecutor( scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) OVERRIDE; - virtual scoped_ptr<VideoFrameCapturer> CreateVideoCapturer( + virtual scoped_ptr<media::ScreenCapturer> CreateVideoCapturer( scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner) OVERRIDE; diff --git a/remoting/host/ipc_video_frame_capturer.cc b/remoting/host/ipc_video_frame_capturer.cc index ce35bc1..21aed74 100644 --- a/remoting/host/ipc_video_frame_capturer.cc +++ b/remoting/host/ipc_video_frame_capturer.cc @@ -4,8 +4,8 @@ #include "remoting/host/ipc_video_frame_capturer.h" -#include "remoting/capturer/capture_data.h" -#include "remoting/capturer/mouse_cursor_shape.h" +#include "media/video/capture/screen/mouse_cursor_shape.h" +#include "media/video/capture/screen/screen_capture_data.h" #include "remoting/host/desktop_session_proxy.h" namespace remoting { @@ -38,13 +38,13 @@ void IpcVideoFrameCapturer::CaptureFrame() { } void IpcVideoFrameCapturer::OnCaptureCompleted( - scoped_refptr<CaptureData> capture_data) { + scoped_refptr<media::ScreenCaptureData> capture_data) { if (delegate_) delegate_->OnCaptureCompleted(capture_data); } void IpcVideoFrameCapturer::OnCursorShapeChanged( - scoped_ptr<MouseCursorShape> cursor_shape) { + scoped_ptr<media::MouseCursorShape> cursor_shape) { if (delegate_) delegate_->OnCursorShapeChanged(cursor_shape.Pass()); } diff --git a/remoting/host/ipc_video_frame_capturer.h b/remoting/host/ipc_video_frame_capturer.h index ba5c517..681361b 100644 --- a/remoting/host/ipc_video_frame_capturer.h +++ b/remoting/host/ipc_video_frame_capturer.h @@ -6,26 +6,29 @@ #define REMOTING_HOST_IPC_VIDEO_FRAME_CAPTURER_H_ #include "base/memory/ref_counted.h" -#include "remoting/capturer/video_frame_capturer.h" +#include "media/video/capture/screen/screen_capturer.h" namespace IPC { class Message; } // namespace IPC +namespace media { +struct MouseCursorShape; +} // namespace media + namespace remoting { class DesktopSessionProxy; -struct MouseCursorShape; -// Routes VideoFrameCapturer calls though the IPC channel to the desktop session -// agent running in the desktop integration process. -class IpcVideoFrameCapturer : public VideoFrameCapturer { +// Routes media::ScreenCapturer calls though the IPC channel to the desktop +// session agent running in the desktop integration process. +class IpcVideoFrameCapturer : public media::ScreenCapturer { public: explicit IpcVideoFrameCapturer( scoped_refptr<DesktopSessionProxy> desktop_session_proxy); virtual ~IpcVideoFrameCapturer(); - // VideoFrameCapturer interface. + // media::ScreenCapturer interface. virtual void Start(Delegate* delegate) OVERRIDE; virtual void Stop() OVERRIDE; virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; @@ -33,14 +36,14 @@ class IpcVideoFrameCapturer : public VideoFrameCapturer { // Called when a video frame has been captured. |capture_data| describes // a captured frame. - void OnCaptureCompleted(scoped_refptr<CaptureData> capture_data); + void OnCaptureCompleted(scoped_refptr<media::ScreenCaptureData> capture_data); // Called when the cursor shape has changed. - void OnCursorShapeChanged(scoped_ptr<MouseCursorShape> cursor_shape); + void OnCursorShapeChanged(scoped_ptr<media::MouseCursorShape> cursor_shape); private: - // Points to the delegate passed to VideoFrameCapturer::Start(). - VideoFrameCapturer::Delegate* delegate_; + // Points to the delegate passed to media::ScreenCapturer::Start(). + media::ScreenCapturer::Delegate* delegate_; // Wraps the IPC channel to the desktop session agent. scoped_refptr<DesktopSessionProxy> desktop_session_proxy_; diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc index 67b1045..3d692d7 100644 --- a/remoting/host/remoting_me2me_host.cc +++ b/remoting/host/remoting_me2me_host.cc @@ -28,12 +28,12 @@ #include "ipc/ipc_channel.h" #include "ipc/ipc_channel_proxy.h" #include "ipc/ipc_listener.h" +#include "media/video/capture/screen/screen_capturer.h" #include "net/base/network_change_notifier.h" #include "net/socket/ssl_server_socket.h" #include "remoting/base/auto_thread_task_runner.h" #include "remoting/base/breakpad.h" #include "remoting/base/constants.h" -#include "remoting/capturer/video_frame_capturer.h" #include "remoting/host/basic_desktop_environment.h" #include "remoting/host/branding.h" #include "remoting/host/chromoting_host.h" @@ -552,7 +552,7 @@ void HostProcess::StartOnUiThread() { #if defined(OS_LINUX) // TODO(sergeyu): Pass configuration parameters to the Linux-specific version // of DesktopEnvironmentFactory when we have it. - remoting::VideoFrameCapturer::EnableXDamage(true); + media::ScreenCapturer::EnableXDamage(true); // If an audio pipe is specific on the command-line then initialize // AudioCapturerLinux to capture from it. diff --git a/remoting/host/sas_injector_win.cc b/remoting/host/sas_injector_win.cc index 3a4ad6f..efab8e6 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 "remoting/capturer/win/desktop.h" -#include "remoting/capturer/win/scoped_thread_desktop.h" +#include "media/video/capture/screen/win/desktop.h" +#include "media/video/capture/screen/win/scoped_thread_desktop.h" namespace remoting { @@ -190,15 +190,15 @@ bool SasInjectorXp::InjectSas() { const wchar_t kSasWindowClassName[] = L"SAS window class"; const wchar_t kSasWindowTitle[] = L"SAS window"; - scoped_ptr<remoting::Desktop> winlogon_desktop( - remoting::Desktop::GetDesktop(kWinlogonDesktopName)); + scoped_ptr<media::Desktop> winlogon_desktop( + media::Desktop::GetDesktop(kWinlogonDesktopName)); if (!winlogon_desktop.get()) { LOG_GETLASTERROR(ERROR) << "Failed to open '" << kWinlogonDesktopName << "' desktop"; return false; } - remoting::ScopedThreadDesktop desktop; + media::ScopedThreadDesktop desktop; if (!desktop.SetThreadDesktop(winlogon_desktop.Pass())) { LOG_GETLASTERROR(ERROR) << "Failed to switch to '" << kWinlogonDesktopName << "' desktop"; diff --git a/remoting/host/video_scheduler.cc b/remoting/host/video_scheduler.cc index 5f2acae..90e635f 100644 --- a/remoting/host/video_scheduler.cc +++ b/remoting/host/video_scheduler.cc @@ -14,9 +14,9 @@ #include "base/stl_util.h" #include "base/sys_info.h" #include "base/time.h" -#include "remoting/capturer/capture_data.h" -#include "remoting/capturer/mouse_cursor_shape.h" -#include "remoting/capturer/video_frame_capturer.h" +#include "media/video/capture/screen/mouse_cursor_shape.h" +#include "media/video/capture/screen/screen_capture_data.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" @@ -36,7 +36,7 @@ scoped_refptr<VideoScheduler> VideoScheduler::Create( scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, - scoped_ptr<VideoFrameCapturer> capturer, + scoped_ptr<media::ScreenCapturer> capturer, scoped_ptr<VideoEncoder> encoder, protocol::CursorShapeStub* cursor_stub, protocol::VideoStub* video_stub) { @@ -58,7 +58,7 @@ scoped_refptr<VideoScheduler> VideoScheduler::Create( // Public methods -------------------------------------------------------------- void VideoScheduler::OnCaptureCompleted( - scoped_refptr<CaptureData> capture_data) { + scoped_refptr<media::ScreenCaptureData> capture_data) { DCHECK(capture_task_runner_->BelongsToCurrentThread()); if (capture_data) { @@ -78,7 +78,7 @@ void VideoScheduler::OnCaptureCompleted( } void VideoScheduler::OnCursorShapeChanged( - scoped_ptr<MouseCursorShape> cursor_shape) { + scoped_ptr<media::MouseCursorShape> cursor_shape) { DCHECK(capture_task_runner_->BelongsToCurrentThread()); scoped_ptr<protocol::CursorShapeInfo> cursor_proto( @@ -140,7 +140,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<VideoFrameCapturer> capturer, + scoped_ptr<media::ScreenCapturer> capturer, scoped_ptr<VideoEncoder> encoder, protocol::CursorShapeStub* cursor_stub, protocol::VideoStub* video_stub) @@ -279,7 +279,7 @@ void VideoScheduler::SendCursorShape( } void VideoScheduler::StopOnNetworkThread( - scoped_ptr<VideoFrameCapturer> capturer) { + scoped_ptr<media::ScreenCapturer> capturer) { DCHECK(network_task_runner_->BelongsToCurrentThread()); // This is posted by StopOnEncodeThread meaning that both capture and encode @@ -289,7 +289,7 @@ void VideoScheduler::StopOnNetworkThread( // Encoder thread -------------------------------------------------------------- void VideoScheduler::EncodeFrame( - scoped_refptr<CaptureData> capture_data) { + scoped_refptr<media::ScreenCaptureData> capture_data) { DCHECK(encode_task_runner_->BelongsToCurrentThread()); // If there is nothing to encode then send an empty keep-alive packet. @@ -323,7 +323,7 @@ void VideoScheduler::EncodedDataAvailableCallback( } void VideoScheduler::StopOnEncodeThread( - scoped_ptr<VideoFrameCapturer> capturer) { + scoped_ptr<media::ScreenCapturer> capturer) { DCHECK(encode_task_runner_->BelongsToCurrentThread()); // This is posted by StopOnCaptureThread, so we know that by the time we diff --git a/remoting/host/video_scheduler.h b/remoting/host/video_scheduler.h index 752dcbe..0e47713 100644 --- a/remoting/host/video_scheduler.h +++ b/remoting/host/video_scheduler.h @@ -12,7 +12,7 @@ #include "base/memory/scoped_ptr.h" #include "base/time.h" #include "base/timer.h" -#include "remoting/capturer/video_frame_capturer.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" @@ -22,11 +22,14 @@ namespace base { class SingleThreadTaskRunner; } // namespace base +namespace media { +class ScreenCaptureData; +class ScreenCapturer; +} // namespace media + namespace remoting { -class CaptureData; class CursorShapeInfo; -class VideoFrameCapturer; namespace protocol { class CursorShapeInfo; @@ -34,7 +37,7 @@ class CursorShapeStub; class VideoStub; } // namespace protocol -// Class responsible for scheduling frame captures from a VideoFrameCapturer, +// 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. // @@ -71,7 +74,7 @@ class VideoStub; // too much CPU, or hogging the host's graphics subsystem. class VideoScheduler : public base::RefCountedThreadSafe<VideoScheduler>, - public VideoFrameCapturer::Delegate { + public media::ScreenCapturer::Delegate { public: // Creates a VideoScheduler running capture, encode and network tasks on the // supplied TaskRunners. Video and cursor shape updates will be pumped to @@ -81,16 +84,16 @@ 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<VideoFrameCapturer> capturer, + scoped_ptr<media::ScreenCapturer> capturer, scoped_ptr<VideoEncoder> encoder, protocol::CursorShapeStub* cursor_stub, protocol::VideoStub* video_stub); - // VideoFrameCapturer::Delegate implementation. + // media::ScreenCapturer::Delegate implementation. virtual void OnCaptureCompleted( - scoped_refptr<CaptureData> capture_data) OVERRIDE; + scoped_refptr<media::ScreenCaptureData> capture_data) OVERRIDE; virtual void OnCursorShapeChanged( - scoped_ptr<MouseCursorShape> cursor_shape) OVERRIDE; + scoped_ptr<media::MouseCursorShape> cursor_shape) OVERRIDE; // Stop scheduling frame captures. This object cannot be re-used once // it has been stopped. @@ -111,7 +114,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<VideoFrameCapturer> capturer, + scoped_ptr<media::ScreenCapturer> capturer, scoped_ptr<VideoEncoder> encoder, protocol::CursorShapeStub* cursor_stub, protocol::VideoStub* video_stub); @@ -149,18 +152,18 @@ class VideoScheduler : public base::RefCountedThreadSafe<VideoScheduler>, // Posted to the network thread to delete |capturer| on the thread that // created it. - void StopOnNetworkThread(scoped_ptr<VideoFrameCapturer> capturer); + void StopOnNetworkThread(scoped_ptr<media::ScreenCapturer> capturer); // Encoder thread ----------------------------------------------------------- // Encode a frame, passing generated VideoPackets to SendVideoPacket(). - void EncodeFrame(scoped_refptr<CaptureData> capture_data); + void EncodeFrame(scoped_refptr<media::ScreenCaptureData> capture_data); void EncodedDataAvailableCallback(scoped_ptr<VideoPacket> packet); // Used to synchronize capture and encode thread teardown, notifying the // network thread when done. - void StopOnEncodeThread(scoped_ptr<VideoFrameCapturer> capturer); + void StopOnEncodeThread(scoped_ptr<media::ScreenCapturer> capturer); // Task runners used by this class. scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; @@ -168,7 +171,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<VideoFrameCapturer> capturer_; + scoped_ptr<media::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 04e1b0a..80b2b332 100644 --- a/remoting/host/video_scheduler_unittest.cc +++ b/remoting/host/video_scheduler_unittest.cc @@ -7,9 +7,9 @@ #include "base/bind.h" #include "base/message_loop.h" #include "base/run_loop.h" +#include "media/video/capture/screen/screen_capture_data.h" +#include "media/video/capture/screen/screen_capturer_mock_objects.h" #include "remoting/base/auto_thread_task_runner.h" -#include "remoting/capturer/capture_data.h" -#include "remoting/capturer/video_capturer_mock_objects.h" #include "remoting/codec/video_encoder.h" #include "remoting/proto/video.pb.h" #include "remoting/protocol/protocol_mock_objects.h" @@ -56,7 +56,7 @@ class MockVideoEncoder : public VideoEncoder { virtual ~MockVideoEncoder(); MOCK_METHOD3(Encode, void( - scoped_refptr<CaptureData> capture_data, + scoped_refptr<media::ScreenCaptureData> capture_data, bool key_frame, const DataAvailableCallback& data_available_callback)); @@ -74,11 +74,11 @@ class VideoSchedulerTest : public testing::Test { virtual void SetUp() OVERRIDE; - void StartVideoScheduler(scoped_ptr<VideoFrameCapturer> capturer); + void StartVideoScheduler(scoped_ptr<media::ScreenCapturer> capturer); void StopVideoScheduler(); - // VideoFrameCapturer mocks. - void OnCapturerStart(VideoFrameCapturer::Delegate* delegate); + // media::ScreenCapturer mocks. + void OnCapturerStart(media::ScreenCapturer::Delegate* delegate); void OnCapturerStop(); void OnCaptureFrame(); @@ -94,10 +94,10 @@ class VideoSchedulerTest : public testing::Test { // The following mock objects are owned by VideoScheduler. MockVideoEncoder* encoder_; - scoped_refptr<CaptureData> data_; + scoped_refptr<media::ScreenCaptureData> data_; - // Points to the delegate passed to VideoFrameCapturer::Start(). - VideoFrameCapturer::Delegate* capturer_delegate_; + // Points to the delegate passed to media::ScreenCapturer::Start(). + media::ScreenCapturer::Delegate* capturer_delegate_; private: DISALLOW_COPY_AND_ASSIGN(VideoSchedulerTest); @@ -116,7 +116,7 @@ void VideoSchedulerTest::SetUp() { } void VideoSchedulerTest::StartVideoScheduler( - scoped_ptr<VideoFrameCapturer> capturer) { + scoped_ptr<media::ScreenCapturer> capturer) { scheduler_ = VideoScheduler::Create( task_runner_, // Capture task_runner_, // Encode @@ -133,7 +133,7 @@ void VideoSchedulerTest::StopVideoScheduler() { } void VideoSchedulerTest::OnCapturerStart( - VideoFrameCapturer::Delegate* delegate) { + media::ScreenCapturer::Delegate* delegate) { EXPECT_FALSE(capturer_delegate_); EXPECT_TRUE(delegate); @@ -156,16 +156,18 @@ void VideoSchedulerTest::OnCaptureFrame() { // VideoScheduler is instructed to come to a complete stop. We expect the stop // sequence to be executed successfully. TEST_F(VideoSchedulerTest, StartAndStop) { - scoped_ptr<MockVideoFrameCapturer> capturer_(new MockVideoFrameCapturer()); + scoped_ptr<media::MockScreenCapturer> capturer( + new media::MockScreenCapturer()); Expectation capturer_start = - EXPECT_CALL(*capturer_, Start(_)) + EXPECT_CALL(*capturer, Start(_)) .WillOnce(Invoke(this, &VideoSchedulerTest::OnCapturerStart)); - data_ = new CaptureData(NULL, kWidth * CaptureData::kBytesPerPixel, - SkISize::Make(kWidth, kHeight)); + data_ = new media::ScreenCaptureData( + NULL, kWidth * media::ScreenCaptureData::kBytesPerPixel, + SkISize::Make(kWidth, kHeight)); // First the capturer is called. - Expectation capturer_capture = EXPECT_CALL(*capturer_, CaptureFrame()) + Expectation capturer_capture = EXPECT_CALL(*capturer, CaptureFrame()) .After(capturer_start) .WillRepeatedly(Invoke(this, &VideoSchedulerTest::OnCaptureFrame)); @@ -185,12 +187,12 @@ TEST_F(VideoSchedulerTest, StartAndStop) { InvokeWithoutArgs(this, &VideoSchedulerTest::StopVideoScheduler))) .RetiresOnSaturation(); - EXPECT_CALL(*capturer_, Stop()) + EXPECT_CALL(*capturer, Stop()) .After(capturer_capture) .WillOnce(Invoke(this, &VideoSchedulerTest::OnCapturerStop)); // Start video frame capture. - StartVideoScheduler(capturer_.PassAs<VideoFrameCapturer>()); + StartVideoScheduler(capturer.PassAs<media::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 35e28bf..fd6ee85 100644 --- a/remoting/host/win/session_desktop_environment.cc +++ b/remoting/host/win/session_desktop_environment.cc @@ -6,7 +6,7 @@ #include "base/logging.h" #include "base/single_thread_task_runner.h" -#include "remoting/capturer/video_frame_capturer.h" +#include "media/video/capture/screen/screen_capturer.h" #include "remoting/host/audio_capturer.h" #include "remoting/host/event_executor.h" #include "remoting/host/win/session_event_executor.h" diff --git a/remoting/host/win/session_event_executor.cc b/remoting/host/win/session_event_executor.cc index 5afb41e..78121f1 100644 --- a/remoting/host/win/session_event_executor.cc +++ b/remoting/host/win/session_event_executor.cc @@ -13,8 +13,8 @@ #include "base/location.h" #include "base/single_thread_task_runner.h" #include "base/win/windows_version.h" -#include "remoting/capturer/win/desktop.h" -#include "remoting/capturer/win/scoped_thread_desktop.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" @@ -80,7 +80,7 @@ class SessionEventExecutorWin::Core scoped_refptr<base::SingleThreadTaskRunner> inject_sas_task_runner_; - ScopedThreadDesktop desktop_; + media::ScopedThreadDesktop desktop_; // Used to inject Secure Attention Sequence on Vista+. base::Closure inject_sas_; @@ -182,7 +182,7 @@ SessionEventExecutorWin::Core::~Core() { void SessionEventExecutorWin::Core::SwitchToInputDesktop() { // Switch to the desktop receiving user input if different from the current // one. - scoped_ptr<Desktop> input_desktop = Desktop::GetInputDesktop(); + scoped_ptr<media::Desktop> input_desktop = media::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. diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index 1382a7c..99d983f 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -246,80 +246,6 @@ }, 'conditions': [ - ['OS=="win" or OS=="mac" or OS=="linux"', { - 'targets': [ - { - 'target_name': 'remoting_screen_capturer', - 'type': 'static_library', - 'variables': { 'enable_wexit_time_destructors': 1, }, - 'dependencies': [ - '../skia/skia.gyp:skia', - ], - 'sources': [ - 'capturer/capture_data.cc', - 'capturer/capture_data.h', - 'capturer/shared_buffer.cc', - 'capturer/shared_buffer.h', - 'capturer/shared_buffer_factory.h', - 'capturer/differ.cc', - 'capturer/differ.h', - 'capturer/differ_block.cc', - 'capturer/differ_block.h', - 'capturer/linux/x_server_pixel_buffer.cc', - 'capturer/linux/x_server_pixel_buffer.h', - 'capturer/mac/desktop_configuration.mm', - 'capturer/mac/desktop_configuration.h', - 'capturer/mac/scoped_pixel_buffer_object.cc', - 'capturer/mac/scoped_pixel_buffer_object.h', - 'capturer/mouse_cursor_shape.cc', - 'capturer/mouse_cursor_shape.h', - 'capturer/video_frame.cc', - 'capturer/video_frame.h', - 'capturer/video_frame_capturer.h', - 'capturer/video_frame_capturer_fake.cc', - 'capturer/video_frame_capturer_fake.h', - 'capturer/video_frame_capturer_helper.cc', - 'capturer/video_frame_capturer_helper.h', - 'capturer/video_frame_capturer_linux.cc', - 'capturer/video_frame_capturer_mac.mm', - 'capturer/video_frame_capturer_win.cc', - 'capturer/video_frame_queue.cc', - 'capturer/video_frame_queue.h', - 'capturer/win/desktop.cc', - 'capturer/win/desktop.h', - 'capturer/win/scoped_thread_desktop.cc', - 'capturer/win/scoped_thread_desktop.h', - ], - 'conditions': [ - [ 'target_arch == "ia32" or target_arch == "x64"', { - 'dependencies': [ - 'differ_block_sse2', - ], - }], - ['OS=="linux"', { - 'link_settings': { - 'libraries': [ - '-lX11', - '-lXdamage', - '-lXext', - '-lXfixes', - ], - }, - }], - ['toolkit_uses_gtk==1', { - 'dependencies': [ - '../build/linux/system.gyp:gtk', - ], - }, { # else toolkit_uses_gtk!=1 - 'sources!': [ - '*_gtk.cc', - ], - }], - ], - }, # end of target remoting_screen_capturer - ], # end of 'targets' - }], # 'OS==win or OS==mac or OS==linux' - ['enable_remoting_host==1', { 'targets': [ { @@ -330,9 +256,9 @@ 'remoting_base', 'remoting_jingle_glue', 'remoting_protocol', - 'remoting_screen_capturer', '../crypto/crypto.gyp:crypto', '../google_apis/google_apis.gyp:google_apis', + '../media/media.gyp:media', '../ipc/ipc.gyp:ipc', ], 'defines': [ @@ -527,12 +453,6 @@ '../third_party/GTM/DebugUtils', '../third_party/GTM/Foundation', ], - 'link_settings': { - 'libraries': [ - '$(SDKROOT)/System/Library/Frameworks/OpenGL.framework', - 'libpam.a', - ], - }, }], ['OS=="win"', { 'dependencies': [ @@ -2179,22 +2099,6 @@ ], }, # end of target 'remoting_protocol' - { - 'target_name': 'differ_block_sse2', - 'type': 'static_library', - 'conditions': [ - [ 'os_posix == 1 and OS != "mac"', { - 'cflags': [ - '-msse2', - ], - }], - ], - 'sources': [ - 'capturer/differ_block_sse2.cc', - 'capturer/differ_block_sse2.h', - ], - }, # end of target differ_block_sse2 - # Remoting unit tests { 'target_name': 'remoting_unittests', @@ -2208,13 +2112,13 @@ 'remoting_host', 'remoting_jingle_glue', 'remoting_protocol', - 'remoting_screen_capturer', 'remoting_host_setup_base', '../base/base.gyp:base', '../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', @@ -2237,14 +2141,6 @@ 'base/resources_unittest.cc', 'base/typed_buffer_unittest.cc', 'base/util_unittest.cc', - 'capturer/video_capturer_mock_objects.cc', - 'capturer/video_capturer_mock_objects.h', - 'capturer/differ_block_unittest.cc', - 'capturer/differ_unittest.cc', - 'capturer/shared_buffer_unittest.cc', - 'capturer/video_frame_capturer_helper_unittest.cc', - 'capturer/video_frame_capturer_mac_unittest.cc', - 'capturer/video_frame_capturer_unittest.cc', 'client/audio_player_unittest.cc', 'client/key_event_mapper_unittest.cc', 'client/plugin/mac_key_event_processor_unittest.cc', |