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" |
| 17 | #include "webrtc/modules/audio_mixer/include/new_audio_conference_mixer.h" |
| 18 | #include "webrtc/modules/audio_mixer/include/audio_mixer_defines.h" |
| 19 | #include "webrtc/modules/utility/include/file_recorder.h" |
| 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. |
| 35 | class AudioMixer : public OldAudioMixerOutputReceiver, public FileCallback { |
| 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 | |
| 51 | int32_t MixActiveChannels(); |
| 52 | |
| 53 | int32_t DoOperationsOnCombinedSignal(bool feed_data_to_apm); |
| 54 | |
| 55 | int32_t SetMixabilityStatus(MixerAudioSource& participant, // NOLINT |
| 56 | bool mixable); |
| 57 | |
| 58 | int32_t SetAnonymousMixabilityStatus(MixerAudioSource& participant, // NOLINT |
| 59 | bool mixable); |
| 60 | |
| 61 | int GetMixedAudio(int sample_rate_hz, |
| 62 | size_t num_channels, |
| 63 | AudioFrame* audioFrame); |
| 64 | |
| 65 | // VoEVolumeControl |
| 66 | int GetSpeechOutputLevel(uint32_t& level); // NOLINT |
| 67 | |
| 68 | int GetSpeechOutputLevelFullRange(uint32_t& level); // NOLINT |
| 69 | |
| 70 | int SetOutputVolumePan(float left, float right); |
| 71 | |
| 72 | int GetOutputVolumePan(float& left, float& right); // NOLINT |
| 73 | |
| 74 | // VoEFile |
| 75 | int StartRecordingPlayout(const char* fileName, const CodecInst* codecInst); |
| 76 | |
| 77 | int StartRecordingPlayout(OutStream* stream, const CodecInst* codecInst); |
| 78 | int StopRecordingPlayout(); |
| 79 | |
| 80 | virtual ~AudioMixer(); |
| 81 | |
| 82 | // from AudioMixerOutputReceiver |
| 83 | virtual void NewMixedAudio(int32_t id, |
| 84 | const AudioFrame& generalAudioFrame, |
| 85 | const AudioFrame** uniqueAudioFrames, |
| 86 | uint32_t size); |
| 87 | |
| 88 | // For file recording |
| 89 | void PlayNotification(int32_t id, uint32_t durationMs); |
| 90 | |
| 91 | void RecordNotification(int32_t id, uint32_t durationMs); |
| 92 | |
| 93 | void PlayFileEnded(int32_t id); |
| 94 | void RecordFileEnded(int32_t id); |
| 95 | |
| 96 | private: |
| 97 | explicit AudioMixer(uint32_t instanceId); |
| 98 | |
| 99 | // uses |
| 100 | Statistics* _engineStatisticsPtr; |
| 101 | AudioProcessing* _audioProcessingModulePtr; |
| 102 | |
| 103 | rtc::CriticalSection _callbackCritSect; |
| 104 | // protect the _outputFileRecorderPtr and _outputFileRecording |
| 105 | rtc::CriticalSection _fileCritSect; |
| 106 | NewAudioConferenceMixer& _mixerModule; |
| 107 | AudioFrame _audioFrame; |
| 108 | // Converts mixed audio to the audio device output rate. |
| 109 | PushResampler<int16_t> resampler_; |
| 110 | // Converts mixed audio to the audio processing rate. |
| 111 | PushResampler<int16_t> audioproc_resampler_; |
| 112 | AudioLevel _audioLevel; // measures audio level for the combined signal |
| 113 | int _instanceId; |
| 114 | VoEMediaProcess* _externalMediaCallbackPtr; |
| 115 | bool _externalMedia; |
| 116 | float _panLeft; |
| 117 | float _panRight; |
| 118 | int _mixingFrequencyHz; |
| 119 | FileRecorder* _outputFileRecorderPtr; |
| 120 | bool _outputFileRecording; |
| 121 | }; |
| 122 | |
| 123 | } // namespace voe |
| 124 | |
| 125 | } // namespace webrtc |
| 126 | |
| 127 | #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_ |