Magnus Jedvert | d4b0c05 | 2017-09-14 10:24:54 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef API_VIDEO_CODECS_VIDEO_DECODER_FACTORY_H_ |
| 12 | #define API_VIDEO_CODECS_VIDEO_DECODER_FACTORY_H_ |
Magnus Jedvert | d4b0c05 | 2017-09-14 10:24:54 +0200 | [diff] [blame] | 13 | |
| 14 | #include <memory> |
Magnus Jedvert | 59ab353 | 2018-09-03 18:07:56 +0200 | [diff] [blame] | 15 | #include <string> |
Magnus Jedvert | d4b0c05 | 2017-09-14 10:24:54 +0200 | [diff] [blame] | 16 | #include <vector> |
| 17 | |
Johannes Kron | c29e1f5 | 2021-04-26 22:18:57 +0200 | [diff] [blame] | 18 | #include "absl/types/optional.h" |
| 19 | #include "api/video_codecs/sdp_video_format.h" |
Mirko Bonadei | 66e7679 | 2019-04-02 11:33:59 +0200 | [diff] [blame] | 20 | #include "rtc_base/system/rtc_export.h" |
| 21 | |
Magnus Jedvert | d4b0c05 | 2017-09-14 10:24:54 +0200 | [diff] [blame] | 22 | namespace webrtc { |
| 23 | |
| 24 | class VideoDecoder; |
Magnus Jedvert | d4b0c05 | 2017-09-14 10:24:54 +0200 | [diff] [blame] | 25 | |
| 26 | // A factory that creates VideoDecoders. |
| 27 | // NOTE: This class is still under development and may change without notice. |
Mirko Bonadei | 66e7679 | 2019-04-02 11:33:59 +0200 | [diff] [blame] | 28 | class RTC_EXPORT VideoDecoderFactory { |
Magnus Jedvert | d4b0c05 | 2017-09-14 10:24:54 +0200 | [diff] [blame] | 29 | public: |
Johannes Kron | c29e1f5 | 2021-04-26 22:18:57 +0200 | [diff] [blame] | 30 | struct CodecSupport { |
| 31 | bool is_supported = false; |
| 32 | bool is_power_efficient = false; |
| 33 | }; |
| 34 | |
Magnus Jedvert | d4b0c05 | 2017-09-14 10:24:54 +0200 | [diff] [blame] | 35 | // Returns a list of supported video formats in order of preference, to use |
| 36 | // for signaling etc. |
| 37 | virtual std::vector<SdpVideoFormat> GetSupportedFormats() const = 0; |
| 38 | |
Johannes Kron | c29e1f5 | 2021-04-26 22:18:57 +0200 | [diff] [blame] | 39 | // Query whether the specifed format is supported or not and if it will be |
| 40 | // power efficient, which is currently interpreted as if there is support for |
| 41 | // hardware acceleration. |
Johannes Kron | 3bb74f3 | 2021-08-19 10:34:32 +0200 | [diff] [blame] | 42 | // The parameter `reference_scaling` is used to query support for prediction |
| 43 | // across spatial layers. An example where support for reference scaling is |
| 44 | // needed is if the video stream is produced with a scalability mode that has |
| 45 | // a dependency between the spatial layers. See |
| 46 | // https://w3c.github.io/webrtc-svc/#scalabilitymodes* for a specification of |
| 47 | // different scalabilty modes. NOTE: QueryCodecSupport is currently an |
| 48 | // experimental feature that is subject to change without notice. |
| 49 | virtual CodecSupport QueryCodecSupport(const SdpVideoFormat& format, |
| 50 | bool reference_scaling) const { |
| 51 | // Default implementation, query for supported formats and check if the |
| 52 | // specified format is supported. Returns false if `reference_scaling` is |
| 53 | // true. |
| 54 | CodecSupport codec_support; |
| 55 | codec_support.is_supported = |
| 56 | !reference_scaling && format.IsCodecInList(GetSupportedFormats()); |
| 57 | return codec_support; |
| 58 | } |
| 59 | |
Magnus Jedvert | d4b0c05 | 2017-09-14 10:24:54 +0200 | [diff] [blame] | 60 | // Creates a VideoDecoder for the specified format. |
| 61 | virtual std::unique_ptr<VideoDecoder> CreateVideoDecoder( |
| 62 | const SdpVideoFormat& format) = 0; |
| 63 | |
| 64 | virtual ~VideoDecoderFactory() {} |
| 65 | }; |
| 66 | |
| 67 | } // namespace webrtc |
| 68 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 69 | #endif // API_VIDEO_CODECS_VIDEO_DECODER_FACTORY_H_ |