From 0dacbf5f62644c4770496d883721666d98d8a63e Mon Sep 17 00:00:00 2001 From: noahric Date: Tue, 28 Jun 2016 06:39:43 -0700 Subject: [PATCH] Create a null decoder for h264 when not supported, instead of crashing. BUG= NOTRY=true Review-Url: https://codereview.webrtc.org/2091923002 Cr-Commit-Position: refs/heads/master@{#13311} --- webrtc/video/video_decoder.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/webrtc/video/video_decoder.cc b/webrtc/video/video_decoder.cc index 5bf503cd80..b15a83f7b3 100644 --- a/webrtc/video/video_decoder.cc +++ b/webrtc/video/video_decoder.cc @@ -20,7 +20,15 @@ namespace webrtc { VideoDecoder* VideoDecoder::Create(VideoDecoder::DecoderType codec_type) { switch (codec_type) { case kH264: - RTC_DCHECK(H264Decoder::IsSupported()); + if (!H264Decoder::IsSupported()) { + // This could happen in a software-fallback for a codec type only + // supported externally (e.g. H.264 on iOS or Android) or in current + // usage in WebRtcVideoEngine2 if the external decoder fails to be + // created. + LOG(LS_ERROR) << "Unable to create an H.264 decoder fallback. " + << "Decoding of this stream will be broken."; + return new NullVideoDecoder(); + } return H264Decoder::Create(); case kVp8: return VP8Decoder::Create();