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 |
11 #ifndef WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_ |
12 #define WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_ | 12 #define WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_ |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 | 15 |
16 #include "webrtc/base/refcount.h" | |
16 #include "webrtc/modules/include/module_common_types.h" | 17 #include "webrtc/modules/include/module_common_types.h" |
17 | 18 |
18 namespace webrtc { | 19 namespace webrtc { |
19 | 20 |
20 class AudioMixer { | 21 class AudioMixer : public rtc::RefCountInterface { |
21 public: | 22 public: |
22 static const int kMaximumAmountOfMixedAudioSources = 3; | |
23 // A callback class that all mixer participants must inherit from/implement. | 23 // A callback class that all mixer participants must inherit from/implement. |
24 class Source { | 24 class Source { |
25 public: | 25 public: |
26 enum class AudioFrameInfo { | 26 enum class AudioFrameInfo { |
27 kNormal, // The samples in audio_frame are valid and should be used. | 27 kNormal, // The samples in audio_frame are valid and should be used. |
28 kMuted, // The samples in audio_frame should not be used, but should be | 28 kMuted, // The samples in audio_frame should not be used, but should be |
29 // implicitly interpreted as zero. Other fields in audio_frame | 29 // implicitly interpreted as zero. Other fields in audio_frame |
30 // may be read and should contain meaningful values. | 30 // may be read and should contain meaningful values. |
31 kError // audio_frame will not be used. | 31 kError // audio_frame will not be used. |
32 }; | 32 }; |
33 | 33 |
34 struct AudioFrameWithMuted { | 34 struct AudioFrameWithMuted { |
35 AudioFrame* audio_frame; | 35 AudioFrame* audio_frame; |
36 AudioFrameInfo audio_frame_info; | 36 AudioFrameInfo audio_frame_info; |
37 }; | 37 }; |
38 | 38 |
39 // The implementation of GetAudioFrameWithMuted should update | 39 // The implementation of GetAudioFrameWithMuted should update |
40 // audio_frame with new audio every time it's called. Implementing | 40 // audio_frame with new audio every time it's called. Implementing |
41 // classes are allowed to return the same AudioFrame pointer on | 41 // classes are allowed to return the same AudioFrame pointer on |
42 // different calls. The pointer must stay valid until the next | 42 // different calls. The pointer must stay valid until the next |
43 // mixing call or until this audio source is disconnected from the | 43 // mixing call or until this audio source is disconnected from the |
44 // mixer. | 44 // mixer. |
45 virtual AudioFrameWithMuted GetAudioFrameWithMuted(int sample_rate_hz) = 0; | 45 virtual AudioFrameWithMuted GetAudioFrameWithMuted(int sample_rate_hz) = 0; |
46 | 46 |
47 // A way for a mixer implementation do distinguish participants. | |
48 virtual int ssrc() = 0; | |
49 | |
47 protected: | 50 protected: |
48 virtual ~Source() {} | 51 virtual ~Source() {} |
49 }; | 52 }; |
50 | 53 |
51 // Factory method. Constructor disabled. | 54 ~AudioMixer() override {} |
52 static std::unique_ptr<AudioMixer> Create(); | |
53 virtual ~AudioMixer() {} | |
54 | 55 |
55 // Add/remove audio sources as candidates for mixing. | 56 // Returns true if adding/removing was successful. Adding the same |
56 virtual int32_t SetMixabilityStatus(Source* audio_source, bool mixable) = 0; | 57 // source twice is forbidden, as is removing a source that is not |
hlundin-webrtc
2016/10/11 11:50:21
Does it have to be "forbidden" in all implementati
the sun
2016/10/11 12:10:55
It's important to not mix up the interface and the
hlundin-webrtc
2016/10/11 12:49:54
OK, solenberg, your turn to have a go at formulati
aleloi
2016/10/12 10:20:53
We want to point out that Add / remove mustn't be
| |
58 // present. | |
59 virtual bool AddSource(Source* audio_source) = 0; | |
60 virtual bool RemoveSource(Source* audio_source) = 0; | |
57 | 61 |
58 // Performs mixing by asking registered audio sources for audio. The | 62 // Performs mixing by asking registered audio sources for audio. The |
59 // mixed result is placed in the provided AudioFrame. Will only be | 63 // mixed result is placed in the provided AudioFrame. Will only be |
60 // called from a single thread. The rate and channels arguments | 64 // called from a single thread. The rate and channels arguments |
61 // specify the rate and number of channels of the mix result. | 65 // specify the rate and number of channels of the mix result. |
62 virtual void Mix(int sample_rate_hz, | 66 virtual void Mix(int sample_rate_hz, |
63 size_t number_of_channels, | 67 size_t number_of_channels, |
64 AudioFrame* audio_frame_for_mixing) = 0; | 68 AudioFrame* audio_frame_for_mixing) = 0; |
65 }; | 69 }; |
66 } // namespace webrtc | 70 } // namespace webrtc |
67 | 71 |
68 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_ | 72 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_ |
OLD | NEW |