• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3  *
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
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_INTERFACE_AUDIO_CONFERENCE_MIXER_DEFINES_H_
12 #define WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_INTERFACE_AUDIO_CONFERENCE_MIXER_DEFINES_H_
13 
14 #include "webrtc/modules/interface/module_common_types.h"
15 #include "webrtc/typedefs.h"
16 
17 namespace webrtc {
18 class MixHistory;
19 
20 // A callback class that all mixer participants must inherit from/implement.
21 class MixerParticipant
22 {
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     virtual int32_t GetAudioFrame(const int32_t id, AudioFrame& audioFrame) = 0;
29 
30     // mixed will be set to true if the participant was mixed this mix iteration
31     int32_t IsMixed(bool& mixed) const;
32 
33     // This function specifies the sampling frequency needed for the AudioFrame
34     // for future GetAudioFrame(..) calls.
35     virtual int32_t NeededFrequency(const int32_t id) = 0;
36 
37     MixHistory* _mixHistory;
38 protected:
39     MixerParticipant();
40     virtual ~MixerParticipant();
41 };
42 
43 // Container struct for participant statistics.
44 struct ParticipantStatistics
45 {
46     int32_t participant;
47     int32_t level;
48 };
49 
50 class AudioMixerStatusReceiver
51 {
52 public:
53     // Callback function that provides an array of ParticipantStatistics for the
54     // participants that were mixed last mix iteration.
55     virtual void MixedParticipants(
56         const int32_t id,
57         const ParticipantStatistics* participantStatistics,
58         const uint32_t size) = 0;
59     // Callback function that provides an array of the ParticipantStatistics for
60     // the participants that had a positiv VAD last mix iteration.
61     virtual void VADPositiveParticipants(
62         const int32_t id,
63         const ParticipantStatistics* participantStatistics,
64         const uint32_t size) = 0;
65     // Callback function that provides the audio level of the mixed audio frame
66     // from the last mix iteration.
67     virtual void MixedAudioLevel(
68         const int32_t  id,
69         const uint32_t level) = 0;
70 protected:
AudioMixerStatusReceiver()71     AudioMixerStatusReceiver() {}
~AudioMixerStatusReceiver()72     virtual ~AudioMixerStatusReceiver() {}
73 };
74 
75 class AudioMixerOutputReceiver
76 {
77 public:
78     // This callback function provides the mixed audio for this mix iteration.
79     // Note that uniqueAudioFrames is an array of AudioFrame pointers with the
80     // size according to the size parameter.
81     virtual void NewMixedAudio(const int32_t id,
82                                const AudioFrame& generalAudioFrame,
83                                const AudioFrame** uniqueAudioFrames,
84                                const uint32_t size) = 0;
85 protected:
AudioMixerOutputReceiver()86     AudioMixerOutputReceiver() {}
~AudioMixerOutputReceiver()87     virtual ~AudioMixerOutputReceiver() {}
88 };
89 }  // namespace webrtc
90 
91 #endif // WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_INTERFACE_AUDIO_CONFERENCE_MIXER_DEFINES_H_
92