andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 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_VOICE_ENGINE_OUTPUT_MIXER_H_ |
| 12 | #define WEBRTC_VOICE_ENGINE_OUTPUT_MIXER_H_ |
| 13 | |
andrew@webrtc.org | b6fadb1 | 2013-04-29 17:27:29 +0000 | [diff] [blame] | 14 | #include "webrtc/common_audio/resampler/include/push_resampler.h" |
| 15 | #include "webrtc/common_types.h" |
| 16 | #include "webrtc/modules/audio_conference_mixer/interface/audio_conference_mixer.h" |
| 17 | #include "webrtc/modules/audio_conference_mixer/interface/audio_conference_mixer_defines.h" |
| 18 | #include "webrtc/modules/utility/interface/file_recorder.h" |
| 19 | #include "webrtc/voice_engine/dtmf_inband.h" |
| 20 | #include "webrtc/voice_engine/level_indicator.h" |
| 21 | #include "webrtc/voice_engine/voice_engine_defines.h" |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 22 | |
| 23 | namespace webrtc { |
| 24 | |
| 25 | class AudioProcessing; |
| 26 | class CriticalSectionWrapper; |
| 27 | class FileWrapper; |
| 28 | class VoEMediaProcess; |
| 29 | |
| 30 | namespace voe { |
| 31 | |
| 32 | class Statistics; |
| 33 | |
| 34 | class OutputMixer : public AudioMixerOutputReceiver, |
| 35 | public AudioMixerStatusReceiver, |
| 36 | public FileCallback |
| 37 | { |
| 38 | public: |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 39 | static int32_t Create(OutputMixer*& mixer, uint32_t instanceId); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 40 | |
| 41 | static void Destroy(OutputMixer*& mixer); |
| 42 | |
pbos@webrtc.org | 54f03bc | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 43 | int32_t SetEngineInformation(Statistics& engineStatistics); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 44 | |
pbos@webrtc.org | 54f03bc | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 45 | int32_t SetAudioProcessingModule( |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 46 | AudioProcessing* audioProcessingModule); |
| 47 | |
| 48 | // VoEExternalMedia |
| 49 | int RegisterExternalMediaProcessing( |
| 50 | VoEMediaProcess& proccess_object); |
| 51 | |
| 52 | int DeRegisterExternalMediaProcessing(); |
| 53 | |
| 54 | // VoEDtmf |
pbos@webrtc.org | 54f03bc | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 55 | int PlayDtmfTone(uint8_t eventCode, int lengthMs, int attenuationDb); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 56 | |
pbos@webrtc.org | 54f03bc | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 57 | int StartPlayingDtmfTone(uint8_t eventCode, int attenuationDb); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 58 | |
| 59 | int StopPlayingDtmfTone(); |
| 60 | |
pbos@webrtc.org | 54f03bc | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 61 | int32_t MixActiveChannels(); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 62 | |
xians@webrtc.org | 91d88e1 | 2014-04-14 10:50:37 +0000 | [diff] [blame] | 63 | int32_t DoOperationsOnCombinedSignal(bool feed_data_to_apm); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 64 | |
pbos@webrtc.org | 54f03bc | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 65 | int32_t SetMixabilityStatus(MixerParticipant& participant, |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 66 | bool mixable); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 67 | |
pbos@webrtc.org | 54f03bc | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 68 | int32_t SetAnonymousMixabilityStatus(MixerParticipant& participant, |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 69 | bool mixable); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 70 | |
| 71 | int GetMixedAudio(int sample_rate_hz, int num_channels, |
| 72 | AudioFrame* audioFrame); |
| 73 | |
| 74 | // VoEVolumeControl |
pbos@webrtc.org | 54f03bc | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 75 | int GetSpeechOutputLevel(uint32_t& level); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 76 | |
pbos@webrtc.org | 54f03bc | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 77 | int GetSpeechOutputLevelFullRange(uint32_t& level); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 78 | |
| 79 | int SetOutputVolumePan(float left, float right); |
| 80 | |
| 81 | int GetOutputVolumePan(float& left, float& right); |
| 82 | |
| 83 | // VoEFile |
| 84 | int StartRecordingPlayout(const char* fileName, |
| 85 | const CodecInst* codecInst); |
| 86 | |
| 87 | int StartRecordingPlayout(OutStream* stream, |
| 88 | const CodecInst* codecInst); |
| 89 | int StopRecordingPlayout(); |
| 90 | |
| 91 | virtual ~OutputMixer(); |
| 92 | |
| 93 | // from AudioMixerOutputReceiver |
| 94 | virtual void NewMixedAudio( |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 95 | int32_t id, |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 96 | const AudioFrame& generalAudioFrame, |
| 97 | const AudioFrame** uniqueAudioFrames, |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 98 | uint32_t size); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 99 | |
| 100 | // from AudioMixerStatusReceiver |
| 101 | virtual void MixedParticipants( |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 102 | int32_t id, |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 103 | const ParticipantStatistics* participantStatistics, |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 104 | uint32_t size); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 105 | |
| 106 | virtual void VADPositiveParticipants( |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 107 | int32_t id, |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 108 | const ParticipantStatistics* participantStatistics, |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 109 | uint32_t size); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 110 | |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 111 | virtual void MixedAudioLevel(int32_t id, uint32_t level); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 112 | |
| 113 | // For file recording |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 114 | void PlayNotification(int32_t id, uint32_t durationMs); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 115 | |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 116 | void RecordNotification(int32_t id, uint32_t durationMs); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 117 | |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 118 | void PlayFileEnded(int32_t id); |
| 119 | void RecordFileEnded(int32_t id); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 120 | |
| 121 | private: |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 122 | OutputMixer(uint32_t instanceId); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 123 | void APMAnalyzeReverseStream(); |
| 124 | int InsertInbandDtmfTone(); |
| 125 | |
| 126 | // uses |
| 127 | Statistics* _engineStatisticsPtr; |
| 128 | AudioProcessing* _audioProcessingModulePtr; |
| 129 | |
| 130 | // owns |
| 131 | CriticalSectionWrapper& _callbackCritSect; |
| 132 | // protect the _outputFileRecorderPtr and _outputFileRecording |
| 133 | CriticalSectionWrapper& _fileCritSect; |
| 134 | AudioConferenceMixer& _mixerModule; |
| 135 | AudioFrame _audioFrame; |
andrew@webrtc.org | b6fadb1 | 2013-04-29 17:27:29 +0000 | [diff] [blame] | 136 | PushResampler resampler_; // converts mixed audio to fit ADM format |
| 137 | PushResampler audioproc_resampler_; // converts mixed audio to fit APM rate |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 138 | AudioLevel _audioLevel; // measures audio level for the combined signal |
| 139 | DtmfInband _dtmfGenerator; |
| 140 | int _instanceId; |
| 141 | VoEMediaProcess* _externalMediaCallbackPtr; |
| 142 | bool _externalMedia; |
| 143 | float _panLeft; |
| 144 | float _panRight; |
| 145 | int _mixingFrequencyHz; |
| 146 | FileRecorder* _outputFileRecorderPtr; |
| 147 | bool _outputFileRecording; |
| 148 | }; |
| 149 | |
pbos@webrtc.org | 3b89e10 | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 150 | } // namespace voe |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 151 | |
pbos@webrtc.org | 3b89e10 | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 152 | } // namespace werbtc |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 153 | |
| 154 | #endif // VOICE_ENGINE_OUTPUT_MIXER_H_ |