aleloi | 77ad394 | 2016-07-04 06:33:02 -0700 | [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_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_ |
| 12 | #define WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_ |
| 13 | |
| 14 | #include "webrtc/base/criticalsection.h" |
| 15 | #include "webrtc/common_audio/resampler/include/push_resampler.h" |
| 16 | #include "webrtc/common_types.h" |
aleloi | 5bcc00e | 2016-08-15 03:01:31 -0700 | [diff] [blame] | 17 | #include "webrtc/modules/audio_mixer/new_audio_conference_mixer.h" |
| 18 | #include "webrtc/modules/audio_mixer/audio_mixer_defines.h" |
kwiberg | 9d7eb13 | 2016-08-16 04:08:30 -0700 | [diff] [blame^] | 19 | #include "webrtc/modules/utility/include/file_recorder.h" |
aleloi | 77ad394 | 2016-07-04 06:33:02 -0700 | [diff] [blame] | 20 | #include "webrtc/voice_engine/level_indicator.h" |
| 21 | #include "webrtc/voice_engine/voice_engine_defines.h" |
| 22 | |
| 23 | namespace webrtc { |
| 24 | |
| 25 | class AudioProcessing; |
| 26 | class FileWrapper; |
| 27 | class VoEMediaProcess; |
| 28 | |
| 29 | namespace voe { |
| 30 | class Statistics; |
| 31 | |
| 32 | // Note: this class is in the process of being rewritten and merged |
| 33 | // with AudioConferenceMixer. Expect inheritance chains to be changed, |
| 34 | // member functions removed or renamed. |
aleloi | 09f4510 | 2016-07-28 03:52:15 -0700 | [diff] [blame] | 35 | class AudioMixer : public FileCallback { |
aleloi | 77ad394 | 2016-07-04 06:33:02 -0700 | [diff] [blame] | 36 | public: |
| 37 | static int32_t Create(AudioMixer*& mixer, uint32_t instanceId); // NOLINT |
| 38 | |
| 39 | static void Destroy(AudioMixer*& mixer); // NOLINT |
| 40 | |
| 41 | int32_t SetEngineInformation(Statistics& engineStatistics); // NOLINT |
| 42 | |
| 43 | int32_t SetAudioProcessingModule(AudioProcessing* audioProcessingModule); |
| 44 | |
| 45 | // VoEExternalMedia |
| 46 | int RegisterExternalMediaProcessing(VoEMediaProcess& // NOLINT |
| 47 | proccess_object); |
| 48 | |
| 49 | int DeRegisterExternalMediaProcessing(); |
| 50 | |
aleloi | 77ad394 | 2016-07-04 06:33:02 -0700 | [diff] [blame] | 51 | int32_t DoOperationsOnCombinedSignal(bool feed_data_to_apm); |
| 52 | |
aleloi | 09f4510 | 2016-07-28 03:52:15 -0700 | [diff] [blame] | 53 | int32_t SetMixabilityStatus(MixerAudioSource& audio_source, // NOLINT |
aleloi | 77ad394 | 2016-07-04 06:33:02 -0700 | [diff] [blame] | 54 | bool mixable); |
| 55 | |
aleloi | 09f4510 | 2016-07-28 03:52:15 -0700 | [diff] [blame] | 56 | int32_t SetAnonymousMixabilityStatus( |
| 57 | MixerAudioSource& audio_source, // NOLINT |
| 58 | bool mixable); |
aleloi | 77ad394 | 2016-07-04 06:33:02 -0700 | [diff] [blame] | 59 | |
| 60 | int GetMixedAudio(int sample_rate_hz, |
| 61 | size_t num_channels, |
| 62 | AudioFrame* audioFrame); |
| 63 | |
| 64 | // VoEVolumeControl |
| 65 | int GetSpeechOutputLevel(uint32_t& level); // NOLINT |
| 66 | |
| 67 | int GetSpeechOutputLevelFullRange(uint32_t& level); // NOLINT |
| 68 | |
| 69 | int SetOutputVolumePan(float left, float right); |
| 70 | |
| 71 | int GetOutputVolumePan(float& left, float& right); // NOLINT |
| 72 | |
| 73 | // VoEFile |
| 74 | int StartRecordingPlayout(const char* fileName, const CodecInst* codecInst); |
| 75 | |
| 76 | int StartRecordingPlayout(OutStream* stream, const CodecInst* codecInst); |
| 77 | int StopRecordingPlayout(); |
| 78 | |
| 79 | virtual ~AudioMixer(); |
| 80 | |
aleloi | 77ad394 | 2016-07-04 06:33:02 -0700 | [diff] [blame] | 81 | // For file recording |
| 82 | void PlayNotification(int32_t id, uint32_t durationMs); |
| 83 | |
| 84 | void RecordNotification(int32_t id, uint32_t durationMs); |
| 85 | |
| 86 | void PlayFileEnded(int32_t id); |
| 87 | void RecordFileEnded(int32_t id); |
| 88 | |
| 89 | private: |
| 90 | explicit AudioMixer(uint32_t instanceId); |
| 91 | |
| 92 | // uses |
| 93 | Statistics* _engineStatisticsPtr; |
| 94 | AudioProcessing* _audioProcessingModulePtr; |
| 95 | |
| 96 | rtc::CriticalSection _callbackCritSect; |
| 97 | // protect the _outputFileRecorderPtr and _outputFileRecording |
| 98 | rtc::CriticalSection _fileCritSect; |
| 99 | NewAudioConferenceMixer& _mixerModule; |
| 100 | AudioFrame _audioFrame; |
aleloi | 77ad394 | 2016-07-04 06:33:02 -0700 | [diff] [blame] | 101 | // Converts mixed audio to the audio processing rate. |
| 102 | PushResampler<int16_t> audioproc_resampler_; |
| 103 | AudioLevel _audioLevel; // measures audio level for the combined signal |
| 104 | int _instanceId; |
| 105 | VoEMediaProcess* _externalMediaCallbackPtr; |
| 106 | bool _externalMedia; |
| 107 | float _panLeft; |
| 108 | float _panRight; |
| 109 | int _mixingFrequencyHz; |
| 110 | FileRecorder* _outputFileRecorderPtr; |
| 111 | bool _outputFileRecording; |
| 112 | }; |
| 113 | |
| 114 | } // namespace voe |
| 115 | |
| 116 | } // namespace webrtc |
| 117 | |
| 118 | #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_ |