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:
parent
3d53f614bd
commit
c3d2bd28a3
@ -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;
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user