blob: 7e1d2ee8831a450c3ddddc7863990161cb6bb218 [file] [log] [blame]
Magnus Jedvertd4b0c052017-09-14 10:24:54 +02001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef API_VIDEO_CODECS_VIDEO_DECODER_FACTORY_H_
12#define API_VIDEO_CODECS_VIDEO_DECODER_FACTORY_H_
Magnus Jedvertd4b0c052017-09-14 10:24:54 +020013
14#include <memory>
Magnus Jedvert59ab3532018-09-03 18:07:56 +020015#include <string>
Magnus Jedvertd4b0c052017-09-14 10:24:54 +020016#include <vector>
17
Johannes Kronc29e1f52021-04-26 22:18:57 +020018#include "absl/types/optional.h"
19#include "api/video_codecs/sdp_video_format.h"
Mirko Bonadei66e76792019-04-02 11:33:59 +020020#include "rtc_base/system/rtc_export.h"
21
Magnus Jedvertd4b0c052017-09-14 10:24:54 +020022namespace webrtc {
23
24class VideoDecoder;
Magnus Jedvertd4b0c052017-09-14 10:24:54 +020025
26// A factory that creates VideoDecoders.
27// NOTE: This class is still under development and may change without notice.
Mirko Bonadei66e76792019-04-02 11:33:59 +020028class RTC_EXPORT VideoDecoderFactory {
Magnus Jedvertd4b0c052017-09-14 10:24:54 +020029 public:
Johannes Kronc29e1f52021-04-26 22:18:57 +020030 struct CodecSupport {
31 bool is_supported = false;
32 bool is_power_efficient = false;
33 };
34
Magnus Jedvertd4b0c052017-09-14 10:24:54 +020035 // 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 Kronc29e1f52021-04-26 22:18:57 +020039 // 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 Kron3bb74f32021-08-19 10:34:32 +020042 // 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 Jedvertd4b0c052017-09-14 10:24:54 +020060 // 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 Bonadei92ea95e2017-09-15 06:47:31 +020069#endif // API_VIDEO_CODECS_VIDEO_DECODER_FACTORY_H_