Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: webrtc/modules/audio_conference_mixer/source/audio_conference_mixer_impl.cc

Issue 1983023002: Add muted parameter to audio_frame_manipulator methods (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@mixer-mod-2
Patch Set: Avoid calling frame manipulator functions when muted Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 // TODO(henrike): this assert triggers in some test cases where SRTP is 570 // TODO(henrike): this assert triggers in some test cases where SRTP is
571 // used which prevents NetEQ from making a VAD. Temporarily disable this 571 // used which prevents NetEQ from making a VAD. Temporarily disable this
572 // assert until the problem is fixed on a higher level. 572 // assert until the problem is fixed on a higher level.
573 // assert(audioFrame->vad_activity_ != AudioFrame::kVadUnknown); 573 // assert(audioFrame->vad_activity_ != AudioFrame::kVadUnknown);
574 if (audioFrame->vad_activity_ == AudioFrame::kVadUnknown) { 574 if (audioFrame->vad_activity_ == AudioFrame::kVadUnknown) {
575 WEBRTC_TRACE(kTraceWarning, kTraceAudioMixerServer, _id, 575 WEBRTC_TRACE(kTraceWarning, kTraceAudioMixerServer, _id,
576 "invalid VAD state from participant"); 576 "invalid VAD state from participant");
577 } 577 }
578 578
579 if(audioFrame->vad_activity_ == AudioFrame::kVadActive) { 579 if(audioFrame->vad_activity_ == AudioFrame::kVadActive) {
580 if(!wasMixed) { 580 if(!wasMixed && !muted) {
581 RampIn(*audioFrame); 581 RampIn(*audioFrame);
582 } 582 }
583 583
584 if(activeList.size() >= *maxAudioFrameCounter) { 584 if(activeList.size() >= *maxAudioFrameCounter) {
585 // There are already more active participants than should be 585 // There are already more active participants than should be
586 // mixed. Only keep the ones with the highest energy. 586 // mixed. Only keep the ones with the highest energy.
587 AudioFrameList::iterator replaceItem; 587 AudioFrameList::iterator replaceItem;
588 uint32_t lowestEnergy = CalculateEnergy(*audioFrame); 588 uint32_t lowestEnergy =
589 muted ? 0 : CalculateEnergy(*audioFrame);
589 590
590 bool found_replace_item = false; 591 bool found_replace_item = false;
591 for (AudioFrameList::iterator iter = activeList.begin(); 592 for (AudioFrameList::iterator iter = activeList.begin();
592 iter != activeList.end(); 593 iter != activeList.end();
593 ++iter) { 594 ++iter) {
594 const uint32_t energy = CalculateEnergy(*iter->frame); 595 const uint32_t energy =
596 muted ? 0 : CalculateEnergy(*iter->frame);
595 if(energy < lowestEnergy) { 597 if(energy < lowestEnergy) {
596 replaceItem = iter; 598 replaceItem = iter;
597 lowestEnergy = energy; 599 lowestEnergy = energy;
598 found_replace_item = true; 600 found_replace_item = true;
599 } 601 }
600 } 602 }
601 if(found_replace_item) { 603 if(found_replace_item) {
604 RTC_DCHECK(!muted); // Cannot replace with a muted frame.
602 FrameAndMuteInfo replaceFrame = *replaceItem; 605 FrameAndMuteInfo replaceFrame = *replaceItem;
603 606
604 bool replaceWasMixed = false; 607 bool replaceWasMixed = false;
605 std::map<int, MixerParticipant*>::const_iterator it = 608 std::map<int, MixerParticipant*>::const_iterator it =
606 mixParticipantList->find(replaceFrame.frame->id_); 609 mixParticipantList->find(replaceFrame.frame->id_);
607 610
608 // When a frame is pushed to |activeList| it is also pushed 611 // When a frame is pushed to |activeList| it is also pushed
609 // to mixParticipantList with the frame's id. This means 612 // to mixParticipantList with the frame's id. This means
610 // that the Find call above should never fail. 613 // that the Find call above should never fail.
611 assert(it != mixParticipantList->end()); 614 assert(it != mixParticipantList->end());
612 replaceWasMixed = it->second->_mixHistory->WasMixed(); 615 replaceWasMixed = it->second->_mixHistory->WasMixed();
613 616
614 mixParticipantList->erase(replaceFrame.frame->id_); 617 mixParticipantList->erase(replaceFrame.frame->id_);
615 activeList.erase(replaceItem); 618 activeList.erase(replaceItem);
616 619
617 activeList.push_front(FrameAndMuteInfo(audioFrame, muted)); 620 activeList.push_front(FrameAndMuteInfo(audioFrame, muted));
618 (*mixParticipantList)[audioFrame->id_] = *participant; 621 (*mixParticipantList)[audioFrame->id_] = *participant;
619 assert(mixParticipantList->size() <= 622 assert(mixParticipantList->size() <=
620 kMaximumAmountOfMixedParticipants); 623 kMaximumAmountOfMixedParticipants);
621 624
622 if (replaceWasMixed) { 625 if (replaceWasMixed) {
hlundin-webrtc 2016/05/17 19:29:54 The formatting is "all over the place" in this fil
minyue-webrtc 2016/05/18 01:34:45 Acknowledged but it is weird
623 RampOut(*replaceFrame.frame); 626 if (!replaceFrame.muted) {
627 RampOut(*replaceFrame.frame);
628 }
624 rampOutList->push_back(replaceFrame); 629 rampOutList->push_back(replaceFrame);
625 assert(rampOutList->size() <= 630 assert(rampOutList->size() <=
626 kMaximumAmountOfMixedParticipants); 631 kMaximumAmountOfMixedParticipants);
627 } else { 632 } else {
628 _audioFramePool->PushMemory(replaceFrame.frame); 633 _audioFramePool->PushMemory(replaceFrame.frame);
629 } 634 }
630 } else { 635 } else {
631 if(wasMixed) { 636 if(wasMixed) {
632 RampOut(*audioFrame); 637 if (!muted) {
638 RampOut(*audioFrame);
639 }
633 rampOutList->push_back(FrameAndMuteInfo(audioFrame, 640 rampOutList->push_back(FrameAndMuteInfo(audioFrame,
634 muted)); 641 muted));
635 assert(rampOutList->size() <= 642 assert(rampOutList->size() <=
636 kMaximumAmountOfMixedParticipants); 643 kMaximumAmountOfMixedParticipants);
637 } else { 644 } else {
638 _audioFramePool->PushMemory(audioFrame); 645 _audioFramePool->PushMemory(audioFrame);
639 } 646 }
640 } 647 }
641 } else { 648 } else {
642 activeList.push_front(FrameAndMuteInfo(audioFrame, muted)); 649 activeList.push_front(FrameAndMuteInfo(audioFrame, muted));
643 (*mixParticipantList)[audioFrame->id_] = *participant; 650 (*mixParticipantList)[audioFrame->id_] = *participant;
644 assert(mixParticipantList->size() <= 651 assert(mixParticipantList->size() <=
645 kMaximumAmountOfMixedParticipants); 652 kMaximumAmountOfMixedParticipants);
646 } 653 }
647 } else { 654 } else {
648 if(wasMixed) { 655 if(wasMixed) {
649 ParticipantFrameStruct* part_struct = 656 ParticipantFrameStruct* part_struct =
650 new ParticipantFrameStruct(*participant, audioFrame, muted); 657 new ParticipantFrameStruct(*participant, audioFrame, muted);
651 passiveWasMixedList.push_back(part_struct); 658 passiveWasMixedList.push_back(part_struct);
652 } else if(mustAddToPassiveList) { 659 } else if(mustAddToPassiveList) {
653 RampIn(*audioFrame); 660 if (!muted) {
661 RampIn(*audioFrame);
662 }
654 ParticipantFrameStruct* part_struct = 663 ParticipantFrameStruct* part_struct =
655 new ParticipantFrameStruct(*participant, audioFrame, muted); 664 new ParticipantFrameStruct(*participant, audioFrame, muted);
656 passiveWasNotMixedList.push_back(part_struct); 665 passiveWasNotMixedList.push_back(part_struct);
657 } else { 666 } else {
658 _audioFramePool->PushMemory(audioFrame); 667 _audioFramePool->PushMemory(audioFrame);
659 } 668 }
660 } 669 }
661 } 670 }
662 assert(activeList.size() <= *maxAudioFrameCounter); 671 assert(activeList.size() <= *maxAudioFrameCounter);
663 // At this point it is known which participants should be mixed. Transfer 672 // At this point it is known which participants should be mixed. Transfer
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 942
934 if(error != _limiter->kNoError) { 943 if(error != _limiter->kNoError) {
935 WEBRTC_TRACE(kTraceError, kTraceAudioMixerServer, _id, 944 WEBRTC_TRACE(kTraceError, kTraceAudioMixerServer, _id,
936 "Error from AudioProcessing: %d", error); 945 "Error from AudioProcessing: %d", error);
937 assert(false); 946 assert(false);
938 return false; 947 return false;
939 } 948 }
940 return true; 949 return true;
941 } 950 }
942 } // namespace webrtc 951 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698