Webrtc源码开发笔记1 —Webrtc视频编码打包流程模块图解

本文详述了Webrtc视频编码与打包流程,从RtpTransceiver到Call模块,再到RTP/RTCP相关模块,梳理了视频采集、编码、打包及发送的关键步骤与涉及的模块。

 

目录

 

Webrtc源码开发笔记1 —Webrtc视频编码打包流程模块图解

1. RtpTransceiver

2.Channel相关模块

2.1 VideoChannel

2.2BaseChannel

2.3 WebRtcVideoChannel

3.Call模块与Stream

4.RTP/RTCP


Webrtc源码开发笔记1 —Webrtc视频编码打包流程模块图解

本章旨在梳理webrtc从transceiver到transport流程,从而宏观上了解webrtc视频采集,编码,打包发送等相关流程与相关模块的对应关系,为开发和快速定位问题提供参考。

第1小节选择以transceiver为起点,transceiver在peerconnection中承接了控制数据收发的功能,内部关联了ChannelInterface与RtpSenderInternal和RtpReceiverInternal。其中channel相关模块负责维护数据收发的业务流程,以视频发送为例,其中Stream相关模块用于视频编码和实现rtp/rtcp相关功能,最终打包后的数据由BaseChannel内的tramsport模块实现视频发送。下图列举了从采集到视频帧到编码和打包的主要模块和流程。

第2小节主要梳理Channel相关模块。Channel是Webrtc实现数据收发相关业务的主要模块,目前Webrtc中有多种Channel,我们将通过视频打包发送流程简单梳理这些Channel的功能以及之间的关系。

第3小节主要介绍Call和Stream相关模块。Call中创建了各种Stream,这些Stream存在于Channel中,封装了数据编解码以及RTP打包、RTCP处理相关功能。

第4小节梳理了视频发送RTP/RTCP相关模块间的关系。

graffle文件下载地址 https://download.youkuaiyun.com/download/lidec/12517879

 

1. RtpTransceiver

下面是RtpTransceiver的注释

// Implementation of the public RtpTransceiverInterface.

//

// The RtpTransceiverInterface is only intended to be used with a PeerConnection

// that enables Unified Plan SDP. Thus, the methods that only need to implement

// public API features and are not used internally can assume exactly one sender

// and receiver.

//

// Since the RtpTransceiver is used internally by PeerConnection for tracking

// RtpSenders, RtpReceivers, and BaseChannels, and PeerConnection needs to be

// backwards compatible with Plan B SDP, this implementation is more flexible

// than that required by the WebRTC specification.

//

// With Plan B SDP, an RtpTransceiver can have any number of senders and

// receivers which map to a=ssrc lines in the m= section.

// With Unified Plan SDP, an RtpTransceiver will have exactly one sender and one

// receiver which are encapsulated by the m= section.

//

// This class manages the RtpSenders, RtpReceivers, and BaseChannel associated

// with this m= section. Since the transceiver, senders, and receivers are

// reference counted and can be referenced from JavaScript (in Chromium), these

// objects must be ready to live for an arbitrary amount of time. The

// BaseChannel is not reference counted and is owned by the ChannelManager, so

// the PeerConnection must take care of creating/deleting the BaseChannel and

// setting the channel reference in the transceiver to null when it has been

// deleted.

//

// The RtpTransceiver is specialized to either audio or video according to the

// MediaType specified in the constructor. Audio RtpTransceivers will have

// AudioRtpSenders, AudioRtpReceivers, and a VoiceChannel. Video RtpTransceivers

// will have VideoRtpSenders, VideoRtpReceivers, and a VideoChannel.

这里RtpTransceiver实现RtpTransceiverInterface,用于实现PeerConnection中Unified Plan SDP所指定的通用功能。其主要用于PeerConnection中维护RtpSenders, RtpReceivers和BaseChannels,同时其设计兼容B SDP。这里Unified Plan SDP中 m= section  指定维护一个sender和一个receiver,Plan B SDP中会维护多个sender和receiver,用a=ssrc区分。这里BaseChannel的生命周期是由ChannelManager管理的,RtpTransceiver中只保持对其指针的使用。对于音频或者视频数据的收发,分别通过AudioRtpSenders, AudioRtpReceivers和VoiceChannel 与 VideoRtpSenders, VideoRtpReceivers,VideoChannel实现。<

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值