michael@0: /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_SpeakerManagerService_h__ michael@0: #define mozilla_dom_SpeakerManagerService_h__ michael@0: michael@0: #include "nsAutoPtr.h" michael@0: #include "nsIObserver.h" michael@0: #include "nsTArray.h" michael@0: #include "SpeakerManager.h" michael@0: #include "nsIAudioManager.h" michael@0: #include "nsCheapSets.h" michael@0: #include "nsHashKeys.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class SpeakerManagerService : public nsIObserver michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSIOBSERVER michael@0: michael@0: static SpeakerManagerService* GetSpeakerManagerService(); michael@0: virtual void ForceSpeaker(bool aEnable, bool aVisible); michael@0: virtual bool GetSpeakerStatus(); michael@0: virtual void SetAudioChannelActive(bool aIsActive); michael@0: // Called by child michael@0: void ForceSpeaker(bool enable, uint64_t aChildid); michael@0: // Register the SpeakerManager to service for notify the speakerforcedchange event michael@0: void RegisterSpeakerManager(SpeakerManager* aSpeakerManager) michael@0: { michael@0: mRegisteredSpeakerManagers.AppendElement(aSpeakerManager); michael@0: } michael@0: void UnRegisterSpeakerManager(SpeakerManager* aSpeakerManager) michael@0: { michael@0: mRegisteredSpeakerManagers.RemoveElement(aSpeakerManager); michael@0: } michael@0: /** michael@0: * Shutdown the singleton. michael@0: */ michael@0: static void Shutdown(); michael@0: michael@0: protected: michael@0: SpeakerManagerService(); michael@0: michael@0: virtual ~SpeakerManagerService(); michael@0: // Notify to UA if device speaker status changed michael@0: virtual void Notify(); michael@0: michael@0: void TuruOnSpeaker(bool aEnable); michael@0: michael@0: nsTArray > mRegisteredSpeakerManagers; michael@0: // Set for remember all the child speaker status michael@0: nsCheapSet mSpeakerStatusSet; michael@0: // The Speaker status assign by UA michael@0: bool mOrgSpeakerStatus; michael@0: michael@0: bool mVisible; michael@0: // This is needed for IPC communication between michael@0: // SpeakerManagerServiceChild and this class. michael@0: friend class ContentParent; michael@0: friend class ContentChild; michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif