| OLD | NEW |
| 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 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 return AudioMixer::Source::AudioFrameInfo::kError; | 639 return AudioMixer::Source::AudioFrameInfo::kError; |
| 640 } | 640 } |
| 641 | 641 |
| 642 if (muted) { | 642 if (muted) { |
| 643 // TODO(henrik.lundin): We should be able to do better than this. But we | 643 // TODO(henrik.lundin): We should be able to do better than this. But we |
| 644 // will have to go through all the cases below where the audio samples may | 644 // will have to go through all the cases below where the audio samples may |
| 645 // be used, and handle the muted case in some way. | 645 // be used, and handle the muted case in some way. |
| 646 AudioFrameOperations::Mute(audio_frame); | 646 AudioFrameOperations::Mute(audio_frame); |
| 647 } | 647 } |
| 648 | 648 |
| 649 // Convert module ID to internal VoE channel ID |
| 650 audio_frame->id_ = VoEChannelId(audio_frame->id_); |
| 649 // Store speech type for dead-or-alive detection | 651 // Store speech type for dead-or-alive detection |
| 650 _outputSpeechType = audio_frame->speech_type_; | 652 _outputSpeechType = audio_frame->speech_type_; |
| 651 | 653 |
| 652 { | 654 { |
| 653 // Pass the audio buffers to an optional sink callback, before applying | 655 // Pass the audio buffers to an optional sink callback, before applying |
| 654 // scaling/panning, as that applies to the mix operation. | 656 // scaling/panning, as that applies to the mix operation. |
| 655 // External recipients of the audio (e.g. via AudioTrack), will do their | 657 // External recipients of the audio (e.g. via AudioTrack), will do their |
| 656 // own mixing/dynamic processing. | 658 // own mixing/dynamic processing. |
| 657 rtc::CritScope cs(&_callbackCritSect); | 659 rtc::CritScope cs(&_callbackCritSect); |
| 658 if (audio_sink_) { | 660 if (audio_sink_) { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 seq_num_allocator_proxy_(new TransportSequenceNumberProxy()), | 789 seq_num_allocator_proxy_(new TransportSequenceNumberProxy()), |
| 788 rtp_packet_sender_proxy_(new RtpPacketSenderProxy()), | 790 rtp_packet_sender_proxy_(new RtpPacketSenderProxy()), |
| 789 retransmission_rate_limiter_(new RateLimiter(Clock::GetRealTimeClock(), | 791 retransmission_rate_limiter_(new RateLimiter(Clock::GetRealTimeClock(), |
| 790 kMaxRetransmissionWindowMs)), | 792 kMaxRetransmissionWindowMs)), |
| 791 decoder_factory_(config.acm_config.decoder_factory), | 793 decoder_factory_(config.acm_config.decoder_factory), |
| 792 use_twcc_plr_for_ana_( | 794 use_twcc_plr_for_ana_( |
| 793 webrtc::field_trial::FindFullName("UseTwccPlrForAna") == "Enabled") { | 795 webrtc::field_trial::FindFullName("UseTwccPlrForAna") == "Enabled") { |
| 794 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), | 796 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), |
| 795 "Channel::Channel() - ctor"); | 797 "Channel::Channel() - ctor"); |
| 796 AudioCodingModule::Config acm_config(config.acm_config); | 798 AudioCodingModule::Config acm_config(config.acm_config); |
| 799 acm_config.id = VoEModuleId(instanceId, channelId); |
| 797 acm_config.neteq_config.enable_muted_state = true; | 800 acm_config.neteq_config.enable_muted_state = true; |
| 798 audio_coding_.reset(AudioCodingModule::Create(acm_config)); | 801 audio_coding_.reset(AudioCodingModule::Create(acm_config)); |
| 799 | 802 |
| 800 _outputAudioLevel.Clear(); | 803 _outputAudioLevel.Clear(); |
| 801 | 804 |
| 802 RtpRtcp::Configuration configuration; | 805 RtpRtcp::Configuration configuration; |
| 803 configuration.audio = true; | 806 configuration.audio = true; |
| 804 configuration.outgoing_transport = this; | 807 configuration.outgoing_transport = this; |
| 805 configuration.overhead_observer = this; | 808 configuration.overhead_observer = this; |
| 806 configuration.receive_statistics = rtp_receive_statistics_.get(); | 809 configuration.receive_statistics = rtp_receive_statistics_.get(); |
| (...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1632 void Channel::ProcessAndEncodeAudio(const AudioFrame& audio_input) { | 1635 void Channel::ProcessAndEncodeAudio(const AudioFrame& audio_input) { |
| 1633 // Avoid posting any new tasks if sending was already stopped in StopSend(). | 1636 // Avoid posting any new tasks if sending was already stopped in StopSend(). |
| 1634 rtc::CritScope cs(&encoder_queue_lock_); | 1637 rtc::CritScope cs(&encoder_queue_lock_); |
| 1635 if (!encoder_queue_is_active_) { | 1638 if (!encoder_queue_is_active_) { |
| 1636 return; | 1639 return; |
| 1637 } | 1640 } |
| 1638 std::unique_ptr<AudioFrame> audio_frame(new AudioFrame()); | 1641 std::unique_ptr<AudioFrame> audio_frame(new AudioFrame()); |
| 1639 // TODO(henrika): try to avoid copying by moving ownership of audio frame | 1642 // TODO(henrika): try to avoid copying by moving ownership of audio frame |
| 1640 // either into pool of frames or into the task itself. | 1643 // either into pool of frames or into the task itself. |
| 1641 audio_frame->CopyFrom(audio_input); | 1644 audio_frame->CopyFrom(audio_input); |
| 1645 audio_frame->id_ = ChannelId(); |
| 1642 encoder_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>( | 1646 encoder_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>( |
| 1643 new ProcessAndEncodeAudioTask(std::move(audio_frame), this))); | 1647 new ProcessAndEncodeAudioTask(std::move(audio_frame), this))); |
| 1644 } | 1648 } |
| 1645 | 1649 |
| 1646 void Channel::ProcessAndEncodeAudio(const int16_t* audio_data, | 1650 void Channel::ProcessAndEncodeAudio(const int16_t* audio_data, |
| 1647 int sample_rate, | 1651 int sample_rate, |
| 1648 size_t number_of_frames, | 1652 size_t number_of_frames, |
| 1649 size_t number_of_channels) { | 1653 size_t number_of_channels) { |
| 1650 // 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(). |
| 1651 rtc::CritScope cs(&encoder_queue_lock_); | 1655 rtc::CritScope cs(&encoder_queue_lock_); |
| 1652 if (!encoder_queue_is_active_) { | 1656 if (!encoder_queue_is_active_) { |
| 1653 return; | 1657 return; |
| 1654 } | 1658 } |
| 1655 CodecInst codec; | 1659 CodecInst codec; |
| 1656 const int result = GetSendCodec(codec); | 1660 const int result = GetSendCodec(codec); |
| 1657 std::unique_ptr<AudioFrame> audio_frame(new AudioFrame()); | 1661 std::unique_ptr<AudioFrame> audio_frame(new AudioFrame()); |
| 1662 audio_frame->id_ = ChannelId(); |
| 1658 // TODO(ossu): Investigate how this could happen. b/62909493 | 1663 // TODO(ossu): Investigate how this could happen. b/62909493 |
| 1659 if (result == 0) { | 1664 if (result == 0) { |
| 1660 audio_frame->sample_rate_hz_ = std::min(codec.plfreq, sample_rate); | 1665 audio_frame->sample_rate_hz_ = std::min(codec.plfreq, sample_rate); |
| 1661 audio_frame->num_channels_ = std::min(number_of_channels, codec.channels); | 1666 audio_frame->num_channels_ = std::min(number_of_channels, codec.channels); |
| 1662 } else { | 1667 } else { |
| 1663 audio_frame->sample_rate_hz_ = sample_rate; | 1668 audio_frame->sample_rate_hz_ = sample_rate; |
| 1664 audio_frame->num_channels_ = number_of_channels; | 1669 audio_frame->num_channels_ = number_of_channels; |
| 1665 LOG(LS_WARNING) << "Unable to get send codec for channel " << ChannelId(); | 1670 LOG(LS_WARNING) << "Unable to get send codec for channel " << ChannelId(); |
| 1666 RTC_NOTREACHED(); | 1671 RTC_NOTREACHED(); |
| 1667 } | 1672 } |
| 1668 RemixAndResample(audio_data, number_of_frames, number_of_channels, | 1673 RemixAndResample(audio_data, number_of_frames, number_of_channels, |
| 1669 sample_rate, &input_resampler_, audio_frame.get()); | 1674 sample_rate, &input_resampler_, audio_frame.get()); |
| 1670 encoder_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>( | 1675 encoder_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>( |
| 1671 new ProcessAndEncodeAudioTask(std::move(audio_frame), this))); | 1676 new ProcessAndEncodeAudioTask(std::move(audio_frame), this))); |
| 1672 } | 1677 } |
| 1673 | 1678 |
| 1674 void Channel::ProcessAndEncodeAudioOnTaskQueue(AudioFrame* audio_input) { | 1679 void Channel::ProcessAndEncodeAudioOnTaskQueue(AudioFrame* audio_input) { |
| 1675 RTC_DCHECK_RUN_ON(encoder_queue_); | 1680 RTC_DCHECK_RUN_ON(encoder_queue_); |
| 1676 RTC_DCHECK_GT(audio_input->samples_per_channel_, 0); | 1681 RTC_DCHECK_GT(audio_input->samples_per_channel_, 0); |
| 1677 RTC_DCHECK_LE(audio_input->num_channels_, 2); | 1682 RTC_DCHECK_LE(audio_input->num_channels_, 2); |
| 1683 RTC_DCHECK_EQ(audio_input->id_, ChannelId()); |
| 1678 | 1684 |
| 1679 bool is_muted = InputMute(); | 1685 bool is_muted = InputMute(); |
| 1680 AudioFrameOperations::Mute(audio_input, previous_frame_muted_, is_muted); | 1686 AudioFrameOperations::Mute(audio_input, previous_frame_muted_, is_muted); |
| 1681 | 1687 |
| 1682 if (_includeAudioLevelIndication) { | 1688 if (_includeAudioLevelIndication) { |
| 1683 size_t length = | 1689 size_t length = |
| 1684 audio_input->samples_per_channel_ * audio_input->num_channels_; | 1690 audio_input->samples_per_channel_ * audio_input->num_channels_; |
| 1685 RTC_CHECK_LE(length, AudioFrame::kMaxDataSizeBytes); | 1691 RTC_CHECK_LE(length, AudioFrame::kMaxDataSizeBytes); |
| 1686 if (is_muted && previous_frame_muted_) { | 1692 if (is_muted && previous_frame_muted_) { |
| 1687 rms_level_.AnalyzeMuted(length); | 1693 rms_level_.AnalyzeMuted(length); |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1950 int64_t min_rtt = 0; | 1956 int64_t min_rtt = 0; |
| 1951 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 1957 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
| 1952 0) { | 1958 0) { |
| 1953 return 0; | 1959 return 0; |
| 1954 } | 1960 } |
| 1955 return rtt; | 1961 return rtt; |
| 1956 } | 1962 } |
| 1957 | 1963 |
| 1958 } // namespace voe | 1964 } // namespace voe |
| 1959 } // namespace webrtc | 1965 } // namespace webrtc |
| OLD | NEW |