| Index: media/video/capture/screen/screen_capturer_win.cc
|
| diff --git a/remoting/capturer/video_frame_capturer_win.cc b/media/video/capture/screen/screen_capturer_win.cc
|
| similarity index 81%
|
| rename from remoting/capturer/video_frame_capturer_win.cc
|
| rename to media/video/capture/screen/screen_capturer_win.cc
|
| index 59e978c517ba515c370fb15ac78c7c1511726ce3..05486e6cc2ca8e38b6be114bac50f6a97c4e5d06 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,20 @@ 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.
|
| +// See remoting/host/screen_capturer.h.
|
| +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 +91,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 +113,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 +127,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 +138,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 +162,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 +181,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 +206,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 +221,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 +240,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 +251,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 +265,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 +275,7 @@ void VideoFrameCapturerWin::CaptureFrame() {
|
| CaptureCursor();
|
| }
|
|
|
| -void VideoFrameCapturerWin::Start(Delegate* delegate) {
|
| +void ScreenCapturerWin::Start(Delegate* delegate) {
|
| DCHECK(delegate_ == NULL);
|
|
|
| delegate_ = delegate;
|
| @@ -298,7 +299,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 +308,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 +350,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 +370,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 +380,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 +403,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 +425,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 +480,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 +508,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 +585,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
|
|
|