When GetEncoder or SetSendCodec failed, we should clean up and return error.

BUG=
TEST=

Review URL: https://webrtc-codereview.appspot.com/490001

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1995 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
wu@webrtc.org 2012-04-06 19:49:28 +00:00
parent 78075451ed
commit 96b3017b33
2 changed files with 14 additions and 5 deletions

View File

@ -317,9 +317,13 @@ bool ViEChannelManager::CreateChannelObject(int channel_id,
}
VideoCodec encoder;
vie_encoder->GetEncoder(encoder);
if (vie_channel->SetSendCodec(encoder) != 0) {
vie_encoder = NULL;
if (vie_encoder->GetEncoder(encoder) != 0 ||
vie_channel->SetSendCodec(encoder) != 0) {
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id),
"%s: Could not GetEncoder or SetSendCodec.", __FUNCTION__);
vie_channel->DeregisterSendRtpRtcpModule();
delete vie_channel;
return false;
}
// Store the channel, add it to the channel group and save the vie_encoder.

View File

@ -87,6 +87,7 @@ 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();
vpm_.EnableTemporalDecimation(true);
@ -115,8 +116,12 @@ ViEEncoder::ViEEncoder(WebRtc_Word32 engine_id, WebRtc_Word32 channel_id,
#ifdef VIDEOCODEC_VP8
VideoCodec video_codec;
if (vcm_.Codec(webrtc::kVideoCodecVP8, &video_codec) == VCM_OK) {
vcm_.RegisterSendCodec(&video_codec, number_of_cores_,
default_rtp_rtcp_.MaxDataPayloadLength());
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);