Line data Source code
1 : /* This Source Code Form is subject to the terms of the Mozilla Public
2 : * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 : * You can obtain one at http://mozilla.org/MPL/2.0/. */
4 :
5 : #ifndef mozilla_dom_SpeechSynthesisChild_h
6 : #define mozilla_dom_SpeechSynthesisChild_h
7 :
8 : #include "mozilla/Attributes.h"
9 : #include "mozilla/dom/PSpeechSynthesisChild.h"
10 : #include "mozilla/dom/PSpeechSynthesisRequestChild.h"
11 : #include "nsSpeechTask.h"
12 :
13 : namespace mozilla {
14 : namespace dom {
15 :
16 : class nsSynthVoiceRegistry;
17 : class SpeechSynthesisRequestChild;
18 : class SpeechTaskChild;
19 :
20 : class SpeechSynthesisChild : public PSpeechSynthesisChild
21 : {
22 : friend class nsSynthVoiceRegistry;
23 :
24 : public:
25 : mozilla::ipc::IPCResult RecvInitialVoicesAndState(nsTArray<RemoteVoice>&& aVoices,
26 : nsTArray<nsString>&& aDefaults,
27 : const bool& aIsSpeaking) override;
28 :
29 : mozilla::ipc::IPCResult RecvVoiceAdded(const RemoteVoice& aVoice) override;
30 :
31 : mozilla::ipc::IPCResult RecvVoiceRemoved(const nsString& aUri) override;
32 :
33 : mozilla::ipc::IPCResult RecvSetDefaultVoice(const nsString& aUri, const bool& aIsDefault) override;
34 :
35 : mozilla::ipc::IPCResult RecvIsSpeakingChanged(const bool& aIsSpeaking) override;
36 :
37 : mozilla::ipc::IPCResult RecvNotifyVoicesChanged() override;
38 :
39 : protected:
40 : SpeechSynthesisChild();
41 : virtual ~SpeechSynthesisChild();
42 :
43 : PSpeechSynthesisRequestChild* AllocPSpeechSynthesisRequestChild(const nsString& aLang,
44 : const nsString& aUri,
45 : const nsString& aText,
46 : const float& aVolume,
47 : const float& aPitch,
48 : const float& aRate) override;
49 : bool DeallocPSpeechSynthesisRequestChild(PSpeechSynthesisRequestChild* aActor) override;
50 : };
51 :
52 : class SpeechSynthesisRequestChild : public PSpeechSynthesisRequestChild
53 : {
54 : public:
55 : explicit SpeechSynthesisRequestChild(SpeechTaskChild* aTask);
56 : virtual ~SpeechSynthesisRequestChild();
57 :
58 : protected:
59 : mozilla::ipc::IPCResult RecvOnStart(const nsString& aUri) override;
60 :
61 : mozilla::ipc::IPCResult RecvOnEnd(const bool& aIsError,
62 : const float& aElapsedTime,
63 : const uint32_t& aCharIndex) override;
64 :
65 : mozilla::ipc::IPCResult RecvOnPause(const float& aElapsedTime, const uint32_t& aCharIndex) override;
66 :
67 : mozilla::ipc::IPCResult RecvOnResume(const float& aElapsedTime, const uint32_t& aCharIndex) override;
68 :
69 : mozilla::ipc::IPCResult RecvOnBoundary(const nsString& aName, const float& aElapsedTime,
70 : const uint32_t& aCharIndex,
71 : const uint32_t& aCharLength,
72 : const uint8_t& argc) override;
73 :
74 : mozilla::ipc::IPCResult RecvOnMark(const nsString& aName, const float& aElapsedTime,
75 : const uint32_t& aCharIndex) override;
76 :
77 : RefPtr<SpeechTaskChild> mTask;
78 : };
79 :
80 0 : class SpeechTaskChild : public nsSpeechTask
81 : {
82 : friend class SpeechSynthesisRequestChild;
83 : public:
84 :
85 : explicit SpeechTaskChild(SpeechSynthesisUtterance* aUtterance);
86 :
87 : NS_IMETHOD Setup(nsISpeechTaskCallback* aCallback,
88 : uint32_t aChannels, uint32_t aRate, uint8_t argc) override;
89 :
90 : NS_IMETHOD SendAudio(JS::Handle<JS::Value> aData, JS::Handle<JS::Value> aLandmarks,
91 : JSContext* aCx) override;
92 :
93 : NS_IMETHOD SendAudioNative(int16_t* aData, uint32_t aDataLen) override;
94 :
95 : void Pause() override;
96 :
97 : void Resume() override;
98 :
99 : void Cancel() override;
100 :
101 : void ForceEnd() override;
102 :
103 : void SetAudioOutputVolume(float aVolume) override;
104 :
105 : private:
106 : SpeechSynthesisRequestChild* mActor;
107 : };
108 :
109 : } // namespace dom
110 : } // namespace mozilla
111 :
112 : #endif
|