1 /* 2 * Copyright (c) 2022 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 MODULES_DESKTOP_CAPTURE_DELEGATED_SOURCE_LIST_CONTROLLER_H_ 12 #define MODULES_DESKTOP_CAPTURE_DELEGATED_SOURCE_LIST_CONTROLLER_H_ 13 14 #include "rtc_base/system/rtc_export.h" 15 16 namespace webrtc { 17 18 // A controller to be implemented and returned by 19 // GetDelegatedSourceListController in capturers that require showing their own 20 // source list and managing user selection there. Apart from ensuring the 21 // visibility of the source list, these capturers should largely be interacted 22 // with the same as a normal capturer, though there may be some caveats for 23 // some DesktopCapturer methods. See GetDelegatedSourceListController for more 24 // information. 25 class RTC_EXPORT DelegatedSourceListController { 26 public: 27 // Notifications that can be used to help drive any UI that the consumer may 28 // want to show around this source list (e.g. if an consumer shows their own 29 // UI in addition to the delegated source list). 30 class Observer { 31 public: 32 // Called after the user has made a selection in the delegated source list. 33 // Note that the consumer will still need to get the source out of the 34 // capturer by calling GetSourceList. 35 virtual void OnSelection() = 0; 36 37 // Called when there is any user action that cancels the source selection. 38 virtual void OnCancelled() = 0; 39 40 // Called when there is a system error that cancels the source selection. 41 virtual void OnError() = 0; 42 43 protected: ~Observer()44 virtual ~Observer() {} 45 }; 46 47 // Observer must remain valid until the owning DesktopCapturer is destroyed. 48 // Only one Observer is allowed at a time, and may be cleared by passing 49 // nullptr. 50 virtual void Observe(Observer* observer) = 0; 51 52 // Used to prompt the capturer to show the delegated source list. If the 53 // source list is already visible, this will be a no-op. Must be called after 54 // starting the DesktopCapturer. 55 // 56 // Note that any selection from a previous invocation of the source list may 57 // be cleared when this method is called. 58 virtual void EnsureVisible() = 0; 59 60 // Used to prompt the capturer to hide the delegated source list. If the 61 // source list is already hidden, this will be a no-op. 62 virtual void EnsureHidden() = 0; 63 64 protected: ~DelegatedSourceListController()65 virtual ~DelegatedSourceListController() {} 66 }; 67 68 } // namespace webrtc 69 70 #endif // MODULES_DESKTOP_CAPTURE_DELEGATED_SOURCE_LIST_CONTROLLER_H_ 71