1 #ifndef DALI_INTERNAL_ACCESSIBILITY_TIZEN_TTS_PLAYER_IMPL_TIZEN_H
2 #define DALI_INTERNAL_ACCESSIBILITY_TIZEN_TTS_PLAYER_IMPL_TIZEN_H
5 * Copyright (c) 2018 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.
26 #include <dali/integration-api/debug.h>
27 #include <dali/public-api/object/base-object.h>
30 #include <dali/public-api/adaptor-framework/tts-player.h>
31 #include <dali/internal/accessibility/common/tts-player-impl.h>
43 * Text-to-speech player
45 class TtsPlayerTizen : public Dali::Internal::Adaptor::TtsPlayer
51 * Create a TtsPlayer with the given mode.
52 * This should only be called once by the Adaptor class for each given mode.
53 * @param mode the mode of tts-player
54 * @return A newly created TtsPlayer.
56 static std::unique_ptr<TtsPlayerTizen> New(Dali::TtsPlayer::Mode mode);
59 * @copydoc TtsPlayer::Play()
61 void Play(const std::string& text) override;
64 * @copydoc TtsPlayer::Stop()
69 * @copydoc TtsPlayer::Pause()
71 void Pause() override;
74 * @copydoc TtsPlayer::Resume()
76 void Resume() override;
79 * @copydoc TtsPlayer::GetState()
81 Dali::TtsPlayer::State GetState() override;
84 * @copydoc TtsPlayer::StateChangedSignal()
86 Dali::TtsPlayer::StateChangedSignalType& StateChangedSignal() override;
91 ~TtsPlayerTizen() override;
96 * Private Constructor; see also TtsPlayer::New()
97 * @param mode the mode of tts-player
99 TtsPlayerTizen(Dali::TtsPlayer::Mode mode);
102 * Initializes the player.
107 * Logs the error code.
108 * @param[in] reason The error code
110 void LogErrorCode(tts_error_e reason);
113 * Used to emit the state changed signal from outside the object (EG. A static function).
114 * @param[in] previous The previous state
115 * @param[in] current The current state
117 void EmitStateChangedSignal( tts_state_e previous, tts_state_e current );
120 * Called when the state of TTS is changed.
122 * @param[in] tts The handle for TTS
123 * @param[in] previous A previous state
124 * @param[in] current A current state
125 * @param[in] userData The user data passed from the callback registration function.
127 static void StateChangedCallback(tts_h tts, tts_state_e previous, tts_state_e current, void *userData);
130 TtsPlayerTizen(const TtsPlayerTizen&);
133 TtsPlayerTizen& operator=(TtsPlayerTizen&);
137 Dali::TtsPlayer::StateChangedSignalType mStateChangedSignal; ///< Signal emitted when the TTS state changes
138 bool mInitialized; ///< Whether the TTS player is initialised successfully or not
139 std::string mUnplayedString; ///< The text that can not be played because tts engine is not yet initialized
140 tts_h mTtsHandle; ///< The handle of TTS
141 int mUtteranceId; ///< The utterance ID
143 Dali::TtsPlayer::Mode mTtsMode; ///< The current mode of tts engine
145 #if defined(DEBUG_ENABLED)
147 static Debug::Filter* gLogFilter;
151 } // namespace Adaptor
153 } // namespace Internal
157 #endif // DALI_INTERNAL_ACCESSIBILITY_TIZEN_TTS_PLAYER_IMPL_TIZEN_H