1*d9f75844SAndroid Build Coastguard Worker /* 2*d9f75844SAndroid Build Coastguard Worker * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3*d9f75844SAndroid Build Coastguard Worker * 4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license 5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source 6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found 7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may 8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree. 9*d9f75844SAndroid Build Coastguard Worker */ 10*d9f75844SAndroid Build Coastguard Worker 11*d9f75844SAndroid Build Coastguard Worker #include "api/video_codecs/video_decoder.h" 12*d9f75844SAndroid Build Coastguard Worker 13*d9f75844SAndroid Build Coastguard Worker #include "absl/types/optional.h" 14*d9f75844SAndroid Build Coastguard Worker #include "api/video/render_resolution.h" 15*d9f75844SAndroid Build Coastguard Worker #include "api/video/video_codec_type.h" 16*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/checks.h" 17*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/strings/string_builder.h" 18*d9f75844SAndroid Build Coastguard Worker 19*d9f75844SAndroid Build Coastguard Worker namespace webrtc { 20*d9f75844SAndroid Build Coastguard Worker Decoded(VideoFrame & decodedImage,int64_t decode_time_ms)21*d9f75844SAndroid Build Coastguard Workerint32_t DecodedImageCallback::Decoded(VideoFrame& decodedImage, 22*d9f75844SAndroid Build Coastguard Worker int64_t decode_time_ms) { 23*d9f75844SAndroid Build Coastguard Worker // The default implementation ignores custom decode time value. 24*d9f75844SAndroid Build Coastguard Worker return Decoded(decodedImage); 25*d9f75844SAndroid Build Coastguard Worker } 26*d9f75844SAndroid Build Coastguard Worker Decoded(VideoFrame & decodedImage,absl::optional<int32_t> decode_time_ms,absl::optional<uint8_t> qp)27*d9f75844SAndroid Build Coastguard Workervoid DecodedImageCallback::Decoded(VideoFrame& decodedImage, 28*d9f75844SAndroid Build Coastguard Worker absl::optional<int32_t> decode_time_ms, 29*d9f75844SAndroid Build Coastguard Worker absl::optional<uint8_t> qp) { 30*d9f75844SAndroid Build Coastguard Worker Decoded(decodedImage, decode_time_ms.value_or(-1)); 31*d9f75844SAndroid Build Coastguard Worker } 32*d9f75844SAndroid Build Coastguard Worker GetDecoderInfo() const33*d9f75844SAndroid Build Coastguard WorkerVideoDecoder::DecoderInfo VideoDecoder::GetDecoderInfo() const { 34*d9f75844SAndroid Build Coastguard Worker DecoderInfo info; 35*d9f75844SAndroid Build Coastguard Worker info.implementation_name = ImplementationName(); 36*d9f75844SAndroid Build Coastguard Worker return info; 37*d9f75844SAndroid Build Coastguard Worker } 38*d9f75844SAndroid Build Coastguard Worker ImplementationName() const39*d9f75844SAndroid Build Coastguard Workerconst char* VideoDecoder::ImplementationName() const { 40*d9f75844SAndroid Build Coastguard Worker return "unknown"; 41*d9f75844SAndroid Build Coastguard Worker } 42*d9f75844SAndroid Build Coastguard Worker ToString() const43*d9f75844SAndroid Build Coastguard Workerstd::string VideoDecoder::DecoderInfo::ToString() const { 44*d9f75844SAndroid Build Coastguard Worker char string_buf[2048]; 45*d9f75844SAndroid Build Coastguard Worker rtc::SimpleStringBuilder oss(string_buf); 46*d9f75844SAndroid Build Coastguard Worker 47*d9f75844SAndroid Build Coastguard Worker oss << "DecoderInfo { " 48*d9f75844SAndroid Build Coastguard Worker << "prefers_late_decoding = " 49*d9f75844SAndroid Build Coastguard Worker << "implementation_name = '" << implementation_name << "', " 50*d9f75844SAndroid Build Coastguard Worker << "is_hardware_accelerated = " 51*d9f75844SAndroid Build Coastguard Worker << (is_hardware_accelerated ? "true" : "false") << " }"; 52*d9f75844SAndroid Build Coastguard Worker return oss.str(); 53*d9f75844SAndroid Build Coastguard Worker } 54*d9f75844SAndroid Build Coastguard Worker operator ==(const DecoderInfo & rhs) const55*d9f75844SAndroid Build Coastguard Workerbool VideoDecoder::DecoderInfo::operator==(const DecoderInfo& rhs) const { 56*d9f75844SAndroid Build Coastguard Worker return is_hardware_accelerated == rhs.is_hardware_accelerated && 57*d9f75844SAndroid Build Coastguard Worker implementation_name == rhs.implementation_name; 58*d9f75844SAndroid Build Coastguard Worker } 59*d9f75844SAndroid Build Coastguard Worker set_number_of_cores(int value)60*d9f75844SAndroid Build Coastguard Workervoid VideoDecoder::Settings::set_number_of_cores(int value) { 61*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_GT(value, 0); 62*d9f75844SAndroid Build Coastguard Worker number_of_cores_ = value; 63*d9f75844SAndroid Build Coastguard Worker } 64*d9f75844SAndroid Build Coastguard Worker 65*d9f75844SAndroid Build Coastguard Worker } // namespace webrtc 66