Line data Source code
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/. */
6 :
7 : #ifndef mozilla_dom_audio_channel_agent_h__
8 : #define mozilla_dom_audio_channel_agent_h__
9 :
10 : #include "nsIAudioChannelAgent.h"
11 : #include "nsCycleCollectionParticipant.h"
12 : #include "nsCOMPtr.h"
13 : #include "nsWeakPtr.h"
14 :
15 : #define NS_AUDIOCHANNELAGENT_CONTRACTID "@mozilla.org/audiochannelagent;1"
16 : // f27688e2-3dd7-11e2-904e-10bf48d64bd4
17 : #define NS_AUDIOCHANNELAGENT_CID {0xf27688e2, 0x3dd7, 0x11e2, \
18 : {0x90, 0x4e, 0x10, 0xbf, 0x48, 0xd6, 0x4b, 0xd4}}
19 :
20 : class nsPIDOMWindowInner;
21 : class nsPIDOMWindowOuter;
22 :
23 : namespace mozilla {
24 : namespace dom {
25 :
26 : class AudioPlaybackConfig;
27 :
28 : /* Header file */
29 : class AudioChannelAgent : public nsIAudioChannelAgent
30 : {
31 : public:
32 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
33 : NS_DECL_NSIAUDIOCHANNELAGENT
34 :
35 2 : NS_DECL_CYCLE_COLLECTION_CLASS(AudioChannelAgent)
36 :
37 : AudioChannelAgent();
38 :
39 : void WindowVolumeChanged();
40 : void WindowSuspendChanged(nsSuspendedTypes aSuspend);
41 : void WindowAudioCaptureChanged(uint64_t aInnerWindowID, bool aCapture);
42 :
43 0 : nsPIDOMWindowOuter* Window() const
44 : {
45 0 : return mWindow;
46 : }
47 :
48 : uint64_t WindowID() const;
49 : uint64_t InnerWindowID() const;
50 :
51 : bool IsPlayingStarted() const;
52 : bool ShouldBlockMedia() const;
53 :
54 : private:
55 : virtual ~AudioChannelAgent();
56 :
57 : AudioPlaybackConfig GetMediaConfig();
58 : bool IsDisposableSuspend(nsSuspendedTypes aSuspend) const;
59 :
60 : // Returns mCallback if that's non-null, or otherwise tries to get an
61 : // nsIAudioChannelAgentCallback out of mWeakCallback.
62 : already_AddRefed<nsIAudioChannelAgentCallback> GetCallback();
63 :
64 : nsresult InitInternal(nsPIDOMWindowInner* aWindow, int32_t aAudioAgentType,
65 : nsIAudioChannelAgentCallback* aCallback,
66 : bool aUseWeakRef);
67 :
68 : void Shutdown();
69 :
70 : nsresult FindCorrectWindow(nsPIDOMWindowInner* aWindow);
71 :
72 : nsCOMPtr<nsPIDOMWindowOuter> mWindow;
73 : nsCOMPtr<nsIAudioChannelAgentCallback> mCallback;
74 :
75 : nsWeakPtr mWeakCallback;
76 :
77 : int32_t mAudioChannelType;
78 : uint64_t mInnerWindowID;
79 : bool mIsRegToService;
80 : };
81 :
82 : } // namespace dom
83 : } // namespace mozilla
84 :
85 :
86 : #endif
|