[dali_2.3.24] Merge branch 'devel/master'
[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) 2020 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 } // namespace DALI_INTERNAL
42
43 /**
44  * @brief The Text-to-speech (TTS) Player.
45  * @SINCE_1_0.0
46  */
47 class DALI_ADAPTOR_API TtsPlayer : public BaseHandle
48 {
49 public: // ENUMs
50   /**
51    * @brief Enumeration for the instance of TTS mode.
52    * @SINCE_1_0.0
53    */
54   enum Mode
55   {
56     DEFAULT = 0,   ///< Default mode for normal application @SINCE_1_0.0
57     NOTIFICATION,  ///< Notification mode, such as playing utterance is started or completed @SINCE_1_0.0
58     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
59     MODE_NUM
60   };
61
62   /**
63    * @brief Enumeration for the instance of TTS state.
64    * @SINCE_1_0.0
65    */
66   enum State
67   {
68     UNAVAILABLE = 0, ///< Player is not available @SINCE_1_0.0
69     READY,           ///< Player is ready to play @SINCE_1_0.0
70     PLAYING,         ///< Player is playing @SINCE_1_0.0
71     PAUSED           ///< Player is paused @SINCE_1_0.0
72   };
73
74 public: // Typedefs
75   /**
76    * @brief Type of signal emitted when the TTS state changes.
77    * @SINCE_1_0.0
78    */
79   typedef Signal<void(const Dali::TtsPlayer::State, const Dali::TtsPlayer::State)> StateChangedSignalType;
80
81 public: // API
82   /**
83    * @brief Creates an uninitialized handle.
84    *
85    * This can be initialized by calling TtsPlayer::Get().
86    * @SINCE_1_0.0
87    */
88   TtsPlayer();
89
90   /**
91    * @brief Gets the singleton of the TtsPlayer for the given mode.
92    *
93    * @SINCE_1_0.0
94    * @param mode The mode of tts-player
95    * @return A handle of the Ttsplayer for the given mode
96    */
97   static TtsPlayer Get(Dali::TtsPlayer::Mode mode = Dali::TtsPlayer::DEFAULT);
98
99   /**
100    * @brief Destructor.
101    *
102    * This is non-virtual since derived Handle types must not contain data or virtual methods.
103    * @SINCE_1_0.0
104    */
105   ~TtsPlayer();
106
107   /**
108    * @brief This copy constructor is required for (smart) pointer semantics.
109    *
110    * @SINCE_1_0.0
111    * @param [in] handle A reference to the copied handle
112    */
113   TtsPlayer(const TtsPlayer& handle);
114
115   /**
116    * @brief This assignment operator is required for (smart) pointer semantics.
117    *
118    * @SINCE_1_0.0
119    * @param [in] rhs A reference to the copied handle
120    * @return A reference to this
121    */
122   TtsPlayer& operator=(const TtsPlayer& rhs);
123
124   /**
125    * @brief Move constructor.
126    *
127    * @SINCE_1_9.24
128    * @param[in] rhs A reference to the moved handle
129    */
130   TtsPlayer(TtsPlayer&& rhs) noexcept;
131
132   /**
133    * @brief Move assignment operator.
134    *
135    * @SINCE_1_9.24
136    * @param[in] rhs A reference to the moved handle
137    * @return A reference to this handle
138    */
139   TtsPlayer& operator=(TtsPlayer&& rhs) noexcept;
140
141   /**
142    * @brief Starts playing the audio data synthesized from the specified text.
143    *
144    * @SINCE_1_0.0
145    * @param[in] text The text to play
146    * @pre The TtsPlayer needs to be initialized.
147    */
148   void Play(const std::string& text);
149
150   /**
151    * @brief Stops playing the utterance.
152    * @SINCE_1_0.0
153    * @pre The TtsPlayer needs to be initialized.
154    */
155   void Stop();
156
157   /**
158    * @brief Pauses the currently playing utterance.
159    * @SINCE_1_0.0
160    * @pre The TtsPlayer needs to be initialized.
161    */
162   void Pause();
163
164   /**
165    * @brief Resumes the previously paused utterance.
166    * @SINCE_1_0.0
167    * @pre The TtsPlayer needs to be initialized.
168    */
169   void Resume();
170
171   /**
172    * @brief Gets the current state of the player.
173    * @SINCE_1_0.0
174    * @return The current TTS state
175    * @pre The TtsPlayer needs to be initialized.
176    */
177   State GetState();
178
179   /**
180    * @brief Allows connection TTS state change signal.
181    * @SINCE_1_0.0
182    * @return A reference to the signal for connection
183    * @note Only supported by some adaptor types.
184    */
185   Dali::TtsPlayer::StateChangedSignalType& StateChangedSignal();
186
187 public: // Not intended for application developers
188   /// @cond internal
189   /**
190    * @brief This constructor is used by TtsPlayer::Get().
191    * @SINCE_1_0.0
192    * @param[in] ttsPlayer A pointer to the TTS player
193    */
194   explicit DALI_INTERNAL TtsPlayer(Internal::Adaptor::TtsPlayer* ttsPlayer);
195   /// @endcond
196 };
197
198 /**
199  * @}
200  */
201 } // namespace Dali
202
203 #endif // DALI_TTS_PLAYER_H