vdr-plugin-softhddevice-drm-gles 1.5.9-20e15de
cVideoStream Class Reference

cVideoStream - Video stream class More...

#include <videostream.h>

Public Member Functions

virtual ~cVideoStream (void)
 cVideoStream destructor
 
void DecodeInput (void)
 Decodes a reassembled codec packet.
 
bool IsInterlaced (void)
 
void Open (AVCodecID, AVCodecParameters *=nullptr, AVRational={ .num=1,.den=90000 })
 Open a video codec.
 
void Exit (void)
 Exit video stream.
 
void ClearVdrCoreToDecoderQueue (void)
 Clears all video stream data, which is buffered to be decoded.
 
void FlushDecoder (void)
 Flush the decoder.
 
void CloseDecoder (void)
 Close the decoder.
 
bool PushAvPacket (AVPacket *avpkt)
 Pushes a pre-assembled AVPacket directly to the processing queue.
 
void Flush (void)
 Flushes the video stream by finalizing any pending data.
 
cVideoDecoderDecoder (void)
 
void StartDecoder ()
 Start the decoder.
 
size_t GetAvPacketsFilled (void)
 
bool IsInputBufferFull (void)
 
enum AVCodecID GetCodecId (void)
 
void ResetTrickSpeedFramesSentCounter (void)
 
bool HasInputPts (void)
 
int64_t GetInputPtsMs (void)
 
int64_t GetInputPts (void)
 
void ResetInputPts (void)
 
void GetVideoSize (int *, int *, double *)
 Get video size and aspect ratio.
 
void ExitDecodingThread (void)
 Stop decoding thread.
 
void DecodingThreadHalt (void)
 
void DecodingThreadResume (void)
 
void CancelFilterThread (void)
 Stop filter thread.
 
void ResetFilterThreadNeededCheck ()
 
virtual void SetDeinterlacerDeactivated (bool deactivate)
 
bool IsDeinterlacerDeactivated (void)
 
int HardwareQuirks (void)
 
void DisableDeint (bool disable)
 
void SetStartDecodingWithIFrame (bool enable)
 
void SetParseH264Dimensions (bool enable)
 
void SetDecoderFallbackToSwNumPkts (int numPackets)
 

Protected Member Functions

 cVideoStream (cVideoRender *, cQueue< cDrmBuffer > *, cSoftHdConfig *, bool, std::function< void(AVFrame *)>)
 cVideoStream constructor
 

Private Member Functions

void RenderFrame (AVFrame *)
 Render a frame.
 
void CheckForcingFrameDecode (void)
 Check, if we need to force the decoder to decode the frame (force a decoder drain)
 
void OpenDecoder (void)
 Open the decoder including an H.264 parsing if needed.
 

Private Attributes

cSoftHdConfigm_pConfig
 plugin config
 
cVideoDecoderm_pDecoder
 video decoder
 
cVideoRenderm_pRender
 video renderer
 
cFilterThreadm_pFilterThread
 pointer to deinterlace filter thread
 
const char * m_identifier
 identifier string for logging
 
std::string m_filterThreadName
 filter thread name string (persists for object lifetime)
 
std::string m_decodingThreadName
 decoding thread name string (persists for object lifetime)
 
std::function< void(AVFrame *)> m_frameOutput
 function to output the frame
 
cQueue< cDrmBuffer > * m_pDrmBufferQueue
 pointer to renderer's DRM buffer queue
 
bool m_checkFilterThreadNeeded
 set, if we have to check, if filter thread is needed at start of playback
 
int m_hardwareQuirks
 hardware specific quirks
 
bool m_userDisabledDeinterlacer = false
 set, if the user configured the deinterlace to be disabled
 
bool m_deinterlacerDeactivated
 set, if the deinterlacer should be disabled temporarily (trickspeed, stillpicture, pip)
 
bool m_startDecodingWithIFrame = false
 wait for an I-Frame to start h264 decoding
 
bool m_parseH264Dimensions = false
 parse width and height when starting an h264 stream
 
int m_decoderFallbackToSwNumPkts = 22
 fallback to sw decoder if hw decoder fails after the given number of packets sent
 
cQueue< AVPacket > m_packets {VIDEO_PACKET_MAX}
 AVPackets queue.
 
enum AVCodecID m_codecId = AV_CODEC_ID_NONE
 current codec id
 
AVCodecParameters * m_pPar = nullptr
 current codec parameters
 
