Move those calls that may fail out of the ctor to Init function.
BUG= TEST= Review URL: https://webrtc-codereview.appspot.com/491002 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2003 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
91ed80e5c3
commit
5d8c102899
@ -92,7 +92,8 @@ int ViEChannelManager::CreateChannel(int& channel_id) {
|
||||
ViEEncoder* vie_encoder = new ViEEncoder(engine_id_, new_channel_id,
|
||||
number_of_cores_,
|
||||
*module_process_thread_);
|
||||
if (!CreateChannelObject(new_channel_id, vie_encoder)) {
|
||||
if (!(vie_encoder->Init() &&
|
||||
CreateChannelObject(new_channel_id, vie_encoder))) {
|
||||
delete vie_encoder;
|
||||
vie_encoder = NULL;
|
||||
ReturnChannelId(new_channel_id);
|
||||
@ -126,7 +127,8 @@ int ViEChannelManager::CreateChannel(int& channel_id,
|
||||
// We need to create a new ViEEncoder.
|
||||
vie_encoder = new ViEEncoder(engine_id_, new_channel_id, number_of_cores_,
|
||||
*module_process_thread_);
|
||||
if (!CreateChannelObject(new_channel_id, vie_encoder)) {
|
||||
if (!(vie_encoder->Init() &&
|
||||
CreateChannelObject(new_channel_id, vie_encoder))) {
|
||||
delete vie_encoder;
|
||||
vie_encoder = NULL;
|
||||
}
|
||||
|
@ -87,44 +87,79 @@ ViEEncoder::ViEEncoder(WebRtc_Word32 engine_id, WebRtc_Word32 channel_id,
|
||||
for (int i = 0; i < kMaxSimulcastStreams; i++) {
|
||||
time_last_intra_request_ms_[i] = 0;
|
||||
}
|
||||
// TODO(wu): Split out those may fail into an Init function.
|
||||
vcm_.InitializeSender();
|
||||
}
|
||||
|
||||
bool ViEEncoder::Init() {
|
||||
if (vcm_.InitializeSender() != 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
|
||||
ViEId(engine_id_, channel_id_),
|
||||
"%s InitializeSender failure", __FUNCTION__);
|
||||
return false;
|
||||
}
|
||||
vpm_.EnableTemporalDecimation(true);
|
||||
|
||||
// Enable/disable content analysis: off by default for now.
|
||||
vpm_.EnableContentAnalysis(false);
|
||||
|
||||
module_process_thread_.RegisterModule(&vcm_);
|
||||
if (module_process_thread_.RegisterModule(&vcm_) != 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
|
||||
ViEId(engine_id_, channel_id_),
|
||||
"%s RegisterModule failure", __FUNCTION__);
|
||||
return false;
|
||||
}
|
||||
if (default_rtp_rtcp_.InitSender() != 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
|
||||
ViEId(engine_id_, channel_id_),
|
||||
"ViEEncoder: RTP::InitSender failure");
|
||||
assert(false);
|
||||
"%s InitSender failure", __FUNCTION__);
|
||||
return false;
|
||||
}
|
||||
if (default_rtp_rtcp_.RegisterIncomingVideoCallback(this) != 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
|
||||
ViEId(engine_id_, channel_id_),
|
||||
"%s RegisterIncomingVideoCallback failure", __FUNCTION__);
|
||||
return false;
|
||||
}
|
||||
if (default_rtp_rtcp_.RegisterIncomingRTCPCallback(this) != 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
|
||||
ViEId(engine_id_, channel_id_),
|
||||
"%s RegisterIncomingRTCPCallback failure", __FUNCTION__);
|
||||
return false;
|
||||
}
|
||||
if (module_process_thread_.RegisterModule(&default_rtp_rtcp_) != 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
|
||||
ViEId(engine_id_, channel_id_),
|
||||
"%s RegisterModule failure", __FUNCTION__);
|
||||
return false;
|
||||
}
|
||||
default_rtp_rtcp_.RegisterIncomingVideoCallback(this);
|
||||
default_rtp_rtcp_.RegisterIncomingRTCPCallback(this);
|
||||
module_process_thread_.RegisterModule(&default_rtp_rtcp_);
|
||||
|
||||
qm_callback_ = new QMVideoSettingsCallback(
|
||||
engine_id_,
|
||||
channel_id_,
|
||||
&vpm_,
|
||||
&vcm_,
|
||||
number_of_cores,
|
||||
number_of_cores_,
|
||||
default_rtp_rtcp_.MaxDataPayloadLength());
|
||||
|
||||
#ifdef VIDEOCODEC_VP8
|
||||
VideoCodec video_codec;
|
||||
if (vcm_.Codec(webrtc::kVideoCodecVP8, &video_codec) == VCM_OK) {
|
||||
if (vcm_.RegisterSendCodec(&video_codec, number_of_cores_,
|
||||
default_rtp_rtcp_.MaxDataPayloadLength()) != 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
|
||||
ViEId(engine_id_, channel_id_),
|
||||
"ViEEncoder: VCM::RegisterSendCodec failure");
|
||||
}
|
||||
default_rtp_rtcp_.RegisterSendPayload(video_codec);
|
||||
} else {
|
||||
assert(false);
|
||||
if (vcm_.Codec(webrtc::kVideoCodecVP8, &video_codec) != VCM_OK) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
|
||||
ViEId(engine_id_, channel_id_),
|
||||
"%s Codec failure", __FUNCTION__);
|
||||
return false;
|
||||
}
|
||||
if (vcm_.RegisterSendCodec(&video_codec, number_of_cores_,
|
||||
default_rtp_rtcp_.MaxDataPayloadLength()) != 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
|
||||
ViEId(engine_id_, channel_id_),
|
||||
"%s RegisterSendCodec failure", __FUNCTION__);
|
||||
return false;
|
||||
}
|
||||
if (default_rtp_rtcp_.RegisterSendPayload(video_codec) != 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
|
||||
ViEId(engine_id_, channel_id_),
|
||||
"%s RegisterSendPayload failure", __FUNCTION__);
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
VideoCodec video_codec;
|
||||
@ -133,7 +168,7 @@ ViEEncoder::ViEEncoder(WebRtc_Word32 engine_id, WebRtc_Word32 channel_id,
|
||||
default_rtp_rtcp_.MaxDataPayloadLength());
|
||||
default_rtp_rtcp_.RegisterSendPayload(video_codec);
|
||||
} else {
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -141,18 +176,21 @@ ViEEncoder::ViEEncoder(WebRtc_Word32 engine_id, WebRtc_Word32 channel_id,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
|
||||
ViEId(engine_id_, channel_id_),
|
||||
"ViEEncoder: VCM::RegisterTransportCallback failure");
|
||||
return false;
|
||||
}
|
||||
if (vcm_.RegisterSendStatisticsCallback(this) != 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
|
||||
ViEId(engine_id_, channel_id_),
|
||||
"ViEEncoder: VCM::RegisterSendStatisticsCallback failure");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (vcm_.RegisterVideoQMCallback(qm_callback_) != 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
|
||||
ViEId(engine_id_, channel_id_),
|
||||
"VCM::RegisterQMCallback failure");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
ViEEncoder::~ViEEncoder() {
|
||||
|
@ -45,6 +45,8 @@ class ViEEncoder
|
||||
ProcessThread& module_process_thread);
|
||||
~ViEEncoder();
|
||||
|
||||
bool Init();
|
||||
|
||||
// Returns the id of the owning channel.
|
||||
int Owner() const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user