1b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org/*
2b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *
4b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  Use of this source code is governed by a BSD-style license
5b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  that can be found in the LICENSE file in the root of the source
6b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  tree. An additional intellectual property rights grant can be found
7b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  in the file PATENTS.  All contributing project authors may
8b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  be found in the AUTHORS file in the root of the source tree.
9b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org */
10b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
11b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org#ifndef WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_INTERFACE_AUDIO_CONFERENCE_MIXER_DEFINES_H_
12b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org#define WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_INTERFACE_AUDIO_CONFERENCE_MIXER_DEFINES_H_
13b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
140c836bfad33cbd3517e2c145cc24241fb98967d8pbos@webrtc.org#include "webrtc/modules/interface/module_common_types.h"
150c836bfad33cbd3517e2c145cc24241fb98967d8pbos@webrtc.org#include "webrtc/typedefs.h"
16b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
17b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgnamespace webrtc {
18b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgclass MixHistory;
19b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
20b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// A callback class that all mixer participants must inherit from/implement.
21b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgclass MixerParticipant
22b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org{
23b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgpublic:
24b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // The implementation of this function should update audioFrame with new
25b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // audio every time it's called.
26b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    //
27b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // If it returns -1, the frame will not be added to the mix.
2874f9bbbf9efe39e1f7df99aa7d6cb02d57978a5cpbos@webrtc.org    virtual int32_t GetAudioFrame(const int32_t id, AudioFrame& audioFrame) = 0;
29b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
30b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // mixed will be set to true if the participant was mixed this mix iteration
3174f9bbbf9efe39e1f7df99aa7d6cb02d57978a5cpbos@webrtc.org    int32_t IsMixed(bool& mixed) const;
32b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
33b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // This function specifies the sampling frequency needed for the AudioFrame
34b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // for future GetAudioFrame(..) calls.
3574f9bbbf9efe39e1f7df99aa7d6cb02d57978a5cpbos@webrtc.org    virtual int32_t NeededFrequency(const int32_t id) = 0;
36b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
37b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    MixHistory* _mixHistory;
38b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgprotected:
39b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    MixerParticipant();
40b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    virtual ~MixerParticipant();
41b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org};
42b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
43b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// Container struct for participant statistics.
44b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgstruct ParticipantStatistics
45b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org{
4674f9bbbf9efe39e1f7df99aa7d6cb02d57978a5cpbos@webrtc.org    int32_t participant;
4774f9bbbf9efe39e1f7df99aa7d6cb02d57978a5cpbos@webrtc.org    int32_t level;
48b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org};
49b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
50b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgclass AudioMixerStatusReceiver
51b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org{
52b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgpublic:
53b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // Callback function that provides an array of ParticipantStatistics for the
54b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // participants that were mixed last mix iteration.
55b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    virtual void MixedParticipants(
5674f9bbbf9efe39e1f7df99aa7d6cb02d57978a5cpbos@webrtc.org        const int32_t id,
57b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org        const ParticipantStatistics* participantStatistics,
5874f9bbbf9efe39e1f7df99aa7d6cb02d57978a5cpbos@webrtc.org        const uint32_t size) = 0;
59b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // Callback function that provides an array of the ParticipantStatistics for
60b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // the participants that had a positiv VAD last mix iteration.
61b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    virtual void VADPositiveParticipants(
6274f9bbbf9efe39e1f7df99aa7d6cb02d57978a5cpbos@webrtc.org        const int32_t id,
63b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org        const ParticipantStatistics* participantStatistics,
6474f9bbbf9efe39e1f7df99aa7d6cb02d57978a5cpbos@webrtc.org        const uint32_t size) = 0;
65b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // Callback function that provides the audio level of the mixed audio frame
66b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // from the last mix iteration.
67b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    virtual void MixedAudioLevel(
6874f9bbbf9efe39e1f7df99aa7d6cb02d57978a5cpbos@webrtc.org        const int32_t  id,
6974f9bbbf9efe39e1f7df99aa7d6cb02d57978a5cpbos@webrtc.org        const uint32_t level) = 0;
70b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgprotected:
71b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    AudioMixerStatusReceiver() {}
72b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    virtual ~AudioMixerStatusReceiver() {}
73b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org};
74b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
75b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgclass AudioMixerOutputReceiver
76b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org{
77b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgpublic:
78b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // This callback function provides the mixed audio for this mix iteration.
79b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // Note that uniqueAudioFrames is an array of AudioFrame pointers with the
80b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    // size according to the size parameter.
8174f9bbbf9efe39e1f7df99aa7d6cb02d57978a5cpbos@webrtc.org    virtual void NewMixedAudio(const int32_t id,
82b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org                               const AudioFrame& generalAudioFrame,
83b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org                               const AudioFrame** uniqueAudioFrames,
8474f9bbbf9efe39e1f7df99aa7d6cb02d57978a5cpbos@webrtc.org                               const uint32_t size) = 0;
85b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgprotected:
86b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    AudioMixerOutputReceiver() {}
87b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org    virtual ~AudioMixerOutputReceiver() {}
88b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org};
893b89e10f31160da35b408fd00cb8f89d2b08862dpbos@webrtc.org}  // namespace webrtc
90b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
91b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org#endif // WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_INTERFACE_AUDIO_CONFERENCE_MIXER_DEFINES_H_
92