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_ENCODER_FACTORY_H_ |
| 12 | #define API_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_H_ |
Magnus Jedvert | d4b0c05 | 2017-09-14 10:24:54 +0200 | [diff] [blame] | 13 | |
| 14 | #include <memory> |
| 15 | #include <vector> |
| 16 | |
philipel | 0bb0881 | 2019-07-11 13:23:16 +0200 | [diff] [blame^] | 17 | #include "api/video_codecs/sdp_video_format.h" |
| 18 | |
Magnus Jedvert | d4b0c05 | 2017-09-14 10:24:54 +0200 | [diff] [blame] | 19 | namespace webrtc { |
| 20 | |
| 21 | class VideoEncoder; |
Magnus Jedvert | d4b0c05 | 2017-09-14 10:24:54 +0200 | [diff] [blame] | 22 | |
| 23 | // A factory that creates VideoEncoders. |
| 24 | // NOTE: This class is still under development and may change without notice. |
| 25 | class VideoEncoderFactory { |
| 26 | public: |
| 27 | // TODO(magjed): Try to get rid of this struct. |
| 28 | struct CodecInfo { |
| 29 | // |is_hardware_accelerated| is true if the encoders created by this factory |
| 30 | // of the given codec will use hardware support. |
| 31 | bool is_hardware_accelerated; |
| 32 | // |has_internal_source| is true if encoders created by this factory of the |
| 33 | // given codec will use internal camera sources, meaning that they don't |
| 34 | // require/expect frames to be delivered via webrtc::VideoEncoder::Encode. |
| 35 | // This flag is used as the internal_source parameter to |
| 36 | // webrtc::ViEExternalCodec::RegisterExternalSendCodec. |
| 37 | bool has_internal_source; |
| 38 | }; |
| 39 | |
| 40 | // Returns a list of supported video formats in order of preference, to use |
| 41 | // for signaling etc. |
| 42 | virtual std::vector<SdpVideoFormat> GetSupportedFormats() const = 0; |
| 43 | |
philipel | 0bb0881 | 2019-07-11 13:23:16 +0200 | [diff] [blame^] | 44 | // Returns a list of supported video formats in order of preference, that can |
| 45 | // also be tagged with additional information to allow the VideoEncoderFactory |
| 46 | // to separate between different implementations when CreateVideoEncoder is |
| 47 | // called. |
| 48 | virtual std::vector<SdpVideoFormat> GetImplementations() const { |
| 49 | return GetSupportedFormats(); |
| 50 | } |
| 51 | |
Magnus Jedvert | d4b0c05 | 2017-09-14 10:24:54 +0200 | [diff] [blame] | 52 | // Returns information about how this format will be encoded. The specified |
| 53 | // format must be one of the supported formats by this factory. |
| 54 | // TODO(magjed): Try to get rid of this method. |
Mirta Dvornicic | 1ec2a16 | 2018-12-10 09:47:34 +0000 | [diff] [blame] | 55 | virtual CodecInfo QueryVideoEncoder(const SdpVideoFormat& format) const = 0; |
Magnus Jedvert | d4b0c05 | 2017-09-14 10:24:54 +0200 | [diff] [blame] | 56 | |
| 57 | // Creates a VideoEncoder for the specified format. |
| 58 | virtual std::unique_ptr<VideoEncoder> CreateVideoEncoder( |
| 59 | const SdpVideoFormat& format) = 0; |
| 60 | |
| 61 | virtual ~VideoEncoderFactory() {} |
| 62 | }; |
| 63 | |
| 64 | } // namespace webrtc |
| 65 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 66 | #endif // API_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_H_ |