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的视频引擎创建代码走读的更多相关文章

  1. webrtc自带client的音频引擎创建代码走读

    src\webrtc\examples\peerconnection\client\conductor.cc1.bool Conductor::InitializePeerConnection()1. ...

  2. WebRTC音视频引擎研究(1)--整体架构分析

    WebRTC技术交流群:234795279 原文地址:http://blog.csdn.net/temotemo/article/details/7530504     1.WebRTC目的     ...

  3. 转: WebRTC音视频引擎研究(1)--整体架构分析

    转自: http://blog.csdn.net/temotemo/article/details/7530504   目录(?)[+]   WebRTC技术交流群:234795279 原文地址:ht ...

  4. 使用 WebRTC 构建简单的前端视频通讯

    在传统的 Web 应用中,浏览器与浏览器之间是无法直接相互通信的,必须借助服务器的帮助,但是随着 WebRTC 在各大浏览器中的普及,这一现状得到了改变. WebRTC(Web Real-Time C ...

  5. 使用“Cocos引擎”创建的cpp工程如何在VS中调试Cocos2d-x源码

    前段时间Cocos2d-x更新了一个Cocos引擎,这是一个集合源码,IDE,Studio这一家老小的整合包,我们可以使用这个Cocos引擎来创建我们的项目. 在Cocos2d-x被整合到Cocos引 ...

  6. 带你走近AngularJS 之创建自定义指令

    带你走近AngularJS 之创建自定义指令 为什么使用AngularJS 指令? 使用过 AngularJS 的朋友应该最感兴趣的是它的指令.现今市场上的前端框架也只有AngularJS 拥有自定义 ...

  7. 使用Three.js网页引擎创建酷炫的3D效果的标签墙

    使用Three.js引擎(这是开源的webgl三维引擎,gitgub)进行一个简单应用. 做一个酷炫的3d效果的标签墙(已经放在我的博客首页,大屏幕可见), 去我的博客首页看看实际效果 www.son ...

  8. WebRTC代码走读(八):代码目录结构

    转载注明出处http://blog.csdn.net/wanghorse ├── ./base //基础平台库,包括线程.锁.socket等 ├── ./build //编译脚本,gyp ├── ./ ...

  9. java版微信公众平台自定义菜单创建代码实现

    微信公众平台自定义菜单创建代码实现—java版 搞了两天的自定义菜单,终于搞定了,现在分享下心得,以便后来者少走弯路...... 好了,先看先微信官方的API 官方写的很详细,但是我看完后很茫然,不知 ...

随机推荐

  1. jQuery仿苹果样式焦点图插件

    在线演示 本地下载

  2. 恢复性训练day1

    DP: 0/1背包一个常见的错误是没有cmax(f[i][j],f[i-1][j]) 0/1背包的拓展中有转移式的变形,以及无限数量背包,分组背包等. 可化为背包问题的一般不会太难. 数组开小,出现大 ...

  3. Android 下的usb框架及功能点【转】

    本文转载自:https://blog.csdn.net/tianruxishui/article/details/37902959 有关USB android框架的链接 http://blog.sin ...

  4. Android电容屏(一)【转】

    本文转载自:http://blog.csdn.net/xubin341719/article/details/7820492 关键词:Android  电容屏 tp  ITO 平台信息:内核:linu ...

  5. windows10添加电源计划修改的快捷方案

    转自:http://news.mydrivers.com/1/431/431346.htm 由于目前的Windows 10预览版在UI方面还未优化到位,所以某些设置选项要想找出来是很难的,这时候如果能 ...

  6. Git使用http clone客户端保存用户名密码

    使用Git Bash时,用命令git pull或git push时总是要输入密码,很烦躁 解决办法 需要注意的是,这个方法是在Windows下使用 1. 新建环境变量   HOME 值为 %USERP ...

  7. shell基础之书写需要用到的小工具

    一.简单介绍 下面介绍几个可能不太常用但是面试题经常会用用到的小工具: 命令:cut 作用:截取某一个字段 '-d' 后面跟分隔字符,把字段分割为若干个区间. '-c' 后面接的是第几个字符,也可以是 ...

  8. JavaScript 对时间日期格式化

    JavaScript 对时间日期格式化 // 对Date的扩展,将 Date 转化为指定格式的String // 月(M).日(d).小时(h).分(m).秒(s).季度(q) 可以用 1-2 个占位 ...

  9. struts2学习(4)

    Struts2拦截器概述 1 Struts2是框架,封装了很多功能,struts2里面封装的概念都是在拦截器里面 2 Struts2里面封装了很多的概念,有很多拦截器,不是每次这些拦截器都执行,每次执 ...

  10. HTML5 JS实现搜索匹配功能

    http://www.codefans.net/jscss/code/4830.shtml <!DOCTYPE html><head><title>jQuery实现 ...