BlueGit

ict rusty-teams

Files

rusty-teams / vendor / webrtc-sys / src / nvidia / h264_decoder_impl.h

h264_decoder_impl.h

h264_decoder_impl.h 1.8 KiB Download Raw
1#ifndef WEBRTC_NVIDIA_H264_DECODER_IMPL_H_
2#define WEBRTC_NVIDIA_H264_DECODER_IMPL_H_
3
4#include <api/video_codecs/h264_profile_level_id.h>
5#include <api/video_codecs/sdp_video_format.h>
6#include <api/video_codecs/video_decoder.h>
7#include <api/video_codecs/video_decoder_factory.h>
8#include <api/video_codecs/video_encoder.h>
9#include <api/video_codecs/video_encoder_factory.h>
10#include <common_video/h264/h264_bitstream_parser.h>
11#include <common_video/h264/pps_parser.h>
12#include <common_video/h264/sps_parser.h>
13#include <common_video/include/video_frame_buffer_pool.h>
14#include <cuda.h>
15#include <media/base/codec.h>
16
17#include "NvDecoder/NvDecoder.h"
18
19namespace webrtc {
20
21class H264BitstreamParserEx : public ::webrtc::H264BitstreamParser {
22 public:
23 std::optional<SpsParser::SpsState> sps() { return sps_; }
24 std::optional<PpsParser::PpsState> pps() { return pps_; }
25};
26
27class NvidiaH264DecoderImpl : public VideoDecoder {
28 public:
29 NvidiaH264DecoderImpl(CUcontext context);
30 NvidiaH264DecoderImpl(const NvidiaH264DecoderImpl&) = delete;
31 NvidiaH264DecoderImpl& operator=(const NvidiaH264DecoderImpl&) = delete;
32 ~NvidiaH264DecoderImpl() override;
33
34 bool Configure(const Settings& settings) override;
35 int32_t Decode(const EncodedImage& input_image,
36 bool missing_frames,
37 int64_t render_time_ms) override;
38 int32_t RegisterDecodeCompleteCallback(
39 DecodedImageCallback* callback) override;
40 int32_t Release() override;
41 DecoderInfo GetDecoderInfo() const override;
42
43 private:
44 CUcontext cu_context_;
45 std::unique_ptr<NvDecoder> decoder_;
46 bool is_configured_decoder_;
47
48 Settings settings_;
49
50 DecodedImageCallback* decoded_complete_callback_ = nullptr;
51 webrtc::VideoFrameBufferPool buffer_pool_;
52 H264BitstreamParserEx h264_bitstream_parser_;
53};
54
55} // end namespace webrtc
56
57#endif // WEBRTC_NVIDIA_H264_DECODER_IMPL_H_