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) 2021 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/internal/accessibility/common/tts-player-impl.h>
31 #include <dali/public-api/adaptor-framework/tts-player.h>
40 * Text-to-speech player
42 class TtsPlayerTizen : public Dali::Internal::Adaptor::TtsPlayer
46 * Create a TtsPlayer with the given mode.
47 * This should only be called once by the Adaptor class for each given mode.
48 * @param mode the mode of tts-player
49 * @return A newly created TtsPlayer.
51 static std::unique_ptr<TtsPlayerTizen> New(Dali::TtsPlayer::Mode mode);
54 * @copydoc TtsPlayer::Play()
56 void Play(const std::string& text) override;
59 * @copydoc TtsPlayer::Stop()
64 * @copydoc TtsPlayer::Pause()
66 void Pause() override;
69 * @copydoc TtsPlayer::Resume()
71 void Resume() override;
74 * @copydoc TtsPlayer::GetState()
76 Dali::TtsPlayer::State GetState() override;
79 * @copydoc TtsPlayer::StateChangedSignal()
81 Dali::TtsPlayer::StateChangedSignalType& StateChangedSignal() override;
86 ~TtsPlayerTizen() override;
90 * Private Constructor; see also TtsPlayer::New()
91 * @param mode the mode of tts-player
93 TtsPlayerTizen(Dali::TtsPlayer::Mode mode);
96 * Initializes the player.
101 * Logs the error code.
102 * @param[in] reason The error code
104 void LogErrorCode(tts_error_e reason);
107 * Used to emit the state changed signal from outside the object (EG. A static function).
108 * @param[in] previous The previous state
109 * @param[in] current The current state
111 void EmitStateChangedSignal(tts_state_e previous, tts_state_e current);
114 * Called when the state of TTS is changed.
116 * @param[in] tts The handle for TTS
117 * @param[in] previous A previous state
118 * @param[in] current A current state
119 * @param[in] userData The user data passed from the callback registration function.
121 static void StateChangedCallback(tts_h tts, tts_state_e previous, tts_state_e current, void* userData);
124 TtsPlayerTizen(const TtsPlayerTizen&);
127 TtsPlayerTizen& operator=(TtsPlayerTizen&);
130 Dali::TtsPlayer::StateChangedSignalType mStateChangedSignal; ///< Signal emitted when the TTS state changes
131 bool mInitialized; ///< Whether the TTS player is initialised successfully or not
132 std::string mUnplayedString; ///< The text that can not be played because tts engine is not yet initialized
133 tts_h mTtsHandle; ///< The handle of TTS
134 int mUtteranceId; ///< The utterance ID
136 Dali::TtsPlayer::Mode mTtsMode; ///< The current mode of tts engine
138 #if defined(DEBUG_ENABLED)
140 static Debug::Filter* gLogFilter;
144 } // namespace Adaptor
146 } // namespace Internal
150 #endif // DALI_INTERNAL_ACCESSIBILITY_TIZEN_TTS_PLAYER_IMPL_TIZEN_H