webrtc自带client的视频引擎创建代码走读
src\webrtc\examples\peerconnection\client\conductor.cc
bool Conductor::InitializePeerConnection()
1 webrtc::CreatePeerConnectionFactory();
src\talk\app\webrtc\peerconnectionfactory.cc
1.1 new rtc::RefCountedObject<PeerConnectionFactory>()
1.2 bool PeerConnectionFactory::Initialize()
1.2.1 cricket::MediaEngineInterface* media_engine = PeerConnectionFactory::CreateMediaEngine_w()
src\talk\media\webrtc\webrtcmediaengine.cc
1.2.1.1
MediaEngineInterface* WebRtcMediaEngineFactory::Create(webrtc::AudioDeviceModule* adm,WebRtcVideoEncoderFactory* encoder_factory,WebRtcVideoDecoderFactory* decoder_factory)
{
return CreateWebRtcMediaEngine(adm, encoder_factory, decoder_factory);
}
1.2.1.2
cricket::MediaEngineInterface* WebRtcMediaEngineFactory:: CreateWebRtcMediaEngine(
webrtc::AudioDeviceModule* adm,WebRtcVideoEncoderFactory* encoder_factory,WebRtcVideoDecoderFactory* decoder_factory)
{
return new cricket::WebRtcMediaEngine2(adm, encoder_factory,decoder_factory);
}
1.2.1.3
class WebRtcMediaEngine2: public CompositeMediaEngine<WebRtcVoiceEngine, WebRtcVideoEngine2>
{
public:
WebRtcMediaEngine2(webrtc::AudioDeviceModule* adm,WebRtcVideoEncoderFactory* encoder_factory,WebRtcVideoDecoderFactory* decoder_factory)
};
1.2.1.4
src\talk\media\webrtc\webrtcmediaengine.cc
WebRtcVideoEngine2::WebRtcVideoEngine2()
: initialized_(false),
external_decoder_factory_(NULL),
external_encoder_factory_(NULL)
{
video_codecs_ = GetSupportedCodecs(); // 获得视频编解码器列表(含内部默认支持的和外部引入的,外部最多引入8个)
}
std::vector<VideoCodec> WebRtcVideoEngine2::GetSupportedCodecs() const
{
//读取默认的视频编解码器列表 VP8(默认最宽640 最高480 最多15fps) VP9(如果内部支持) H264(如果内部支持) Rtx Red Ulpfec
std::vector<VideoCodec> supported_codecs = DefaultVideoCodecList();
}
1.2.2 channel_manager_.reset(
new cricket::ChannelManager(media_engine, worker_thread_));
1.2.2.1 ConstructDataEngine{new HybridDataEngine(new RtpDataEngine(), new SctpDataEngine())}
1.2.2.2 new CaptureManager()
1.2.2.3 audio_options_ = media_engine_->GetAudioOptions();
1.2.3 channel_manager_->Init()
1.2.3.1 ChannelManager::InitMediaEngine_w调用media_engine_->Init(worker_thread_)
template<class VOICE, class VIDEO>
class CompositeMediaEngine : public MediaEngineInterface
{
virtual bool Init(rtc::Thread* worker_thread)
{
if (!voice_.Init(worker_thread)) return false;
video_.Init();
return true;
}
};
1.2.3.2 SetAudioOptions(audio_options_)
1.2.3.3 SetOutputVolume(audio_output_volume_)
1.2.3.4 SetDefaultVideoEncoderConfig(default_video_encoder_config_)
2 peer_connection_ =
peer_connection_factory_->CreatePeerConnection()
2.1 PeerConnection::Initialize
2.1.1 ParseIceServers(configuration.servers, &stun_config, &turn_config)
2.1.2 port_allocator_->SetIceServers(cricket_stuns, cricket_turns);
2.1.3 media_controller_.reset(factory_->CreateMediaController());
2.1.4 remote_stream_factory_.reset(new RemoteMediaStreamFactory)
2.1.5 session_.reset(new WebRtcSession)
2.1.6 stats_.reset(new StatsCollector(this));
2.1.7 session_->Initialize()
2.1.8 session_->RegisterIceObserver(this);
2.1.9 session_->SignalState.connect(this, &PeerConnection::OnSessionStateChange);
Conductor::OnSuccess(webrtc::SessionDescriptionInterface* desc)
{
peer_connection_->SetLocalDescription(DummySetSessionDescriptionObserver::Create(), desc);
}
PeerConnection::SetLocalDescription()
{
session_->SetLocalDescription(desc, &error)
}
WebRtcSession::SetLocalDescription
{
if (action == kOffer && !CreateChannels(local_desc_->description()))
}
bool WebRtcSession::CreateChannels(const SessionDescription* desc)
{
CreateVoiceChannel(voice)
CreateVideoChannel(video)->ChannelManager::CreateVideoChannel->ChannelManager::CreateVideoChannel_w
CreateDataChannel(data)
}
WebRtcSession::SetRemoteDescription类同SetLocalDescription
VideoChannel* ChannelManager::CreateVideoChannel_w()
{
VideoMediaChannel* media_channel =
media_engine_->CreateVideoChannel即media_engine_指向WebRtcVideoChannel2
}
class WebRtcVideoChannel2 : public rtc::MessageHandler,public VideoMediaChannel,
WebRtcVideoChannel2* WebRtcVideoEngine2::CreateChannel(webrtc::Call* call,const VideoOptions& options)
{
return new WebRtcVideoChannel2(call, options, video_codecs_,external_encoder_factory_, external_decoder_factory_);
}
VideoChannel* video_channel = new VideoChannel
video_channel->Init()
BaseChannel::Init()
3 Conductor::AddStreams()
3.1 peer_connection_factory_->CreateAudioTrack
3.2 peer_connection_factory_->CreateAudioSource
3.3 peer_connection_factory_->CreateVideoTrack
3.4 peer_connection_factory_->CreateVideoSource(OpenVideoCaptureDevice())
3.5 peer_connection_factory_->CreateLocalMediaStream(kStreamLabel)
3.6 stream->AddTrack(audio_track);
3.7 stream->AddTrack(video_track);
3.8 peer_connection_->AddStream(stream)
3.4.1
rtc::scoped_ptr<cricket::DeviceManagerInterface> dev_manager
DeviceManagerInterface* DeviceManagerFactory::Create() {
return new Win32DeviceManager();
}
class Win32DeviceManager : public DeviceManager
dev_manager->Init()
dev_manager->GetVideoCaptureDevices(&devs)
capturer = dev_manager->CreateVideoCapturer(*dev_it) // 可能是从文件读取的假捕获器
DeviceManager::DeviceManager()
{
SetVideoDeviceCapturerFactory(new WebRtcVideoDeviceCapturerFactory()); // 给video_device_capturer_factory_赋值
}
VideoCapturer* DeviceManager::CreateVideoCapturer(const Device& device)
{
rtc::scoped_ptr<
VideoDeviceCapturerFactory> video_device_capturer_factory_;
capturer = video_device_capturer_factory_->Create(device);
}
VideoCapturer* WebRtcVideoDeviceCapturerFactory::Create(const Device& device)
{
rtc::scoped_ptr<WebRtcVideoCapturer> capturer(new WebRtcVideoCapturer());
capturer->Init(device)
}
src\talk\media\webrtc\webrtcvideocapturer.cc
WebRtcVideoCapturer::WebRtcVideoCapturer()
: factory_(new WebRtcVcmFactory)
,module_(nullptr)
,captured_frames_(0)
,start_thread_(nullptr)
,async_invoker_(nullptr)
{
set_frame_factory(new WebRtcVideoFrameFactory());
}
bool WebRtcVideoCapturer::Init(const Device& device)
{
webrtc::VideoCaptureModule::DeviceInfo* info = factory_->CreateDeviceInfo(0);
int num_cams = info->NumberOfDevices();
std::vector<VideoFormat> supported;
int32_t num_caps = info->NumberOfCapabilities(vcm_id);
module_ = factory_->Create(0, vcm_id);
SetId(device.id);
SetSupportedFormats(supported);
}
src\webrtc\modules\video_capture\video_capture_impl.cc
class WebRtcVcmFactory : public WebRtcVcmFactoryInterface
{
virtual webrtc::VideoCaptureModule::DeviceInfo* CreateDeviceInfo(int id)
{
return webrtc::VideoCaptureFactory::CreateDeviceInfo(id);
}
};
src\webrtc\modules\video_capture\video_capture_factory.cc
VideoCaptureModule::DeviceInfo* VideoCaptureFactory::CreateDeviceInfo(
const int32_t id)
{
return videocapturemodule::VideoCaptureImpl::CreateDeviceInfo(id);
}
src\webrtc\modules\video_capture\windows\video_capture_factory_windows.cc
// static
VideoCaptureModule::DeviceInfo* VideoCaptureImpl::CreateDeviceInfo(
const int32_t id)
{
return DeviceInfoDS::Create(id);
}
VideoCaptureModule* VideoCaptureImpl::Create(const int32_t id, const char* device_id) {
// TODO(tommi): Use Media Foundation implementation for Vista and up.
RefCountImpl<VideoCaptureDS>* capture = new RefCountImpl<VideoCaptureDS>(id);
if (capture->Init(id, device_id) != 0) {
delete capture;
capture = NULL;
}
return capture;
}
src\webrtc\modules\video_capture\windows\device_info_ds.h
class DeviceInfoDS: public DeviceInfoImpl{
};
3.4.2 new rtc::RefCountedObject<VideoSource>(channel_manager,
capturer));
3.4.3 source->Initialize(constraints);
3.4.3.1 std::vector<cricket::VideoFormat> formats =
channel_manager_->GetSupportedFormats(video_capturer_.get());
3.4.3.2 channel_manager_->StartVideoCapture(video_capturer_.get(), format_)
3.4.3.2.1 RegisterVideoCapturer(video_capturer)
3.4.3.2.2 StartWithBestCaptureFormat{video_capturer->StartCapturing}
bool CaptureManager::RegisterVideoCapturer(VideoCapturer* video_capturer)
{
VideoCapturerState* capture_state = VideoCapturerState::Create(video_capturer);
}
// static
VideoCapturerState* VideoCapturerState::Create(VideoCapturer* video_capturer)
{
CaptureRenderAdapter* adapter = CaptureRenderAdapter::Create(video_capturer);
return new VideoCapturerState(adapter);
}
CaptureRenderAdapter* CaptureRenderAdapter::Create(
VideoCapturer* video_capturer)
{
CaptureRenderAdapter* return_value = new CaptureRenderAdapter(video_capturer);
return_value->Init(); // Can't fail.
return return_value;
}
void CaptureRenderAdapter::Init(){
video_capturer_->SignalVideoFrame.connect(this,&CaptureRenderAdapter::OnVideoFrame);
}
void CaptureRenderAdapter::OnVideoFrame(VideoCapturer* capturer,
const VideoFrame* video_frame)
{
for (VideoRenderers::iterator iter = video_renderers_.begin();
iter != video_renderers_.end(); ++iter)
{
VideoRenderer* video_renderer = iter->renderer;
video_renderer->RenderFrame(video_frame);
}
}
bool WebRtcVideoChannel2::AddSendStream(const StreamParams& sp)
{
new WebRtcVideoSendStream
}
bool WebRtcVideoChannel2::AddRecvStream(const StreamParams& sp,
bool default_stream)
{
new WebRtcVideoReceiveStream
}
webrtc自带client的视频引擎创建代码走读的更多相关文章
- webrtc自带client的音频引擎创建代码走读
src\webrtc\examples\peerconnection\client\conductor.cc1.bool Conductor::InitializePeerConnection()1. ...
- WebRTC音视频引擎研究(1)--整体架构分析
WebRTC技术交流群:234795279 原文地址:http://blog.csdn.net/temotemo/article/details/7530504 1.WebRTC目的 ...
- 转: WebRTC音视频引擎研究(1)--整体架构分析
转自: http://blog.csdn.net/temotemo/article/details/7530504 目录(?)[+] WebRTC技术交流群:234795279 原文地址:ht ...
- 使用 WebRTC 构建简单的前端视频通讯
在传统的 Web 应用中,浏览器与浏览器之间是无法直接相互通信的,必须借助服务器的帮助,但是随着 WebRTC 在各大浏览器中的普及,这一现状得到了改变. WebRTC(Web Real-Time C ...
- 使用“Cocos引擎”创建的cpp工程如何在VS中调试Cocos2d-x源码
前段时间Cocos2d-x更新了一个Cocos引擎,这是一个集合源码,IDE,Studio这一家老小的整合包,我们可以使用这个Cocos引擎来创建我们的项目. 在Cocos2d-x被整合到Cocos引 ...
- 带你走近AngularJS 之创建自定义指令
带你走近AngularJS 之创建自定义指令 为什么使用AngularJS 指令? 使用过 AngularJS 的朋友应该最感兴趣的是它的指令.现今市场上的前端框架也只有AngularJS 拥有自定义 ...
- 使用Three.js网页引擎创建酷炫的3D效果的标签墙
使用Three.js引擎(这是开源的webgl三维引擎,gitgub)进行一个简单应用. 做一个酷炫的3d效果的标签墙(已经放在我的博客首页,大屏幕可见), 去我的博客首页看看实际效果 www.son ...
- WebRTC代码走读(八):代码目录结构
转载注明出处http://blog.csdn.net/wanghorse ├── ./base //基础平台库,包括线程.锁.socket等 ├── ./build //编译脚本,gyp ├── ./ ...
- java版微信公众平台自定义菜单创建代码实现
微信公众平台自定义菜单创建代码实现—java版 搞了两天的自定义菜单,终于搞定了,现在分享下心得,以便后来者少走弯路...... 好了,先看先微信官方的API 官方写的很详细,但是我看完后很茫然,不知 ...
随机推荐
- 网络:W5500 UDP数据包格式注意事项
1. 主题 使用W5500测试UDP功能,发现收到的数据包和wireshark抓包的数据不同. 原来W5500接收寄存器的数据包并不是网络上的数据流,而是经过内部处理后展现出来的. 对于这个问题目前 ...
- 【Head First Servlets and JSP】笔记12:URL重写
1.会话管理的核心在于“交换会话ID”,来回传递cookie是最简单的方法,容器通过客户端发来的JSSESIONID查找匹配的对话. 2.如果浏览器禁用了cookie,那就意味着浏览器将忽略响应首部中 ...
- MVC6 (ASP.NET5) 自定义TagHelper
1) 在 _ViewImports.cshtml 中引入TagHelper类所在的 Assembly . (注意不是namespace) : @addTagHelper "*, WebAp ...
- centos中如何寻找Nginx,Apache,PHP,mysql的配置路径
很多小伙伴都可能会碰到安装好环境之后忘记了或者不知道怎么查看配置环境的文件路径了, 下面我就来介绍centos中nginx.apache.php.mysql配置文件路径查看方法吧. 1.判断apach ...
- dfs枚举
深度优先搜索(DFS,Depth-First Search)是搜索手段之一.它从某个状态开始,不断的转移状态知道无法转移,然后退回到前一步的状态,继续转移到其他状态,如此不断重复,直到找到最终的解. ...
- 使用kibana进行简单的CRUD和版本控制
使用: ##创建文档之前先创建索引 PUT /toov5 ##查询索引 GET /toov5 ##创建文档 /索引/类型/id PUT /toov5/user/1 { "name" ...
- JavaWeb -- Jsp 和 JavaBean
JSP技术提供了三个关于JavaBean组件的动作元素,即JSP标签,它们分别为: <jsp:useBean>标签:用于在JSP页面中查找或实例化一个JavaBean组件. <jsp ...
- Codeforces Round #283 (Div. 2) E. Distributing Parts 贪心+set二分
E. Distributing Parts time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- c++ STL库deque和vector的例子
头文件wuyong.h: #pragma once #include<iostream> #include<vector> #include<deque> #inc ...
- HTML5 JS实现搜索匹配功能
http://www.codefans.net/jscss/code/4830.shtml <!DOCTYPE html><head><title>jQuery实现 ...