Bug 1943761 - Add class alignment to the mozsearch analysis file. r=asuth
[gecko.git] / dom / media / webspeech / recognition / SpeechTrackListener.h
blobaa41be379c493266dd4c017e8722a76efbeb6cee
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"
15 namespace mozilla {
17 class AudioSegment;
19 namespace dom {
21 class SpeechRecognition;
23 class SpeechTrackListener : public MediaTrackListener {
24 private:
25 explicit SpeechTrackListener(SpeechRecognition* aRecognition);
27 public:
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;
40 private:
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;
48 public:
49 const RefPtr<GenericNonExclusivePromise> mRemovedPromise;
52 } // namespace dom
53 } // namespace mozilla
55 #endif