Niels Möller | f906378 | 2018-02-20 16:09:48 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 18 | namespace webrtc { |
| 19 | |
| 20 | class 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öller | f906378 | 2018-02-20 16:09:48 +0100 | [diff] [blame] | 37 | bool internal_source); |
| 38 | |
Niels Möller | bf3dbb4 | 2018-03-16 13:38:46 +0100 | [diff] [blame^] | 39 | // Deregisters any external encoder. |
| 40 | void DeregisterExternalEncoder(); |
Niels Möller | f906378 | 2018-02-20 16:09:48 +0100 | [diff] [blame] | 41 | |
| 42 | VCMGenericEncoder* GetEncoder(); |
| 43 | |
Niels Möller | f906378 | 2018-02-20 16:09:48 +0100 | [diff] [blame] | 44 | 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öller | f906378 | 2018-02-20 16:09:48 +0100 | [diff] [blame] | 55 | bool pending_encoder_reset_; |
| 56 | VideoCodec send_codec_; |
Niels Möller | f906378 | 2018-02-20 16:09:48 +0100 | [diff] [blame] | 57 | 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_ |