Backed out 22 changesets (bug 1839396) for causing build bustages on js/Printer.h...
[gecko.git] / dom / audiochannel / AudioChannelAgent.h
blob968221984406f5eace150b0a32b34fbf98b77659
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_audio_channel_agent_h__
8 #define mozilla_dom_audio_channel_agent_h__
10 #include "nsIAudioChannelAgent.h"
11 #include "nsCycleCollectionParticipant.h"
12 #include "nsCOMPtr.h"
13 #include "nsIWeakReferenceUtils.h"
15 class nsPIDOMWindowInner;
16 class nsPIDOMWindowOuter;
18 namespace mozilla::dom {
20 class AudioPlaybackConfig;
22 /* Header file */
23 class AudioChannelAgent : public nsIAudioChannelAgent {
24 public:
25 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
26 NS_DECL_NSIAUDIOCHANNELAGENT
28 NS_DECL_CYCLE_COLLECTION_CLASS(AudioChannelAgent)
30 AudioChannelAgent();
32 // nsIAudioChannelAgentCallback MUST call this function after calling
33 // NotifyStartedPlaying() to require the initial update for
34 // volume/suspend/audio-capturing which might set before starting the agent.
35 // Ex. starting the agent in a tab which has been muted before, so the agent
36 // should apply mute state to its callback.
37 void PullInitialUpdate();
39 uint64_t WindowID() const;
41 bool IsWindowAudioCapturingEnabled() const;
42 bool IsPlayingStarted() const;
44 private:
45 virtual ~AudioChannelAgent();
47 friend class AudioChannelService;
48 void WindowVolumeChanged(float aVolume, bool aMuted);
49 void WindowSuspendChanged(nsSuspendedTypes aSuspend);
50 void WindowAudioCaptureChanged(uint64_t aInnerWindowID, bool aCapture);
52 nsPIDOMWindowOuter* Window() const { return mWindow; }
53 uint64_t InnerWindowID() const;
54 AudioPlaybackConfig GetMediaConfig() const;
56 // Returns mCallback if that's non-null, or otherwise tries to get an
57 // nsIAudioChannelAgentCallback out of mWeakCallback.
58 already_AddRefed<nsIAudioChannelAgentCallback> GetCallback();
60 nsresult InitInternal(nsPIDOMWindowInner* aWindow,
61 nsIAudioChannelAgentCallback* aCallback,
62 bool aUseWeakRef);
64 void Shutdown();
66 nsresult FindCorrectWindow(nsPIDOMWindowInner* aWindow);
68 nsCOMPtr<nsPIDOMWindowOuter> mWindow;
69 nsCOMPtr<nsIAudioChannelAgentCallback> mCallback;
71 nsWeakPtr mWeakCallback;
73 uint64_t mInnerWindowID;
74 bool mIsRegToService;
77 } // namespace mozilla::dom
79 #endif