1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
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/. */
7 #ifndef mozilla_dom_SpeechStreamListener_h
8 #define mozilla_dom_SpeechStreamListener_h
10 #include "MediaTrackGraph.h"
11 #include "MediaTrackListener.h"
12 #include "AudioSegment.h"
13 #include "mozilla/MozPromise.h"
21 class SpeechRecognition
;
23 class SpeechTrackListener
: public MediaTrackListener
{
25 explicit SpeechTrackListener(SpeechRecognition
* aRecognition
);
28 static already_AddRefed
<SpeechTrackListener
> Create(
29 SpeechRecognition
* aRecognition
);
31 ~SpeechTrackListener() = default;
33 void NotifyQueuedChanges(MediaTrackGraph
* aGraph
, TrackTime aTrackOffset
,
34 const MediaSegment
& aQueuedMedia
) override
;
36 void NotifyEnded(MediaTrackGraph
* aGraph
) override
;
38 void NotifyRemoved(MediaTrackGraph
* aGraph
) override
;
41 template <typename SampleFormatType
>
42 void ConvertAndDispatchAudioChunk(int aDuration
, float aVolume
,
43 SampleFormatType
* aData
,
44 TrackRate aTrackRate
);
45 nsMainThreadPtrHandle
<SpeechRecognition
> mRecognition
;
46 MozPromiseHolder
<GenericNonExclusivePromise
> mRemovedHolder
;
49 const RefPtr
<GenericNonExclusivePromise
> mRemovedPromise
;
53 } // namespace mozilla