vdr-plugin-softhddevice-drm-gles 1.4.0
videostream.h
Go to the documentation of this file.
1
21#ifndef __VIDEOSTREAM_H
22#define __VIDEOSTREAM_H
23
24#include <atomic>
25#include <functional>
26#include <vector>
27
28extern "C" {
29#include <libavfilter/avfilter.h>
30#include <libavcodec/avcodec.h>
31#include <libavutil/avutil.h>
32}
33
34#include "codec_video.h"
35#include "videorender.h"
36#include "pes.h"
37#include "threads.h"
38#include "drmbuffer.h"
39#include "queue.h"
40
41#define VIDEO_BUFFER_SIZE (512 * 1024)
42#define VIDEO_PACKET_MAX 192
43
44class cVideoDecoder;
45class cVideoRender;
46
51{
52public:
53 cVideoStream(cVideoRender *, cQueue<cDrmBuffer> *, cSoftHdConfig *, const char *, std::function<void(AVFrame *)>);
54 virtual ~cVideoStream(void);
55
56 void DecodeInput(void);
57 bool IsInterlaced(void) { return false; };
58
59 void Open(AVCodecID, AVCodecParameters * = nullptr, AVRational = { .num = 1, .den = 90000 });
60 void Exit(void);
62 void FlushDecoder(void);
63 void CloseDecoder(void);
64 bool PushAvPacket(AVPacket *avpkt);
65 void Flush(void);
66
67 // getters and setters
68 cVideoDecoder *Decoder(void) { return m_pDecoder; };
69 void StartDecoder();
70 size_t GetAvPacketsFilled(void) { return m_packets.Size(); };
71 bool IsInputBufferFull(void) { return m_packets.Size() >= VIDEO_PACKET_MAX; };
72 enum AVCodecID GetCodecId(void) { return m_codecId; };
74 bool HasInputPts(void) { return m_inputPts != AV_NOPTS_VALUE; }
75 int64_t GetInputPtsMs(void);
76 int64_t GetInputPts(void) { return m_inputPts; };
77 void GetVideoSize(int *, int *, double *);
78
79 // decoding thread
80 void ExitDecodingThread(void);
83
84 // Filter
85 void CancelFilterThread(void);
87
88 void SetDeinterlacerDeactivated(bool deactivate) { m_deinterlacerDeactivated = deactivate; };
90 int HardwareQuirks(void) { return m_hardwareQuirks; };
91 void DisableDeint(bool disable) { m_userDisabledDeinterlacer = disable; };
92
93private:
97 const char *m_identifier;
98 std::string m_filterThreadName;
100 std::function<void(AVFrame *)> m_frameOutput;
102
107
109
110 enum AVCodecID m_codecId = AV_CODEC_ID_NONE;
111 AVCodecParameters *m_pPar = nullptr;
112 std::atomic<struct AVRational> m_timebase;
115 volatile bool m_newStream;
117
120
121 void RenderFrame(AVFrame *);
122};
123
124#endif
Decoding thread class.
Definition: threads.h:39
void Resume(void)
Definition: threads.h:45
void Halt(void)
Definition: threads.h:44
Filter thread class.
Definition: threads.h:100
size_t Size(void)
Get the current size of the queue.
Definition: queue.h:128
cVideoDecoder - VideoDecoder class
Definition: codec_video.h:34
cVideoRender - Video render class
Definition: videorender.h:122
cVideoStream - Video stream class
Definition: videostream.h:51
cDecodingThread * m_pDecodingThread
pointer to decoding thread
Definition: videostream.h:118
bool m_interlaced
flag for interlaced stream
Definition: videostream.h:116
void GetVideoSize(int *, int *, double *)
Get video size and aspect ratio.
cFilterThread * m_pFilterThread
pointer to deinterlace filter thread
Definition: videostream.h:96
int HardwareQuirks(void)
Definition: videostream.h:90
void SetDeinterlacerDeactivated(bool deactivate)
Definition: videostream.h:88
std::function< void(AVFrame *)> m_frameOutput
function to output the frame
Definition: videostream.h:100
const char * m_identifier
identifier string for logging
Definition: videostream.h:97
int64_t m_inputPts
PTS of the first packet in the input buffer.
Definition: videostream.h:119
bool m_deinterlacerDeactivated
set, if the deinterlacer shall be deactivated temporarily (used for trick speed and still picture)
Definition: videostream.h:106
int m_sentTrickPkts
how many avpkt have been sent to the decoder in trickspeed mode?
Definition: videostream.h:114
std::string m_decodingThreadName
decoding thread name string (persists for object lifetime)
Definition: videostream.h:99
void Flush(void)
Flushes the video stream by finalizing any pending data.
void StartDecoder()
Start the decoder.
void DecodingThreadResume(void)
Definition: videostream.h:82
cVideoDecoder * Decoder(void)
Definition: videostream.h:68
void ClearVdrCoreToDecoderQueue(void)
Clears all video stream data, which is buffered to be decoded.
bool m_userDisabledDeinterlacer
set, if the user configured the deinterlace to be disabled
Definition: videostream.h:105
volatile bool m_newStream
flag for new stream
Definition: videostream.h:115
enum AVCodecID m_codecId
current codec id
Definition: videostream.h:110
bool m_checkFilterThreadNeeded
set, if we have to check, if filter thread is needed at start of playback
Definition: videostream.h:103
bool IsInterlaced(void)
Definition: videostream.h:57
size_t GetAvPacketsFilled(void)
Definition: videostream.h:70
AVCodecParameters * m_pPar
current codec parameters
Definition: videostream.h:111
void DecodeInput(void)
Decodes a reassembled codec packet.
cQueue< cDrmBuffer > * m_pDrmBufferQueue
pointer to renderer's DRM buffer queue
Definition: videostream.h:101
void DisableDeint(bool disable)
Definition: videostream.h:91
cVideoStream(cVideoRender *, cQueue< cDrmBuffer > *, cSoftHdConfig *, const char *, std::function< void(AVFrame *)>)
cVideoStream constructor
bool IsDeinterlacerDeactivated(void)
Definition: videostream.h:89
void CloseDecoder(void)
Close the decoder.
int m_hardwareQuirks
hardware specific quirks
Definition: videostream.h:104
cVideoDecoder * m_pDecoder
video decoder
Definition: videostream.h:94
void Exit(void)
Exit video stream.
virtual ~cVideoStream(void)
cVideoStream destructor
void CancelFilterThread(void)
Stop filter thread.
void DecodingThreadHalt(void)
Definition: videostream.h:81
cVideoRender * m_pRender
video renderer
Definition: videostream.h:95
int m_trickpkts
how many avpkt does the decoder need in trickspeed mode?
Definition: videostream.h:113
void RenderFrame(AVFrame *)
Render a frame.
cQueue< AVPacket > m_packets
AVPackets queue.
Definition: videostream.h:108
void ExitDecodingThread(void)
Stop decoding thread.
void FlushDecoder(void)
Flush the decoder.
void Open(AVCodecID, AVCodecParameters *=nullptr, AVRational={ .num=1,.den=90000 })
Open a video codec.
bool PushAvPacket(AVPacket *avpkt)
Pushes a pre-assembled AVPacket directly to the processing queue.
bool IsInputBufferFull(void)
Definition: videostream.h:71
int64_t GetInputPts(void)
Definition: videostream.h:76
void ResetFilterThreadNeededCheck()
Definition: videostream.h:86
int64_t GetInputPtsMs(void)
std::string m_filterThreadName
filter thread name string (persists for object lifetime)
Definition: videostream.h:98
void ResetTrickSpeedFramesSentCounter(void)
Definition: videostream.h:73
enum AVCodecID GetCodecId(void)
Definition: videostream.h:72
std::atomic< struct AVRational > m_timebase
current codec timebase
Definition: videostream.h:112
bool HasInputPts(void)
Definition: videostream.h:74
Video decoder header file.
DRM buffer header file.
#define AV_NOPTS_VALUE
Definition: misc.h:35
PES packet parser header.
Thread-safe queue header file.
Thread classes header file.
Rendering class header file.
#define VIDEO_PACKET_MAX
max number of video packets held in the buffer
Definition: videostream.h:42