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_ENCODER_FACTORY_H_
12 #define API_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_H_
13 
14 #include <memory>
15 #include <vector>
16 
17 namespace webrtc {
18 
19 class VideoEncoder;
20 struct SdpVideoFormat;
21 
22 // A factory that creates VideoEncoders.
23 // NOTE: This class is still under development and may change without notice.
24 class VideoEncoderFactory {
25  public:
26   // TODO(magjed): Try to get rid of this struct.
27   struct CodecInfo {
28     // |is_hardware_accelerated| is true if the encoders created by this factory
29     // of the given codec will use hardware support.
30     bool is_hardware_accelerated;
31     // |has_internal_source| is true if encoders created by this factory of the
32     // given codec will use internal camera sources, meaning that they don't
33     // require/expect frames to be delivered via webrtc::VideoEncoder::Encode.
34     // This flag is used as the internal_source parameter to
35     // webrtc::ViEExternalCodec::RegisterExternalSendCodec.
36     bool has_internal_source;
37   };
38 
39   // Returns a list of supported video formats in order of preference, to use
40   // for signaling etc.
41   virtual std::vector<SdpVideoFormat> GetSupportedFormats() const = 0;
42 
43   // Returns information about how this format will be encoded. The specified
44   // format must be one of the supported formats by this factory.
45   // TODO(magjed): Try to get rid of this method.
46   virtual CodecInfo QueryVideoEncoder(const SdpVideoFormat& format) const = 0;
47 
48   // Creates a VideoEncoder for the specified format.
49   virtual std::unique_ptr<VideoEncoder> CreateVideoEncoder(
50       const SdpVideoFormat& format) = 0;
51 
~VideoEncoderFactory()52   virtual ~VideoEncoderFactory() {}
53 };
54 
55 }  // namespace webrtc
56 
57 #endif  // API_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_H_
58