8b07ad9daf3f47a0c778e56b07e9281c31c51054
[platform/framework/web/crosswalk-tizen.git] /
1 // Copyright (c) 2014 Samsung Electronics Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BROWSER_SPEECH_TTS_TIZEN_H_
6 #define BROWSER_SPEECH_TTS_TIZEN_H_
7
8 #include "build/tizen_version.h"
9
10 typedef int tts_voice_type_e;
11
12 #include "content/browser/speech/tts_message_filter_efl.h"
13 #include "content/common/tts_utterance_request_efl.h"
14
15 #include <tts.h>
16 #include <vector>
17
18 namespace content {
19 class TtsMessageFilterEfl;
20
21 // TtsTizen is the class that actually communicate with tts engine.
22 // It handles tts instance, callbacks and callback returns
23 class TtsTizen {
24  public:
25   TtsTizen(TtsMessageFilterEfl* tts_message_filter_efl);
26   ~TtsTizen();
27   bool Init();
28
29   // Return voice list
30   const std::vector<TtsVoice>& GetVoiceList();
31   void Speak(const TtsUtteranceRequest& utterance);
32   void Pause();
33   void Resume();
34   void Cancel();
35   tts_h GetTTS() { return tts_handle_; }
36   TtsMessageFilterEfl* GetTtsMessageFilterEfl() {
37     return tts_message_filter_efl_; }
38   const TtsUtteranceRequest& GetUtterance() const { return utterance_; }
39   void TtsReady();
40
41   // Get voices one by one from tts engine, append them into a voice list
42   void AddVoice(std::string language, tts_voice_type_e name);
43   bool IsTtsInitialized() const { return tts_initialized_; }
44
45  private:
46   // Create and Set tts and tts callback. If any of these failes, tts will not work at all.
47   bool SetTtsCallback();
48   void StoreTtsDefaultVoice();
49   void SpeakStoredUtterance();
50   TtsMessageFilterEfl* tts_message_filter_efl_;
51   TtsUtteranceRequest utterance_;
52   tts_h tts_handle_;
53   std::string default_language_;
54   tts_voice_type_e default_voice_;
55
56   // This variable stores list of voicees that tts engine support.
57   std::vector<TtsVoice> voice_list_;
58
59   // This variable check whether tts is initialized.
60   // It will be true when tts engine set the variable tts_.
61   bool tts_initialized_;
62
63   // This variable check whether tts is ready, after initialized.
64   // Initial value is false and it will be true when tts state change to
65   // TTS_STATE_CREATED && TTS_STATE_READY.
66   bool tts_state_ready_;
67
68   // This variable check whether any utterance is currently wating to speak.
69   bool utterance_waiting_;
70 };
71
72 }  // namespace content
73
74 #endif // BROWSER_SPEECH_TTS_TIZEN_H_