| 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 8b10cac31431364ee152a0c1f24d7726823ccc2a..4ad326dd9e419815431ac3b8764ac5b893b15dc2 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,14 +21,14 @@
|
| #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/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/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"
|
|
|
| -namespace remoting {
|
| +namespace media {
|
|
|
| namespace {
|
|
|
| @@ -82,10 +82,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 SkISize& size);
|
| - virtual ~VideoFrameMac();
|
| + explicit ScreenCaptureFrameMac(const SkISize& size);
|
| + virtual ~ScreenCaptureFrameMac();
|
|
|
| const SkIPoint& dpi() const { return dpi_; }
|
|
|
| @@ -96,18 +96,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;
|
| @@ -116,10 +116,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();
|
| @@ -149,7 +149,7 @@ class VideoFrameCapturerMac : public VideoFrameCapturer {
|
| ScopedPixelBufferObject pixel_buffer_object_;
|
|
|
| // Queue of the frames buffers.
|
| - VideoFrameQueue queue_;
|
| + ScreenCaptureFrameQueue queue_;
|
|
|
| // Current display configuration.
|
| std::vector<CGDirectDisplayID> display_ids_;
|
| @@ -157,7 +157,7 @@ class VideoFrameCapturerMac : public VideoFrameCapturer {
|
|
|
| // 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_;
|
| @@ -187,10 +187,10 @@ 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 SkISize& size) {
|
| +ScreenCaptureFrameMac::ScreenCaptureFrameMac(const SkISize& size) {
|
| set_bytes_per_row(size.width() * sizeof(uint32_t));
|
| set_dimensions(size);
|
|
|
| @@ -205,10 +205,10 @@ VideoFrameMac::VideoFrameMac(const SkISize& size) {
|
| dpi_.set(resolution.width, resolution.height);
|
| }
|
|
|
| -VideoFrameMac::~VideoFrameMac() {
|
| +ScreenCaptureFrameMac::~ScreenCaptureFrameMac() {
|
| }
|
|
|
| -VideoFrameCapturerMac::VideoFrameCapturerMac()
|
| +ScreenCapturerMac::ScreenCapturerMac()
|
| : delegate_(NULL),
|
| cgl_context_(NULL),
|
| display_configuration_capture_event_(false, true),
|
| @@ -221,35 +221,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;
|
| @@ -259,7 +259,7 @@ bool VideoFrameCapturerMac::Init() {
|
| return true;
|
| }
|
|
|
| -void VideoFrameCapturerMac::ReleaseBuffers() {
|
| +void ScreenCapturerMac::ReleaseBuffers() {
|
| if (cgl_context_) {
|
| pixel_buffer_object_.Release();
|
| CGLDestroyContext(cgl_context_);
|
| @@ -271,7 +271,7 @@ void VideoFrameCapturerMac::ReleaseBuffers() {
|
| queue_.SetAllFramesNeedUpdate();
|
| }
|
|
|
| -void VideoFrameCapturerMac::Start(Delegate* delegate) {
|
| +void ScreenCapturerMac::Start(Delegate* delegate) {
|
| DCHECK(delegate_ == NULL);
|
|
|
| delegate_ = delegate;
|
| @@ -292,7 +292,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;
|
| @@ -303,13 +303,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();
|
|
|
| @@ -328,12 +328,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(
|
| + scoped_ptr<ScreenCaptureFrameMac> buffer(new ScreenCaptureFrameMac(
|
| SkISize::Make(desktop_bounds_.width(), desktop_bounds_.height())));
|
| - queue_.ReplaceCurrentFrame(buffer.PassAs<VideoFrame>());
|
| + 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()) {
|
| @@ -361,8 +361,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());
|
| @@ -382,7 +382,7 @@ void VideoFrameCapturerMac::CaptureFrame() {
|
| delegate_->OnCaptureCompleted(data);
|
| }
|
|
|
| -void VideoFrameCapturerMac::CaptureCursor() {
|
| +void ScreenCapturerMac::CaptureCursor() {
|
| NSCursor* cursor = [NSCursor currentSystemCursor];
|
| if (cursor == nil) {
|
| return;
|
| @@ -458,7 +458,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();
|
| @@ -525,7 +525,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);
|
| @@ -539,7 +539,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();
|
|
|
| @@ -592,7 +592,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();
|
|
|
| @@ -652,7 +652,7 @@ void VideoFrameCapturerMac::CgBlitPostLion(const VideoFrame& buffer,
|
| }
|
| }
|
|
|
| -void VideoFrameCapturerMac::ScreenConfigurationChanged() {
|
| +void ScreenCapturerMac::ScreenConfigurationChanged() {
|
| // Release existing buffers, which will be of the wrong size.
|
| ReleaseBuffers();
|
|
|
| @@ -753,7 +753,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_bounds_.isEmpty()) {
|
| return;
|
| @@ -768,7 +768,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) {
|
| SkIRect skirect_array[count];
|
| @@ -783,7 +783,7 @@ void VideoFrameCapturerMac::ScreenUpdateMove(CGScreenUpdateMoveDelta delta,
|
| InvalidateRegion(region);
|
| }
|
|
|
| -void VideoFrameCapturerMac::DisplaysReconfigured(
|
| +void ScreenCapturerMac::DisplaysReconfigured(
|
| CGDirectDisplayID display,
|
| CGDisplayChangeSummaryFlags flags) {
|
| if (flags & kCGDisplayBeginConfigurationFlag) {
|
| @@ -809,10 +809,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_bounds_.isEmpty()) {
|
| capturer->ScreenConfigurationChanged();
|
| @@ -820,21 +820,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);
|
| }
|
| @@ -842,18 +842,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
|
|
|