Add support for new accessibility actions
[platform/core/uifw/dali-adaptor.git] / adaptors / 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 namespace Internal DALI_INTERNAL
29 {
30 namespace Adaptor
31 {
32 class TtsPlayer;
33 }
34 }
35
36 /**
37  * @brief The Text-to-speech Player.
38  */
39 class DALI_IMPORT_API TtsPlayer : public BaseHandle
40 {
41 public: // ENUMs
42
43   /**
44    * @brief Enumeration of TTS mode.
45    */
46   enum Mode
47   {
48     DEFAULT = 0,  ///< Default mode for normal application
49     NOTIFICATION, ///< Notification mode
50     SCREEN_READER, ///< Screen reader mode
51     MODE_NUM
52   };
53
54   /**
55    * @brief Enumeration of TTS state.
56    */
57   enum State
58   {
59     UNAVAILABLE = 0,    ///< Player is not available
60     READY,              ///< Player is ready to play
61     PLAYING,            ///< Player is playing
62     PAUSED              ///< Player is paused
63   };
64
65 public: // Typedefs
66
67   /**
68    * @brief Type of signal emitted when the TTS state changes.
69    */
70   typedef Signal< void ( const Dali::TtsPlayer::State, const Dali::TtsPlayer::State ) > StateChangedSignalType;
71
72 public: // API
73
74   /**
75    * @brief Create an uninitialized handle.
76    *
77    * This can be initialized by calling TtsPlayer::Get().
78    */
79   TtsPlayer();
80
81   /**
82    * @brief Gets the singleton of the TtsPlayer for the given mode.
83    *
84    * @param mode the mode of tts-player
85    * @return A handle of the Ttsplayer for the given mode.
86    */
87   static TtsPlayer Get(Dali::TtsPlayer::Mode mode = Dali::TtsPlayer::DEFAULT);
88
89   /**
90    * @brief Destructor
91    *
92    * This is non-virtual since derived Handle types must not contain data or virtual methods.
93    */
94   ~TtsPlayer();
95
96   /**
97    * @brief This copy constructor is required for (smart) pointer semantics.
98    *
99    * @param [in] handle A reference to the copied handle
100    */
101   TtsPlayer(const TtsPlayer& handle);
102
103   /**
104    * @brief This assignment operator is required for (smart) pointer semantics.
105    *
106    * @param [in] rhs  A reference to the copied handle
107    * @return A reference to this
108    */
109   TtsPlayer& operator=(const TtsPlayer& rhs);
110
111   /**
112    * @brief Start playing the audio data synthesized from the specified text.
113    *
114    * @pre The TtsPlayer needs to be initialized.
115    * @param[in] text to play.
116    */
117   void Play(const std::string& text);
118
119   /**
120    * @brief Stops playing the utterance.
121    * @pre The TtsPlayer needs to be initialized.
122    */
123   void Stop();
124
125   /**
126    * @brief Pauses the currently playing utterance.
127    * @pre The TtsPlayer needs to be initialized.
128    */
129   void Pause();
130
131   /**
132    * @brief Resumes the previously paused utterance.
133    * @pre The TtsPlayer needs to be initialized.
134    */
135   void Resume();
136
137   /**
138    * @brief Gets the current state of the player.
139    * @pre The TtsPlayer needs to be initialized.
140    */
141   State GetState();
142
143   /**
144    * @brief Allows connection TTS state change signal.
145    * Note: Only supported by some adaptor types.
146    * @return A reference to the signal for connection.
147    */
148   Dali::TtsPlayer::StateChangedSignalType& StateChangedSignal();
149
150 public: // Not intended for application developers
151
152   /**
153    * @brief This constructor is used by TtsPlayer::Get().
154    * @param[in] ttsPlayer A pointer to the TTS player.
155    */
156   explicit DALI_INTERNAL TtsPlayer( Internal::Adaptor::TtsPlayer* ttsPlayer );
157 };
158
159 } // namespace Dali
160
161 #endif // __DALI_TTS_PLAYER_H__