2013-04-03 22:13:16 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2013-11-18 00:48:02 +00:00
|
|
|
#ifndef mozilla_dom_nsSynthVoiceRegistry_h
|
|
|
|
#define mozilla_dom_nsSynthVoiceRegistry_h
|
2013-04-03 22:13:16 +00:00
|
|
|
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsISynthVoiceRegistry.h"
|
|
|
|
#include "nsRefPtrHashtable.h"
|
|
|
|
#include "nsTArray.h"
|
2015-04-02 16:37:24 +00:00
|
|
|
#include "MediaStreamGraph.h"
|
2013-04-03 22:13:16 +00:00
|
|
|
|
2013-04-03 22:13:17 +00:00
|
|
|
class nsISpeechService;
|
|
|
|
|
2013-04-03 22:13:16 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class RemoteVoice;
|
|
|
|
class SpeechSynthesisUtterance;
|
2013-04-03 22:13:17 +00:00
|
|
|
class SpeechSynthesisChild;
|
2013-04-03 22:13:16 +00:00
|
|
|
class nsSpeechTask;
|
|
|
|
class VoiceData;
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class nsSynthVoiceRegistry final : public nsISynthVoiceRegistry
|
2013-04-03 22:13:16 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSISYNTHVOICEREGISTRY
|
|
|
|
|
|
|
|
nsSynthVoiceRegistry();
|
|
|
|
|
2013-04-03 22:13:17 +00:00
|
|
|
already_AddRefed<nsSpeechTask> SpeakUtterance(SpeechSynthesisUtterance& aUtterance,
|
|
|
|
const nsAString& aDocLang);
|
|
|
|
|
|
|
|
void Speak(const nsAString& aText, const nsAString& aLang,
|
2015-04-23 20:06:43 +00:00
|
|
|
const nsAString& aUri, const float& aVolume, const float& aRate,
|
|
|
|
const float& aPitch, nsSpeechTask* aTask);
|
2013-04-03 22:13:17 +00:00
|
|
|
|
2013-04-03 22:13:17 +00:00
|
|
|
void SendVoices(InfallibleTArray<RemoteVoice>* aVoices,
|
|
|
|
InfallibleTArray<nsString>* aDefaults);
|
|
|
|
|
2013-04-03 22:13:16 +00:00
|
|
|
static nsSynthVoiceRegistry* GetInstance();
|
|
|
|
|
|
|
|
static already_AddRefed<nsSynthVoiceRegistry> GetInstanceForService();
|
|
|
|
|
2013-04-03 22:13:17 +00:00
|
|
|
static void RecvRemoveVoice(const nsAString& aUri);
|
|
|
|
|
|
|
|
static void RecvAddVoice(const RemoteVoice& aVoice);
|
|
|
|
|
|
|
|
static void RecvSetDefaultVoice(const nsAString& aUri, bool aIsDefault);
|
|
|
|
|
2013-04-03 22:13:16 +00:00
|
|
|
static void Shutdown();
|
|
|
|
|
|
|
|
private:
|
2014-06-24 16:36:43 +00:00
|
|
|
virtual ~nsSynthVoiceRegistry();
|
|
|
|
|
2013-04-03 22:13:17 +00:00
|
|
|
VoiceData* FindBestMatch(const nsAString& aUri, const nsAString& lang);
|
|
|
|
|
|
|
|
bool FindVoiceByLang(const nsAString& aLang, VoiceData** aRetval);
|
|
|
|
|
|
|
|
nsresult AddVoiceImpl(nsISpeechService* aService,
|
2013-04-03 22:13:16 +00:00
|
|
|
const nsAString& aUri,
|
|
|
|
const nsAString& aName,
|
|
|
|
const nsAString& aLang,
|
2015-08-05 17:25:42 +00:00
|
|
|
bool aLocalService,
|
|
|
|
bool aQueuesUtterances);
|
2013-04-03 22:13:16 +00:00
|
|
|
|
|
|
|
nsTArray<nsRefPtr<VoiceData> > mVoices;
|
|
|
|
|
|
|
|
nsTArray<nsRefPtr<VoiceData> > mDefaultVoices;
|
|
|
|
|
|
|
|
nsRefPtrHashtable<nsStringHashKey, VoiceData> mUriVoiceMap;
|
2013-04-03 22:13:17 +00:00
|
|
|
|
|
|
|
SpeechSynthesisChild* mSpeechSynthChild;
|
2015-04-02 16:37:24 +00:00
|
|
|
|
|
|
|
nsRefPtr<ProcessedMediaStream> mStream;
|
2015-08-05 17:25:42 +00:00
|
|
|
|
|
|
|
bool mUseGlobalQueue;
|
2013-04-03 22:13:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2013-11-18 00:48:02 +00:00
|
|
|
|
|
|
|
#endif
|