Line data Source code
1 : /* This Source Code Form is subject to the terms of the Mozilla Public
2 : * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 : * You can obtain one at http://mozilla.org/MPL/2.0/. */
4 :
5 : #ifndef AUDIOOUTPUTOBSERVER_H_
6 : #define AUDIOOUTPUTOBSERVER_H_
7 :
8 : #include "mozilla/StaticPtr.h"
9 : #include "nsAutoPtr.h"
10 : #include "AudioMixer.h"
11 :
12 : namespace webrtc {
13 : class SingleRwFifo;
14 : }
15 :
16 : namespace mozilla {
17 :
18 : typedef struct FarEndAudioChunk_ {
19 : uint16_t mSamples;
20 : bool mOverrun;
21 : int16_t mData[1]; // variable-length
22 : } FarEndAudioChunk;
23 :
24 : // This class is used to packetize and send the mixed audio from an MSG, in
25 : // int16, to the AEC module of WebRTC.org.
26 : class AudioOutputObserver
27 : {
28 : public:
29 : AudioOutputObserver();
30 :
31 0 : NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AudioOutputObserver);
32 :
33 : void Clear();
34 : void InsertFarEnd(const AudioDataValue *aBuffer, uint32_t aFrames, bool aOverran,
35 : int aFreq, int aChannels);
36 0 : uint32_t PlayoutFrequency() { return mPlayoutFreq; }
37 0 : uint32_t PlayoutChannels() { return mPlayoutChannels; }
38 :
39 : FarEndAudioChunk *Pop();
40 : uint32_t Size();
41 :
42 : private:
43 : virtual ~AudioOutputObserver();
44 : uint32_t mPlayoutFreq;
45 : uint32_t mPlayoutChannels;
46 :
47 : nsAutoPtr<webrtc::SingleRwFifo> mPlayoutFifo;
48 : uint32_t mChunkSize;
49 :
50 : // chunking to 10ms support
51 : FarEndAudioChunk *mSaved; // can't be nsAutoPtr since we need to use free(), not delete
52 : uint32_t mSamplesSaved;
53 : };
54 :
55 : extern StaticRefPtr<AudioOutputObserver> gFarendObserver;
56 :
57 : }
58 :
59 : #endif
|