vdr-plugin-softhddevice-drm-gles 1.4.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
cVideoStream Class Reference

cVideoStream - Video stream class More...

#include <videostream.h>

Collaboration diagram for cVideoStream:
Collaboration graph
[legend]

Public Member Functions

 cVideoStream (cVideoRender *, cQueue< cDrmBuffer > *, cSoftHdConfig *, const char *, std::function< void(AVFrame *)>)
 cVideoStream constructor More...
 
virtual ~cVideoStream (void)
 cVideoStream destructor More...
 
void DecodeInput (void)
 Decodes a reassembled codec packet. More...
 
bool IsInterlaced (void)
 
void Open (AVCodecID, AVCodecParameters *=nullptr, AVRational={ .num=1,.den=90000 })
 Open a video codec. More...
 
void Exit (void)
 Exit video stream. More...
 
void ClearVdrCoreToDecoderQueue (void)
 Clears all video stream data, which is buffered to be decoded. More...
 
void FlushDecoder (void)
 Flush the decoder. More...
 
void CloseDecoder (void)
 Close the decoder. More...
 
bool PushAvPacket (AVPacket *avpkt)
 Pushes a pre-assembled AVPacket directly to the processing queue. More...
 
void Flush (void)
 Flushes the video stream by finalizing any pending data. More...
 
cVideoDecoderDecoder (void)
 
void StartDecoder ()
 Start the decoder. More...
 
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 GetVideoSize (int *, int *, double *)
 Get video size and aspect ratio. More...
 
void ExitDecodingThread (void)
 Stop decoding thread. More...
 
void DecodingThreadHalt (void)
 
void DecodingThreadResume (void)
 
void CancelFilterThread (void)
 Stop filter thread. More...
 
void ResetFilterThreadNeededCheck ()
 
void SetDeinterlacerDeactivated (bool deactivate)
 
bool IsDeinterlacerDeactivated (void)
 
int HardwareQuirks (void)
 
void DisableDeint (bool disable)
 

Private Member Functions

void RenderFrame (AVFrame *)
 Render a frame. More...
 

Private Attributes

cVideoDecoderm_pDecoder
 video decoder More...
 
cVideoRenderm_pRender
 video renderer More...
 
cFilterThreadm_pFilterThread
 pointer to deinterlace filter thread More...
 
const char * m_identifier
 identifier string for logging More...
 
std::string m_filterThreadName
 filter thread name string (persists for object lifetime) More...
 
std::string m_decodingThreadName
 decoding thread name string (persists for object lifetime) More...
 
std::function< void(AVFrame *)> m_frameOutput
 function to output the frame More...
 
cQueue< cDrmBuffer > * m_pDrmBufferQueue
 pointer to renderer's DRM buffer queue More...
 
bool m_checkFilterThreadNeeded
 set, if we have to check, if filter thread is needed at start of playback More...
 
int m_hardwareQuirks
 hardware specific quirks More...
 
bool m_userDisabledDeinterlacer = false
 set, if the user configured the deinterlace to be disabled More...
 
bool m_deinterlacerDeactivated = false
 set, if the deinterlacer shall be deactivated temporarily (used for trick speed and still picture) More...
 
cQueue< AVPacket > m_packets {VIDEO_PACKET_MAX}
 AVPackets queue. More...
 
enum AVCodecID m_codecId = AV_CODEC_ID_NONE
 current codec id More...
 
AVCodecParameters * m_pPar = nullptr
 current codec parameters More...
 
std::atomic< struct AVRational > m_timebase
 current codec timebase More...
 
int m_trickpkts
 how many avpkt does the decoder need in trickspeed mode? More...
 
int m_sentTrickPkts = 0
 how many avpkt have been sent to the decoder in trickspeed mode? More...
 
volatile bool m_newStream
 flag for new stream More...
 
bool m_interlaced
 flag for interlaced stream More...
 
cDecodingThreadm_pDecodingThread
 pointer to decoding thread More...
 
int64_t m_inputPts = AV_NOPTS_VALUE
 PTS of the first packet in the input buffer. More...
 

Detailed Description

cVideoStream - Video stream class

Definition at line 50 of file videostream.h.

Constructor & Destructor Documentation

◆ cVideoStream()

cVideoStream::cVideoStream ( cVideoRender render,
cQueue< cDrmBuffer > *  drmBufferQueue,
cSoftHdConfig config,
const char *  identifier,
std::function< void(AVFrame *)>  frameOutput 
)

◆ ~cVideoStream()

cVideoStream::~cVideoStream ( void  )
virtual

cVideoStream destructor

Definition at line 193 of file videostream.cpp.

References LOGDEBUG, and m_pFilterThread.

Member Function Documentation

◆ CancelFilterThread()

void cVideoStream::CancelFilterThread ( void  )

◆ ClearVdrCoreToDecoderQueue()

void cVideoStream::ClearVdrCoreToDecoderQueue ( void  )

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

Definition at line 256 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(), cSoftHdDevice::DelPip(), Exit(), and cSoftHdDevice::OnEnteringState().

◆ CloseDecoder()

void cVideoStream::CloseDecoder ( void  )

Close the decoder.

Definition at line 284 of file videostream.cpp.

References cVideoDecoder::Close(), L_CODEC, LOGDEBUG2, m_codecId, m_identifier, m_pDecoder, and m_pPar.

