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

Side by Side Diff: webrtc/modules/desktop_capture/window_capturer_mac.mm

Issue 1152733005: Use one scoped_refptr. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: remove from BUILD.gn Created 5 years, 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/modules/desktop_capture/window_capturer.h" 11 #include "webrtc/modules/desktop_capture/window_capturer.h"
12 12
13 #include <assert.h> 13 #include <assert.h>
14 #include <ApplicationServices/ApplicationServices.h> 14 #include <ApplicationServices/ApplicationServices.h>
15 #include <Cocoa/Cocoa.h> 15 #include <Cocoa/Cocoa.h>
16 #include <CoreFoundation/CoreFoundation.h> 16 #include <CoreFoundation/CoreFoundation.h>
17 17
18 #include "webrtc/base/macutils.h" 18 #include "webrtc/base/macutils.h"
19 #include "webrtc/base/scoped_ref_ptr.h"
19 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" 20 #include "webrtc/modules/desktop_capture/desktop_capture_options.h"
20 #include "webrtc/modules/desktop_capture/desktop_frame.h" 21 #include "webrtc/modules/desktop_capture/desktop_frame.h"
21 #include "webrtc/modules/desktop_capture/mac/desktop_configuration.h" 22 #include "webrtc/modules/desktop_capture/mac/desktop_configuration.h"
22 #include "webrtc/modules/desktop_capture/mac/full_screen_chrome_window_detector. h" 23 #include "webrtc/modules/desktop_capture/mac/full_screen_chrome_window_detector. h"
23 #include "webrtc/modules/desktop_capture/mac/window_list_utils.h" 24 #include "webrtc/modules/desktop_capture/mac/window_list_utils.h"
24 #include "webrtc/system_wrappers/interface/logging.h" 25 #include "webrtc/system_wrappers/interface/logging.h"
25 #include "webrtc/system_wrappers/interface/scoped_refptr.h"
26 #include "webrtc/system_wrappers/interface/tick_util.h" 26 #include "webrtc/system_wrappers/interface/tick_util.h"
27 27
28 namespace webrtc { 28 namespace webrtc {
29 29
30 namespace { 30 namespace {
31 31
32 // Returns true if the window exists. 32 // Returns true if the window exists.
33 bool IsWindowValid(CGWindowID id) { 33 bool IsWindowValid(CGWindowID id) {
34 CFArrayRef window_id_array = 34 CFArrayRef window_id_array =
35 CFArrayCreate(NULL, reinterpret_cast<const void **>(&id), 1, NULL); 35 CFArrayCreate(NULL, reinterpret_cast<const void **>(&id), 1, NULL);
36 CFArrayRef window_array = 36 CFArrayRef window_array =
37 CGWindowListCreateDescriptionFromArray(window_id_array); 37 CGWindowListCreateDescriptionFromArray(window_id_array);
38 bool valid = window_array && CFArrayGetCount(window_array); 38 bool valid = window_array && CFArrayGetCount(window_array);
39 CFRelease(window_id_array); 39 CFRelease(window_id_array);
40 CFRelease(window_array); 40 CFRelease(window_array);
41 41
42 return valid; 42 return valid;
43 } 43 }
44 44
45 class WindowCapturerMac : public WindowCapturer { 45 class WindowCapturerMac : public WindowCapturer {
46 public: 46 public:
47 explicit WindowCapturerMac( 47 explicit WindowCapturerMac(rtc::scoped_refptr<FullScreenChromeWindowDetector>
48 scoped_refptr<FullScreenChromeWindowDetector> 48 full_screen_chrome_window_detector);
49 full_screen_chrome_window_detector);
50 virtual ~WindowCapturerMac(); 49 virtual ~WindowCapturerMac();
51 50
52 // WindowCapturer interface. 51 // WindowCapturer interface.
53 bool GetWindowList(WindowList* windows) override; 52 bool GetWindowList(WindowList* windows) override;
54 bool SelectWindow(WindowId id) override; 53 bool SelectWindow(WindowId id) override;
55 bool BringSelectedWindowToFront() override; 54 bool BringSelectedWindowToFront() override;
56 55
57 // DesktopCapturer interface. 56 // DesktopCapturer interface.
58 void Start(Callback* callback) override; 57 void Start(Callback* callback) override;
59 void Capture(const DesktopRegion& region) override; 58 void Capture(const DesktopRegion& region) override;
60 59
61 private: 60 private:
62 Callback* callback_; 61 Callback* callback_;
63 62
64 // The window being captured. 63 // The window being captured.
65 CGWindowID window_id_; 64 CGWindowID window_id_;
66 65
67 scoped_refptr<FullScreenChromeWindowDetector> 66 rtc::scoped_refptr<FullScreenChromeWindowDetector>
68 full_screen_chrome_window_detector_; 67 full_screen_chrome_window_detector_;
69 68
70 DISALLOW_COPY_AND_ASSIGN(WindowCapturerMac); 69 DISALLOW_COPY_AND_ASSIGN(WindowCapturerMac);
71 }; 70 };
72 71
73 WindowCapturerMac::WindowCapturerMac( 72 WindowCapturerMac::WindowCapturerMac(rtc::scoped_refptr<
74 scoped_refptr<FullScreenChromeWindowDetector> 73 FullScreenChromeWindowDetector> full_screen_chrome_window_detector)
75 full_screen_chrome_window_detector)
76 : callback_(NULL), 74 : callback_(NULL),
77 window_id_(0), 75 window_id_(0),
78 full_screen_chrome_window_detector_(full_screen_chrome_window_detector) { 76 full_screen_chrome_window_detector_(full_screen_chrome_window_detector) {
79 } 77 }
80 78
81 WindowCapturerMac::~WindowCapturerMac() { 79 WindowCapturerMac::~WindowCapturerMac() {
82 } 80 }
83 81
84 bool WindowCapturerMac::GetWindowList(WindowList* windows) { 82 bool WindowCapturerMac::GetWindowList(WindowList* windows) {
85 // Only get on screen, non-desktop windows. 83 // Only get on screen, non-desktop windows.
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 } 232 }
235 233
236 } // namespace 234 } // namespace
237 235
238 // static 236 // static
239 WindowCapturer* WindowCapturer::Create(const DesktopCaptureOptions& options) { 237 WindowCapturer* WindowCapturer::Create(const DesktopCaptureOptions& options) {
240 return new WindowCapturerMac(options.full_screen_chrome_window_detector()); 238 return new WindowCapturerMac(options.full_screen_chrome_window_detector());
241 } 239 }
242 240
243 } // namespace webrtc 241 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/desktop_capture/shared_desktop_frame.cc ('k') | webrtc/modules/desktop_capture/window_capturer_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698