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_nsSpeechTask_h michael@0: #define mozilla_dom_nsSpeechTask_h michael@0: michael@0: #include "MediaStreamGraph.h" michael@0: #include "SpeechSynthesisUtterance.h" michael@0: #include "nsISpeechService.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class SpeechSynthesisUtterance; michael@0: class SpeechSynthesis; michael@0: class SynthStreamListener; michael@0: michael@0: class nsSpeechTask : public nsISpeechTask michael@0: { michael@0: friend class SynthStreamListener; michael@0: michael@0: public: michael@0: NS_DECL_CYCLE_COLLECTING_ISUPPORTS michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsSpeechTask, nsISpeechTask) michael@0: michael@0: NS_DECL_NSISPEECHTASK michael@0: michael@0: nsSpeechTask(SpeechSynthesisUtterance* aUtterance); michael@0: nsSpeechTask(float aVolume, const nsAString& aText); michael@0: michael@0: virtual ~nsSpeechTask(); michael@0: michael@0: virtual void Pause(); michael@0: michael@0: virtual void Resume(); michael@0: michael@0: virtual void Cancel(); michael@0: michael@0: float GetCurrentTime(); michael@0: michael@0: uint32_t GetCurrentCharOffset(); michael@0: michael@0: void SetSpeechSynthesis(SpeechSynthesis* aSpeechSynthesis); michael@0: michael@0: void SetIndirectAudio(bool aIndirectAudio) { mIndirectAudio = aIndirectAudio; } michael@0: michael@0: protected: michael@0: virtual nsresult DispatchStartImpl(); michael@0: michael@0: virtual nsresult DispatchEndImpl(float aElapsedTime, uint32_t aCharIndex); michael@0: michael@0: virtual nsresult DispatchPauseImpl(float aElapsedTime, uint32_t aCharIndex); michael@0: michael@0: virtual nsresult DispatchResumeImpl(float aElapsedTime, uint32_t aCharIndex); michael@0: michael@0: virtual nsresult DispatchErrorImpl(float aElapsedTime, uint32_t aCharIndex); michael@0: michael@0: virtual nsresult DispatchBoundaryImpl(const nsAString& aName, michael@0: float aElapsedTime, michael@0: uint32_t aCharIndex); michael@0: michael@0: virtual nsresult DispatchMarkImpl(const nsAString& aName, michael@0: float aElapsedTime, uint32_t aCharIndex); michael@0: michael@0: nsRefPtr mUtterance; michael@0: michael@0: float mVolume; michael@0: michael@0: nsString mText; michael@0: michael@0: private: michael@0: void End(); michael@0: michael@0: void SendAudioImpl(int16_t* aData, uint32_t aDataLen); michael@0: michael@0: nsRefPtr mStream; michael@0: michael@0: nsCOMPtr mCallback; michael@0: michael@0: uint32_t mChannels; michael@0: michael@0: nsRefPtr mSpeechSynthesis; michael@0: michael@0: bool mIndirectAudio; michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif