Revert "[Tizen] Added 'make clean' on each profile build."
[platform/core/uifw/dali-adaptor.git] / adaptors / tizen / tts-player-impl.h
1 #ifndef __DALI_INTERNAL_TTS_PLAYER_H__
2 #define __DALI_INTERNAL_TTS_PLAYER_H__
3
4 /*
5  * Copyright (c) 2014 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 <tts.h>
23 #include <string>
24
25 #include <dali/integration-api/debug.h>
26 #include <dali/public-api/object/base-object.h>
27
28 // INTERNAL INCLUDES
29 #include <tts-player.h>
30
31 namespace Dali
32 {
33
34 namespace Internal
35 {
36
37 namespace Adaptor
38 {
39
40 /**
41  * Text-to-speech player
42  */
43 class TtsPlayer : public Dali::BaseObject
44 {
45
46 public:
47
48   /**
49    * Create a TtsPlayer with the given mode.
50    * This should only be called once by the Adaptor class for each given mode.
51    * @param mode the mode of tts-player
52    * @return A newly created TtsPlayer.
53    */
54   static Dali::TtsPlayer New(Dali::TtsPlayer::Mode mode);
55
56   /**
57    * @copydoc TtsPlayer::Play()
58    */
59   void Play(const std::string& text);
60
61   /**
62    * @copydoc TtsPlayer::Stop()
63    */
64   void Stop();
65
66   /**
67    * @copydoc TtsPlayer::Pause()
68    */
69   void Pause();
70
71   /**
72    * @copydoc TtsPlayer::Resume()
73    */
74   void Resume();
75
76   /**
77    * @copydoc TtsPlayer::GetState()
78    */
79   Dali::TtsPlayer::State GetState();
80
81   /**
82    * @copydoc TtsPlayer::StateChangedSignal()
83    */
84   Dali::TtsPlayer::StateChangedSignalType& StateChangedSignal();
85
86 private:
87
88   /**
89    * Private Constructor; see also TtsPlayer::New()
90    * @param mode the mode of tts-player
91    */
92   TtsPlayer(Dali::TtsPlayer::Mode mode);
93
94   /**
95    * Destructor
96    */
97   virtual ~TtsPlayer();
98
99   /**
100    * Initializes the player.
101    */
102   void Initialize();
103
104   /**
105    * Logs the error code.
106    * @param[in] reason The error code
107    */
108   void LogErrorCode(tts_error_e reason);
109
110   /**
111    * Used to emit the state changed signal from outside the object (EG. A static function).
112    * @param[in] previous The previous state
113    * @param[in] current The current state
114    */
115   void EmitStateChangedSignal( tts_state_e previous, tts_state_e current );
116
117   /**
118    * Called when the state of TTS is changed.
119    *
120    * @param[in] tts The handle for TTS
121    * @param[in] previous A previous state
122    * @param[in] current A current state
123    * @param[in] userData The user data passed from the callback registration function.
124    */
125   static void StateChangedCallback(tts_h tts, tts_state_e previous, tts_state_e current, void *userData);
126
127   // Undefined
128   TtsPlayer(const TtsPlayer&);
129
130   // Undefined
131   TtsPlayer& operator=(TtsPlayer&);
132
133 private:
134
135   Dali::TtsPlayer::StateChangedSignalType mStateChangedSignal; ///< Signal emitted when the TTS state changes
136   bool mInitialized; ///< Whether the TTS player is initialised successfully or not
137   std::string mUnplayedString; ///< The text that can not be played because tts engine is not yet initialized
138   tts_h mTtsHandle;  ///< The handle of TTS
139   int mUtteranceId;  ///< The utterance ID
140
141   Dali::TtsPlayer::Mode mTtsMode; ///< The current mode of tts engine
142
143 #if defined(DEBUG_ENABLED)
144 public:
145   static Debug::Filter* gLogFilter;
146 #endif
147 };
148
149 } // namespace Adaptor
150
151 } // namespace Internal
152
153 // Helpers for public-api forwarding methods
154
155 inline Internal::Adaptor::TtsPlayer& GetImplementation(Dali::TtsPlayer& player)
156 {
157   DALI_ASSERT_ALWAYS( player && "TtsPlayer handle is empty" );
158
159   BaseObject& handle = player.GetBaseObject();
160
161   return static_cast<Internal::Adaptor::TtsPlayer&>(handle);
162 }
163
164 inline const Internal::Adaptor::TtsPlayer& GetImplementation(const Dali::TtsPlayer& player)
165 {
166   DALI_ASSERT_ALWAYS( player && "TtsPlayer handle is empty" );
167
168   const BaseObject& handle = player.GetBaseObject();
169
170   return static_cast<const Internal::Adaptor::TtsPlayer&>(handle);
171 }
172
173 } // namespace Dali
174
175 #endif // __DALI_INTERNAL_TTS_PLAYER_H__