tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

AudioFocusManager.h (1479B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 #ifndef DOM_MEDIA_MEDIACONTROL_AUDIOFOCUSMANAGER_H_
      6 #define DOM_MEDIA_MEDIACONTROL_AUDIOFOCUSMANAGER_H_
      7 
      8 #include "VideoUtils.h"
      9 #include "base/basictypes.h"
     10 #include "nsTArray.h"
     11 
     12 namespace mozilla::dom {
     13 
     14 class IMediaController;
     15 class MediaControlService;
     16 
     17 /**
     18 * AudioFocusManager is used to assign the audio focus to different requester
     19 * and decide which requester can own audio focus when audio competing happens.
     20 * When the audio competing happens, the last request would be a winner who can
     21 * still own the audio focus, and all the other requesters would lose the audio
     22 * focus. Now MediaController is the onlt requester, it would request the audio
     23 * focus when it becomes audible and revoke the audio focus when the controller
     24 * is no longer active.
     25 */
     26 class AudioFocusManager {
     27 public:
     28  void RequestAudioFocus(IMediaController* aController);
     29  void RevokeAudioFocus(IMediaController* aController);
     30 
     31  explicit AudioFocusManager() = default;
     32  ~AudioFocusManager() = default;
     33 
     34  uint32_t GetAudioFocusNums() const;
     35 
     36 private:
     37  friend class MediaControlService;
     38  void ClearFocusControllersIfNeeded();
     39 
     40  nsTArray<RefPtr<IMediaController>> mOwningFocusControllers;
     41 };
     42 
     43 }  // namespace mozilla::dom
     44 
     45 #endif  //  DOM_MEDIA_MEDIACONTROL_AUDIOFOCUSMANAGER_H_