OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... | |
28 public: | 28 public: |
29 enum class AudioFrameInfo { | 29 enum class AudioFrameInfo { |
30 kNormal, // The samples in audio_frame are valid and should be used. | 30 kNormal, // The samples in audio_frame are valid and should be used. |
31 kMuted, // The samples in audio_frame should not be used, but | 31 kMuted, // The samples in audio_frame should not be used, but |
32 // should be implicitly interpreted as zero. Other | 32 // should be implicitly interpreted as zero. Other |
33 // fields in audio_frame may be read and should | 33 // fields in audio_frame may be read and should |
34 // contain meaningful values. | 34 // contain meaningful values. |
35 kError, // The audio_frame will not be used. | 35 kError, // The audio_frame will not be used. |
36 }; | 36 }; |
37 | 37 |
38 struct AudioFrameWithInfo { | 38 // Overwrites |audio_frame|. The data_ field is overwritten with |
hlundin-webrtc
2016/10/18 22:16:13
So, the data_ field is overwritten, but what other
aleloi
2016/10/19 09:56:46
That is a good question. The simple answer is 'all
aleloi
2016/10/19 11:33:40
I just realized that I answered the wrong question
| |
39 AudioFrame* audio_frame; | 39 // 10 ms of new audio (either 1 or 2 interleaved channels) at |
40 AudioFrameInfo audio_frame_info; | 40 // |sample_rate_hz|. |
41 }; | 41 virtual AudioFrameInfo GetAudioFrameWithInfo(int sample_rate_hz, |
42 | 42 AudioFrame* audio_frame) = 0; |
43 // The implementation of GetAudioFrameWithInfo should update | |
44 // audio_frame with new audio every time it's called. Implementing | |
45 // classes are allowed to return the same AudioFrame pointer on | |
46 // different calls. The pointer must stay valid until the next | |
47 // mixing call or until this audio source is disconnected from the | |
48 // mixer. The mixer may modify the contents of the passed | |
49 // AudioFrame pointer at any time until the next call to | |
50 // GetAudioFrameWithInfo, or until the source is removed from the | |
51 // mixer. | |
52 virtual AudioFrameWithInfo GetAudioFrameWithInfo(int sample_rate_hz) = 0; | |
53 | 43 |
54 // A way for a mixer implementation to distinguish participants. | 44 // A way for a mixer implementation to distinguish participants. |
55 virtual int Ssrc() = 0; | 45 virtual int Ssrc() = 0; |
56 | 46 |
57 protected: | |
58 virtual ~Source() {} | 47 virtual ~Source() {} |
59 }; | 48 }; |
60 | 49 |
61 // Since the mixer is reference counted, the destructor may be | |
62 // called from any thread. | |
63 ~AudioMixer() override {} | |
64 | |
65 // Returns true if adding/removing was successful. A source is never | 50 // Returns true if adding/removing was successful. A source is never |
66 // added twice and removal is never attempted if a source has not | 51 // added twice and removal is never attempted if a source has not |
67 // been successfully added to the mixer. Addition and removal can | 52 // been successfully added to the mixer. Addition and removal can |
68 // happen on different threads. | 53 // happen on different threads. |
69 virtual bool AddSource(Source* audio_source) = 0; | 54 virtual bool AddSource(Source* audio_source) = 0; |
70 virtual bool RemoveSource(Source* audio_source) = 0; | 55 virtual bool RemoveSource(Source* audio_source) = 0; |
71 | 56 |
72 // Performs mixing by asking registered audio sources for audio. The | 57 // Performs mixing by asking registered audio sources for audio. The |
73 // mixed result is placed in the provided AudioFrame. Will only be | 58 // mixed result is placed in the provided AudioFrame. Will only be |
74 // called from a single thread. The rate and channels arguments | 59 // called from a single thread. The rate and channels arguments |
75 // specify the rate and number of channels of the mix result. | 60 // specify the rate and number of channels of the mix result. |
76 virtual void Mix(int sample_rate_hz, | 61 virtual void Mix(int sample_rate_hz, |
77 size_t number_of_channels, | 62 size_t number_of_channels, |
78 AudioFrame* audio_frame_for_mixing) = 0; | 63 AudioFrame* audio_frame_for_mixing) = 0; |
64 | |
65 protected: | |
66 // Since the mixer is reference counted, the destructor may be | |
67 // called from any thread. | |
68 ~AudioMixer() override {} | |
79 }; | 69 }; |
80 } // namespace webrtc | 70 } // namespace webrtc |
81 | 71 |
82 #endif // WEBRTC_API_AUDIO_AUDIO_MIXER_H_ | 72 #endif // WEBRTC_API_AUDIO_AUDIO_MIXER_H_ |
OLD | NEW |