2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2018-02-20 16:09:48 +01:00
|
|
|
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-02-20 16:09:48 +01:00
|
|
|
#ifndef MODULES_VIDEO_CODING_DECODER_DATABASE_H_
|
|
|
|
|
#define MODULES_VIDEO_CODING_DECODER_DATABASE_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2021-08-06 12:30:02 +02:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
2012-01-20 14:04:13 +00:00
|
|
|
#include <map>
|
|
|
|
|
|
2021-08-06 12:30:02 +02:00
|
|
|
#include "absl/types/optional.h"
|
2022-08-19 11:48:10 +02:00
|
|
|
#include "api/sequence_checker.h"
|
2021-08-06 12:30:02 +02:00
|
|
|
#include "api/video_codecs/video_decoder.h"
|
|
|
|
|
#include "modules/video_coding/encoded_frame.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/video_coding/generic_decoder.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2012-10-11 11:21:38 +00:00
|
|
|
namespace webrtc {
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2018-02-20 16:09:48 +01:00
|
|
|
class VCMDecoderDataBase {
|
2012-10-11 11:21:38 +00:00
|
|
|
public:
|
2022-08-19 11:48:10 +02:00
|
|
|
VCMDecoderDataBase();
|
2021-08-06 12:30:02 +02:00
|
|
|
VCMDecoderDataBase(const VCMDecoderDataBase&) = delete;
|
|
|
|
|
VCMDecoderDataBase& operator=(const VCMDecoderDataBase&) = delete;
|
|
|
|
|
~VCMDecoderDataBase() = default;
|
2012-10-11 11:21:38 +00:00
|
|
|
|
2022-08-22 12:56:38 +02:00
|
|
|
// Returns a pointer to the previously registered decoder or nullptr if none
|
|
|
|
|
// was registered for the `payload_type`.
|
|
|
|
|
VideoDecoder* DeregisterExternalDecoder(uint8_t payload_type);
|
2021-08-06 12:30:02 +02:00
|
|
|
void RegisterExternalDecoder(uint8_t payload_type,
|
|
|
|
|
VideoDecoder* external_decoder);
|
2021-02-18 23:37:22 +01:00
|
|
|
bool IsExternalDecoderRegistered(uint8_t payload_type) const;
|
2012-10-11 11:21:38 +00:00
|
|
|
|
2021-08-13 18:15:55 +02:00
|
|
|
void RegisterReceiveCodec(uint8_t payload_type,
|
2021-08-13 16:50:37 +02:00
|
|
|
const VideoDecoder::Settings& settings);
|
2012-10-11 11:21:38 +00:00
|
|
|
bool DeregisterReceiveCodec(uint8_t payload_type);
|
|
|
|
|
|
2018-06-01 15:13:42 +02:00
|
|
|
// Returns a decoder specified by frame.PayloadType. The decoded frame
|
2021-08-09 13:02:57 +02:00
|
|
|
// callback of the decoder is set to `decoded_frame_callback`. If no such
|
2018-06-01 15:13:42 +02:00
|
|
|
// decoder already exists an instance will be created and initialized.
|
|
|
|
|
// nullptr is returned if no decoder with the specified payload type was found
|
2012-10-11 11:21:38 +00:00
|
|
|
// and the function failed to create one.
|
|
|
|
|
VCMGenericDecoder* GetDecoder(
|
2015-11-27 14:23:21 +01:00
|
|
|
const VCMEncodedFrame& frame,
|
|
|
|
|
VCMDecodedFrameCallback* decoded_frame_callback);
|
2012-10-11 11:21:38 +00:00
|
|
|
|
|
|
|
|
private:
|
2022-08-19 11:48:10 +02:00
|
|
|
void CreateAndInitDecoder(const VCMEncodedFrame& frame)
|
|
|
|
|
RTC_RUN_ON(decoder_sequence_checker_);
|
|
|
|
|
|
|
|
|
|
SequenceChecker decoder_sequence_checker_;
|
2021-08-06 12:30:02 +02:00
|
|
|
|
|
|
|
|
absl::optional<uint8_t> current_payload_type_;
|
2022-08-19 11:48:10 +02:00
|
|
|
absl::optional<VCMGenericDecoder> current_decoder_
|
|
|
|
|
RTC_GUARDED_BY(decoder_sequence_checker_);
|
2021-08-06 12:30:02 +02:00
|
|
|
// Initialization paramaters for decoders keyed by payload type.
|
2021-08-13 16:50:37 +02:00
|
|
|
std::map<uint8_t, VideoDecoder::Settings> decoder_settings_;
|
2021-08-06 12:30:02 +02:00
|
|
|
// Decoders keyed by payload type.
|
2022-08-19 11:48:10 +02:00
|
|
|
std::map<uint8_t, VideoDecoder*> decoders_
|
|
|
|
|
RTC_GUARDED_BY(decoder_sequence_checker_);
|
2018-02-20 16:09:48 +01:00
|
|
|
};
|
2012-10-11 11:21:38 +00:00
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2018-02-20 16:09:48 +01:00
|
|
|
#endif // MODULES_VIDEO_CODING_DECODER_DATABASE_H_
|