2251026fadeb4ddf4544784c79b043ed473ae0bd
[platform/core/uifw/dali-adaptor.git] / dali / public-api / adaptor-framework / tts-player.h
1 #ifndef DALI_TTS_PLAYER_H
2 #define DALI_TTS_PLAYER_H
3
4 /*
5  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/base-handle.h>
23 #include <dali/public-api/signals/dali-signal.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/public-api/dali-adaptor-common.h>
27
28 namespace Dali
29 {
30 /**
31  * @addtogroup dali_adaptor_framework
32  * @{
33  */
34
35 namespace Internal DALI_INTERNAL
36 {
37 namespace Adaptor
38 {
39 class TtsPlayer;
40 }
41 }
42
43 /**
44  * @brief The Text-to-speech (TTS) Player.
45  * @deprecated Instead of this class use Dali::Accessibility::Say() method
46  * @SINCE_1_0.0
47  */
48 class DALI_ADAPTOR_API TtsPlayer : public BaseHandle
49 {
50 public: // ENUMs
51
52   /**
53    * @brief Enumeration for the instance of TTS mode.
54    * @SINCE_1_0.0
55    */
56   enum Mode
57   {
58     DEFAULT = 0,  ///< Default mode for normal application @SINCE_1_0.0
59     NOTIFICATION, ///< Notification mode, such as playing utterance is started or completed @SINCE_1_0.0
60     SCREEN_READER, ///< Screen reader mode. To help visually impaired users interact with their devices, screen reader reads text or graphic elements on the screen using the TTS engine. @SINCE_1_0.0
61     MODE_NUM
62   };
63
64   /**
65    * @brief Enumeration for the instance of TTS state.
66    * @SINCE_1_0.0
67    */
68   enum State
69   {
70     UNAVAILABLE = 0,    ///< Player is not available @SINCE_1_0.0
71     READY,              ///< Player is ready to play @SINCE_1_0.0
72     PLAYING,            ///< Player is playing @SINCE_1_0.0
73     PAUSED              ///< Player is paused @SINCE_1_0.0
74   };
75
76 public: // Typedefs
77
78   /**
79    * @brief Type of signal emitted when the TTS state changes.
80    * @SINCE_1_0.0
81    */
82   typedef Signal< void ( const Dali::TtsPlayer::State, const Dali::TtsPlayer::State ) > StateChangedSignalType;
83
84 public: // API
85
86   /**
87    * @brief Creates an uninitialized handle.
88    *
89    * This can be initialized by calling TtsPlayer::Get().
90    * @SINCE_1_0.0
91    */
92   TtsPlayer();
93
94   /**
95    * @brief Gets the singleton of the TtsPlayer for the given mode.
96    *
97    * @SINCE_1_0.0
98    * @param mode The mode of tts-player
99    * @return A handle of the Ttsplayer for the given mode
100    */
101   static TtsPlayer Get(Dali::TtsPlayer::Mode mode = Dali::TtsPlayer::DEFAULT);
102
103   /**
104    * @brief Destructor.
105    *
106    * This is non-virtual since derived Handle types must not contain data or virtual methods.
107    * @SINCE_1_0.0
108    */
109   ~TtsPlayer();
110
111   /**
112    * @brief This copy constructor is required for (smart) pointer semantics.
113    *
114    * @SINCE_1_0.0
115    * @param [in] handle A reference to the copied handle
116    */
117   TtsPlayer(const TtsPlayer& handle);
118
119   /**
120    * @brief This assignment operator is required for (smart) pointer semantics.
121    *
122    * @SINCE_1_0.0
123    * @param [in] rhs A reference to the copied handle
124    * @return A reference to this
125    */
126   TtsPlayer& operator=(const TtsPlayer& rhs);
127
128   /**
129    * @brief Starts playing the audio data synthesized from the specified text.
130    *
131    * @SINCE_1_0.0
132    * @param[in] text The text to play
133    * @pre The TtsPlayer needs to be initialized.
134    */
135   void Play(const std::string& text);
136
137   /**
138    * @brief Stops playing the utterance.
139    * @SINCE_1_0.0
140    * @pre The TtsPlayer needs to be initialized.
141    */
142   void Stop();
143
144   /**
145    * @brief Pauses the currently playing utterance.
146    * @SINCE_1_0.0
147    * @pre The TtsPlayer needs to be initialized.
148    */
149   void Pause();
150
151   /**
152    * @brief Resumes the previously paused utterance.
153    * @SINCE_1_0.0
154    * @pre The TtsPlayer needs to be initialized.
155    */
156   void Resume();
157
158   /**
159    * @brief Gets the current state of the player.
160    * @SINCE_1_0.0
161    * @return The current TTS state
162    * @pre The TtsPlayer needs to be initialized.
163    */
164   State GetState();
165
166   /**
167    * @brief Allows connection TTS state change signal.
168    * @SINCE_1_0.0
169    * @return A reference to the signal for connection
170    * @note Only supported by some adaptor types.
171    */
172   Dali::TtsPlayer::StateChangedSignalType& StateChangedSignal();
173
174 public: // Not intended for application developers
175
176   /// @cond internal
177   /**
178    * @brief This constructor is used by TtsPlayer::Get().
179    * @SINCE_1_0.0
180    * @param[in] ttsPlayer A pointer to the TTS player
181    */
182   explicit DALI_INTERNAL TtsPlayer( Internal::Adaptor::TtsPlayer* ttsPlayer );
183   /// @endcond
184 };
185
186 /**
187  * @}
188  */
189 } // namespace Dali
190
191 #endif // DALI_TTS_PLAYER_H