std::atomic< struct AVRational > m_timebase
 current codec timebase
 
int m_trickpkts
 how many avpkt does the decoder need in trickspeed mode?
 
int m_sentTrickPkts = 0
 how many avpkt have been sent to the decoder in trickspeed mode?
 
volatile bool m_newStream = false
 flag for new stream
 
bool m_interlaced
 flag for interlaced stream
 
cDecodingThreadm_pDecodingThread
 pointer to decoding thread
 
int64_t m_inputPts = AV_NOPTS_VALUE
 PTS of the first packet in the input buffer.
 

Detailed Description

cVideoStream - Video stream class

Definition at line 54 of file videostream.h.

Constructor & Destructor Documentation

◆ ~cVideoStream()

cVideoStream::~cVideoStream ( void  )
virtual

cVideoStream destructor

Definition at line 179 of file videostream.cpp.

References LOGDEBUG, and m_pFilterThread.

◆ cVideoStream()

cVideoStream::cVideoStream ( cVideoRender render,
cQueue< cDrmBuffer > *  drmBufferQueue,
cSoftHdConfig config,
bool  isPipStream,
std::function< void(AVFrame *)>  frameOutput 
)
protected

Member Function Documentation

◆ CancelFilterThread()

void cVideoStream::CancelFilterThread ( void  )

◆ CheckForcingFrameDecode()

void cVideoStream::CheckForcingFrameDecode ( void  )
private

Check, if we need to force the decoder to decode the frame (force a decoder drain)

Get the number of packets we need to have in the buffer while in interlaced trickspeed mode, in order to get a decoded frameout of the decoder.

In a normal interlaced h264 stream we need to force decoding after sending 2 packets in backwards trickspeed to get a decoded frame, in an mpeg2 stream 1 packet is enough.

This minPkts magic guarantees, that we don't drain the decoder too early, but exactly after the right amount of packets was sent in trickspeed mode.

Definition at line 309 of file videostream.cpp.

References cVideoRender::IsForwardTrickspeed(), m_interlaced, m_pDecoder, m_pRender, m_sentTrickPkts, m_trickpkts, and cVideoDecoder::SendPacket().

Referenced by DecodeInput().

◆ ClearVdrCoreToDecoderQueue()

void cVideoStream::ClearVdrCoreToDecoderQueue ( void  )

Clears all video stream data, which is buffered to be decoded.

Definition at line 242 of file videostream.cpp.

References AV_NOPTS_VALUE, cQueue< T >::IsEmpty(), LOGDEBUG, m_identifier, m_inputPts, m_packets, cQueue< T >::Pop(), and cQueue< T >::Size().

Referenced by cSoftHdDevice::Clear(), Exit(), cSoftHdDevice::OnEnteringState(), and cSoftHdDevice::ResetPipStream().

◆ CloseDecoder()

void cVideoStream::CloseDecoder ( void  )

◆ DecodeInput()

◆ Decoder()

cVideoDecoder * cVideoStream::Decoder ( void  )
inline

Definition at line 71 of file videostream.h.

References m_pDecoder.

◆ DecodingThreadHalt()

void cVideoStream::DecodingThreadHalt ( void  )
inline

◆ DecodingThreadResume()

void cVideoStream::DecodingThreadResume ( void  )
inline

◆ DisableDeint()

void cVideoStream::DisableDeint ( bool  disable)
inline

Definition at line 95 of file videostream.h.

References m_userDisabledDeinterlacer.

Referenced by cSoftHdDevice::SetDisableDeint().

◆ Exit()

void cVideoStream::Exit ( void  )

◆ ExitDecodingThread()

void cVideoStream::ExitDecodingThread ( void  )

Stop decoding thread.

Definition at line 455 of file videostream.cpp.

References LOGDEBUG, m_identifier, m_pDecodingThread, and cDecodingThread::Stop().

Referenced by Exit().

◆ Flush()

void cVideoStream::Flush ( void  )

Flushes the video stream by finalizing any pending data.

This function completes processing of any remaining PES fragments in the fragmentation buffer, then pushes a nullptr packet to the queue to signal a flush operation to the decoder.

Definition at line 193 of file videostream.cpp.

References m_packets, and cQueue< T >::Push().

Referenced by cSoftHdDevice::HandleStillPicture().

◆ FlushDecoder()

void cVideoStream::FlushDecoder ( void  )

Flush the decoder.

Some hardware (RPI) needs a reopen workaround (close/open) here, because hardware doesn't do the hardware flush right.

