summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Reufer <thomas@reufer.ch>2014-10-06 12:27:53 +0200
committerThomas Reufer <thomas@reufer.ch>2014-10-06 12:27:53 +0200
commit50ae3a6c391be3150e2803a82d5af06f1c80ecb2 (patch)
treed5710db33682854404afaeeee15efb23dfdcf0d8
parent41fa08c6ed1b45cac4bbf6f0de042dd059748fd0 (diff)
downloadvdr-plugin-rpihddevice-50ae3a6c391be3150e2803a82d5af06f1c80ecb2.tar.gz
vdr-plugin-rpihddevice-50ae3a6c391be3150e2803a82d5af06f1c80ecb2.tar.bz2
introduce OMX stream start callback
-rw-r--r--omx.c56
-rw-r--r--omx.h21
-rw-r--r--omxdevice.c18
-rw-r--r--omxdevice.h4
4 files changed, 72 insertions, 27 deletions
diff --git a/omx.c b/omx.c
index 75a7a8a..fc45524 100644
--- a/omx.c
+++ b/omx.c
@@ -234,22 +234,22 @@ void cOmx::HandlePortSettingsChanged(unsigned int portId)
&interlace) != OMX_ErrorNone)
ELOG("failed to get video decoder interlace config!");
- m_videoWidth = portdef.format.video.nFrameWidth;
- m_videoHeight = portdef.format.video.nFrameHeight;
- m_videoInterlaced = interlace.eMode != OMX_InterlaceProgressive;
+ m_videoFormat.width = portdef.format.video.nFrameWidth;
+ m_videoFormat.height = portdef.format.video.nFrameHeight;
+ m_videoFormat.interlaced = interlace.eMode != OMX_InterlaceProgressive;
+ m_videoFormat.frameRate =
+ ALIGN_UP(portdef.format.video.xFramerate, 1 << 16) >> 16;
+ if (m_videoFormat.interlaced)
+ m_videoFormat.frameRate = m_videoFormat.frameRate * 2;
- bool deinterlace;
- deinterlace = (cRpiSetup::IsDisplayProgressive() && m_videoInterlaced);
-
- ILOG("decoding video %dx%d%s, %sabling deinterlacer",
- m_videoWidth, m_videoHeight, m_videoInterlaced ? "i" : "p",
- deinterlace ? "en" : "dis");
+ if (m_onStreamStart)
+ m_onStreamStart(m_onStreamStartData);
OMX_CONFIG_IMAGEFILTERPARAMSTYPE filterparam;
OMX_INIT_STRUCT(filterparam);
filterparam.nPortIndex = 191;
filterparam.eImageFilter = OMX_ImageFilterNone;
- if (deinterlace)
+ if (cRpiSetup::IsDisplayProgressive() && m_videoFormat.interlaced)
{
filterparam.nNumParams = 1;
filterparam.nParams[0] = 3;
@@ -313,9 +313,6 @@ void cOmx::OnError(void *instance, COMPONENT_T *comp, OMX_U32 data)
cOmx::cOmx() :
cThread(),
m_client(NULL),
- m_videoWidth(0),
- m_videoHeight(0),
- m_videoInterlaced(false),
m_setAudioStartTime(false),
m_setVideoStartTime(false),
m_setVideoDiscontinuity(false),
@@ -329,10 +326,17 @@ cOmx::cOmx() :
m_onBufferStall(0),
m_onBufferStallData(0),
m_onEndOfStream(0),
- m_onEndOfStreamData(0)
+ m_onEndOfStreamData(0),
+ m_onStreamStart(0),
+ m_onStreamStartData(0)
{
memset(m_tun, 0, sizeof(m_tun));
memset(m_comp, 0, sizeof(m_comp));
+
+ m_videoFormat.width = 0;
+ m_videoFormat.height = 0;
+ m_videoFormat.frameRate = 0;
+ m_videoFormat.interlaced = false;
}
cOmx::~cOmx()
@@ -459,6 +463,12 @@ void cOmx::SetEndOfStreamCallback(void (*onEndOfStream)(void*), void* data)
m_onEndOfStreamData = data;
}
+void cOmx::SetStreamStartCallback(void (*onStreamStart)(void*), void* data)
+{
+ m_onStreamStart = onStreamStart;
+ m_onStreamStartData = data;
+}
+
OMX_TICKS cOmx::ToOmxTicks(int64_t val)
{
OMX_TICKS ticks;
@@ -795,9 +805,11 @@ void cOmx::StopVideo(void)
m_spareVideoBuffers, NULL, NULL);
m_spareVideoBuffers = 0;
- m_videoWidth = 0;
- m_videoHeight = 0;
- m_videoInterlaced = false;
+
+ m_videoFormat.width = 0;
+ m_videoFormat.height = 0;
+ m_videoFormat.frameRate = 0;
+ m_videoFormat.interlaced = false;
}
void cOmx::StopAudio(void)
@@ -1057,11 +1069,13 @@ int cOmx::SetupAudioRender(cAudioCodec::eCodec outputFormat, int channels,
return 0;
}
-void cOmx::GetVideoSize(int &width, int &height, bool &interlaced)
+void cOmx::GetVideoFormat(int &width, int &height, int &frameRate,
+ bool &interlaced)
{
- width = m_videoWidth;
- height = m_videoHeight;
- interlaced = m_videoInterlaced;
+ width = m_videoFormat.width;
+ height = m_videoFormat.height;
+ frameRate = m_videoFormat.frameRate;
+ interlaced = m_videoFormat.interlaced;
}
void cOmx::SetDisplayMode(bool fill, bool noaspect)
diff --git a/omx.h b/omx.h
index c162a88..ea97561 100644
--- a/omx.h
+++ b/omx.h
@@ -29,7 +29,8 @@ public:
int DeInit(void);
void SetBufferStallCallback(void (*onBufferStall)(void*), void* data);
- void SetEndOfStreamCallback(void (*onBufferStall)(void*), void* data);
+ void SetEndOfStreamCallback(void (*onEndOfStream)(void*), void* data);
+ void SetStreamStartCallback(void (*onStreamStart)(void*), void* data);
static OMX_TICKS ToOmxTicks(int64_t val);
static int64_t FromOmxTicks(OMX_TICKS &ticks);
@@ -85,7 +86,8 @@ public:
eDataUnitType dataUnit = eArbitraryStreamSection);
int SetupAudioRender(cAudioCodec::eCodec outputFormat,
int channels, cRpiAudioPort::ePort audioPort, int samplingRate = 0);
- void GetVideoSize(int &width, int &height, bool &interlaced);
+ void GetVideoFormat(int &width, int &height, int &frameRate,
+ bool &interlaced);
void SetDisplayMode(bool letterbox, bool noaspect);
void SetDisplayRegion(int x, int y, int width, int height);
@@ -127,9 +129,15 @@ private:
COMPONENT_T *m_comp[cOmx::eNumComponents + 1];
TUNNEL_T m_tun[cOmx::eNumTunnels + 1];
- int m_videoWidth;
- int m_videoHeight;
- bool m_videoInterlaced;
+ struct VideoFormat
+ {
+ int width;
+ int height;
+ int frameRate;
+ bool interlaced;
+ };
+
+ VideoFormat m_videoFormat;
bool m_setAudioStartTime;
bool m_setVideoStartTime;
@@ -152,6 +160,9 @@ private:
void (*m_onEndOfStream)(void*);
void *m_onEndOfStreamData;
+ void (*m_onStreamStart)(void*);
+ void *m_onStreamStartData;
+
void HandlePortSettingsChanged(unsigned int portId);
void SetBufferStallThreshold(int delayMs);
bool IsBufferStall(void);
diff --git a/omxdevice.c b/omxdevice.c
index 7c41fac..0b26390 100644
--- a/omxdevice.c
+++ b/omxdevice.c
@@ -78,6 +78,7 @@ int cOmxDevice::Init(void)
}
m_omx->SetBufferStallCallback(&OnBufferStall, this);
m_omx->SetEndOfStreamCallback(&OnEndOfStream, this);
+ m_omx->SetStreamStartCallback(&OnStreamStart, this);
cRpiSetup::SetVideoSetupChangedCallback(&OnVideoSetupChanged, this);
HandleVideoSetupChanged();
@@ -110,7 +111,9 @@ void cOmxDevice::GetOsdSize(int &Width, int &Height, double &PixelAspect)
void cOmxDevice::GetVideoSize(int &Width, int &Height, double &VideoAspect)
{
bool interlaced;
- m_omx->GetVideoSize(Width, Height, interlaced);
+ int frameRate;
+
+ m_omx->GetVideoFormat(Width, Height, frameRate, interlaced);
if (Height)
VideoAspect = (double)Width / Height;
@@ -605,6 +608,19 @@ void cOmxDevice::HandleEndOfStream()
m_omx->StartClock(m_hasVideo, m_hasAudio);
}
+void cOmxDevice::HandleStreamStart()
+{
+ DBG("HandleStreamStart()");
+
+ int width, height, frameRate;
+ bool interlaced;
+
+ m_omx->GetVideoFormat(width, height, frameRate, interlaced);
+
+ ILOG("video stream started %dx%d@%d%s",
+ width, height, frameRate, interlaced ? "i" : "p");
+}
+
void cOmxDevice::HandleVideoSetupChanged()
{
DBG("HandleVideoSettingsChanged()");
diff --git a/omxdevice.h b/omxdevice.h
index 62b1971..6070555 100644
--- a/omxdevice.h
+++ b/omxdevice.h
@@ -132,11 +132,15 @@ private:
static void OnEndOfStream(void *data)
{ (static_cast <cOmxDevice*> (data))->HandleEndOfStream(); }
+ static void OnStreamStart(void *data)
+ { (static_cast <cOmxDevice*> (data))->HandleStreamStart(); }
+
static void OnVideoSetupChanged(void *data)
{ (static_cast <cOmxDevice*> (data))->HandleVideoSetupChanged(); }
void HandleBufferStall();
void HandleEndOfStream();
+ void HandleStreamStart();
void HandleVideoSetupChanged();
void FlushStreams(bool flushVideoRender = false);