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

Side by Side Diff: webrtc/voice_engine/channel.cc

Issue 2750783004: Add mute state field to AudioFrame. (Closed)
Patch Set: don't return from Add() too early Created 3 years, 9 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
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 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 ChannelState::State state = channel_state_.Get(); 643 ChannelState::State state = channel_state_.Get();
644 644
645 { 645 {
646 // Pass the audio buffers to an optional sink callback, before applying 646 // Pass the audio buffers to an optional sink callback, before applying
647 // scaling/panning, as that applies to the mix operation. 647 // scaling/panning, as that applies to the mix operation.
648 // External recipients of the audio (e.g. via AudioTrack), will do their 648 // External recipients of the audio (e.g. via AudioTrack), will do their
649 // own mixing/dynamic processing. 649 // own mixing/dynamic processing.
650 rtc::CritScope cs(&_callbackCritSect); 650 rtc::CritScope cs(&_callbackCritSect);
651 if (audio_sink_) { 651 if (audio_sink_) {
652 AudioSinkInterface::Data data( 652 AudioSinkInterface::Data data(
653 &audioFrame->data_[0], audioFrame->samples_per_channel_, 653 audioFrame->data(), audioFrame->samples_per_channel_,
654 audioFrame->sample_rate_hz_, audioFrame->num_channels_, 654 audioFrame->sample_rate_hz_, audioFrame->num_channels_,
655 audioFrame->timestamp_); 655 audioFrame->timestamp_);
656 audio_sink_->OnData(data); 656 audio_sink_->OnData(data);
657 } 657 }
658 } 658 }
659 659
660 float output_gain = 1.0f; 660 float output_gain = 1.0f;
661 { 661 {
662 rtc::CritScope cs(&volume_settings_critsect_); 662 rtc::CritScope cs(&volume_settings_critsect_);
663 output_gain = _outputGain; 663 output_gain = _outputGain;
(...skipping 1950 matching lines...) Expand 10 before | Expand all | Expand 10 after
2614 if (channel_state_.Get().input_file_playing) { 2614 if (channel_state_.Get().input_file_playing) {
2615 MixOrReplaceAudioWithFile(mixingFrequency); 2615 MixOrReplaceAudioWithFile(mixingFrequency);
2616 } 2616 }
2617 2617
2618 bool is_muted = InputMute(); // Cache locally as InputMute() takes a lock. 2618 bool is_muted = InputMute(); // Cache locally as InputMute() takes a lock.
2619 AudioFrameOperations::Mute(&_audioFrame, previous_frame_muted_, is_muted); 2619 AudioFrameOperations::Mute(&_audioFrame, previous_frame_muted_, is_muted);
2620 2620
2621 if (_includeAudioLevelIndication) { 2621 if (_includeAudioLevelIndication) {
2622 size_t length = 2622 size_t length =
2623 _audioFrame.samples_per_channel_ * _audioFrame.num_channels_; 2623 _audioFrame.samples_per_channel_ * _audioFrame.num_channels_;
2624 RTC_CHECK_LE(length, sizeof(_audioFrame.data_)); 2624 RTC_CHECK_LE(length, AudioFrame::kMaxDataSizeBytes);
2625 if (is_muted && previous_frame_muted_) { 2625 if (is_muted && previous_frame_muted_) {
2626 rms_level_.AnalyzeMuted(length); 2626 rms_level_.AnalyzeMuted(length);
2627 } else { 2627 } else {
2628 rms_level_.Analyze( 2628 rms_level_.Analyze(
2629 rtc::ArrayView<const int16_t>(_audioFrame.data_, length)); 2629 rtc::ArrayView<const int16_t>(_audioFrame.data(), length));
2630 } 2630 }
2631 } 2631 }
2632 previous_frame_muted_ = is_muted; 2632 previous_frame_muted_ = is_muted;
2633 2633
2634 return 0; 2634 return 0;
2635 } 2635 }
2636 2636
2637 uint32_t Channel::EncodeAndSend() { 2637 uint32_t Channel::EncodeAndSend() {
2638 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), 2638 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId),
2639 "Channel::EncodeAndSend()"); 2639 "Channel::EncodeAndSend()");
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
2796 "Channel::MixOrReplaceAudioWithFile() file is ended"); 2796 "Channel::MixOrReplaceAudioWithFile() file is ended");
2797 return 0; 2797 return 0;
2798 } 2798 }
2799 } 2799 }
2800 2800
2801 assert(_audioFrame.samples_per_channel_ == fileSamples); 2801 assert(_audioFrame.samples_per_channel_ == fileSamples);
2802 2802
2803 if (_mixFileWithMicrophone) { 2803 if (_mixFileWithMicrophone) {
2804 // Currently file stream is always mono. 2804 // Currently file stream is always mono.
2805 // TODO(xians): Change the code when FilePlayer supports real stereo. 2805 // TODO(xians): Change the code when FilePlayer supports real stereo.
2806 MixWithSat(_audioFrame.data_, _audioFrame.num_channels_, fileBuffer.get(), 2806 MixWithSat(_audioFrame.mutable_data(), _audioFrame.num_channels_,
2807 1, fileSamples); 2807 fileBuffer.get(), 1, fileSamples);
2808 } else { 2808 } else {
2809 // Replace ACM audio with file. 2809 // Replace ACM audio with file.
2810 // Currently file stream is always mono. 2810 // Currently file stream is always mono.
2811 // TODO(xians): Change the code when FilePlayer supports real stereo. 2811 // TODO(xians): Change the code when FilePlayer supports real stereo.
2812 _audioFrame.UpdateFrame( 2812 _audioFrame.UpdateFrame(
2813 _channelId, 0xFFFFFFFF, fileBuffer.get(), fileSamples, mixingFrequency, 2813 _channelId, 0xFFFFFFFF, fileBuffer.get(), fileSamples, mixingFrequency,
2814 AudioFrame::kNormalSpeech, AudioFrame::kVadUnknown, 1); 2814 AudioFrame::kNormalSpeech, AudioFrame::kVadUnknown, 1);
2815 } 2815 }
2816 return 0; 2816 return 0;
2817 } 2817 }
(...skipping 18 matching lines...) Expand all
2836 fileBuffer.get(), &fileSamples, mixingFrequency) == -1) { 2836 fileBuffer.get(), &fileSamples, mixingFrequency) == -1) {
2837 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), 2837 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId),
2838 "Channel::MixAudioWithFile() file mixing failed"); 2838 "Channel::MixAudioWithFile() file mixing failed");
2839 return -1; 2839 return -1;
2840 } 2840 }
2841 } 2841 }
2842 2842
2843 if (audioFrame.samples_per_channel_ == fileSamples) { 2843 if (audioFrame.samples_per_channel_ == fileSamples) {
2844 // Currently file stream is always mono. 2844 // Currently file stream is always mono.
2845 // TODO(xians): Change the code when FilePlayer supports real stereo. 2845 // TODO(xians): Change the code when FilePlayer supports real stereo.
2846 MixWithSat(audioFrame.data_, audioFrame.num_channels_, fileBuffer.get(), 1, 2846 MixWithSat(audioFrame.mutable_data(), audioFrame.num_channels_,
2847 fileSamples); 2847 fileBuffer.get(), 1, fileSamples);
2848 } else { 2848 } else {
2849 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), 2849 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId),
2850 "Channel::MixAudioWithFile() samples_per_channel_(%" PRIuS 2850 "Channel::MixAudioWithFile() samples_per_channel_(%" PRIuS
2851 ") != " 2851 ") != "
2852 "fileSamples(%" PRIuS ")", 2852 "fileSamples(%" PRIuS ")",
2853 audioFrame.samples_per_channel_, fileSamples); 2853 audioFrame.samples_per_channel_, fileSamples);
2854 return -1; 2854 return -1;
2855 } 2855 }
2856 2856
2857 return 0; 2857 return 0;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
2992 int64_t min_rtt = 0; 2992 int64_t min_rtt = 0;
2993 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 2993 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) !=
2994 0) { 2994 0) {
2995 return 0; 2995 return 0;
2996 } 2996 }
2997 return rtt; 2997 return rtt;
2998 } 2998 }
2999 2999
3000 } // namespace voe 3000 } // namespace voe
3001 } // namespace webrtc 3001 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698