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. Android LCD(三):LCD接口篇【转】

    本文转载自:http://blog.csdn.net/xubin341719/article/details/9177085 关键词:Android LCD控制器 Framebuffer PWM  平 ...

  2. composer启用国内镜像网站的配置更改办法

    用法: 有两种方式启用本镜像服务: 将以下配置信息添加到 Composer 的配置文件 config.json 中(系统全局配置).见“例1” 将以下配置信息添加到你的项目的 composer.jso ...

  3. HDU 4000 Fruit Ninja (树状数组+反向思维)

    题意:给你一串数且每个数都不同,问你(x,y,z)出现 x<z<y 的总次数 首先我们直接想的话不能使用O(n*log2 n)解决,所以可以正难则反 可以求得x<(y,z)的值,减去 ...

  4. Java -- 数据库 多表操作,1对多,多对多,1对1。 基于dbutils框架

    1. 1对多,部门--员工 为例, 多的一方建外键. domain,建立bean对象 public class Department { private String id; private Stri ...

  5. 透透彻彻IoC

    本文转载自:http://stamen.iteye.com/blog/1489223/ 引述:IoC(控制反转:Inverse of Control)是Spring容器的内核,AOP.声明式事务等功能 ...

  6. 【转】移动oracle LOB索引到其他表空间

    http://blog.chinaunix.net/uid-22948773-id-3451103.html

  7. 项目开发之git配置

    1.本地安装git配置 安装步骤,这里不详细介绍,软件下载然后安装即可. 查看git安装版本 #git --version 2.git密钥生成 ssh-keygen -t rsa -C "f ...

  8. Java-集合类源码List篇(二)

    前言 上篇中,我们分析了ArrayList的常用方法及其实现机制.ArrayList是基于内存空间连续的数组来实现的,List中其实还提供了一种基于链表结构的LinkedList来实现集合.同时多线程 ...

  9. Windows环境下CGAL的安装

    1 准备工作 下载cmake 下载CGAL安装包 学习如何设置环境变量 安装Qt运行demos. libQGLViewer用来运行 3D CGAL demos. 确定Visual Studio 相应的 ...

  10. Java中常见的比较器的实现方法

    在Java中经常会涉及到对象数组的排序问题,那么就涉及到对象之间的比较问题. 通常对象之间的比较可以从两个方面去看: 第一个方面:对象的地址是否一样,也就是是否引用自同一个对象.这种方式可以直接使用& ...