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_INCLUDE_AUDIO_MIXER_DEFINES_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_MIXER_INCLUDE_AUDIO_MIXER_DEFINES_H_ |
12 #define WEBRTC_MODULES_AUDIO_MIXER_INCLUDE_AUDIO_MIXER_DEFINES_H_ | 12 #define WEBRTC_MODULES_AUDIO_MIXER_INCLUDE_AUDIO_MIXER_DEFINES_H_ |
13 | 13 |
14 #include "webrtc/base/checks.h" | 14 #include "webrtc/base/checks.h" |
15 #include "webrtc/modules/include/module_common_types.h" | 15 #include "webrtc/modules/include/module_common_types.h" |
16 #include "webrtc/typedefs.h" | 16 #include "webrtc/typedefs.h" |
17 | 17 |
18 namespace webrtc { | 18 namespace webrtc { |
19 class NewMixHistory; | 19 class NewMixHistory; |
20 | 20 |
21 // A callback class that all mixer participants must inherit from/implement. | 21 // A callback class that all mixer participants must inherit from/implement. |
22 class MixerAudioSource { | 22 class MixerAudioSource { |
23 public: | 23 public: |
24 // The implementation of this function should update audioFrame with new | |
25 // audio every time it's called. | |
26 // | |
27 // If it returns -1, the frame will not be added to the mix. | |
28 // | |
29 // NOTE: This function should not be called. It will remain for a short | |
30 // time so that subclasses can override it without getting warnings. | |
31 // TODO(henrik.lundin) Remove this function. | |
32 virtual int32_t GetAudioFrame(int32_t id, AudioFrame* audioFrame) { | |
33 RTC_CHECK(false); | |
34 return -1; | |
35 } | |
36 | |
37 // The implementation of GetAudioFrameWithMuted should update audio_frame | |
38 // with new audio every time it's called. The return value will be | |
39 // interpreted as follows. | |
40 enum class AudioFrameInfo { | 24 enum class AudioFrameInfo { |
41 kNormal, // The samples in audio_frame are valid and should be used. | 25 kNormal, // The samples in audio_frame are valid and should be used. |
42 kMuted, // The samples in audio_frame should not be used, but should be | 26 kMuted, // The samples in audio_frame should not be used, but should be |
43 // implicitly interpreted as zero. Other fields in audio_frame | 27 // implicitly interpreted as zero. Other fields in audio_frame |
44 // may be read and should contain meaningful values. | 28 // may be read and should contain meaningful values. |
45 kError // audio_frame will not be used. | 29 kError // audio_frame will not be used. |
46 }; | 30 }; |
47 | 31 |
48 virtual AudioFrameInfo GetAudioFrameWithMuted(int32_t id, | 32 struct AudioFrameWithInfo { |
49 AudioFrame* audio_frame) { | 33 AudioFrame* audio_frame; |
50 return GetAudioFrame(id, audio_frame) == -1 ? AudioFrameInfo::kError | 34 AudioFrameInfo audio_frame_info; |
51 : AudioFrameInfo::kNormal; | 35 }; |
52 } | 36 |
| 37 // The implementation of GetAudioFrameWithMuted should update |
| 38 // audio_frame with new audio every time it's called. Implementing |
| 39 // classes are allowed to return the same AudioFrame pointer on |
| 40 // different calls. The pointer must stay valid until the next |
| 41 // mixing call or until this audio source is disconnected from the |
| 42 // mixer. |
| 43 virtual AudioFrameWithInfo GetAudioFrameWithMuted(int32_t id, |
| 44 int sample_rate_hz) = 0; |
53 | 45 |
54 // Returns true if the participant was mixed this mix iteration. | 46 // Returns true if the participant was mixed this mix iteration. |
55 bool IsMixed() const; | 47 bool IsMixed() const; |
56 | 48 |
57 // This function specifies the sampling frequency needed for the AudioFrame | 49 // This function specifies the sampling frequency needed for the AudioFrame |
58 // for future GetAudioFrame(..) calls. | 50 // for future GetAudioFrame(..) calls. |
59 virtual int32_t NeededFrequency(int32_t id) const = 0; | 51 virtual int32_t NeededFrequency(int32_t id) const = 0; |
60 | 52 |
61 NewMixHistory* _mixHistory; | 53 NewMixHistory* _mixHistory; |
62 | 54 |
63 protected: | 55 protected: |
64 MixerAudioSource(); | 56 MixerAudioSource(); |
65 virtual ~MixerAudioSource(); | 57 virtual ~MixerAudioSource(); |
66 }; | 58 }; |
67 } // namespace webrtc | 59 } // namespace webrtc |
68 | 60 |
69 #endif // WEBRTC_MODULES_AUDIO_MIXER_INCLUDE_AUDIO_MIXER_DEFINES_H_ | 61 #endif // WEBRTC_MODULES_AUDIO_MIXER_INCLUDE_AUDIO_MIXER_DEFINES_H_ |
OLD | NEW |