blob: ef908099f158f42e38c0a1cb101b05c854a56a3d [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.
42 // See https://w3c.github.io/webrtc-svc/#scalabilitymodes* for a specification
Artem Titov0e61fdd2021-07-25 21:50:14 +020043 // of valid values for `scalability_mode`.
Johannes Kronc29e1f52021-04-26 22:18:57 +020044 // NOTE: QueryCodecSupport is currently an experimental feature that is
45 // subject to change without notice.
46 virtual CodecSupport QueryCodecSupport(
47 const SdpVideoFormat& format,
48 absl::optional<std::string> scalability_mode) const {
49 // Default implementation, query for supported formats and check if the
50 // specified format is supported. Returns false if scalability_mode is
51 // specified.
52 CodecSupport codec_support;
53 if (!scalability_mode) {
54 codec_support.is_supported = format.IsCodecInList(GetSupportedFormats());
55 }
56 return codec_support;
57 }
58
Magnus Jedvertd4b0c052017-09-14 10:24:54 +020059 // Creates a VideoDecoder for the specified format.
60 virtual std::unique_ptr<VideoDecoder> CreateVideoDecoder(
61 const SdpVideoFormat& format) = 0;
62
63 virtual ~VideoDecoderFactory() {}
64};
65
66} // namespace webrtc
67
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020068#endif // API_VIDEO_CODECS_VIDEO_DECODER_FACTORY_H_