Adaptor refactor
[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) 2015 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 namespace Dali
26 {
27 /**
28  * @addtogroup dali_adaptor_framework
29  * @{
30  */
31
32 namespace Internal DALI_INTERNAL
33 {
34 namespace Adaptor
35 {
36 class TtsPlayer;
37 }
38 }
39
40 /**
41  * @brief The Text-to-speech (TTS) Player.
42  * @SINCE_1_0.0
43  */
44 class DALI_IMPORT_API TtsPlayer : public BaseHandle
45 {
46 public: // ENUMs
47
48   /**
49    * @brief Enumeration for the instance of TTS mode.
50    * @SINCE_1_0.0
51    */
52   enum Mode
53   {
54     DEFAULT = 0,  ///< Default mode for normal application @SINCE_1_0.0
55     NOTIFICATION, ///< Notification mode, such as playing utterance is started or completed @SINCE_1_0.0
56     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
57     MODE_NUM
58   };
59
60   /**
61    * @brief Enumeration for the instance of TTS state.
62    * @SINCE_1_0.0
63    */
64   enum State
65   {
66     UNAVAILABLE = 0,    ///< Player is not available @SINCE_1_0.0
67     READY,              ///< Player is ready to play @SINCE_1_0.0
68     PLAYING,            ///< Player is playing @SINCE_1_0.0
69     PAUSED              ///< Player is paused @SINCE_1_0.0
70   };
71
72 public: // Typedefs
73
74   /**
75    * @brief Type of signal emitted when the TTS state changes.
76    * @SINCE_1_0.0
77    */
78   typedef Signal< void ( const Dali::TtsPlayer::State, const Dali::TtsPlayer::State ) > StateChangedSignalType;
79
80 public: // API
81
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 Starts playing the audio data synthesized from the specified text.
126    *
127    * @SINCE_1_0.0
128    * @param[in] text The text to play
129    * @pre The TtsPlayer needs to be initialized.
130    */
131   void Play(const std::string& text);
132
133   /**
134    * @brief Stops playing the utterance.
135    * @SINCE_1_0.0
136    * @pre The TtsPlayer needs to be initialized.
137    */
138   void Stop();
139
140   /**
141    * @brief Pauses the currently playing utterance.
142    * @SINCE_1_0.0
143    * @pre The TtsPlayer needs to be initialized.
144    */
145   void Pause();
146
147   /**
148    * @brief Resumes the previously paused utterance.
149    * @SINCE_1_0.0
150    * @pre The TtsPlayer needs to be initialized.
151    */
152   void Resume();
153
154   /**
155    * @brief Gets the current state of the player.
156    * @SINCE_1_0.0
157    * @return The current TTS state
158    * @pre The TtsPlayer needs to be initialized.
159    */
160   State GetState();
161
162   /**
163    * @brief Allows connection TTS state change signal.
164    * @SINCE_1_0.0
165    * @return A reference to the signal for connection
166    * @note Only supported by some adaptor types.
167    */
168   Dali::TtsPlayer::StateChangedSignalType& StateChangedSignal();
169
170 public: // Not intended for application developers
171
172   /// @cond internal
173   /**
174    * @brief This constructor is used by TtsPlayer::Get().
175    * @SINCE_1_0.0
176    * @param[in] ttsPlayer A pointer to the TTS player
177    */
178   explicit DALI_INTERNAL TtsPlayer( Internal::Adaptor::TtsPlayer* ttsPlayer );
179   /// @endcond
180 };
181
182 /**
183  * @}
184  */
185 } // namespace Dali
186
187 #endif // __DALI_TTS_PLAYER_H__