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 | int32_t MixActiveChannels(); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 58 | |
xians@webrtc.org | 91d88e1 | 2014-04-14 10:50:37 +0000 | [diff] [blame] | 59 | int32_t DoOperationsOnCombinedSignal(bool feed_data_to_apm); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 60 | |
pbos@webrtc.org | 54f03bc | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 61 | int32_t SetMixabilityStatus(MixerParticipant& participant, |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 62 | bool mixable); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 63 | |
pbos@webrtc.org | 54f03bc | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 64 | int32_t SetAnonymousMixabilityStatus(MixerParticipant& participant, |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 65 | bool mixable); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 66 | |
| 67 | int GetMixedAudio(int sample_rate_hz, int num_channels, |
| 68 | AudioFrame* audioFrame); |
| 69 | |
| 70 | // VoEVolumeControl |
pbos@webrtc.org | 54f03bc | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 71 | int GetSpeechOutputLevel(uint32_t& level); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 72 | |
pbos@webrtc.org | 54f03bc | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 73 | int GetSpeechOutputLevelFullRange(uint32_t& level); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 74 | |
| 75 | int SetOutputVolumePan(float left, float right); |
| 76 | |
| 77 | int GetOutputVolumePan(float& left, float& right); |
| 78 | |
| 79 | // VoEFile |
| 80 | int StartRecordingPlayout(const char* fileName, |
| 81 | const CodecInst* codecInst); |
| 82 | |
| 83 | int StartRecordingPlayout(OutStream* stream, |
| 84 | const CodecInst* codecInst); |
| 85 | int StopRecordingPlayout(); |
| 86 | |
| 87 | virtual ~OutputMixer(); |
| 88 | |
| 89 | // from AudioMixerOutputReceiver |
| 90 | virtual void NewMixedAudio( |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 91 | int32_t id, |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 92 | const AudioFrame& generalAudioFrame, |
| 93 | const AudioFrame** uniqueAudioFrames, |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 94 | uint32_t size); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 95 | |
| 96 | // from AudioMixerStatusReceiver |
| 97 | virtual void MixedParticipants( |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 98 | int32_t id, |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 99 | const ParticipantStatistics* participantStatistics, |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 100 | uint32_t size); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 101 | |
| 102 | virtual void VADPositiveParticipants( |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 103 | int32_t id, |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 104 | const ParticipantStatistics* participantStatistics, |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 105 | uint32_t size); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 106 | |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 107 | virtual void MixedAudioLevel(int32_t id, uint32_t level); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 108 | |
| 109 | // For file recording |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 110 | void PlayNotification(int32_t id, uint32_t durationMs); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 111 | |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 112 | void RecordNotification(int32_t id, uint32_t durationMs); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 113 | |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 114 | void PlayFileEnded(int32_t id); |
| 115 | void RecordFileEnded(int32_t id); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 116 | |
| 117 | private: |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 118 | OutputMixer(uint32_t instanceId); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 119 | void APMAnalyzeReverseStream(); |
| 120 | int InsertInbandDtmfTone(); |
| 121 | |
| 122 | // uses |
| 123 | Statistics* _engineStatisticsPtr; |
| 124 | AudioProcessing* _audioProcessingModulePtr; |
| 125 | |
| 126 | // owns |
| 127 | CriticalSectionWrapper& _callbackCritSect; |
| 128 | // protect the _outputFileRecorderPtr and _outputFileRecording |
| 129 | CriticalSectionWrapper& _fileCritSect; |
| 130 | AudioConferenceMixer& _mixerModule; |
| 131 | AudioFrame _audioFrame; |
andrew@webrtc.org | 708ff4d | 2014-04-19 00:32:07 +0000 | [diff] [blame] | 132 | // Converts mixed audio to the audio device output rate. |
| 133 | PushResampler<int16_t> resampler_; |
| 134 | // Converts mixed audio to the audio processing rate. |
| 135 | PushResampler<int16_t> audioproc_resampler_; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 136 | AudioLevel _audioLevel; // measures audio level for the combined signal |
| 137 | DtmfInband _dtmfGenerator; |
| 138 | int _instanceId; |
| 139 | VoEMediaProcess* _externalMediaCallbackPtr; |
| 140 | bool _externalMedia; |
| 141 | float _panLeft; |
| 142 | float _panRight; |
| 143 | int _mixingFrequencyHz; |
| 144 | FileRecorder* _outputFileRecorderPtr; |
| 145 | bool _outputFileRecording; |
| 146 | }; |
| 147 | |
pbos@webrtc.org | 3b89e10 | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 148 | } // namespace voe |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 149 | |
pbos@webrtc.org | 3b89e10 | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 150 | } // namespace werbtc |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 151 | |
| 152 | #endif // VOICE_ENGINE_OUTPUT_MIXER_H_ |