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_DECODER_DATABASE_H_ |
| 12 | #define MODULES_VIDEO_CODING_DECODER_DATABASE_H_ |
| 13 | |
Danil Chapovalov | 7b78a31 | 2021-08-06 12:30:02 +0200 | [diff] [blame] | 14 | #include <stdint.h> |
Niels Möller | f906378 | 2018-02-20 16:09:48 +0100 | [diff] [blame] | 15 | |
Danil Chapovalov | 7b78a31 | 2021-08-06 12:30:02 +0200 | [diff] [blame] | 16 | #include <map> |
| 17 | |
| 18 | #include "absl/types/optional.h" |
| 19 | #include "api/video_codecs/video_decoder.h" |
| 20 | #include "modules/video_coding/encoded_frame.h" |
Niels Möller | f906378 | 2018-02-20 16:09:48 +0100 | [diff] [blame] | 21 | #include "modules/video_coding/generic_decoder.h" |
| 22 | |
| 23 | namespace webrtc { |
| 24 | |
Niels Möller | f906378 | 2018-02-20 16:09:48 +0100 | [diff] [blame] | 25 | class VCMDecoderDataBase { |
| 26 | public: |
Danil Chapovalov | 7b78a31 | 2021-08-06 12:30:02 +0200 | [diff] [blame] | 27 | VCMDecoderDataBase() = default; |
| 28 | VCMDecoderDataBase(const VCMDecoderDataBase&) = delete; |
| 29 | VCMDecoderDataBase& operator=(const VCMDecoderDataBase&) = delete; |
| 30 | ~VCMDecoderDataBase() = default; |
Niels Möller | f906378 | 2018-02-20 16:09:48 +0100 | [diff] [blame] | 31 | |
| 32 | bool DeregisterExternalDecoder(uint8_t payload_type); |
Danil Chapovalov | 7b78a31 | 2021-08-06 12:30:02 +0200 | [diff] [blame] | 33 | void RegisterExternalDecoder(uint8_t payload_type, |
| 34 | VideoDecoder* external_decoder); |
Johannes Kron | 16359f6 | 2021-02-18 23:37:22 +0100 | [diff] [blame] | 35 | bool IsExternalDecoderRegistered(uint8_t payload_type) const; |
Niels Möller | f906378 | 2018-02-20 16:09:48 +0100 | [diff] [blame] | 36 | |
Danil Chapovalov | ba0a306 | 2021-08-13 18:15:55 +0200 | [diff] [blame^] | 37 | void RegisterReceiveCodec(uint8_t payload_type, |
Danil Chapovalov | 355b8d2 | 2021-08-13 16:50:37 +0200 | [diff] [blame] | 38 | const VideoDecoder::Settings& settings); |
Niels Möller | f906378 | 2018-02-20 16:09:48 +0100 | [diff] [blame] | 39 | bool DeregisterReceiveCodec(uint8_t payload_type); |
| 40 | |
Åsa Persson | 6cb74fd | 2018-06-01 15:13:42 +0200 | [diff] [blame] | 41 | // Returns a decoder specified by frame.PayloadType. The decoded frame |
Artem Titov | dcd7fc7 | 2021-08-09 13:02:57 +0200 | [diff] [blame] | 42 | // callback of the decoder is set to `decoded_frame_callback`. If no such |
Åsa Persson | 6cb74fd | 2018-06-01 15:13:42 +0200 | [diff] [blame] | 43 | // decoder already exists an instance will be created and initialized. |
| 44 | // nullptr is returned if no decoder with the specified payload type was found |
Niels Möller | f906378 | 2018-02-20 16:09:48 +0100 | [diff] [blame] | 45 | // and the function failed to create one. |
| 46 | VCMGenericDecoder* GetDecoder( |
| 47 | const VCMEncodedFrame& frame, |
| 48 | VCMDecodedFrameCallback* decoded_frame_callback); |
| 49 | |
Niels Möller | f906378 | 2018-02-20 16:09:48 +0100 | [diff] [blame] | 50 | private: |
Danil Chapovalov | 7b78a31 | 2021-08-06 12:30:02 +0200 | [diff] [blame] | 51 | void CreateAndInitDecoder(const VCMEncodedFrame& frame); |
Niels Möller | f906378 | 2018-02-20 16:09:48 +0100 | [diff] [blame] | 52 | |
Danil Chapovalov | 7b78a31 | 2021-08-06 12:30:02 +0200 | [diff] [blame] | 53 | absl::optional<uint8_t> current_payload_type_; |
| 54 | absl::optional<VCMGenericDecoder> current_decoder_; |
| 55 | // Initialization paramaters for decoders keyed by payload type. |
Danil Chapovalov | 355b8d2 | 2021-08-13 16:50:37 +0200 | [diff] [blame] | 56 | std::map<uint8_t, VideoDecoder::Settings> decoder_settings_; |
Danil Chapovalov | 7b78a31 | 2021-08-06 12:30:02 +0200 | [diff] [blame] | 57 | // Decoders keyed by payload type. |
| 58 | std::map<uint8_t, VideoDecoder*> decoders_; |
Niels Möller | f906378 | 2018-02-20 16:09:48 +0100 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | } // namespace webrtc |
| 62 | |
| 63 | #endif // MODULES_VIDEO_CODING_DECODER_DATABASE_H_ |