diff options
| author | Thomas Reufer <thomas@reufer.ch> | 2016-04-07 13:49:20 +0200 |
|---|---|---|
| committer | Thomas Reufer <thomas@reufer.ch> | 2016-04-07 13:49:20 +0200 |
| commit | f2debe7f370cc0356dba9aa04103a6fa413ba95d (patch) | |
| tree | 7dbd88b95038ad759d333fc70dfe0f186d18ce8c | |
| parent | cce1619ad5f7ebdc4d07bd3a136bf406ca67022d (diff) | |
| download | vdr-plugin-rpihddevice-f2debe7f370cc0356dba9aa04103a6fa413ba95d.tar.gz vdr-plugin-rpihddevice-f2debe7f370cc0356dba9aa04103a6fa413ba95d.tar.bz2 | |
move end of stream notification to video decoder
| -rw-r--r-- | omxdevice.c | 4 | ||||
| -rw-r--r-- | video.c | 26 | ||||
| -rw-r--r-- | video.h | 17 |
3 files changed, 34 insertions, 13 deletions
diff --git a/omxdevice.c b/omxdevice.c index e0b5c74..8f578a1 100644 --- a/omxdevice.c +++ b/omxdevice.c @@ -98,7 +98,6 @@ int cOmxDevice::Init(void) ELOG("failed to initialize audio!"); return -1; } - m_omx->SetEndOfStreamCallback(&OnEndOfStream, this); cRpiSetup::SetVideoSetupChangedCallback(&OnVideoSetupChanged, this); return 0; } @@ -352,7 +351,8 @@ int cOmxDevice::PlayVideo(const uchar *Data, int Length, bool EndOfFrame) pts != OMX_INVALID_PTS) { if (cRpiSetup::IsVideoCodecSupported(codec)) - m_video = new cRpiOmxVideoDecoder(codec, m_omx, &OnStreamStart, this); + m_video = new cRpiOmxVideoDecoder(codec, m_omx, + &OnStreamStart, &OnEndOfStream, this); else Skins.QueueMessage(mtError, tr("video format not supported!")); } @@ -34,11 +34,12 @@ const unsigned char cRpiVideoDecoder::s_h264EndOfSequence[8] = { cRpiVideoDecoder::cRpiVideoDecoder(cVideoCodec::eCodec codec, void (*onStreamStart)(void*, const cVideoFrameFormat *format), - void* onStreamStartData) : + void (*onEndOfStream)(void*), void* callbackData) : m_codec(codec), m_format(), m_onStreamStart(onStreamStart), - m_onStreamStartData(onStreamStartData) + m_onEndOfStream(onEndOfStream), + m_callbackData(callbackData) { m_format.width = 0; m_format.height = 0; @@ -51,17 +52,30 @@ cRpiVideoDecoder::cRpiVideoDecoder(cVideoCodec::eCodec codec, cRpiVideoDecoder::~cRpiVideoDecoder() { } +void cRpiVideoDecoder::NotifyStreamStart(void) +{ + if (m_onStreamStart) + m_onStreamStart(m_callbackData, &m_format); +} + +void cRpiVideoDecoder::NotifyEndOfStream(void) +{ + if (m_onEndOfStream) + m_onEndOfStream(m_callbackData); +} + /* ------------------------------------------------------------------------- */ cRpiOmxVideoDecoder::cRpiOmxVideoDecoder(cVideoCodec::eCodec codec, cOmx *omx, void (*onStreamStart)(void*, const cVideoFrameFormat *format), - void* onStreamStartData) : - cRpiVideoDecoder(codec, onStreamStart, onStreamStartData), + void (*onEndOfStream)(void*), void* callbackData) : + cRpiVideoDecoder(codec, onStreamStart, onEndOfStream, callbackData), m_omx(omx) { DLOG("new OMX %s video codec", cVideoCodec::Str(codec)); m_omx->SetVideoCodec(codec); m_omx->SetStreamStartCallback(OnStreamStart, this); + m_omx->SetEndOfStreamCallback(OnEndOfStream, this); m_omx->SetBufferStallCallback(OnBufferStall, this); } @@ -69,6 +83,7 @@ cRpiOmxVideoDecoder::~cRpiOmxVideoDecoder() { Clear(true); m_omx->SetBufferStallCallback(0, 0); + m_omx->SetEndOfStreamCallback(0, 0); m_omx->SetStreamStartCallback(0, 0); m_omx->StopVideo(); } @@ -141,8 +156,7 @@ void cRpiOmxVideoDecoder::HandleStreamStart(int width, int height, m_format.pixelHeight = pixelHeight; // forward to device instance - if (m_onStreamStart) - m_onStreamStart(m_onStreamStartData, &m_format); + NotifyStreamStart(); // if necessary, setup deinterlacer m_omx->SetupDeinterlacer( @@ -31,8 +31,9 @@ class cRpiVideoDecoder public: - cRpiVideoDecoder(cVideoCodec::eCodec codec, void (*onStreamStart)( - void*, const cVideoFrameFormat *format), void* onStreamStartData); + cRpiVideoDecoder(cVideoCodec::eCodec codec, + void (*onStreamStart)(void*, const cVideoFrameFormat *format), + void (*onEndOfStream)(void*), void* callbackData); virtual ~cRpiVideoDecoder(); cVideoCodec::eCodec GetCodec(void) { return m_codec; }; @@ -54,8 +55,12 @@ protected: cVideoCodec::eCodec m_codec; cVideoFrameFormat m_format; + void NotifyStreamStart(void); + void NotifyEndOfStream(void); + void (*m_onStreamStart)(void*, const cVideoFrameFormat *format); - void *m_onStreamStartData; + void (*m_onEndOfStream)(void*); + void *m_callbackData; }; @@ -66,7 +71,7 @@ public: cRpiOmxVideoDecoder(cVideoCodec::eCodec codec, cOmx *omx, void (*onStreamStart)(void*, const cVideoFrameFormat *format), - void* onStreamStartData); + void (*onEndOfStream)(void*), void* callbackData); virtual ~cRpiOmxVideoDecoder(); virtual bool WriteData(const unsigned char *data, @@ -86,8 +91,10 @@ protected: { (static_cast <cRpiOmxVideoDecoder*> (data))->HandleStreamStart( width, height, frameRate, scanMode, pixelWidth, pixelHeight); } - void HandleBufferStall(void); + static void OnEndOfStream(void *data) + { (static_cast <cRpiOmxVideoDecoder*> (data))->NotifyEndOfStream(); } + void HandleBufferStall(void); static void OnBufferStall(void *data) { (static_cast <cRpiOmxVideoDecoder*> (data))->HandleBufferStall(); } |
