blob: 1f80fa74db7596b03a24d065e1789835a6fc03e6 [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_ENCODER_FACTORY_H_
12#define API_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_H_
Magnus Jedvertd4b0c052017-09-14 10:24:54 +020013
14#include <memory>
15#include <vector>
16
philipel0bb08812019-07-11 13:23:16 +020017#include "api/video_codecs/sdp_video_format.h"
18
Magnus Jedvertd4b0c052017-09-14 10:24:54 +020019namespace webrtc {
20
21class VideoEncoder;
Magnus Jedvertd4b0c052017-09-14 10:24:54 +020022
23// A factory that creates VideoEncoders.
24// NOTE: This class is still under development and may change without notice.
25class 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
philipel0bb08812019-07-11 13:23:16 +020044 // 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 Jedvertd4b0c052017-09-14 10:24:54 +020052 // 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 Dvornicic1ec2a162018-12-10 09:47:34 +000055 virtual CodecInfo QueryVideoEncoder(const SdpVideoFormat& format) const = 0;
Magnus Jedvertd4b0c052017-09-14 10:24:54 +020056
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 Bonadei92ea95e2017-09-15 06:47:31 +020066#endif // API_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_H_