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

Side by Side Diff: webrtc/media/engine/videodecodersoftwarefallbackwrapper.cc

Issue 2521203002: Move VideoDecoder::Create() logic to separate internal video decoder factory (Closed)
Patch Set: Add unittest Created 4 years 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 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/media/engine/videodecodersoftwarefallbackwrapper.h" 11 #include "webrtc/media/engine/videodecodersoftwarefallbackwrapper.h"
12 12
13 #include <string> 13 #include <string>
14 14
15 #include "webrtc/base/logging.h" 15 #include "webrtc/base/logging.h"
16 #include "webrtc/media/engine/internaldecoderfactory.h"
16 #include "webrtc/modules/video_coding/include/video_error_codes.h" 17 #include "webrtc/modules/video_coding/include/video_error_codes.h"
17 18
18 namespace webrtc { 19 namespace webrtc {
19 20
20 namespace {
21
22 VideoDecoder::DecoderType CodecTypeToDecoderType(VideoCodecType codec_type) {
23 switch (codec_type) {
24 case kVideoCodecH264:
25 return VideoDecoder::kH264;
26 case kVideoCodecVP8:
27 return VideoDecoder::kVp8;
28 case kVideoCodecVP9:
29 return VideoDecoder::kVp9;
30 default:
31 return VideoDecoder::kUnsupportedCodec;
32 }
33 }
34
35 } // anonymous namespace
36
37 VideoDecoderSoftwareFallbackWrapper::VideoDecoderSoftwareFallbackWrapper( 21 VideoDecoderSoftwareFallbackWrapper::VideoDecoderSoftwareFallbackWrapper(
38 VideoCodecType codec_type, 22 VideoCodecType codec_type,
39 VideoDecoder* decoder) 23 VideoDecoder* decoder)
40 : decoder_type_(CodecTypeToDecoderType(codec_type)), 24 : codec_type_(codec_type), decoder_(decoder), callback_(nullptr) {}
41 decoder_(decoder),
42 callback_(nullptr) {
43 }
44 25
45 int32_t VideoDecoderSoftwareFallbackWrapper::InitDecode( 26 int32_t VideoDecoderSoftwareFallbackWrapper::InitDecode(
46 const VideoCodec* codec_settings, 27 const VideoCodec* codec_settings,
47 int32_t number_of_cores) { 28 int32_t number_of_cores) {
48 codec_settings_ = *codec_settings; 29 codec_settings_ = *codec_settings;
49 number_of_cores_ = number_of_cores; 30 number_of_cores_ = number_of_cores;
50 return decoder_->InitDecode(codec_settings, number_of_cores); 31 return decoder_->InitDecode(codec_settings, number_of_cores);
51 } 32 }
52 33
53 bool VideoDecoderSoftwareFallbackWrapper::InitFallbackDecoder() { 34 bool VideoDecoderSoftwareFallbackWrapper::InitFallbackDecoder() {
54 RTC_CHECK(decoder_type_ != kUnsupportedCodec) 35 RTC_CHECK(codec_type_ != kVideoCodecUnknown)
55 << "Decoder requesting fallback to codec not supported in software."; 36 << "Decoder requesting fallback to codec not supported in software.";
56 LOG(LS_WARNING) << "Decoder falling back to software decoding."; 37 LOG(LS_WARNING) << "Decoder falling back to software decoding.";
57 fallback_decoder_.reset(VideoDecoder::Create(decoder_type_)); 38 cricket::InternalDecoderFactory internal_decoder_factory;
39 fallback_decoder_.reset(
40 internal_decoder_factory.CreateVideoDecoder(codec_type_));
58 if (fallback_decoder_->InitDecode(&codec_settings_, number_of_cores_) != 41 if (fallback_decoder_->InitDecode(&codec_settings_, number_of_cores_) !=
59 WEBRTC_VIDEO_CODEC_OK) { 42 WEBRTC_VIDEO_CODEC_OK) {
60 LOG(LS_ERROR) << "Failed to initialize software-decoder fallback."; 43 LOG(LS_ERROR) << "Failed to initialize software-decoder fallback.";
61 fallback_decoder_.reset(); 44 fallback_decoder_.reset();
62 return false; 45 return false;
63 } 46 }
64 if (callback_) 47 if (callback_)
65 fallback_decoder_->RegisterDecodeCompleteCallback(callback_); 48 fallback_decoder_->RegisterDecodeCompleteCallback(callback_);
66 fallback_implementation_name_ = 49 fallback_implementation_name_ =
67 std::string(fallback_decoder_->ImplementationName()) + 50 std::string(fallback_decoder_->ImplementationName()) +
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 return decoder_->PrefersLateDecoding(); 104 return decoder_->PrefersLateDecoding();
122 } 105 }
123 106
124 const char* VideoDecoderSoftwareFallbackWrapper::ImplementationName() const { 107 const char* VideoDecoderSoftwareFallbackWrapper::ImplementationName() const {
125 if (fallback_decoder_) 108 if (fallback_decoder_)
126 return fallback_implementation_name_.c_str(); 109 return fallback_implementation_name_.c_str();
127 return decoder_->ImplementationName(); 110 return decoder_->ImplementationName();
128 } 111 }
129 112
130 } // namespace webrtc 113 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/media/engine/videodecodersoftwarefallbackwrapper.h ('k') | webrtc/media/engine/webrtcvideoengine2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698