src\webrtc\examples\peerconnection\client\conductor.cc
1、bool Conductor::InitializePeerConnection()
1.1 webrtc::CreatePeerConnectionFactory();

src\talk\app\webrtc\peerconnectionfactory.cc
2、 bool PeerConnectionFactory::Initialize()
2.1.1 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() {

return cricket::WebRtcMediaEngineFactory::Create(default_adm_.get(), video_encoder_factory_.get(),video_decoder_factory_.get());
}

src\talk\media\webrtc\webrtcmediaengine.cc
2.1.2
MediaEngineInterface* WebRtcMediaEngineFactory::Create(
webrtc::AudioDeviceModule* adm,WebRtcVideoEncoderFactory* encoder_factory,WebRtcVideoDecoderFactory* decoder_factory)
{
return CreateWebRtcMediaEngine(adm, encoder_factory, decoder_factory);
}
2.1.3
cricket::MediaEngineInterface* WebRtcMediaEngineFactory::CreateWebRtcMediaEngine(
webrtc::AudioDeviceModule* adm,WebRtcVideoEncoderFactory* encoder_factory,WebRtcVideoDecoderFactory* decoder_factory)
{
return new cricket::WebRtcMediaEngine2(adm, encoder_factory,
decoder_factory);
}

2.1.4
class WebRtcMediaEngine2
: public CompositeMediaEngine<WebRtcVoiceEngine, WebRtcVideoEngine2>
{

public:

WebRtcMediaEngine2(webrtc::AudioDeviceModule* adm,WebRtcVideoEncoderFactory* encoder_factory,WebRtcVideoDecoderFactory* decoder_factory)
};

2.1.5
\src\talk\media\webrtc\webrtcvoiceengine.cc
WebRtcVoiceEngine::WebRtcVoiceEngine()

: voe_wrapper_(new VoEWrapper())
{
Construct();
}

2.1.6

src\talk\media\webrtc\webrtcvoe.h
class VoEWrapper {

public:

VoEWrapper()
: engine_(webrtc::VoiceEngine::Create())
, processing_(engine_),
base_(engine_), codec_(engine_)
, dtmf_(engine_),
hw_(engine_), network_(engine_)
, rtp_(engine_), volume_(engine_){}
};

2.1.7
src\webrtc\voice_engine\voice_engine_impl.cc
VoiceEngine* VoiceEngine::Create()
{
return GetVoiceEngine(config, true);

}

VoiceEngine* GetVoiceEngine(const Config* config, bool owns_config)
{
VoiceEngineImpl* self = new VoiceEngineImpl(config, owns_config);
}

2.1.9
src\webrtc\voice_engine\voice_engine_impl.h
class VoiceEngineImpl : public voe::SharedData, public VoiceEngine, public VoEBaseImpl ,public VoEHardwareImpl
{public:

VoiceEngineImpl(const Config* config, bool owns_config)
:SharedData(*config),

VoEBaseImpl(this),

VoEHardwareImpl(this),
{}

};

2.1.10
void WebRtcVoiceEngine::Construct() 
{
// Load our audio codec list.
内部调用voe_wrapper_->codec()->NumOfCodecs() 
ConstructCodecs();

//获取是否需要回音消除,降噪,自动调节音量等
options_ = GetDefaultEngineOptions(); 
}

src\talk\session\media\channelmanager.cc
2.2
bool ChannelManager::Init()
{
initialized_ = worker_thread_->Invoke<bool>(Bind(
&ChannelManager::InitMediaEngine_w, this));
}
2.2.1
bool ChannelManager::InitMediaEngine_w()
{

return (media_engine_->Init(worker_thread_));

}

2.2.2
template<class VOICE, class VIDEO>

class CompositeMediaEngine : public MediaEngineInterface
{
public:
virtual bool Init(rtc::Thread* worker_thread)
{

if (!voice_.Init(worker_thread))

return false;

video_.Init();

return true;

}
protected:

VOICE voice_; //默认的WebRtcVoiceEngine或自定义的音频引擎
}

2.2.3
bool WebRtcVoiceEngine::Init(rtc::Thread* worker_thread)
{
bool res = InitInternal();
}

2.2.4
bool WebRtcVoiceEngine::InitInternal()
{
if (voe_wrapper_->base()->Init(adm_) == -1) // VoiceEngineImpl 的init
}

2.2.5

VoiceEngineImpl(const Config* config, bool owns_config)
:SharedData(*config)
, VoEHardwareImpl(this)

,VoEBaseImpl(this)

src\webrtc\voice_engine\voe_base_impl.cc

VoEBaseImpl::VoEBaseImpl(voe::SharedData* shared)

:shared_(shared)