Definition at line 285 of file videostream.cpp.

References cVideoDecoder::FlushBuffers(), cVideoDecoder::IsHardwareDecoder(), L_CODEC, LOGDEBUG2, LOGFATAL, m_codecId, m_hardwareQuirks, m_identifier, m_pDecoder, m_pPar, m_timebase, QUIRK_CODEC_FLUSH_WORKAROUND, and cVideoDecoder::ReopenCodec().

Referenced by cSoftHdDevice::Clear(), and DecodeInput().

◆ GetAvPacketsFilled()

size_t cVideoStream::GetAvPacketsFilled ( void  )
inline

◆ GetCodecId()

enum AVCodecID cVideoStream::GetCodecId ( void  )
inline

Definition at line 75 of file videostream.h.

References m_codecId.

Referenced by cSoftHdDevice::PlayVideoInternal().

◆ GetInputPts()

int64_t cVideoStream::GetInputPts ( void  )
inline

Definition at line 79 of file videostream.h.

References m_inputPts.

◆ GetInputPtsMs()

int64_t cVideoStream::GetInputPtsMs ( void  )

Definition at line 216 of file videostream.cpp.

References m_inputPts, and m_timebase.

Referenced by cSoftHdDevice::IsBufferingThresholdReached().

◆ GetVideoSize()

void cVideoStream::GetVideoSize ( int *  width,
int *  height,
double *  aspect_ratio 
)

Get video size and aspect ratio.

Parameters
[out]widthvideo stream width
[out]heightvideo stream height
[out]aspect_ratiovideo stream aspect ratio (is currently width/ height)

Definition at line 418 of file videostream.cpp.

References cVideoDecoder::GetContext(), and m_pDecoder.

Referenced by cSoftHdDevice::GetVideoSize().

◆ HardwareQuirks()

int cVideoStream::HardwareQuirks ( void  )
inline

Definition at line 94 of file videostream.h.

References m_hardwareQuirks.

◆ HasInputPts()

bool cVideoStream::HasInputPts ( void  )
inline

◆ IsDeinterlacerDeactivated()

bool cVideoStream::IsDeinterlacerDeactivated ( void  )
inline

Definition at line 93 of file videostream.h.

References m_deinterlacerDeactivated.

◆ IsInputBufferFull()

bool cVideoStream::IsInputBufferFull ( void  )
inline

◆ IsInterlaced()

bool cVideoStream::IsInterlaced ( void  )
inline

Definition at line 60 of file videostream.h.

◆ Open()

void cVideoStream::Open ( AVCodecID  codecId,
AVCodecParameters *  par = nullptr,
AVRational  timebase = { .num = 1, .den = 90000 } 
)

Open a video codec.

Parameters
codecIdvideo codec id
parvideo codec parameters
timebasetimebase

Definition at line 440 of file videostream.cpp.

References m_codecId, m_newStream, m_pPar, m_timebase, and m_trickpkts.

Referenced by cSoftHdDevice::PlayVideoInternal(), and cSoftHdDevice::SetVideoCodec().

◆ OpenDecoder()

◆ PushAvPacket()

bool cVideoStream::PushAvPacket ( AVPacket *  avpkt)

Pushes a pre-assembled AVPacket directly to the processing queue.

This function bypasses the PES fragmentation/reassembly mechanism and directly pushes an already-complete AVPacket to the m_packets queue for decoding. Used when packets are received from sources that don't require fragmentation handling.

Parameters
avpktThe AVPacket to push to the queue
Returns
true if the packet was successfully pushed, false otherwise

Definition at line 208 of file videostream.cpp.

References AV_NOPTS_VALUE, m_inputPts, m_packets, and cQueue< T >::Push().

Referenced by cSoftHdDevice::HandleStillPicture(), cSoftHdDevice::PlayVideoInternal(), and cSoftHdDevice::PlayVideoPkts().

◆ RenderFrame()

void cVideoStream::RenderFrame ( AVFrame *  frame)
private

Render a frame.

Frames either go through the filter thread or directly into the render buffer.

Parameters
videoCtxffmpeg video codec context
frameframe to render

Definition at line 485 of file videostream.cpp.

References cVideoDecoder::GetContext(), cFilterThread::GetNumFramesToFilter(), cFilterThread::InitAndStart(), isInterlacedFrame(), LOGDEBUG, LOGWARNING, m_checkFilterThreadNeeded, m_deinterlacerDeactivated, m_frameOutput, m_hardwareQuirks, m_identifier, m_interlaced, m_pDecoder, m_pFilterThread, m_timebase, m_userDisabledDeinterlacer, cFilterThread::PushFrame(), and QUIRK_NO_HW_DEINT.

