1 #ifndef __DALI_INTERNAL_TTS_PLAYER_H__
2 #define __DALI_INTERNAL_TTS_PLAYER_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
25 #include <dali/integration-api/debug.h>
26 #include <dali/public-api/object/base-object.h>
29 #include <tts-player.h>
41 * Text-to-speech player
43 class TtsPlayer : public Dali::BaseObject
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.
54 static Dali::TtsPlayer New(Dali::TtsPlayer::Mode mode);
57 * @copydoc TtsPlayer::Play()
59 void Play(const std::string& text);
62 * @copydoc TtsPlayer::Stop()
67 * @copydoc TtsPlayer::Pause()
72 * @copydoc TtsPlayer::Resume()
79 * Private Constructor; see also TtsPlayer::New()
80 * @param mode the mode of tts-player
82 TtsPlayer(Dali::TtsPlayer::Mode mode);
90 * Initializes the player.
95 * Logs the error code.
96 * @param[in] reason The error code
98 void LogErrorCode(tts_error_e reason);
101 * Called when the state of TTS is changed.
103 * @param[in] tts The handle for TTS
104 * @param[in] previous A previous state
105 * @param[in] current A current state
106 * @param[in] userData The user data passed from the callback registration function.
108 static void StateChangedCallback(tts_h tts, tts_state_e previous, tts_state_e current, void *userData);
111 TtsPlayer(const TtsPlayer&);
114 TtsPlayer& operator=(TtsPlayer&);
118 bool mInitialized; ///< Whether the TTS player is initialised successfully or not
119 std::string mUnplayedString; ///< The text that can not be played because tts engine is not yet initialized
120 tts_h mTtsHandle; ///< The handle of TTS
121 int mUtteranceId; ///< The utterance ID
123 Dali::TtsPlayer::Mode mTtsMode; ///< The current mode of tts engine
125 #if defined(DEBUG_ENABLED)
127 static Debug::Filter* gLogFilter;
131 } // namespace Adaptor
133 } // namespace Internal
135 // Helpers for public-api forwarding methods
137 inline Internal::Adaptor::TtsPlayer& GetImplementation(Dali::TtsPlayer& player)
139 DALI_ASSERT_ALWAYS( player && "TtsPlayer handle is empty" );
141 BaseObject& handle = player.GetBaseObject();
143 return static_cast<Internal::Adaptor::TtsPlayer&>(handle);
146 inline const Internal::Adaptor::TtsPlayer& GetImplementation(const Dali::TtsPlayer& player)
148 DALI_ASSERT_ALWAYS( player && "TtsPlayer handle is empty" );
150 const BaseObject& handle = player.GetBaseObject();
152 return static_cast<const Internal::Adaptor::TtsPlayer&>(handle);
157 #endif // __DALI_INTERNAL_TTS_PLAYER_H__