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

Unified Diff: media/video/capture/screen/screen_capturer_win.cc

Issue 12047101: Move screen capturers from remoting/capturer to media/video/capturer/screen (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/video/capture/screen/screen_capturer_unittest.cc ('k') | media/video/capture/screen/shared_buffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..bf6bfae6e41b1ea3e8080c6721bfcffedd94ed5a 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
« no previous file with comments | « media/video/capture/screen/screen_capturer_unittest.cc ('k') | media/video/capture/screen/shared_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698