nativeCreateVideoSource
初始化
PeerConnectionFactory(pc/peerconnectionfactory
) 创建PeerConnection方法中:
1 | rtc::scoped_refptr<PeerConnectionInterface> |
构造PeerConnection对象pc,并调用初始化方法Initialize,Initialize中:
1 | ool PeerConnection::Initialize( |
调用CreateCall_w创建call对象:
1 | void PeerConnection::CreateCall_w() { |
使用call对象以及PeerConnectionFactory中channel_manager(PeerConnectionFactory中Initialize中创建)构造WebRtcSession对象session_,调用Initialize方法初始化session_,初始化session_槽函数等.session_初始化方法中创建WebRtcSessionDescriptionFactory对象webrtc_session_desc_factory_.
创建Channel
WebRtcSession::SetLocalDescription:
1 | bool WebRtcSession::SetLocalDescription(SessionDescriptionInterface* desc, |
action为offer时CreateChannel创建channels:
1 | bool WebRtcSession::CreateChannels(const SessionDescription* desc) { |
CreateChannels中创建三个Channel,其中CreateVideoChannel创建视频Channel:
1 | bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content, |
调用channel_manager的CreateVideoChannel创建BaseChannel基类的cricket::VideoChannel. VideoChannel需要传入VideoMediaChannel作为构造参数:
1 | //pc/channelmanager.h/cc |
VideoMediaChannel实例media_channel由MediaEngineInterface对象media_engine创建,media_engine由ChannelManager构造方法传入并初始化,ChannelManager由PeerConnectionFactory创建,在PeerConnection初始化方法中,media_engine被创建:
1 | //pc/peerconnectionfactory.cc |
WebRtcMediaEngine2继承自CompositeMediaEngine,CompositeMediaEngine父类MediaEngineInterface有WebRtcVoiceEngine voice
与WebRtcVideoEngine2 video
两个对象
WebRtcVideoEngine2
WebRtcVideoEngine2定义在media/engine/webrtcvideoengine2.h
下,用于创建WebRtcVideoChannel2(定义在同一头文件),WebRtcVideoChannel2定义了WebRtcVideoSendStream与WebRtcVideoReceiveStream两个内部类.