Referenced by cSoftHdDevice::DelPip(), and cSoftHdDevice::OnEnteringState().

◆ DecodeInput()

void cVideoStream::DecodeInput ( void  )

◆ Decoder()

cVideoDecoder * cVideoStream::Decoder ( void  )
inline

Definition at line 68 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 91 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 424 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 207 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 299 of file videostream.cpp.

References cVideoDecoder::FlushBuffers(), 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 72 of file videostream.h.

References m_codecId.

Referenced by cSoftHdDevice::PlayVideoInternal().

◆ GetInputPts()

int64_t cVideoStream::GetInputPts ( void  )
inline

Definition at line 76 of file videostream.h.

References m_inputPts.

◆ GetInputPtsMs()

int64_t cVideoStream::GetInputPtsMs ( void  )

Definition at line 230 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 387 of file videostream.cpp.

References cVideoDecoder::GetContext(), and m_pDecoder.

Referenced by cSoftHdDevice::GetVideoSize().

◆ HardwareQuirks()

int cVideoStream::HardwareQuirks ( void  )
inline

Definition at line 90 of file videostream.h.

References m_hardwareQuirks.

◆ HasInputPts()

bool cVideoStream::HasInputPts ( void  )
inline

◆ IsDeinterlacerDeactivated()

bool cVideoStream::IsDeinterlacerDeactivated ( void  )
inline

Definition at line 89 of file videostream.h.

References m_deinterlacerDeactivated.

◆ IsInputBufferFull()

bool cVideoStream::IsInputBufferFull ( void  )
inline

◆ IsInterlaced()

bool cVideoStream::IsInterlaced ( void  )
inline

Definition at line 57 of file videostream.h.

Referenced by cVideoRender::GetTrickSpeed().

◆ 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 409 of file videostream.cpp.

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

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

◆ 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 222 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 453 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

◆ ResetTrickSpeedFramesSentCounter()

void cVideoStream::ResetTrickSpeedFramesSentCounter ( void  )
inline

Definition at line 73 of file videostream.h.

References m_sentTrickPkts.

Referenced by cSoftHdDevice::OnLeavingState().

◆ SetDeinterlacerDeactivated()

void cVideoStream::SetDeinterlacerDeactivated ( bool  deactivate)
inline

◆ StartDecoder()

void cVideoStream::StartDecoder ( )

Start the decoder.

Definition at line 271 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 103 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 110 of file videostream.h.

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

◆ m_decodingThreadName

std::string cVideoStream::m_decodingThreadName
private

decoding thread name string (persists for object lifetime)

Definition at line 99 of file videostream.h.

Referenced by StartDecoder().

◆ m_deinterlacerDeactivated

bool cVideoStream::m_deinterlacerDeactivated = false
private

set, if the deinterlacer shall be deactivated temporarily (used for trick speed and still picture)

Definition at line 106 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 98 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 100 of file videostream.h.

Referenced by cVideoStream(), and RenderFrame().

◆ m_hardwareQuirks

int cVideoStream::m_hardwareQuirks
private

hardware specific quirks

Definition at line 104 of file videostream.h.

Referenced by cVideoStream(), DecodeInput(), FlushDecoder(), HardwareQuirks(), 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 119 of file videostream.h.

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

◆ m_interlaced

bool cVideoStream::m_interlaced
private

flag for interlaced stream

Definition at line 116 of file videostream.h.

Referenced by DecodeInput(), and RenderFrame().

◆ m_newStream

volatile bool cVideoStream::m_newStream
private

flag for new stream

Definition at line 115 of file videostream.h.

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

◆ m_packets

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

AVPackets queue.

Definition at line 108 of file videostream.h.

Referenced by ClearVdrCoreToDecoderQueue(), DecodeInput(), Flush(), GetAvPacketsFilled(), IsInputBufferFull(), and PushAvPacket().

◆ m_pDecoder

cVideoDecoder* cVideoStream::m_pDecoder
private

◆ m_pDecodingThread

cDecodingThread* cVideoStream::m_pDecodingThread
private

pointer to decoding thread

Definition at line 118 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 101 of file videostream.h.

Referenced by cVideoStream(), and DecodeInput().

◆ m_pFilterThread

cFilterThread* cVideoStream::m_pFilterThread
private

pointer to deinterlace filter thread

Definition at line 96 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 111 of file videostream.h.

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

◆ m_pRender

cVideoRender* cVideoStream::m_pRender
private

video renderer

Definition at line 95 of file videostream.h.

Referenced by cVideoStream(), 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 114 of file videostream.h.

Referenced by DecodeInput(), and ResetTrickSpeedFramesSentCounter().

◆ m_timebase

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

current codec timebase

Definition at line 112 of file videostream.h.

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

◆ m_trickpkts

int cVideoStream::m_trickpkts
private

how many avpkt does the decoder need in trickspeed mode?

Definition at line 113 of file videostream.h.

Referenced by DecodeInput(), and Open().

◆ m_userDisabledDeinterlacer

bool cVideoStream::m_userDisabledDeinterlacer = false
private

set, if the user configured the deinterlace to be disabled

Definition at line 105 of file videostream.h.

Referenced by cVideoStream(), DisableDeint(), and RenderFrame().


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