blob: a9db4e15c808d4ee72e1f76be8c330a87d340a94 [file] [log] [blame]
Niels Möllerf9063782018-02-20 16:09:48 +01001/*
2 * Copyright (c) 2018 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 MODULES_VIDEO_CODING_ENCODER_DATABASE_H_
12#define MODULES_VIDEO_CODING_ENCODER_DATABASE_H_
13
14#include <memory>
15
16#include "modules/video_coding/generic_encoder.h"
17
18namespace webrtc {
19
20class VCMEncoderDataBase {
21 public:
22 explicit VCMEncoderDataBase(VCMEncodedFrameCallback* encoded_frame_callback);
23 ~VCMEncoderDataBase();
24
25 // Sets the sender side codec and initiates the desired codec given the
26 // VideoCodec struct.
27 // Returns true if the codec was successfully registered, false otherwise.
28 bool SetSendCodec(const VideoCodec* send_codec,
29 int number_of_cores,
30 size_t max_payload_size);
31
32 // Registers and initializes an external encoder object.
33 // |internal_source| should be set to true if the codec has an internal
34 // video source and doesn't need the user to provide it with frames via
35 // the Encode() method.
36 void RegisterExternalEncoder(VideoEncoder* external_encoder,
Niels Möllerf9063782018-02-20 16:09:48 +010037 bool internal_source);
38
Niels Möllerbf3dbb42018-03-16 13:38:46 +010039 // Deregisters any external encoder.
40 void DeregisterExternalEncoder();
Niels Möllerf9063782018-02-20 16:09:48 +010041
42 VCMGenericEncoder* GetEncoder();
43
Niels Möllerf9063782018-02-20 16:09:48 +010044 bool MatchesCurrentResolution(int width, int height) const;
45
46 private:
47 // Determines whether a new codec has to be created or not.
48 // Checks every setting apart from maxFramerate and startBitrate.
49 bool RequiresEncoderReset(const VideoCodec& send_codec);
50
51 void DeleteEncoder();
52
53 int number_of_cores_;
54 size_t max_payload_size_;
Niels Möllerf9063782018-02-20 16:09:48 +010055 bool pending_encoder_reset_;
56 VideoCodec send_codec_;
Niels Möllerf9063782018-02-20 16:09:48 +010057 VideoEncoder* external_encoder_;
58 bool internal_source_;
59 VCMEncodedFrameCallback* const encoded_frame_callback_;
60 std::unique_ptr<VCMGenericEncoder> ptr_encoder_;
61};
62
63} // namespace webrtc
64
65#endif // MODULES_VIDEO_CODING_ENCODER_DATABASE_H_