Referenced by DecodeInput().

◆ ResetFilterThreadNeededCheck()

void cVideoStream::ResetFilterThreadNeededCheck ( )
inline

◆ ResetInputPts()

void cVideoStream::ResetInputPts ( void  )
inline

Definition at line 80 of file videostream.h.

References AV_NOPTS_VALUE, and m_inputPts.

Referenced by cSoftHdDevice::HandleStillPicture().

◆ ResetTrickSpeedFramesSentCounter()

void cVideoStream::ResetTrickSpeedFramesSentCounter ( void  )
inline

Definition at line 76 of file videostream.h.

References m_sentTrickPkts.

Referenced by cSoftHdDevice::OnLeavingState().

◆ SetDecoderFallbackToSwNumPkts()

void cVideoStream::SetDecoderFallbackToSwNumPkts ( int  numPackets)
inline

Definition at line 98 of file videostream.h.

References m_decoderFallbackToSwNumPkts.

Referenced by cSoftHdDevice::SetDecoderFallbackToSw().

◆ SetDeinterlacerDeactivated()

virtual void cVideoStream::SetDeinterlacerDeactivated ( bool  deactivate)
inlinevirtual

◆ SetParseH264Dimensions()

void cVideoStream::SetParseH264Dimensions ( bool  enable)
inline

Definition at line 97 of file videostream.h.

References m_parseH264Dimensions.

Referenced by cSoftHdDevice::SetParseH264Dimensions().

◆ SetStartDecodingWithIFrame()

void cVideoStream::SetStartDecodingWithIFrame ( bool  enable)
inline

Definition at line 96 of file videostream.h.

References m_startDecodingWithIFrame.

Referenced by cSoftHdDevice::SetDecoderNeedsIFrame().

◆ StartDecoder()

void cVideoStream::StartDecoder ( )

Start the decoder.

Definition at line 257 of file videostream.cpp.

References L_CODEC, LOGDEBUG2, m_decodingThreadName, m_hardwareQuirks, m_identifier, m_pDecoder, and m_pDecodingThread.

Referenced by cSoftHdDevice::OnLeavingState().

Member Data Documentation

◆ m_checkFilterThreadNeeded

bool cVideoStream::m_checkFilterThreadNeeded
private

set, if we have to check, if filter thread is needed at start of playback

Definition at line 114 of file videostream.h.

Referenced by CancelFilterThread(), RenderFrame(), and ResetFilterThreadNeededCheck().

◆ m_codecId

enum AVCodecID cVideoStream::m_codecId = AV_CODEC_ID_NONE
private

current codec id

Definition at line 124 of file videostream.h.

Referenced by CloseDecoder(), DecodeInput(), FlushDecoder(), GetCodecId(), Open(), and OpenDecoder().

◆ m_decoderFallbackToSwNumPkts

int cVideoStream::m_decoderFallbackToSwNumPkts = 22
private

fallback to sw decoder if hw decoder fails after the given number of packets sent

Definition at line 120 of file videostream.h.

Referenced by cVideoStream(), DecodeInput(), and SetDecoderFallbackToSwNumPkts().

◆ m_decodingThreadName

std::string cVideoStream::m_decodingThreadName
private

decoding thread name string (persists for object lifetime)

Definition at line 110 of file videostream.h.

Referenced by StartDecoder().

◆ m_deinterlacerDeactivated

bool cVideoStream::m_deinterlacerDeactivated
private

set, if the deinterlacer should be disabled temporarily (trickspeed, stillpicture, pip)

Definition at line 117 of file videostream.h.

Referenced by IsDeinterlacerDeactivated(), RenderFrame(), and SetDeinterlacerDeactivated().

◆ m_filterThreadName

std::string cVideoStream::m_filterThreadName
private

filter thread name string (persists for object lifetime)

Definition at line 109 of file videostream.h.

Referenced by cVideoStream().

◆ m_frameOutput

std::function<void(AVFrame *)> cVideoStream::m_frameOutput
private

function to output the frame

Definition at line 111 of file videostream.h.

Referenced by RenderFrame().

◆ m_hardwareQuirks

int cVideoStream::m_hardwareQuirks
private

hardware specific quirks

Definition at line 115 of file videostream.h.

