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

Unified Diff: media/video/capture/screen/screen_capturer_mac.mm

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
Index: media/video/capture/screen/screen_capturer_mac.mm
diff --git a/remoting/capturer/video_frame_capturer_mac.mm b/media/video/capture/screen/screen_capturer_mac.mm
similarity index 88%
rename from remoting/capturer/video_frame_capturer_mac.mm
rename to media/video/capture/screen/screen_capturer_mac.mm
index d77dd15409a4f40b589aee8c03778b1f374ae96c..1baa0904cea6707df256dad5e386307016b18065 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
« no previous file with comments | « media/video/capture/screen/screen_capturer_linux.cc ('k') | media/video/capture/screen/screen_capturer_mac_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698