thread.cc
void Thread::ReceiveSends() {
ReceiveSendsFromThread(NULL);
}
void Thread::ReceiveSendsFromThread(const Thread* source) {
// Receive a sent message. Cleanup scenarios:
// - thread sending exits: We don't allow this, since thread can exit
// only via Join, so Send must complete.
// - thread receiving exits: Wakeup/set ready in Thread::Clear()
// - object target cleared: Wakeup/set ready in Thread::Clear()
_SendMessage smsg;
crit_.Enter();
while (PopSendMessageFromThread(source, &smsg)) {
crit_.Leave();
smsg.msg.phandler->OnMessage(&smsg.msg);//发送消息
crit_.Enter();
*smsg.ready = true;
smsg.thread->socketserver()->WakeUp();
}
crit_.Leave();
}
此msg里带有消息为:
(cricket::VoiceChannel *(cricket::ChannelManager::*)
(cricket::ChannelManager * const, webrtc::MediaControllerInterface *, cricket::TransportController *, const std::__cxx11::basic_string,
std::allocator > &, const std::__cxx11::basic_string, std::allocator > *, bool, const cricket::AudioOptions &))
0xe74a66 , std::allocator > const&,
std::__cxx11::basic_string, std::allocator > const*, bool, cricket::AudioOptions const&)>
#即调用VoiceChannel::CreateVoiceChannel_w函数
通过webrtc/base/bind.h来建立联系
template
class MethodFunctor6 {
public:
MethodFunctor6(MethodT method, ObjectT* object,
P1 p1,
P2 p2,
P3 p3,
P4 p4,
P5 p5,
P6 p6)
: method_(method), object_(object),
p1_(p1),
p2_(p2),
p3_(p3),
p4_(p4),
p5_(p5),
p6_(p6) {}
R operator()() const {
return (object_->*method_)(p1_, p2_, p3_, p4_, p5_, p6_); } //这里
private:
MethodT method_;
typename detail::PointerType::type object_;
typename rtc::remove_reference::type p1_;
typename rtc::remove_reference::type p2_;
typename rtc::remove_reference::type p3_;
typename rtc::remove_reference::type p4_;
typename rtc::remove_reference::type p5_;
typename rtc::remove_reference::type p6_;
};
接着调用channelmanager.cc
VoiceChannel* ChannelManager::CreateVoiceChannel_w(
webrtc::MediaControllerInterface* media_controller,
TransportController* transport_controller,
const std::string& content_name,
const std::string* bundle_transport_name,
bool rtcp,
const AudioOptions& options) {
ASSERT(initialized_);
ASSERT(worker_thread_ == rtc::Thread::Current());
ASSERT(nullptr != media_controller);
VoiceMediaChannel* media_channel = media_engine_->CreateChannel(
media_controller->call_w(), media_controller->config(), options);//这里
if (!media_channel)
return nullptr;
VoiceChannel* voice_channel =
new VoiceChannel(worker_thread_, network_thread_, media_engine_.get(),
media_channel, transport_controller, content_name, rtcp);
if (!voice_channel->Init_w(bundle_transport_name)) {
delete voice_channel;
return nullptr;
}
voice_channels_.push_back(voice_channel);
return voice_channel;
}
mediacontroller.cc
webrtc::Call* call_w() override {
RTC_DCHECK(worker_thread_->IsCurrent());
if (!call_) {
call_.reset(webrtc::Call::Create(call_config_));
}
return call_.get();
}
call/call.cc
Call* Call::Create(const Call::Config& config) {
return new internal::Call(config);
}
congestion_controller.cc
void CongestionController::SetBweBitrates(int min_bitrate_bps,
int start_bitrate_bps,
int max_bitrate_bps) {
ClampBitrates(&start_bitrate_bps, &min_bitrate_bps, &max_bitrate_bps);
bitrate_controller_->SetBitrates(start_bitrate_bps,
min_bitrate_bps,
max_bitrate_bps);
if (remote_bitrate_estimator_)
remote_bitrate_estimator_->SetMinBitrate(min_bitrate_bps);
min_bitrate_bps_ = min_bitrate_bps;
transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate(
min_bitrate_bps_);
MaybeTriggerOnNetworkChanged();
}
modules/bitrate_controller/bitrate_controller_impl.cc
void BitrateControllerImpl::SetBitrates(int start_bitrate_bps,
int min_bitrate_bps,
int max_bitrate_bps) {
{
rtc::CritScope cs(&critsect_);
bandwidth_estimation_.SetBitrates(start_bitrate_bps,
min_bitrate_bps,
max_bitrate_bps);
}
MaybeTriggerOnNetworkChanged();
}