Referenced by cVideoStream(), FlushDecoder(), HardwareQuirks(), OpenDecoder(), RenderFrame(), and StartDecoder().

◆ m_identifier

const char* cVideoStream::m_identifier
private

◆ m_inputPts

int64_t cVideoStream::m_inputPts = AV_NOPTS_VALUE
private

PTS of the first packet in the input buffer.

Definition at line 133 of file videostream.h.

Referenced by ClearVdrCoreToDecoderQueue(), GetInputPts(), GetInputPtsMs(), HasInputPts(), PushAvPacket(), and ResetInputPts().

◆ m_interlaced

bool cVideoStream::m_interlaced
private

flag for interlaced stream

Definition at line 130 of file videostream.h.

Referenced by CheckForcingFrameDecode(), and RenderFrame().

◆ m_newStream

volatile bool cVideoStream::m_newStream = false
private

flag for new stream

Definition at line 129 of file videostream.h.

Referenced by DecodeInput(), Open(), and OpenDecoder().

◆ m_packets

cQueue<AVPacket> cVideoStream::m_packets {VIDEO_PACKET_MAX}
private

◆ m_parseH264Dimensions

bool cVideoStream::m_parseH264Dimensions = false
private

parse width and height when starting an h264 stream

Definition at line 119 of file videostream.h.

Referenced by OpenDecoder(), and SetParseH264Dimensions().

◆ m_pConfig

cSoftHdConfig* cVideoStream::m_pConfig
private

plugin config

Definition at line 104 of file videostream.h.

Referenced by DecodeInput(), and OpenDecoder().

◆ m_pDecoder

cVideoDecoder* cVideoStream::m_pDecoder
private

◆ m_pDecodingThread

cDecodingThread* cVideoStream::m_pDecodingThread
private

pointer to decoding thread

Definition at line 132 of file videostream.h.

Referenced by DecodingThreadHalt(), DecodingThreadResume(), ExitDecodingThread(), and StartDecoder().

◆ m_pDrmBufferQueue

cQueue<cDrmBuffer>* cVideoStream::m_pDrmBufferQueue
private

pointer to renderer's DRM buffer queue

Definition at line 112 of file videostream.h.

Referenced by cVideoStream(), and DecodeInput().

◆ m_pFilterThread

cFilterThread* cVideoStream::m_pFilterThread
private

pointer to deinterlace filter thread

Definition at line 107 of file videostream.h.

Referenced by CancelFilterThread(), cVideoStream(), DecodeInput(), RenderFrame(), and ~cVideoStream().

◆ m_pPar

AVCodecParameters* cVideoStream::m_pPar = nullptr
private

current codec parameters

Definition at line 125 of file videostream.h.

Referenced by CloseDecoder(), DecodeInput(), FlushDecoder(), Open(), and OpenDecoder().

◆ m_pRender

cVideoRender* cVideoStream::m_pRender
private

video renderer

Definition at line 106 of file videostream.h.

Referenced by CheckForcingFrameDecode(), and DecodeInput().

◆ m_sentTrickPkts

int cVideoStream::m_sentTrickPkts = 0
private

how many avpkt have been sent to the decoder in trickspeed mode?

Definition at line 128 of file videostream.h.

Referenced by CheckForcingFrameDecode(), DecodeInput(), and ResetTrickSpeedFramesSentCounter().

◆ m_startDecodingWithIFrame

bool cVideoStream::m_startDecodingWithIFrame = false
private

wait for an I-Frame to start h264 decoding

Definition at line 118 of file videostream.h.

Referenced by OpenDecoder(), and SetStartDecodingWithIFrame().

◆ m_timebase

std::atomic<struct AVRational> cVideoStream::m_timebase
private

current codec timebase

Definition at line 126 of file videostream.h.

Referenced by DecodeInput(), FlushDecoder(), GetInputPtsMs(), Open(), OpenDecoder(), and RenderFrame().

◆ m_trickpkts

int cVideoStream::m_trickpkts
private

how many avpkt does the decoder need in trickspeed mode?

Definition at line 127 of file videostream.h.

Referenced by CheckForcingFrameDecode(), and Open().

◆ m_userDisabledDeinterlacer

bool cVideoStream::m_userDisabledDeinterlacer = false
private

set, if the user configured the deinterlace to be disabled

Definition at line 116 of file videostream.h.

Referenced by DisableDeint(), and RenderFrame().


The documentation for this class was generated from the following files: