niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
andrew@webrtc.org | 4ecea3e | 2012-06-27 03:25:31 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
andrew@webrtc.org | 4ecea3e | 2012-06-27 03:25:31 +0000 | [diff] [blame] | 11 | #ifndef WEBRTC_VOICE_ENGINE_OUTPUT_MIXER_H_ |
| 12 | #define WEBRTC_VOICE_ENGINE_OUTPUT_MIXER_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
tommi | 31fc21f | 2016-01-21 10:37:37 -0800 | [diff] [blame^] | 14 | #include "webrtc/base/criticalsection.h" |
andrew@webrtc.org | 50b2efe | 2013-04-29 17:27:29 +0000 | [diff] [blame] | 15 | #include "webrtc/common_audio/resampler/include/push_resampler.h" |
| 16 | #include "webrtc/common_types.h" |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 17 | #include "webrtc/modules/audio_conference_mixer/include/audio_conference_mixer.h" |
| 18 | #include "webrtc/modules/audio_conference_mixer/include/audio_conference_mixer_defines.h" |
| 19 | #include "webrtc/modules/utility/include/file_recorder.h" |
andrew@webrtc.org | 50b2efe | 2013-04-29 17:27:29 +0000 | [diff] [blame] | 20 | #include "webrtc/voice_engine/dtmf_inband.h" |
| 21 | #include "webrtc/voice_engine/level_indicator.h" |
| 22 | #include "webrtc/voice_engine/voice_engine_defines.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 23 | |
| 24 | namespace webrtc { |
| 25 | |
| 26 | class AudioProcessing; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 27 | class FileWrapper; |
| 28 | class VoEMediaProcess; |
| 29 | |
| 30 | namespace voe { |
| 31 | |
| 32 | class Statistics; |
| 33 | |
| 34 | class OutputMixer : public AudioMixerOutputReceiver, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 35 | public FileCallback |
| 36 | { |
| 37 | public: |
pbos@webrtc.org | 9213521 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 38 | static int32_t Create(OutputMixer*& mixer, uint32_t instanceId); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | |
| 40 | static void Destroy(OutputMixer*& mixer); |
| 41 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 42 | int32_t SetEngineInformation(Statistics& engineStatistics); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 43 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 44 | int32_t SetAudioProcessingModule( |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 45 | AudioProcessing* audioProcessingModule); |
| 46 | |
| 47 | // VoEExternalMedia |
| 48 | int RegisterExternalMediaProcessing( |
| 49 | VoEMediaProcess& proccess_object); |
| 50 | |
| 51 | int DeRegisterExternalMediaProcessing(); |
| 52 | |
| 53 | // VoEDtmf |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 54 | int PlayDtmfTone(uint8_t eventCode, int lengthMs, int attenuationDb); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 55 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 56 | int32_t MixActiveChannels(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 57 | |
xians@webrtc.org | 5692531 | 2014-04-14 10:50:37 +0000 | [diff] [blame] | 58 | int32_t DoOperationsOnCombinedSignal(bool feed_data_to_apm); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 59 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 60 | int32_t SetMixabilityStatus(MixerParticipant& participant, |
pbos@webrtc.org | 9213521 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 61 | bool mixable); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 62 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 63 | int32_t SetAnonymousMixabilityStatus(MixerParticipant& participant, |
pbos@webrtc.org | 9213521 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 64 | bool mixable); |
henrike@webrtc.org | 066f9e5 | 2011-10-28 23:15:47 +0000 | [diff] [blame] | 65 | |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 66 | int GetMixedAudio(int sample_rate_hz, size_t num_channels, |
andrew@webrtc.org | 4ecea3e | 2012-06-27 03:25:31 +0000 | [diff] [blame] | 67 | AudioFrame* audioFrame); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 68 | |
| 69 | // VoEVolumeControl |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 70 | int GetSpeechOutputLevel(uint32_t& level); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 71 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 72 | int GetSpeechOutputLevelFullRange(uint32_t& level); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 73 | |
| 74 | int SetOutputVolumePan(float left, float right); |
| 75 | |
| 76 | int GetOutputVolumePan(float& left, float& right); |
| 77 | |
| 78 | // VoEFile |
| 79 | int StartRecordingPlayout(const char* fileName, |
| 80 | const CodecInst* codecInst); |
| 81 | |
| 82 | int StartRecordingPlayout(OutStream* stream, |
| 83 | const CodecInst* codecInst); |
| 84 | int StopRecordingPlayout(); |
| 85 | |
| 86 | virtual ~OutputMixer(); |
| 87 | |
andrew@webrtc.org | 4ecea3e | 2012-06-27 03:25:31 +0000 | [diff] [blame] | 88 | // from AudioMixerOutputReceiver |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 89 | virtual void NewMixedAudio( |
pbos@webrtc.org | 9213521 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 90 | int32_t id, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 91 | const AudioFrame& generalAudioFrame, |
| 92 | const AudioFrame** uniqueAudioFrames, |
pbos@webrtc.org | 9213521 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 93 | uint32_t size); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 94 | |
andrew@webrtc.org | 4ecea3e | 2012-06-27 03:25:31 +0000 | [diff] [blame] | 95 | // For file recording |
pbos@webrtc.org | 9213521 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 96 | void PlayNotification(int32_t id, uint32_t durationMs); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 97 | |
pbos@webrtc.org | 9213521 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 98 | void RecordNotification(int32_t id, uint32_t durationMs); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 99 | |
pbos@webrtc.org | 9213521 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 100 | void PlayFileEnded(int32_t id); |
| 101 | void RecordFileEnded(int32_t id); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 102 | |
| 103 | private: |
pbos@webrtc.org | 9213521 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 104 | OutputMixer(uint32_t instanceId); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 105 | int InsertInbandDtmfTone(); |
| 106 | |
andrew@webrtc.org | 4ecea3e | 2012-06-27 03:25:31 +0000 | [diff] [blame] | 107 | // uses |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 108 | Statistics* _engineStatisticsPtr; |
| 109 | AudioProcessing* _audioProcessingModulePtr; |
| 110 | |
tommi | 31fc21f | 2016-01-21 10:37:37 -0800 | [diff] [blame^] | 111 | rtc::CriticalSection _callbackCritSect; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 112 | // protect the _outputFileRecorderPtr and _outputFileRecording |
tommi | 31fc21f | 2016-01-21 10:37:37 -0800 | [diff] [blame^] | 113 | rtc::CriticalSection _fileCritSect; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 114 | AudioConferenceMixer& _mixerModule; |
| 115 | AudioFrame _audioFrame; |
andrew@webrtc.org | f5a33f1 | 2014-04-19 00:32:07 +0000 | [diff] [blame] | 116 | // Converts mixed audio to the audio device output rate. |
| 117 | PushResampler<int16_t> resampler_; |
| 118 | // Converts mixed audio to the audio processing rate. |
| 119 | PushResampler<int16_t> audioproc_resampler_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 120 | AudioLevel _audioLevel; // measures audio level for the combined signal |
| 121 | DtmfInband _dtmfGenerator; |
xians@google.com | 0b0665a | 2011-08-08 08:18:44 +0000 | [diff] [blame] | 122 | int _instanceId; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 123 | VoEMediaProcess* _externalMediaCallbackPtr; |
| 124 | bool _externalMedia; |
| 125 | float _panLeft; |
| 126 | float _panRight; |
xians@google.com | 0b0665a | 2011-08-08 08:18:44 +0000 | [diff] [blame] | 127 | int _mixingFrequencyHz; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 128 | FileRecorder* _outputFileRecorderPtr; |
| 129 | bool _outputFileRecording; |
| 130 | }; |
| 131 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 132 | } // namespace voe |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 133 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 134 | } // namespace werbtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 135 | |
andrew@webrtc.org | 4ecea3e | 2012-06-27 03:25:31 +0000 | [diff] [blame] | 136 | #endif // VOICE_ENGINE_OUTPUT_MIXER_H_ |