Niels Möller | be682d4 | 2018-03-27 08:31:45 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #include "api/video_codecs/video_decoder.h" |
| 12 | |
Erik Språng | c12f625 | 2021-01-13 21:49:59 +0100 | [diff] [blame] | 13 | #include "rtc_base/strings/string_builder.h" |
| 14 | |
Niels Möller | be682d4 | 2018-03-27 08:31:45 +0200 | [diff] [blame] | 15 | namespace webrtc { |
| 16 | |
| 17 | int32_t DecodedImageCallback::Decoded(VideoFrame& decodedImage, |
| 18 | int64_t decode_time_ms) { |
| 19 | // The default implementation ignores custom decode time value. |
| 20 | return Decoded(decodedImage); |
| 21 | } |
| 22 | |
| 23 | void DecodedImageCallback::Decoded(VideoFrame& decodedImage, |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 24 | absl::optional<int32_t> decode_time_ms, |
| 25 | absl::optional<uint8_t> qp) { |
Niels Möller | be682d4 | 2018-03-27 08:31:45 +0200 | [diff] [blame] | 26 | Decoded(decodedImage, decode_time_ms.value_or(-1)); |
| 27 | } |
| 28 | |
Erik Språng | c12f625 | 2021-01-13 21:49:59 +0100 | [diff] [blame] | 29 | VideoDecoder::DecoderInfo VideoDecoder::GetDecoderInfo() const { |
| 30 | DecoderInfo info; |
| 31 | info.implementation_name = ImplementationName(); |
| 32 | return info; |
| 33 | } |
| 34 | |
Niels Möller | be682d4 | 2018-03-27 08:31:45 +0200 | [diff] [blame] | 35 | const char* VideoDecoder::ImplementationName() const { |
| 36 | return "unknown"; |
| 37 | } |
| 38 | |
Erik Språng | c12f625 | 2021-01-13 21:49:59 +0100 | [diff] [blame] | 39 | std::string VideoDecoder::DecoderInfo::ToString() const { |
| 40 | char string_buf[2048]; |
| 41 | rtc::SimpleStringBuilder oss(string_buf); |
| 42 | |
| 43 | oss << "DecoderInfo { " |
| 44 | << "prefers_late_decoding = " |
| 45 | << "implementation_name = '" << implementation_name << "', " |
| 46 | << "is_hardware_accelerated = " |
| 47 | << (is_hardware_accelerated ? "true" : "false") << " }"; |
| 48 | return oss.str(); |
| 49 | } |
| 50 | |
| 51 | bool VideoDecoder::DecoderInfo::operator==(const DecoderInfo& rhs) const { |
| 52 | return is_hardware_accelerated == rhs.is_hardware_accelerated && |
| 53 | implementation_name == rhs.implementation_name; |
| 54 | } |
| 55 | |
Niels Möller | be682d4 | 2018-03-27 08:31:45 +0200 | [diff] [blame] | 56 | } // namespace webrtc |