content/media/webspeech/synth/nsSpeechTask.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/webspeech/synth/nsSpeechTask.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,93 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef mozilla_dom_nsSpeechTask_h
    1.11 +#define mozilla_dom_nsSpeechTask_h
    1.12 +
    1.13 +#include "MediaStreamGraph.h"
    1.14 +#include "SpeechSynthesisUtterance.h"
    1.15 +#include "nsISpeechService.h"
    1.16 +
    1.17 +namespace mozilla {
    1.18 +namespace dom {
    1.19 +
    1.20 +class SpeechSynthesisUtterance;
    1.21 +class SpeechSynthesis;
    1.22 +class SynthStreamListener;
    1.23 +
    1.24 +class nsSpeechTask : public nsISpeechTask
    1.25 +{
    1.26 +  friend class SynthStreamListener;
    1.27 +
    1.28 +public:
    1.29 +  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    1.30 +  NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsSpeechTask, nsISpeechTask)
    1.31 +
    1.32 +  NS_DECL_NSISPEECHTASK
    1.33 +
    1.34 +  nsSpeechTask(SpeechSynthesisUtterance* aUtterance);
    1.35 +  nsSpeechTask(float aVolume, const nsAString& aText);
    1.36 +
    1.37 +  virtual ~nsSpeechTask();
    1.38 +
    1.39 +  virtual void Pause();
    1.40 +
    1.41 +  virtual void Resume();
    1.42 +
    1.43 +  virtual void Cancel();
    1.44 +
    1.45 +  float GetCurrentTime();
    1.46 +
    1.47 +  uint32_t GetCurrentCharOffset();
    1.48 +
    1.49 +  void SetSpeechSynthesis(SpeechSynthesis* aSpeechSynthesis);
    1.50 +
    1.51 +  void SetIndirectAudio(bool aIndirectAudio) { mIndirectAudio = aIndirectAudio; }
    1.52 +
    1.53 +protected:
    1.54 +  virtual nsresult DispatchStartImpl();
    1.55 +
    1.56 +  virtual nsresult DispatchEndImpl(float aElapsedTime, uint32_t aCharIndex);
    1.57 +
    1.58 +  virtual nsresult DispatchPauseImpl(float aElapsedTime, uint32_t aCharIndex);
    1.59 +
    1.60 +  virtual nsresult DispatchResumeImpl(float aElapsedTime, uint32_t aCharIndex);
    1.61 +
    1.62 +  virtual nsresult DispatchErrorImpl(float aElapsedTime, uint32_t aCharIndex);
    1.63 +
    1.64 +  virtual nsresult DispatchBoundaryImpl(const nsAString& aName,
    1.65 +                                        float aElapsedTime,
    1.66 +                                        uint32_t aCharIndex);
    1.67 +
    1.68 +  virtual nsresult DispatchMarkImpl(const nsAString& aName,
    1.69 +                                    float aElapsedTime, uint32_t aCharIndex);
    1.70 +
    1.71 +  nsRefPtr<SpeechSynthesisUtterance> mUtterance;
    1.72 +
    1.73 +  float mVolume;
    1.74 +
    1.75 +  nsString mText;
    1.76 +
    1.77 +private:
    1.78 +  void End();
    1.79 +
    1.80 +  void SendAudioImpl(int16_t* aData, uint32_t aDataLen);
    1.81 +
    1.82 +  nsRefPtr<SourceMediaStream> mStream;
    1.83 +
    1.84 +  nsCOMPtr<nsISpeechTaskCallback> mCallback;
    1.85 +
    1.86 +  uint32_t mChannels;
    1.87 +
    1.88 +  nsRefPtr<SpeechSynthesis> mSpeechSynthesis;
    1.89 +
    1.90 +  bool mIndirectAudio;
    1.91 +};
    1.92 +
    1.93 +} // namespace dom
    1.94 +} // namespace mozilla
    1.95 +
    1.96 +#endif

mercurial