AudioChannelAgent.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_dom_audio_channel_agent_h__
  6. #define mozilla_dom_audio_channel_agent_h__
  7. #include "nsIAudioChannelAgent.h"
  8. #include "nsCycleCollectionParticipant.h"
  9. #include "nsCOMPtr.h"
  10. #include "nsWeakPtr.h"
  11. #define NS_AUDIOCHANNELAGENT_CONTRACTID "@mozilla.org/audiochannelagent;1"
  12. // f27688e2-3dd7-11e2-904e-10bf48d64bd4
  13. #define NS_AUDIOCHANNELAGENT_CID {0xf27688e2, 0x3dd7, 0x11e2, \
  14. {0x90, 0x4e, 0x10, 0xbf, 0x48, 0xd6, 0x4b, 0xd4}}
  15. class nsPIDOMWindowInner;
  16. class nsPIDOMWindowOuter;
  17. namespace mozilla {
  18. namespace dom {
  19. class AudioPlaybackConfig;
  20. /* Header file */
  21. class AudioChannelAgent : public nsIAudioChannelAgent
  22. {
  23. public:
  24. NS_DECL_CYCLE_COLLECTING_ISUPPORTS
  25. NS_DECL_NSIAUDIOCHANNELAGENT
  26. NS_DECL_CYCLE_COLLECTION_CLASS(AudioChannelAgent)
  27. AudioChannelAgent();
  28. void WindowVolumeChanged();
  29. void WindowSuspendChanged(nsSuspendedTypes aSuspend);
  30. void WindowAudioCaptureChanged(uint64_t aInnerWindowID, bool aCapture);
  31. nsPIDOMWindowOuter* Window() const
  32. {
  33. return mWindow;
  34. }
  35. uint64_t WindowID() const;
  36. uint64_t InnerWindowID() const;
  37. bool IsPlayingStarted() const;
  38. bool ShouldBlockMedia() const;
  39. private:
  40. virtual ~AudioChannelAgent();
  41. AudioPlaybackConfig GetMediaConfig();
  42. bool IsDisposableSuspend(nsSuspendedTypes aSuspend) const;
  43. // Returns mCallback if that's non-null, or otherwise tries to get an
  44. // nsIAudioChannelAgentCallback out of mWeakCallback.
  45. already_AddRefed<nsIAudioChannelAgentCallback> GetCallback();
  46. nsresult InitInternal(nsPIDOMWindowInner* aWindow, int32_t aAudioAgentType,
  47. nsIAudioChannelAgentCallback* aCallback,
  48. bool aUseWeakRef);
  49. void Shutdown();
  50. nsresult FindCorrectWindow(nsPIDOMWindowInner* aWindow);
  51. nsCOMPtr<nsPIDOMWindowOuter> mWindow;
  52. nsCOMPtr<nsIAudioChannelAgentCallback> mCallback;
  53. nsWeakPtr mWeakCallback;
  54. int32_t mAudioChannelType;
  55. uint64_t mInnerWindowID;
  56. bool mIsRegToService;
  57. };
  58. } // namespace dom
  59. } // namespace mozilla
  60. #endif