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

Side by Side Diff: webrtc/modules/desktop_capture/desktop_capturer.h

Issue 1988783003: Use std::unique_ptr<> to pass frame ownership in DesktopCapturer impls. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 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 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_ 11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_
12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_ 12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_
13 13
14 #include <stddef.h> 14 #include <stddef.h>
15 15
16 #include <memory> 16 #include <memory>
17 17
18 #include "webrtc/modules/desktop_capture/desktop_frame.h"
18 #include "webrtc/modules/desktop_capture/desktop_capture_types.h" 19 #include "webrtc/modules/desktop_capture/desktop_capture_types.h"
19 #include "webrtc/modules/desktop_capture/shared_memory.h" 20 #include "webrtc/modules/desktop_capture/shared_memory.h"
20 21
21 namespace webrtc { 22 namespace webrtc {
22 23
23 class DesktopFrame; 24 class DesktopFrame;
24 class DesktopRegion;
25 25
26 // Abstract interface for screen and window capturers. 26 // Abstract interface for screen and window capturers.
27 class DesktopCapturer { 27 class DesktopCapturer {
28 public: 28 public:
29 enum class Result {
30 // The frame was captured successfully.
31 SUCCESS,
32
33 // There was a temporary error. The caller should continue calling
34 // Capture(), in the expectation that it will eventually recover.
35 ERROR_TEMPORARY,
36
37 // Capture has failed and will keep failing if the caller tries calling
38 // Capture() again.
39 ERROR_PERMANENT,
40 };
41
29 // Interface that must be implemented by the DesktopCapturer consumers. 42 // Interface that must be implemented by the DesktopCapturer consumers.
30 class Callback { 43 class Callback {
31 public: 44 public:
32 // Called after a frame has been captured. Handler must take ownership of 45 // Called after a frame has been captured. |frame| is not nullptr if and
33 // |frame|. If capture has failed for any reason |frame| is set to NULL 46 // only if |result| is SUCCESS.
34 // (e.g. the window has been closed). 47 virtual void OnCaptureResult(Result result,
35 virtual void OnCaptureCompleted(DesktopFrame* frame) = 0; 48 std::unique_ptr<DesktopFrame> frame) {
49 OnCaptureCompleted(frame.release());
50 }
51
52 // Deprecated version of the method above that uses raw pointer instead of
53 // std::unique_ptr<>.
54 // TODO(sergeyu): Remove this method and make OnCaptureResult() pure
55 // virtual. crbug.com/webrtc/5950
56 virtual void OnCaptureCompleted(DesktopFrame* frame) { delete frame; };
36 57
37 protected: 58 protected:
38 virtual ~Callback() {} 59 virtual ~Callback() {}
39 }; 60 };
40 61
41 virtual ~DesktopCapturer() {} 62 virtual ~DesktopCapturer() {}
42 63
43 // Called at the beginning of a capturing session. |callback| must remain 64 // Called at the beginning of a capturing session. |callback| must remain
44 // valid until capturer is destroyed. 65 // valid until capturer is destroyed.
45 virtual void Start(Callback* callback) = 0; 66 virtual void Start(Callback* callback) = 0;
(...skipping 16 matching lines...) Expand all
62 // Sets the window to be excluded from the captured image in the future 83 // Sets the window to be excluded from the captured image in the future
63 // Capture calls. Used to exclude the screenshare notification window for 84 // Capture calls. Used to exclude the screenshare notification window for
64 // screen capturing. 85 // screen capturing.
65 virtual void SetExcludedWindow(WindowId window) {} 86 virtual void SetExcludedWindow(WindowId window) {}
66 }; 87 };
67 88
68 } // namespace webrtc 89 } // namespace webrtc
69 90
70 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_ 91 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_
71 92
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698