Fix GetStats() crash.

GetStats() can be called before codecs are set and the underlying
webrtc::VideoSendStream is created, leading to a null-pointer
dereference.

BUG=1788
R=pthatcher@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6876 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pbos@webrtc.org 2014-08-12 20:55:10 +00:00
parent 3d53f614bd
commit c3d2bd28a3
2 changed files with 11 additions and 0 deletions

View File

@ -1592,6 +1592,10 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::GetVideoSenderInfo() {
info.add_ssrc(parameters_.config.rtp.ssrcs[i]);
}
if (stream_ == NULL) {
return info;
}
webrtc::VideoSendStream::Stats stats = stream_->GetStats();
info.framerate_input = stats.input_frame_rate;
info.framerate_sent = stats.encode_frame_rate;

View File

@ -455,6 +455,13 @@ TEST_F(WebRtcVideoEngine2Test, SetSendFailsBeforeSettingCodecs) {
<< "Channel should be stoppable even without set codecs.";
}
TEST_F(WebRtcVideoEngine2Test, GetStatsWithoutSendCodecsSetDoesNotCrash) {
rtc::scoped_ptr<VideoMediaChannel> channel(engine_.CreateChannel(NULL));
EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123)));
VideoMediaInfo info;
channel->GetStats(&info);
}
class WebRtcVideoEngine2BaseTest
: public VideoEngineTest<cricket::WebRtcVideoEngine2> {
protected: