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

Side by Side Diff: voice_engine/channel.cc

Issue 3019543002: Remove various IDs (Closed)
Patch Set: rebase+build error Created 3 years, 2 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 | « modules/module_common_types_unittest.cc ('k') | voice_engine/voice_engine_defines.h » ('j') | 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 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 return AudioMixer::Source::AudioFrameInfo::kError; 640 return AudioMixer::Source::AudioFrameInfo::kError;
641 } 641 }
642 642
643 if (muted) { 643 if (muted) {
644 // TODO(henrik.lundin): We should be able to do better than this. But we 644 // TODO(henrik.lundin): We should be able to do better than this. But we
645 // will have to go through all the cases below where the audio samples may 645 // will have to go through all the cases below where the audio samples may
646 // be used, and handle the muted case in some way. 646 // be used, and handle the muted case in some way.
647 AudioFrameOperations::Mute(audio_frame); 647 AudioFrameOperations::Mute(audio_frame);
648 } 648 }
649 649
650 // Convert module ID to internal VoE channel ID
651 audio_frame->id_ = VoEChannelId(audio_frame->id_);
652 // Store speech type for dead-or-alive detection 650 // Store speech type for dead-or-alive detection
653 _outputSpeechType = audio_frame->speech_type_; 651 _outputSpeechType = audio_frame->speech_type_;
654 652
655 { 653 {
656 // Pass the audio buffers to an optional sink callback, before applying 654 // Pass the audio buffers to an optional sink callback, before applying
657 // scaling/panning, as that applies to the mix operation. 655 // scaling/panning, as that applies to the mix operation.
658 // External recipients of the audio (e.g. via AudioTrack), will do their 656 // External recipients of the audio (e.g. via AudioTrack), will do their
659 // own mixing/dynamic processing. 657 // own mixing/dynamic processing.
660 rtc::CritScope cs(&_callbackCritSect); 658 rtc::CritScope cs(&_callbackCritSect);
661 if (audio_sink_) { 659 if (audio_sink_) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 seq_num_allocator_proxy_(new TransportSequenceNumberProxy()), 788 seq_num_allocator_proxy_(new TransportSequenceNumberProxy()),
791 rtp_packet_sender_proxy_(new RtpPacketSenderProxy()), 789 rtp_packet_sender_proxy_(new RtpPacketSenderProxy()),
792 retransmission_rate_limiter_(new RateLimiter(Clock::GetRealTimeClock(), 790 retransmission_rate_limiter_(new RateLimiter(Clock::GetRealTimeClock(),
793 kMaxRetransmissionWindowMs)), 791 kMaxRetransmissionWindowMs)),
794 decoder_factory_(config.acm_config.decoder_factory), 792 decoder_factory_(config.acm_config.decoder_factory),
795 use_twcc_plr_for_ana_( 793 use_twcc_plr_for_ana_(
796 webrtc::field_trial::FindFullName("UseTwccPlrForAna") == "Enabled") { 794 webrtc::field_trial::FindFullName("UseTwccPlrForAna") == "Enabled") {
797 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), 795 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId),
798 "Channel::Channel() - ctor"); 796 "Channel::Channel() - ctor");
799 AudioCodingModule::Config acm_config(config.acm_config); 797 AudioCodingModule::Config acm_config(config.acm_config);
800 acm_config.id = VoEModuleId(instanceId, channelId);
801 acm_config.neteq_config.enable_muted_state = true; 798 acm_config.neteq_config.enable_muted_state = true;
802 audio_coding_.reset(AudioCodingModule::Create(acm_config)); 799 audio_coding_.reset(AudioCodingModule::Create(acm_config));
803 800
804 _outputAudioLevel.Clear(); 801 _outputAudioLevel.Clear();
805 802
806 RtpRtcp::Configuration configuration; 803 RtpRtcp::Configuration configuration;
807 configuration.audio = true; 804 configuration.audio = true;
808 configuration.outgoing_transport = this; 805 configuration.outgoing_transport = this;
809 configuration.overhead_observer = this; 806 configuration.overhead_observer = this;
810 configuration.receive_statistics = rtp_receive_statistics_.get(); 807 configuration.receive_statistics = rtp_receive_statistics_.get();
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 void Channel::ProcessAndEncodeAudio(const AudioFrame& audio_input) { 1633 void Channel::ProcessAndEncodeAudio(const AudioFrame& audio_input) {
1637 // Avoid posting any new tasks if sending was already stopped in StopSend(). 1634 // Avoid posting any new tasks if sending was already stopped in StopSend().
1638 rtc::CritScope cs(&encoder_queue_lock_); 1635 rtc::CritScope cs(&encoder_queue_lock_);
1639 if (!encoder_queue_is_active_) { 1636 if (!encoder_queue_is_active_) {
1640 return; 1637 return;
1641 } 1638 }
1642 std::unique_ptr<AudioFrame> audio_frame(new AudioFrame()); 1639 std::unique_ptr<AudioFrame> audio_frame(new AudioFrame());
1643 // TODO(henrika): try to avoid copying by moving ownership of audio frame 1640 // TODO(henrika): try to avoid copying by moving ownership of audio frame
1644 // either into pool of frames or into the task itself. 1641 // either into pool of frames or into the task itself.
1645 audio_frame->CopyFrom(audio_input); 1642 audio_frame->CopyFrom(audio_input);
1646 audio_frame->id_ = ChannelId();
1647 // Profile time between when the audio frame is added to the task queue and 1643 // Profile time between when the audio frame is added to the task queue and
1648 // when the task is actually executed. 1644 // when the task is actually executed.
1649 audio_frame->UpdateProfileTimeStamp(); 1645 audio_frame->UpdateProfileTimeStamp();
1650 encoder_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>( 1646 encoder_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(
1651 new ProcessAndEncodeAudioTask(std::move(audio_frame), this))); 1647 new ProcessAndEncodeAudioTask(std::move(audio_frame), this)));
1652 } 1648 }
1653 1649
1654 void Channel::ProcessAndEncodeAudio(const int16_t* audio_data, 1650 void Channel::ProcessAndEncodeAudio(const int16_t* audio_data,
1655 int sample_rate, 1651 int sample_rate,
1656 size_t number_of_frames, 1652 size_t number_of_frames,
1657 size_t number_of_channels) { 1653 size_t number_of_channels) {
1658 // Avoid posting as new task if sending was already stopped in StopSend(). 1654 // Avoid posting as new task if sending was already stopped in StopSend().
1659 rtc::CritScope cs(&encoder_queue_lock_); 1655 rtc::CritScope cs(&encoder_queue_lock_);
1660 if (!encoder_queue_is_active_) { 1656 if (!encoder_queue_is_active_) {
1661 return; 1657 return;
1662 } 1658 }
1663 CodecInst codec; 1659 CodecInst codec;
1664 const int result = GetSendCodec(codec); 1660 const int result = GetSendCodec(codec);
1665 std::unique_ptr<AudioFrame> audio_frame(new AudioFrame()); 1661 std::unique_ptr<AudioFrame> audio_frame(new AudioFrame());
1666 audio_frame->id_ = ChannelId();
1667 // TODO(ossu): Investigate how this could happen. b/62909493 1662 // TODO(ossu): Investigate how this could happen. b/62909493
1668 if (result == 0) { 1663 if (result == 0) {
1669 audio_frame->sample_rate_hz_ = std::min(codec.plfreq, sample_rate); 1664 audio_frame->sample_rate_hz_ = std::min(codec.plfreq, sample_rate);
1670 audio_frame->num_channels_ = std::min(number_of_channels, codec.channels); 1665 audio_frame->num_channels_ = std::min(number_of_channels, codec.channels);
1671 } else { 1666 } else {
1672 audio_frame->sample_rate_hz_ = sample_rate; 1667 audio_frame->sample_rate_hz_ = sample_rate;
1673 audio_frame->num_channels_ = number_of_channels; 1668 audio_frame->num_channels_ = number_of_channels;
1674 LOG(LS_WARNING) << "Unable to get send codec for channel " << ChannelId(); 1669 LOG(LS_WARNING) << "Unable to get send codec for channel " << ChannelId();
1675 RTC_NOTREACHED(); 1670 RTC_NOTREACHED();
1676 } 1671 }
1677 RemixAndResample(audio_data, number_of_frames, number_of_channels, 1672 RemixAndResample(audio_data, number_of_frames, number_of_channels,
1678 sample_rate, &input_resampler_, audio_frame.get()); 1673 sample_rate, &input_resampler_, audio_frame.get());
1679 encoder_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>( 1674 encoder_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(
1680 new ProcessAndEncodeAudioTask(std::move(audio_frame), this))); 1675 new ProcessAndEncodeAudioTask(std::move(audio_frame), this)));
1681 } 1676 }
1682 1677
1683 void Channel::ProcessAndEncodeAudioOnTaskQueue(AudioFrame* audio_input) { 1678 void Channel::ProcessAndEncodeAudioOnTaskQueue(AudioFrame* audio_input) {
1684 RTC_DCHECK_RUN_ON(encoder_queue_); 1679 RTC_DCHECK_RUN_ON(encoder_queue_);
1685 RTC_DCHECK_GT(audio_input->samples_per_channel_, 0); 1680 RTC_DCHECK_GT(audio_input->samples_per_channel_, 0);
1686 RTC_DCHECK_LE(audio_input->num_channels_, 2); 1681 RTC_DCHECK_LE(audio_input->num_channels_, 2);
1687 RTC_DCHECK_EQ(audio_input->id_, ChannelId());
1688 1682
1689 // Measure time between when the audio frame is added to the task queue and 1683 // Measure time between when the audio frame is added to the task queue and
1690 // when the task is actually executed. Goal is to keep track of unwanted 1684 // when the task is actually executed. Goal is to keep track of unwanted
1691 // extra latency added by the task queue. 1685 // extra latency added by the task queue.
1692 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Audio.EncodingTaskQueueLatencyMs", 1686 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Audio.EncodingTaskQueueLatencyMs",
1693 audio_input->ElapsedProfileTimeMs()); 1687 audio_input->ElapsedProfileTimeMs());
1694 1688
1695 bool is_muted = InputMute(); 1689 bool is_muted = InputMute();
1696 AudioFrameOperations::Mute(audio_input, previous_frame_muted_, is_muted); 1690 AudioFrameOperations::Mute(audio_input, previous_frame_muted_, is_muted);
1697 1691
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 int64_t min_rtt = 0; 1960 int64_t min_rtt = 0;
1967 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 1961 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) !=
1968 0) { 1962 0) {
1969 return 0; 1963 return 0;
1970 } 1964 }
1971 return rtt; 1965 return rtt;
1972 } 1966 }
1973 1967
1974 } // namespace voe 1968 } // namespace voe
1975 } // namespace webrtc 1969 } // namespace webrtc
OLDNEW
« no previous file with comments | « modules/module_common_types_unittest.cc ('k') | voice_engine/voice_engine_defines.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698