michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et cindent: */ 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 michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_nsSynthVoiceRegistry_h michael@0: #define mozilla_dom_nsSynthVoiceRegistry_h michael@0: michael@0: #include "nsAutoPtr.h" michael@0: #include "nsISynthVoiceRegistry.h" michael@0: #include "nsRefPtrHashtable.h" michael@0: #include "nsTArray.h" michael@0: michael@0: class nsISpeechService; michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class RemoteVoice; michael@0: class SpeechSynthesisUtterance; michael@0: class SpeechSynthesisChild; michael@0: class nsSpeechTask; michael@0: class VoiceData; michael@0: michael@0: class nsSynthVoiceRegistry : public nsISynthVoiceRegistry michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSISYNTHVOICEREGISTRY michael@0: michael@0: nsSynthVoiceRegistry(); michael@0: virtual ~nsSynthVoiceRegistry(); michael@0: michael@0: already_AddRefed SpeakUtterance(SpeechSynthesisUtterance& aUtterance, michael@0: const nsAString& aDocLang); michael@0: michael@0: void Speak(const nsAString& aText, const nsAString& aLang, michael@0: const nsAString& aUri, const float& aRate, const float& aPitch, michael@0: nsSpeechTask* aTask); michael@0: michael@0: void SendVoices(InfallibleTArray* aVoices, michael@0: InfallibleTArray* aDefaults); michael@0: michael@0: static nsSynthVoiceRegistry* GetInstance(); michael@0: michael@0: static already_AddRefed GetInstanceForService(); michael@0: michael@0: static void RecvRemoveVoice(const nsAString& aUri); michael@0: michael@0: static void RecvAddVoice(const RemoteVoice& aVoice); michael@0: michael@0: static void RecvSetDefaultVoice(const nsAString& aUri, bool aIsDefault); michael@0: michael@0: static void Shutdown(); michael@0: michael@0: private: michael@0: VoiceData* FindBestMatch(const nsAString& aUri, const nsAString& lang); michael@0: michael@0: bool FindVoiceByLang(const nsAString& aLang, VoiceData** aRetval); michael@0: michael@0: nsresult AddVoiceImpl(nsISpeechService* aService, michael@0: const nsAString& aUri, michael@0: const nsAString& aName, michael@0: const nsAString& aLang, michael@0: bool aLocalService); michael@0: michael@0: nsTArray > mVoices; michael@0: michael@0: nsTArray > mDefaultVoices; michael@0: michael@0: nsRefPtrHashtable mUriVoiceMap; michael@0: michael@0: SpeechSynthesisChild* mSpeechSynthChild; michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif