2019-08-07 04:46:08 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2019-10-30 02:08:05 +03:00
|
|
|
#ifndef DOM_MEDIA_MEDIACONTROL_AUDIOFOCUSMANAGER_H_
|
|
|
|
#define DOM_MEDIA_MEDIACONTROL_AUDIOFOCUSMANAGER_H_
|
2019-08-07 04:46:08 +03:00
|
|
|
|
|
|
|
#include "base/basictypes.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2020-05-14 01:08:01 +03:00
|
|
|
class IMediaController;
|
2019-08-07 04:46:08 +03:00
|
|
|
class MediaControlService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* AudioFocusManager is used to assign the audio focus to different requester
|
|
|
|
* and decide which requester can own audio focus when audio competing happens.
|
|
|
|
* When the audio competing happens, the last request would be a winner who can
|
|
|
|
* still own the audio focus, and all the other requesters would lose the audio
|
|
|
|
* focus. Now MediaController is the onlt requester, it would request the audio
|
|
|
|
* focus when it becomes audible and revoke the audio focus when the controller
|
|
|
|
* is no longer active.
|
|
|
|
*/
|
|
|
|
class AudioFocusManager {
|
|
|
|
public:
|
2020-05-14 01:08:01 +03:00
|
|
|
void RequestAudioFocus(IMediaController* aController);
|
|
|
|
void RevokeAudioFocus(IMediaController* aController);
|
2019-08-07 04:46:08 +03:00
|
|
|
|
2020-01-16 02:26:29 +03:00
|
|
|
explicit AudioFocusManager() = default;
|
2019-08-07 04:46:08 +03:00
|
|
|
~AudioFocusManager() = default;
|
|
|
|
|
|
|
|
uint32_t GetAudioFocusNums() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class MediaControlService;
|
2020-01-16 03:06:59 +03:00
|
|
|
void ClearFocusControllersIfNeeded();
|
2019-08-07 04:46:08 +03:00
|
|
|
|
2020-05-14 01:08:01 +03:00
|
|
|
nsTArray<RefPtr<IMediaController>> mOwningFocusControllers;
|
2019-08-07 04:46:08 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2019-10-30 02:08:05 +03:00
|
|
|
#endif // DOM_MEDIA_MEDIACONTROL_AUDIOFOCUSMANAGER_H_
|