当前位置:网站首页>webrtc代码解读一:音频数据的接收解码播放过程
webrtc代码解读一:音频数据的接收解码播放过程
2022-08-04 05:32:00 【睏哥RTC】
RTP connection创建过程(从下往上调用):
Channel::Channel调用RtpRtcp::CreateRtpRtcp
Channel::Channel 调用RtpReceiver::CreateAudioReceiver (RtpReceiver,这里注册Channel类为RTP包回调处理类)
ChannelProxy::ChannelProxy里调用new voe::Channel
CreateChannelAndProxy里调用new voe::ChannelProxy
AudioReceiveStream::AudioReceiveStream调用CreateChannelAndProxy
call::CreateAudioReceiveStream里new internal::AudioReceiveStream (成员列表里也保存了new出的对象,注意:internal::AudioReceiveStream 继承自webrtc::AudioReceiveStream )
WebRtcVoiceMediaChannel::RecreateAudioReceiveStream里调用: call::CreateAudioReceiveStream; (保存到成员变量:webrtc::AudioReceiveStream* stream_)
WebRtcVoiceMediaChannel构造函数等里调用RecreateAudioReceiveStream
WebRtcVoiceEngine::CreateChannel 里new出WebRtcVoiceMediaChannel对象
ChannelManager::CreateVoiceChannel里调用WebRtcVoiceEngine::CreateChannel
PeerConnection::CreateVoiceChannel里调用ChannelManager::CreateVoiceChannel
PeerConnection::CreateChannels里调用PeerConnection::CreateVoiceChannel
PeerConnection::ApplyLocalDescription里调用PeerConnection::CreateChannels
PeerConnection::SetLocalDescription里调用PeerConnection::ApplyLocalDescription
RTP回调函数注册:
注册SignalReadPacket的回调:
PeerConnection::SetLocalDescription->PeerConnection::ApplyLocalDescription->PeerConnection::PushdownTransportDescription -> JsepTransportController::SetLocalDescription->JsepTransportController::ApplyDescription_n -> JsepTransportController::MaybeCreateJsepTransport->JsepTransportController::CreateDtlsSrtpTransport-> DtlsSrtpTransport::SetDtlsTransports->RtpTransport::SetRtpPacketTransport -> new_packet_transport->SignalReadPacket.connect(this,&RtpTransport::OnReadPacket);
JsepTransportController::MaybeCreateJsepTransport -> JsepTransportController::CreateDtlsTransport -> new cricket::P2PTransportChannel
AllocationSequence::CreateUDPPorts调用UDPPort::Create
AllocationSequence::Init调用rtc::AsyncPacketSocket::connect(this, &AllocationSequence::OnReadPacket)
AllocationSequence::OnReadPacket调用UDPPort::OnReadPacket调用(Connection::OnReadPacket或Port::OnReadPacket)
Connection::OnReadPacket转发到P2PTransportChannel::OnReadPacket
注册SignalPacketReceived的回调:
PeerConnection::CreateVoiceChannel 调用 voice_channel->SetRtpTransport(rtp_transport); 调用BaseChannel::ConnectToRtpTransport 调用 rtp_transport_->SignalPacketReceived.connect(this,
&BaseChannel::OnPacketReceived);
RTP包投递过程:
AsyncUDPSocket::OnReadEvent发出SignalReadPacket事件, RtpTransport::OnReadPacket 处理事件,转发 BaseChannel::OnPacketReceived->BaseChannel::ProcessPacket->WebRtcVoiceMediaChannel::OnPacketReceived -> Call::DeliverPacket->Call::DeliverRtp -> audio_receiver_controller_.OnRtpPacket -> demuxer_.OnRtpPacket -> (sink->OnRtpPacket(packet) 此处sink为addsink添加的ChannelProxy指针) -> ChannelProxy::OnRtpPacket -> Channel::OnRtpPacket->Channel::ReceivePacket-> (rtp_receiver_->IncomingRtpPacket) -> RTPReceiverVideo::ParseRtpPacket ->Channel::OnReceivedPayloadData(rtp模块回调未解码原始帧) -> audio_coding_->IncomingPacket ->receiver_.InsertPacket -> NetEqImpl::InsertPacket -> NetEqImpl::InsertPacketInternal
音频解码:
AudioDeviceWindowsCore::DoRenderThread()->AudioDeviceBuffer::RequestPlayoutData->AudioTransportImpl::NeedMorePlayData->AudioTransportImpl::PullRenderData->AudioMixerImpl::Mix->AudioMixerImpl::GetAudioFromSources->AudioReceiveStream::GetAudioFrameWithInfo(AudioReceiveStream实现了AudioMixer::Source) ->ChannelProxy::GetAudioFrameWithInfo->Channel::GetAudioFrameWithInfo->AudioCodingModuleImpl::PlayoutData10Ms->AcmReceiver::GetAudio->NetEqImpl::GetAudio->NetEqImpl::GetAudioInternal -> NetEqImpl::Decode -> NetEqImpl::DecodeLoop
边栏推荐
- 在AWS-EC2中安装Minikube集群
- Stream API
- Question 1000: Input two integers a and b, calculate the sum of a+b, this question is multiple sets of test data
- LeetCode_Dec_2nd_Week
- [开发杂项][编辑器][代码阅读]ctags&vim
- LeetCode_Nov_5th_Week
- 第三章 标准单元库(下)
- file permission management ugo
- 淘宝分布式文件系统存储(二)
- 题目1000:输入两个整数a和b,计算a+b的和,此题是多组测试数据
猜你喜欢
安装MySQL的详细步骤
Golang environment variable settings (2)--GOMODULE & GOPROXY
The second official example analysis of the MOOSE platform - about creating a Kernel and solving the convection-diffusion equation
Question 1000: Input two integers a and b, calculate the sum of a+b, this question is multiple sets of test data
Shell基础
target has libraries with conflicting names: libcrypto.a and libssl.a.
arm-3-中断体系结构
[Deep Learning Diary] Day 1: Hello world, Hello CNN MNIST
C语言静态变量static的分析
基于语音识别的QT设计的csgo互动类视频游戏
随机推荐
JDBC第一学之进行数据库连接时出现The server time zone.....解决办法
Tensorflow/Pytorch安装(Anaconda环境下,无版本冲突,亲测有效)
代码庆端午--粽你心意
实现高并发服务器(二)
Completely remove MySQL tutorial
LeetCode_Nov_3rd_Week
Amazon Cloud Technology Build On 2022 - AIot Season 2 IoT Special Experiment Experience
tmux concept and usage
[开发杂项][调试]debug into kernel
counting cycle
LeetCode_22_Apr_2nd_Week
Detailed steps to install MySQL
[日常办公][杂项][vscode]tab space
Design and implementation of legal aid platform based on asp.net (with project link)
Shell基础
MNIST Handwritten Digit Recognition - Image Analysis Method for Binary Classification
安装MySQL的详细步骤
IEEE802.X protocol suite
A code example of the PCL method in the domain of DG (Domain Generalization)
题目1000:输入两个整数a和b,计算a+b的和,此题是多组测试数据