int VoEBaseImpl::Init(AudioDeviceModule* external_adm,AudioProcessing* audioproc)
{
if (external_adm == nullptr)
{
// Create the internal ADM implementation. //shared_指向VoiceEngineImpl
shared_->set_audio_device(AudioDeviceModuleImpl::Create(
VoEId(shared_->instance_id(), -1), shared_->audio_device_layer())); // create函数中调用CreatePlatformSpecificObjects
}
else
{
// Use the already existing external ADM implementation.
shared_->set_audio_device(external_adm);  
}

SharedData::SharedData(const Config& config)

: _channelManager(_gInstanceCounter, config)
,_audioDevicePtr(NULL)
{
_audioDeviceLayer = AudioDeviceModule::kPlatformDefaultAudio;
}

SharedData::set_audio_device(AudioDeviceModule* audio_device){ _audioDevicePtr = audio_device;}

AudioDeviceModule* SharedData::audio_device() { return _audioDevicePtr; }

// Register the AudioObserver implementation

if (shared_->audio_device()->RegisterEventObserver(this) != 0)

// Register the AudioTransport implementation

if (shared_->audio_device()->RegisterAudioCallback(this) != 0)

// ADM initialization

if (shared_->audio_device()->Init() != 0)  // AudioDeviceModuleImpl::Init(),调用_ptrAudioDevice->Init()开启了一些音频处理线程,这些线程负责来采集音频,

// 如AudioDeviceWindowsWave::Init()中调用 _ptrThread = ThreadWrapper::CreateThread(ThreadFunc, this, threadName);

//->AudioDeviceWindowsWave::ThreadFunc

//->AudioDeviceWindowsWave::ThreadProcess()

//->AudioDeviceWindowsWave::RecProc(LONGLONG& consumedTime)

//->_ptrAudioBuffer->DeliverRecordedData();

int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects()

{
AudioDeviceGeneric* ptrAudioDevice(NULL);
AudioLayer audioLayer(PlatformAudioLayer()); // AudioDeviceModule::kPlatformDefaultAudio;

ptrAudioDevice = new AudioDeviceWindowsWave(Id());


ptrAudioDevice = new AudioDeviceWindowsCore(Id());
_ptrAudioDevice = ptrAudioDevice;
}

// Initialize the default speaker
if (shared_->audio_device()->SetPlayoutDevice(WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE) != 0)
if (shared_->audio_device()->InitSpeaker() != 0)

// Initialize the default microphone
if (shared_->audio_device()->SetRecordingDevice(WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE) != 0)

int32_t AudioDeviceModuleImpl::SetRecordingDevice(WindowsDeviceType device)

{

return (_ptrAudioDevice->SetRecordingDevice(device));

}

if (shared_->audio_device()->InitMicrophone() != 0)

// Set number of channels
if (shared_->audio_device()->StereoPlayoutIsAvailable(&available) != 0)
if (shared_->audio_device()->SetStereoPlayout(available) != 0)

if (!audioproc) {
audioproc = AudioProcessing::Create();
}
shared_->set_audio_processing(audioproc);
}

VoEBaseImpl::StartSend()

{

 if (shared_->audio_device()->StartRecording() != 0)

}

int32_t AudioDeviceModuleImpl::StartRecording()

{
return (_ptrAudioDevice->StartRecording()); // AudioDeviceWindowsWave或AudioDeviceWindowsCore启动录音

}

webrtc自带client的音频引擎创建代码走读的更多相关文章

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

    src\webrtc\examples\peerconnection\client\conductor.ccbool Conductor::InitializePeerConnection()1 we ...

  2. WebRTC源码分析:音频模块结构分析

    一.概要介绍WebRTC的音频处理流程,见下图: webRTC将音频会话抽象为一个通道Channel,譬如A与B进行音频通话,则A需要建立一个Channel与B进行音频数据传输.上图中有三个Chann ...

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

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

  4. 基于cocos2d-x的Android游戏中使用fmod音频引擎

    cocos2d-x的音频引擎是cocosDenshion, 它的Android版比较弱, 只能播放一个背景音乐和些许音效, 如果要实现稍微复杂一点的音频播放, 比如同时播放几个音轨就不能了. 这一点远 ...

  5. 【Cocos2d入门教程八】浅析Cocoss2d下的音频引擎及封装音频类

    Cocos2d-x提供了一个音频CocosDenshion引擎,CocosDenshion引擎可以独立于Cocos2d-x单独使用,CocosDenshion引擎本质上封装了OpenAL音频处理库.具 ...

  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之DOM操作大全

    jQuery属性操作 获取元素属性的语法:attr(name) 例子:$("#img1").attr("src"); 设置元素单个属性的语法:attr(key, ...

  2. 微服务(MicroServices)

    微服务Architecture(MicroServices) 微服务架构简单的定义 采用一组Service的方式来构建一个应用,服务独立部署在不同的进程(Container)中,不同Service通过 ...

  3. JMeter学习(十一)属性和变量

    一.Jmeter中的属性: 1.JMeter属性统一定义在jmeter.properties文件中,我们可以在该文件中添加自定义的属性 2.JMeter属性在测试脚本的任何地方都是可见的(全局),通常 ...

  4. struts2中常用配置

    1.Post提交乱码问题,如果编码采用的是utf-8,那么默认不需要自己处理,因为其默认的常量配置文件就是处理UTF-8的 这个常量值只处理POST提交,get如果乱码还得自己写拦截器处理,一般只要页 ...

  5. 【bzoj5055】膜法师(离散化+树状数组)

    传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=5055 这道题……不得不说,从标题到题面都能看出一股浓浓的膜法气息……苟…… 题意就是统计顺序 ...

  6. java深入探究08-连接池,分页

    1.连接池 1)自定义连接池 思路:定义一个类Pool->添加4个属性(最大连接数,初始化连接数,当前连接数,用来存放连接对象的LinkList集合对象)->定义一个createConne ...

  7. 关于es集群转换为单点后,主分片丢失的问题(健康检测状态为red)

    正在找解决方案 前后情况是, 之前是es双节点,之后更改为单节点,data中的数据都是双节点的,也许导致了单节点的状态不正常,删除了data目录下内容后,重启es,好了,这是测试环境,所以这么干的

  8. How to use QToolBar and QToolButton in Qt

    http://developer.nokia.com/Community/Wiki/How_to_use_QToolBar_and_QToolButton_in_Qt How to use QTool ...

  9. QT QFtp使用实例 从FTP下载一个文件

    1. ftp://ftp.denx.de/pub/u-boot/lowboot-1.0.0.patch.gz  下载文件 FtpGet.h #ifndef FTPGET_H #define FTPGE ...

  10. SGU 106 The equation 扩展欧几里德

    106. The equation time limit per test: 0.25 sec. memory limit per test: 4096 KB There is an equation ...