summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/modules/desktop_capture/delegated_source_list_controller.h
blob: cada7dc817a6f7295d5e382df61368f86c485ab5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 *  Copyright (c) 2022 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#ifndef MODULES_DESKTOP_CAPTURE_DELEGATED_SOURCE_LIST_CONTROLLER_H_
#define MODULES_DESKTOP_CAPTURE_DELEGATED_SOURCE_LIST_CONTROLLER_H_

#include "rtc_base/system/rtc_export.h"

namespace webrtc {

// A controller to be implemented and returned by
// GetDelegatedSourceListController in capturers that require showing their own
// source list and managing user selection there. Apart from ensuring the
// visibility of the source list, these capturers should largely be interacted
// with the same as a normal capturer, though there may be some caveats for
// some DesktopCapturer methods. See GetDelegatedSourceListController for more
// information.
class RTC_EXPORT DelegatedSourceListController {
 public:
  // Notifications that can be used to help drive any UI that the consumer may
  // want to show around this source list (e.g. if an consumer shows their own
  // UI in addition to the delegated source list).
  class Observer {
   public:
    // Called after the user has made a selection in the delegated source list.
    // Note that the consumer will still need to get the source out of the
    // capturer by calling GetSourceList.
    virtual void OnSelection() = 0;

    // Called when there is any user action that cancels the source selection.
    virtual void OnCancelled() = 0;

    // Called when there is a system error that cancels the source selection.
    virtual void OnError() = 0;

   protected:
    virtual ~Observer() {}
  };

  // Observer must remain valid until the owning DesktopCapturer is destroyed.
  // Only one Observer is allowed at a time, and may be cleared by passing
  // nullptr.
  virtual void Observe(Observer* observer) = 0;

  // Used to prompt the capturer to show the delegated source list. If the
  // source list is already visible, this will be a no-op. Must be called after
  // starting the DesktopCapturer.
  //
  // Note that any selection from a previous invocation of the source list may
  // be cleared when this method is called.
  virtual void EnsureVisible() = 0;

  // Used to prompt the capturer to hide the delegated source list. If the
  // source list is already hidden, this will be a no-op.
  virtual void EnsureHidden() = 0;

 protected:
  virtual ~DelegatedSourceListController() {}
};

}  // namespace webrtc

#endif  // MODULES_DESKTOP_CAPTURE_DELEGATED_SOURCE_LIST_CONTROLLER_H_