Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit 5a2e524

Browse files
daijhDuan, Xiande
authored andcommitted
Support multiple inputs from one audio mixer participant
Change-Id: Ieccb668215049164b31562dc7466592c0deccbaa Reviewed-on: https://git-ccr-1.devtools.intel.com/gerrit/95930 Reviewed-by: Dai, Jianhui J <[email protected]> Reviewed-by: Duan, Xiande <[email protected]> Tested-by: Duan, Xiande <[email protected]>
1 parent fb4d9fc commit 5a2e524

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

webrtc/modules/audio_conference_mixer/include/audio_conference_mixer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ class AudioConferenceMixer : public Module
7474
const uint32_t amountOf10MsBetweenCallbacks) = 0;
7575
virtual int32_t UnRegisterMixerVadCallback() = 0;
7676

77+
virtual void SetMultipleInputs(bool enable) = 0;
78+
7779
protected:
7880
AudioConferenceMixer() {}
7981
};

webrtc/modules/audio_conference_mixer/source/audio_conference_mixer_impl.cc

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#define _VAD_METHOD_VOICE_DETECTION_
2020
//#define _VAD_METHOD_JOINT_ENERGY_VOICE_DETECTION_
2121

22+
#define GROUP_ID(id) (((id) >> 16) & 0xffff)
23+
2224
namespace webrtc {
2325
namespace {
2426

@@ -133,7 +135,8 @@ AudioConferenceMixerImpl::AudioConferenceMixerImpl(int id)
133135
_vadReceiver(NULL),
134136
_amountOf10MsBetweenVadCallbacks(0),
135137
_amountOf10MsAll(0),
136-
_amountOf10MsRemainder(0) {}
138+
_amountOf10MsRemainder(0),
139+
_supportMultipleInputs(false) {}
137140

138141
bool AudioConferenceMixerImpl::Init() {
139142
Config config;
@@ -339,6 +342,7 @@ void AudioConferenceMixerImpl::Process() {
339342
MixAnonomouslyFromList(generalFrame, rampOutList);
340343

341344
// 2. mix workList and anonomouslyMixerdFrame
345+
std::map<uint16_t, bool> groupIds;
342346
for (size_t i = 0; i <= mixList.size(); ++i) {
343347
AudioFrameList workList = mixList;
344348
int id = -1;
@@ -351,7 +355,24 @@ void AudioConferenceMixerImpl::Process() {
351355
AudioFrameList::iterator it = workList.begin();
352356
advance(it, i);
353357
id = (*it).frame->id_;
354-
workList.erase(it);
358+
359+
if (_supportMultipleInputs) {
360+
uint16_t groupId = GROUP_ID(id);
361+
if (groupIds.find(groupId) != groupIds.end()) {
362+
continue;
363+
}
364+
365+
groupIds[groupId] = true;
366+
for (it = workList.begin(); it != workList.end(); ) {
367+
if (GROUP_ID((*it).frame->id_) == groupId) {
368+
it = workList.erase(it);
369+
} else {
370+
++it;
371+
}
372+
}
373+
} else {
374+
workList.erase(it);
375+
}
355376

356377
mixedAudio->CopyFrom(*generalFrame);
357378
}
@@ -1117,10 +1138,19 @@ void AudioConferenceMixerImpl::UpdateVadStatistics(AudioFrameList* mixList) {
11171138
_vadParticipantEnergyList[id] += energy;
11181139

11191140
WEBRTC_TRACE(kTraceStream, kTraceAudioMixerServer, _id,
1120-
"###VadStatistics id(%d), energy(%12u), allEnergy(%12ld)",
1141+
"###VadStatistics id(0x%-8x), energy(%12u), allEnergy(%12ld)",
11211142
id, energy, _vadParticipantEnergyList[id]);
11221143
}
11231144
}
11241145
}
11251146

1147+
void AudioConferenceMixerImpl::SetMultipleInputs(bool enable)
1148+
{
1149+
WEBRTC_TRACE(kTraceInfo, kTraceAudioMixerServer, _id,
1150+
"Support multiple inputs: %d",
1151+
enable);
1152+
1153+
_supportMultipleInputs = enable;
1154+
}
1155+
11261156
} // namespace webrtc

webrtc/modules/audio_conference_mixer/source/audio_conference_mixer_impl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ class AudioConferenceMixerImpl : public AudioConferenceMixer
9090
const uint32_t amountOf10MsBetweenCallbacks) override;
9191
int32_t UnRegisterMixerVadCallback() override;
9292

93+
void SetMultipleInputs(bool enable) override;
94+
9395
private:
9496
enum{DEFAULT_AUDIO_FRAME_POOLSIZE = 50};
9597

@@ -208,6 +210,8 @@ class AudioConferenceMixerImpl : public AudioConferenceMixer
208210
std::map<int32_t, std::unique_ptr<AudioProcessing>> _apms;
209211

210212
std::vector<ParticipantVadStatistics> _vadStatistics;
213+
214+
bool _supportMultipleInputs;
211215
};
212216
} // namespace webrtc
213217

0 commit comments

Comments
 (0)