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 11 #ifndef API_VIDEO_CODECS_VIDEO_DECODER_FACTORY_H_ 12 #define API_VIDEO_CODECS_VIDEO_DECODER_FACTORY_H_ 13 14 #include <memory> 15 #include <string> 16 #include <vector> 17 18 #include "absl/types/optional.h" 19 #include "api/video_codecs/sdp_video_format.h" 20 #include "rtc_base/system/rtc_export.h" 21 22 namespace webrtc { 23 24 class VideoDecoder; 25 26 // A factory that creates VideoDecoders. 27 // NOTE: This class is still under development and may change without notice. 28 class RTC_EXPORT VideoDecoderFactory { 29 public: 30 struct CodecSupport { 31 bool is_supported = false; 32 bool is_power_efficient = false; 33 }; 34 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 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. 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. QueryCodecSupport(const SdpVideoFormat & format,bool reference_scaling)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 60 // Creates a VideoDecoder for the specified format. 61 virtual std::unique_ptr<VideoDecoder> CreateVideoDecoder( 62 const SdpVideoFormat& format) = 0; 63 ~VideoDecoderFactory()64 virtual ~VideoDecoderFactory() {} 65 }; 66 67 } // namespace webrtc 68 69 #endif // API_VIDEO_CODECS_VIDEO_DECODER_FACTORY_H_ 70