WebRTCDemo.apk代码走读(三):音频接收流程

收到音频包
UdpSocketManagerPosixImpl::Run
    UdpSocketManagerPosixImpl::Process
        UdpSocketPosix::HasIncoming(recvfrom)
            UdpTransportImpl::IncomingRTPCallback
                UdpTransportImpl::IncomingRTPFunction
                    VoiceChannelTransport::IncomingRTPPacket
                        VoENetworkImpl::ReceivedRTPPacket
                            Channel::ReceivedRTPPacket
                                UpdatePlayoutTimestamp
                                    AudioCodingModuleImpl::PlayoutTimestamp
                                        AcmReceiver::GetPlayoutTimestamp
                                            InitialDelayManager::GetPlayoutTimestamp
                                    AudioDeviceModuleImpl::PlayoutDelay
                                        AudioDeviceTemplate::PlayoutDelay
                                            OpenSlesOutput::PlayoutDelay
                                Channel::IsPacketInOrder
                                    ReceiveStatisticsImpl::GetStatistician (这个类应该管理所有的流)
                                    StreamStatisticianImpl::IsPacketInOrder
                                        StreamStatisticianImpl::InOrderPacketInternal (可以学习一下这个判断乱序代码)
                                Channel::IsPacketRetransmitted
                                    StreamStatisticianImpl::IsRetransmitOfOldPacket (可以学习一下这个判断重传代码)
                                ReceiveStatisticsImpl::IncomingPacket       
                                    如果是第一次收到,创建StreamStatisticianImpl                                   
                                    StreamStatisticianImpl::IncomingPacket
                                        StreamStatisticianImpl::UpdateCounters  记录必要的信息, 用于统计,如乱序、重传、jitbuff、计算bitrate
                                        StreamStatisticianImpl::NotifyRtpCallback
                                            ReceiveStatisticsImpl::DataCountersUpdated(没做处理)
                                Channel::ReceivePacket
                                    RtpReceiverImpl::IncomingRtpPacket
                                        check ssrc/play/timestamp
                                        RtpReceiverImpl::CheckSSRCChanged
                                            如果是第一次,则Channel::OnInitializeDecoder
                                                AudioCodingModule::Codec, 选择具体的Codec Inst(数组,一开始已经初始化好所有的)
                                                AudioCodingModuleImpl::RegisterReceiveCodec
                                                    AudioCodingModuleImpl::GetAudioDecoder
                                                        AudioCodingModuleImpl::CreateCodec
                                                            ACMCodecDB::CreateCodecInstance
                                                                new ACMISAC
                                                    AcmReceiver::AddCodec
                                                        NetEq初始化
                                                        NetEqImpl::RegisterExternalDecoder
                                        RTPReceiverAudio::ParseRtpPacket
                                            RTPReceiverAudio::ParseAudioCodecSpecific
                                                判断是不是dtmf、cgn、2833等
                                                Channel::OnReceivedPayloadData
                                                    AudioCodingModuleImpl::IncomingPacket
                                                        AcmReceiver::InsertPacket
                                                            ack
                                                            唇音同步
                                                            NetEqImpl::InsertPacket
                                                                NetEqImpl::InsertPacketInternal
                                                                    ACMISAC::IncomingPacket
                                                        ACMISAC::UpdateDecoderSampFreq
                                                            WebRtcIsac_SetDecSampRate
                                                                DecoderInitUb
                                                    Channel::UpdatePacketDelay
                                                        Channel::GetPlayoutFrequency(
                                                            AudioCodingModuleImpl::PlayoutFrequency()
AudioTrackJni::PlayThreadProcess
    AudioDeviceBuffer::RequestPlayoutData
        VoEBaseImpl::NeedMorePlayData
            VoEBaseImpl::GetPlayoutData
                AudioConferenceMixerImpl::Process
                    AudioConferenceMixerImpl::UpdateToMix
                        所有的与会者Channel::GetAudioFrame
                            AudioCodingModuleImpl::PlayoutData10Ms
                                AcmReceiver::GetAudio
                                    时间判断
                                    可能产生静音包
                                    NetEqImpl::GetAudio
                                        NetEqImpl::GetAudioInternal
                                            NetEqImpl::Decode
                                                ACMISAC::DecodePlc
                                                NetEqImpl::DecodeLoop
                                                    ACMISAC::Decode
                                    NetEqImpl::DecodedRtpInfo
                                    ack的处理
                                    重采样
                            Channel::UpdateRxVadDetection
                                Channel::OnRxVadDetected
                             AudioProcessingImpl::ProcessStream
                                 AudioBuffer::DeinterleaveFrom
                                 AudioBuffer::InterleaveTo
                             必要的音频处理,scale之类的
                        音量判断
                    合成声音                
                OutputMixer::GetMixedAudio  获取合成完的数据
    AudioDeviceBuffer::GetPlayoutData
    复制到java内存
    调用Java程序CallIntMethod(_javaScObj, _javaMidPlayAudio,                                                            

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。