Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: webrtc/video/video_decoder.cc

Issue 1657023002: Implement NullVideoDecoder to avoid crash on unsupported decoders. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Removed DCHECK / NOTREACHED. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « talk/media/webrtc/webrtcvideoengine2.cc ('k') | webrtc/video_decoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/video_decoder.h" 11 #include "webrtc/video_decoder.h"
12 12
13 #include "webrtc/base/checks.h" 13 #include "webrtc/base/checks.h"
14 #include "webrtc/base/logging.h" 14 #include "webrtc/base/logging.h"
15 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" 15 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
16 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" 16 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
17 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" 17 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
18 18
19 namespace webrtc { 19 namespace webrtc {
20 VideoDecoder* VideoDecoder::Create(VideoDecoder::DecoderType codec_type) { 20 VideoDecoder* VideoDecoder::Create(VideoDecoder::DecoderType codec_type) {
21 switch (codec_type) { 21 switch (codec_type) {
22 case kH264: 22 case kH264:
23 RTC_DCHECK(H264Decoder::IsSupported()); 23 RTC_DCHECK(H264Decoder::IsSupported());
24 return H264Decoder::Create(); 24 return H264Decoder::Create();
25 case kVp8: 25 case kVp8:
26 return VP8Decoder::Create(); 26 return VP8Decoder::Create();
27 case kVp9: 27 case kVp9:
28 return VP9Decoder::Create(); 28 return VP9Decoder::Create();
29 case kUnsupportedCodec: 29 case kUnsupportedCodec:
30 RTC_NOTREACHED(); 30 return new NullVideoDecoder();
pbos-webrtc 2016/02/02 13:59:13 I'd prefer a log here as well.
joachim 2016/02/02 14:31:33 Done.
31 return nullptr;
32 } 31 }
33 RTC_NOTREACHED(); 32 RTC_NOTREACHED();
34 return nullptr; 33 return nullptr;
35 } 34 }
36 35
37 VideoDecoder::DecoderType CodecTypeToDecoderType(VideoCodecType codec_type) { 36 VideoDecoder::DecoderType CodecTypeToDecoderType(VideoCodecType codec_type) {
38 switch (codec_type) { 37 switch (codec_type) {
39 case kVideoCodecH264: 38 case kVideoCodecH264:
40 return VideoDecoder::kH264; 39 return VideoDecoder::kH264;
41 case kVideoCodecVP8: 40 case kVideoCodecVP8:
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 return fallback_decoder_->PrefersLateDecoding(); 138 return fallback_decoder_->PrefersLateDecoding();
140 return decoder_->PrefersLateDecoding(); 139 return decoder_->PrefersLateDecoding();
141 } 140 }
142 141
143 const char* VideoDecoderSoftwareFallbackWrapper::ImplementationName() const { 142 const char* VideoDecoderSoftwareFallbackWrapper::ImplementationName() const {
144 if (fallback_decoder_) 143 if (fallback_decoder_)
145 return fallback_implementation_name_.c_str(); 144 return fallback_implementation_name_.c_str();
146 return decoder_->ImplementationName(); 145 return decoder_->ImplementationName();
147 } 146 }
148 147
148 NullVideoDecoder::NullVideoDecoder() {}
149
150 int32_t NullVideoDecoder::InitDecode(const VideoCodec* codec_settings,
151 int32_t number_of_cores) {
152 LOG(LS_ERROR) << "Can't initialize NullVideoDecoder.";
153 return WEBRTC_VIDEO_CODEC_OK;
154 }
155
156 int32_t NullVideoDecoder::Decode(const EncodedImage& input_image,
157 bool missing_frames,
158 const RTPFragmentationHeader* fragmentation,
159 const CodecSpecificInfo* codec_specific_info,
160 int64_t render_time_ms) {
161 LOG(LS_ERROR) << "The NullVideoDecoder doesn't support decoding.";
162 return WEBRTC_VIDEO_CODEC_OK;
163 }
164
165 int32_t NullVideoDecoder::RegisterDecodeCompleteCallback(
166 DecodedImageCallback* callback) {
167 LOG(LS_ERROR)
168 << "Can't register decode complete callback on NullVideoDecoder.";
169 return WEBRTC_VIDEO_CODEC_OK;
170 }
171
172 int32_t NullVideoDecoder::Release() {
173 return WEBRTC_VIDEO_CODEC_OK;
174 }
175
176 int32_t NullVideoDecoder::Reset() {
177 return WEBRTC_VIDEO_CODEC_OK;
178 }
179
180 const char* NullVideoDecoder::ImplementationName() const {
181 return "null";
noahric 2016/02/02 14:06:43 Maybe NullVideoDecoder, so the logging doesn't loo
joachim 2016/02/02 14:31:33 Done.
182 }
183
149 } // namespace webrtc 184 } // namespace webrtc
OLDNEW
« no previous file with comments | « talk/media/webrtc/webrtcvideoengine2.cc ('k') | webrtc/video_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698