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

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

Issue 2697453002: [DesktopCapturer] FallbackDesktopCapturerWrapper and its tests (Closed)
Patch Set: Resolve review comments Created 3 years, 10 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
(Empty)
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_FALLBACK_DESKTOP_CAPTURER_WRAPPER_H_
12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_FALLBACK_DESKTOP_CAPTURER_WRAPPER_H_
13
14 #include <memory>
15
16 #include "webrtc/modules/desktop_capture/desktop_capturer.h"
17 #include "webrtc/modules/desktop_capture/desktop_capture_types.h"
18 #include "webrtc/modules/desktop_capture/desktop_frame.h"
19 #include "webrtc/modules/desktop_capture/shared_memory.h"
20
21 namespace webrtc {
22
23 // A DesktopCapturer wrapper owns two DesktopCapturer implementations. If the
24 // main DesktopCapturer fails, it uses the secondary one instead. Two capturers
25 // are expected to return same SourceList, and the meaning of each SourceId is
26 // identical, otherwise FallbackDesktopCapturerWrapper may return frames from
27 // different sources. Using asynchronized DesktopCapturer implementations with
28 // SharedMemoryFactory is not supported, and may result crash or assertion
29 // failure.
30 class FallbackDesktopCapturerWrapper final : public DesktopCapturer,
31 public DesktopCapturer::Callback {
32 public:
33 FallbackDesktopCapturerWrapper(
34 std::unique_ptr<DesktopCapturer> main_capturer,
35 std::unique_ptr<DesktopCapturer> secondary_capturer);
36 ~FallbackDesktopCapturerWrapper() override;
37
38 // DesktopCapturer interface.
39 void Start(DesktopCapturer::Callback* callback) override;
40 void SetSharedMemoryFactory(
41 std::unique_ptr<SharedMemoryFactory> shared_memory_factory) override;
42 void CaptureFrame() override;
43 void SetExcludedWindow(WindowId window) override;
44 bool GetSourceList(SourceList* sources) override;
45 bool SelectSource(SourceId id) override;
46 bool FocusOnSelectedSource() override;
47
48 private:
49 // DesktopCapturer::Callback interface.
50 void OnCaptureResult(Result result,
51 std::unique_ptr<DesktopFrame> frame) override;
52
53 const std::unique_ptr<DesktopCapturer> main_capturer_;
54 const std::unique_ptr<DesktopCapturer> secondary_capturer_;
55 std::unique_ptr<SharedMemoryFactory> shared_memory_factory_;
56 bool main_capturer_permanent_error_ = false;
57 DesktopCapturer::Callback* callback_ = nullptr;
58 };
59
60 } // namespace webrtc
61
62 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_FALLBACK_DESKTOP_CAPTURER_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698