content/media/webspeech/synth/nsSpeechTask.h

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:aa9e41f25141
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #ifndef mozilla_dom_nsSpeechTask_h
8 #define mozilla_dom_nsSpeechTask_h
9
10 #include "MediaStreamGraph.h"
11 #include "SpeechSynthesisUtterance.h"
12 #include "nsISpeechService.h"
13
14 namespace mozilla {
15 namespace dom {
16
17 class SpeechSynthesisUtterance;
18 class SpeechSynthesis;
19 class SynthStreamListener;
20
21 class nsSpeechTask : public nsISpeechTask
22 {
23 friend class SynthStreamListener;
24
25 public:
26 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
27 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsSpeechTask, nsISpeechTask)
28
29 NS_DECL_NSISPEECHTASK
30
31 nsSpeechTask(SpeechSynthesisUtterance* aUtterance);
32 nsSpeechTask(float aVolume, const nsAString& aText);
33
34 virtual ~nsSpeechTask();
35
36 virtual void Pause();
37
38 virtual void Resume();
39
40 virtual void Cancel();
41
42 float GetCurrentTime();
43
44 uint32_t GetCurrentCharOffset();
45
46 void SetSpeechSynthesis(SpeechSynthesis* aSpeechSynthesis);
47
48 void SetIndirectAudio(bool aIndirectAudio) { mIndirectAudio = aIndirectAudio; }
49
50 protected:
51 virtual nsresult DispatchStartImpl();
52
53 virtual nsresult DispatchEndImpl(float aElapsedTime, uint32_t aCharIndex);
54
55 virtual nsresult DispatchPauseImpl(float aElapsedTime, uint32_t aCharIndex);
56
57 virtual nsresult DispatchResumeImpl(float aElapsedTime, uint32_t aCharIndex);
58
59 virtual nsresult DispatchErrorImpl(float aElapsedTime, uint32_t aCharIndex);
60
61 virtual nsresult DispatchBoundaryImpl(const nsAString& aName,
62 float aElapsedTime,
63 uint32_t aCharIndex);
64
65 virtual nsresult DispatchMarkImpl(const nsAString& aName,
66 float aElapsedTime, uint32_t aCharIndex);
67
68 nsRefPtr<SpeechSynthesisUtterance> mUtterance;
69
70 float mVolume;
71
72 nsString mText;
73
74 private:
75 void End();
76
77 void SendAudioImpl(int16_t* aData, uint32_t aDataLen);
78
79 nsRefPtr<SourceMediaStream> mStream;
80
81 nsCOMPtr<nsISpeechTaskCallback> mCallback;
82
83 uint32_t mChannels;
84
85 nsRefPtr<SpeechSynthesis> mSpeechSynthesis;
86
87 bool mIndirectAudio;
88 };
89
90 } // namespace dom
91 } // namespace mozilla
92
93 #endif

mercurial