Index: webrtc/modules/desktop_capture/screen_capturer_x11.cc |
diff --git a/webrtc/modules/desktop_capture/screen_capturer_x11.cc b/webrtc/modules/desktop_capture/screen_capturer_x11.cc |
index 57c2e5fc163981a5a5136f38a6e90d98a494043c..5540e6820fa1f7f66468f1173c6a1de3e18552f7 100644 |
--- a/webrtc/modules/desktop_capture/screen_capturer_x11.cc |
+++ b/webrtc/modules/desktop_capture/screen_capturer_x11.cc |
@@ -66,7 +66,7 @@ |
// from HandleXEvent(). 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. |
- std::unique_ptr<DesktopFrame> CaptureScreen(); |
+ DesktopFrame* CaptureScreen(); |
// Called when the screen configuration is changed. |
void ScreenConfigurationChanged(); |
@@ -82,23 +82,23 @@ |
DesktopCaptureOptions options_; |
- Callback* callback_ = nullptr; |
+ Callback* callback_; |
// X11 graphics context. |
- GC gc_ = nullptr; |
- Window root_window_ = BadValue; |
+ GC gc_; |
+ Window root_window_; |
// XFixes. |
- bool has_xfixes_ = false; |
- int xfixes_event_base_ = -1; |
- int xfixes_error_base_ = -1; |
+ bool has_xfixes_; |
+ int xfixes_event_base_; |
+ int xfixes_error_base_; |
// XDamage information. |
- bool use_damage_ = false; |
- Damage damage_handle_ = 0; |
- int damage_event_base_ = -1; |
- int damage_error_base_ = -1; |
- XserverRegion damage_region_ = 0; |
+ bool use_damage_; |
+ Damage damage_handle_; |
+ int damage_event_base_; |
+ int damage_error_base_; |
+ XserverRegion damage_region_; |
// Access to the X Server's pixel buffer. |
XServerPixelBuffer x_server_pixel_buffer_; |
@@ -120,7 +120,18 @@ |
RTC_DISALLOW_COPY_AND_ASSIGN(ScreenCapturerLinux); |
}; |
-ScreenCapturerLinux::ScreenCapturerLinux() { |
+ScreenCapturerLinux::ScreenCapturerLinux() |
+ : callback_(NULL), |
+ gc_(NULL), |
+ root_window_(BadValue), |
+ has_xfixes_(false), |
+ xfixes_event_base_(-1), |
+ xfixes_error_base_(-1), |
+ use_damage_(false), |
+ damage_handle_(0), |
+ damage_event_base_(-1), |
+ damage_error_base_(-1), |
+ damage_region_(0) { |
helper_.SetLogGridSize(4); |
} |
@@ -238,7 +249,7 @@ |
// in a good shape. |
if (!x_server_pixel_buffer_.is_initialized()) { |
// We failed to initialize pixel buffer. |
- callback_->OnCaptureResult(Result::ERROR_PERMANENT, nullptr); |
+ callback_->OnCaptureCompleted(NULL); |
return; |
} |
@@ -246,26 +257,29 @@ |
// Note that we can't reallocate other buffers at this point, since the caller |
// may still be reading from them. |
if (!queue_.current_frame()) { |
- queue_.ReplaceCurrentFrame( |
- SharedDesktopFrame::Wrap(std::unique_ptr<DesktopFrame>( |
- new BasicDesktopFrame(x_server_pixel_buffer_.window_size())))); |
+ std::unique_ptr<DesktopFrame> frame( |
+ new BasicDesktopFrame(x_server_pixel_buffer_.window_size())); |
+ queue_.ReplaceCurrentFrame(SharedDesktopFrame::Wrap(frame.release())); |
} |
// Refresh the Differ helper used by CaptureFrame(), if needed. |
DesktopFrame* frame = queue_.current_frame(); |
- if (!use_damage_ && |
- (!differ_ || (differ_->width() != frame->size().width()) || |
- (differ_->height() != frame->size().height()) || |
- (differ_->bytes_per_row() != frame->stride()))) { |
+ if (!use_damage_ && ( |
+ !differ_.get() || |
+ (differ_->width() != frame->size().width()) || |
+ (differ_->height() != frame->size().height()) || |
+ (differ_->bytes_per_row() != frame->stride()))) { |
differ_.reset(new Differ(frame->size().width(), frame->size().height(), |
- DesktopFrame::kBytesPerPixel, frame->stride())); |
- } |
- |
- std::unique_ptr<DesktopFrame> result = CaptureScreen(); |
+ DesktopFrame::kBytesPerPixel, |
+ frame->stride())); |
+ } |
+ |
+ DesktopFrame* result = CaptureScreen(); |
last_invalid_region_ = result->updated_region(); |
- result->set_capture_time_ms((rtc::TimeNanos() - capture_start_time_nanos) / |
- rtc::kNumNanosecsPerMillisec); |
- callback_->OnCaptureResult(Result::SUCCESS, std::move(result)); |
+ result->set_capture_time_ms( |
+ (rtc::TimeNanos() - capture_start_time_nanos) / |
+ rtc::kNumNanosecsPerMillisec); |
+ callback_->OnCaptureCompleted(result); |
} |
bool ScreenCapturerLinux::GetScreenList(ScreenList* screens) { |
@@ -297,8 +311,8 @@ |
return false; |
} |
-std::unique_ptr<DesktopFrame> ScreenCapturerLinux::CaptureScreen() { |
- std::unique_ptr<SharedDesktopFrame> frame = queue_.current_frame()->Share(); |
+DesktopFrame* ScreenCapturerLinux::CaptureScreen() { |
+ DesktopFrame* frame = queue_.current_frame()->Share(); |
assert(x_server_pixel_buffer_.window_size().equals(frame->size())); |
// Pass the screen size to the helper, so it can clip the invalid region if it |
@@ -340,18 +354,18 @@ |
for (DesktopRegion::Iterator it(*updated_region); |
!it.IsAtEnd(); it.Advance()) { |
- x_server_pixel_buffer_.CaptureRect(it.rect(), frame.get()); |
+ x_server_pixel_buffer_.CaptureRect(it.rect(), frame); |
} |
} else { |
// Doing full-screen polling, or this is the first capture after a |
// screen-resolution change. In either case, need a full-screen capture. |
DesktopRect screen_rect = DesktopRect::MakeSize(frame->size()); |
- x_server_pixel_buffer_.CaptureRect(screen_rect, frame.get()); |
+ x_server_pixel_buffer_.CaptureRect(screen_rect, frame); |
if (queue_.previous_frame()) { |
// Full-screen polling, so calculate the invalid rects here, based on the |
// changed pixels between current and previous buffers. |
- RTC_DCHECK(differ_); |
+ RTC_DCHECK(differ_.get() != NULL); |
RTC_DCHECK(queue_.previous_frame()->data()); |
differ_->CalcDirtyRegion(queue_.previous_frame()->data(), |
frame->data(), updated_region); |
@@ -364,7 +378,7 @@ |
} |
} |
- return std::move(frame); |
+ return frame; |
} |
void ScreenCapturerLinux::ScreenConfigurationChanged() { |
@@ -401,7 +415,7 @@ |
void ScreenCapturerLinux::DeinitXlib() { |
if (gc_) { |
XFreeGC(display(), gc_); |
- gc_ = nullptr; |
+ gc_ = NULL; |
} |
x_server_pixel_buffer_.Release(); |
@@ -424,7 +438,7 @@ |
// static |
ScreenCapturer* ScreenCapturer::Create(const DesktopCaptureOptions& options) { |
if (!options.x_display()) |
- return nullptr; |
+ return NULL; |
std::unique_ptr<ScreenCapturerLinux> capturer(new ScreenCapturerLinux()); |
if (!capturer->Init(options)) |