tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

SpeechSynthesisService.h (2061B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_dom_SpeechSynthesisService_h
      8 #define mozilla_dom_SpeechSynthesisService_h
      9 
     10 #include "mozilla/StaticPtr.h"
     11 #include "mozilla/java/SpeechSynthesisServiceNatives.h"
     12 #include "nsISpeechService.h"
     13 
     14 namespace mozilla {
     15 namespace dom {
     16 
     17 class SpeechSynthesisService final
     18    : public nsISpeechService,
     19      public java::SpeechSynthesisService::Natives<SpeechSynthesisService> {
     20 public:
     21  NS_DECL_ISUPPORTS
     22  NS_DECL_NSISPEECHSERVICE
     23 
     24  SpeechSynthesisService() {};
     25 
     26  void Setup();
     27 
     28  static void DoneRegisteringVoices();
     29 
     30  static void RegisterVoice(jni::String::Param aUri, jni::String::Param aName,
     31                            jni::String::Param aLocale, bool aIsNetwork,
     32                            bool aIsDefault);
     33 
     34  static void DispatchStart(jni::String::Param aUtteranceId);
     35 
     36  static void DispatchEnd(jni::String::Param aUtteranceId);
     37 
     38  static void DispatchError(jni::String::Param aUtteranceId);
     39 
     40  static void DispatchBoundary(jni::String::Param aUtteranceId, int32_t aStart,
     41                               int32_t aEnd);
     42 
     43  static SpeechSynthesisService* GetInstance(bool aCreate = true);
     44  static already_AddRefed<SpeechSynthesisService> GetInstanceForService();
     45 
     46  static StaticRefPtr<SpeechSynthesisService> sSingleton;
     47 
     48 private:
     49  virtual ~SpeechSynthesisService() {};
     50 
     51  nsCOMPtr<nsISpeechTask> mTask;
     52 
     53  // Unique ID assigned to utterance when it is sent to system service.
     54  nsCString mTaskUtteranceId;
     55 
     56  // Time stamp from the moment the utterance is started.
     57  TimeStamp mTaskStartTime;
     58 
     59  // Length of text of the utterance.
     60  uint32_t mTaskTextLength;
     61 
     62  // Current offset in characters of what has been spoken.
     63  uint32_t mTaskTextOffset;
     64 };
     65 
     66 }  // namespace dom
     67 }  // namespace mozilla
     68 #endif