| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  *  Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2  *  Copyright (c) 2016 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/media/engine/videodecodersoftwarefallbackwrapper.h" | 
| 12 | 12 | 
| 13 #include "webrtc/base/checks.h" | 13 #include <string> | 
|  | 14 | 
| 14 #include "webrtc/base/logging.h" | 15 #include "webrtc/base/logging.h" | 
| 15 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" | 16 #include "webrtc/modules/video_coding/include/video_error_codes.h" | 
| 16 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" |  | 
| 17 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" |  | 
| 18 | 17 | 
| 19 namespace webrtc { | 18 namespace webrtc { | 
| 20 VideoDecoder* VideoDecoder::Create(VideoDecoder::DecoderType codec_type) { | 19 | 
| 21   switch (codec_type) { | 20 namespace { | 
| 22     case kH264: |  | 
| 23       if (!H264Decoder::IsSupported()) { |  | 
| 24         // This could happen in a software-fallback for a codec type only |  | 
| 25         // supported externally (e.g. H.264 on iOS or Android) or in current |  | 
| 26         // usage in WebRtcVideoEngine2 if the external decoder fails to be |  | 
| 27         // created. |  | 
| 28         LOG(LS_ERROR) << "Unable to create an H.264 decoder fallback. " |  | 
| 29                       << "Decoding of this stream will be broken."; |  | 
| 30         return new NullVideoDecoder(); |  | 
| 31       } |  | 
| 32       return H264Decoder::Create(); |  | 
| 33     case kVp8: |  | 
| 34       return VP8Decoder::Create(); |  | 
| 35     case kVp9: |  | 
| 36       RTC_DCHECK(VP9Decoder::IsSupported()); |  | 
| 37       return VP9Decoder::Create(); |  | 
| 38     case kUnsupportedCodec: |  | 
| 39       LOG(LS_ERROR) << "Creating NullVideoDecoder for unsupported codec."; |  | 
| 40       return new NullVideoDecoder(); |  | 
| 41   } |  | 
| 42   RTC_NOTREACHED(); |  | 
| 43   return nullptr; |  | 
| 44 } |  | 
| 45 | 21 | 
| 46 VideoDecoder::DecoderType CodecTypeToDecoderType(VideoCodecType codec_type) { | 22 VideoDecoder::DecoderType CodecTypeToDecoderType(VideoCodecType codec_type) { | 
| 47   switch (codec_type) { | 23   switch (codec_type) { | 
| 48     case kVideoCodecH264: | 24     case kVideoCodecH264: | 
| 49       return VideoDecoder::kH264; | 25       return VideoDecoder::kH264; | 
| 50     case kVideoCodecVP8: | 26     case kVideoCodecVP8: | 
| 51       return VideoDecoder::kVp8; | 27       return VideoDecoder::kVp8; | 
| 52     case kVideoCodecVP9: | 28     case kVideoCodecVP9: | 
| 53       return VideoDecoder::kVp9; | 29       return VideoDecoder::kVp9; | 
| 54     default: | 30     default: | 
| 55       return VideoDecoder::kUnsupportedCodec; | 31       return VideoDecoder::kUnsupportedCodec; | 
| 56   } | 32   } | 
| 57 } | 33 } | 
| 58 | 34 | 
|  | 35 }  // anonymous namespace | 
|  | 36 | 
| 59 VideoDecoderSoftwareFallbackWrapper::VideoDecoderSoftwareFallbackWrapper( | 37 VideoDecoderSoftwareFallbackWrapper::VideoDecoderSoftwareFallbackWrapper( | 
| 60     VideoCodecType codec_type, | 38     VideoCodecType codec_type, | 
| 61     VideoDecoder* decoder) | 39     VideoDecoder* decoder) | 
| 62     : decoder_type_(CodecTypeToDecoderType(codec_type)), | 40     : decoder_type_(CodecTypeToDecoderType(codec_type)), | 
| 63       decoder_(decoder), | 41       decoder_(decoder), | 
| 64       callback_(nullptr) { | 42       callback_(nullptr) { | 
| 65 } | 43 } | 
| 66 | 44 | 
| 67 int32_t VideoDecoderSoftwareFallbackWrapper::InitDecode( | 45 int32_t VideoDecoderSoftwareFallbackWrapper::InitDecode( | 
| 68     const VideoCodec* codec_settings, | 46     const VideoCodec* codec_settings, | 
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 142     return fallback_decoder_->PrefersLateDecoding(); | 120     return fallback_decoder_->PrefersLateDecoding(); | 
| 143   return decoder_->PrefersLateDecoding(); | 121   return decoder_->PrefersLateDecoding(); | 
| 144 } | 122 } | 
| 145 | 123 | 
| 146 const char* VideoDecoderSoftwareFallbackWrapper::ImplementationName() const { | 124 const char* VideoDecoderSoftwareFallbackWrapper::ImplementationName() const { | 
| 147   if (fallback_decoder_) | 125   if (fallback_decoder_) | 
| 148     return fallback_implementation_name_.c_str(); | 126     return fallback_implementation_name_.c_str(); | 
| 149   return decoder_->ImplementationName(); | 127   return decoder_->ImplementationName(); | 
| 150 } | 128 } | 
| 151 | 129 | 
| 152 NullVideoDecoder::NullVideoDecoder() {} |  | 
| 153 |  | 
| 154 int32_t NullVideoDecoder::InitDecode(const VideoCodec* codec_settings, |  | 
| 155                                      int32_t number_of_cores) { |  | 
| 156   LOG(LS_ERROR) << "Can't initialize NullVideoDecoder."; |  | 
| 157   return WEBRTC_VIDEO_CODEC_OK; |  | 
| 158 } |  | 
| 159 |  | 
| 160 int32_t NullVideoDecoder::Decode(const EncodedImage& input_image, |  | 
| 161     bool missing_frames, |  | 
| 162     const RTPFragmentationHeader* fragmentation, |  | 
| 163     const CodecSpecificInfo* codec_specific_info, |  | 
| 164     int64_t render_time_ms) { |  | 
| 165   LOG(LS_ERROR) << "The NullVideoDecoder doesn't support decoding."; |  | 
| 166   return WEBRTC_VIDEO_CODEC_OK; |  | 
| 167 } |  | 
| 168 |  | 
| 169 int32_t NullVideoDecoder::RegisterDecodeCompleteCallback( |  | 
| 170     DecodedImageCallback* callback) { |  | 
| 171   LOG(LS_ERROR) |  | 
| 172       << "Can't register decode complete callback on NullVideoDecoder."; |  | 
| 173   return WEBRTC_VIDEO_CODEC_OK; |  | 
| 174 } |  | 
| 175 |  | 
| 176 int32_t NullVideoDecoder::Release() { |  | 
| 177   return WEBRTC_VIDEO_CODEC_OK; |  | 
| 178 } |  | 
| 179 |  | 
| 180 const char* NullVideoDecoder::ImplementationName() const { |  | 
| 181   return "NullVideoDecoder"; |  | 
| 182 } |  | 
| 183 |  | 
| 184 }  // namespace webrtc | 130 }  // namespace webrtc | 
| OLD | NEW | 
|---|