diff options
-rw-r--r-- | include/vdr-xineliboutput/service_pip.h | 49 | ||||
-rw-r--r-- | tools/pip_service_impl.h | 80 |
2 files changed, 129 insertions, 0 deletions
diff --git a/include/vdr-xineliboutput/service_pip.h b/include/vdr-xineliboutput/service_pip.h new file mode 100644 index 00000000..ee168fcf --- /dev/null +++ b/include/vdr-xineliboutput/service_pip.h @@ -0,0 +1,49 @@ +/* + * vdr-xineliboutput/service_pip.h: xineliboutput Picture-In-Picture service interface + * + * See the main source file 'xineliboutput.c' for copyright information and + * how to reach the author. + * + * $Id: service_pip.h,v 1.1 2010-03-12 21:15:05 phintuka Exp $ + * + */ + +#ifndef VDR_XINELIBOUTPUT_SERVICE_PIP_H +#define VDR_XINELIBOUTPUT_SERVICE_PIP_H + +/* + * Example: + * + * cXineliboutputPipService *pip_if; + * + * if (Plugin->Service(XINELIBOUTPUT_SERVICE_PIP_ID, &pip_if)) { + * while(...) + * pip_if->PlayTs(...); + * delete pip_if; + * } + * + */ + +#define XINELIBOUTPUT_SERVICE_PIP_ID "Xineliboutput_Pip_Open" + +#define XINELIBOUTPUT_SERVICE_PIP_VERSION 0x0100 + +class cXineliboutputPipService { + + public: + + /* Set location and size (in % of full screen) + * Example: + * Blend PIP picture to left-top corner, resize to 20% of full screen: + * SetPosition(5, 5, 20, 20); + */ + virtual void SetPosition(uint X, uint Y, uint W, uint H) = 0; + + /* PIP input: single MPEG-TS video packet */ + virtual int PlayTs(const uint8_t *Data) = 0; + + virtual ~cXineliboutputPipService() {}; +}; + + +#endif /* VDR_XINELIBOUTPUT_SERVICE_PIP_H */ diff --git a/tools/pip_service_impl.h b/tools/pip_service_impl.h new file mode 100644 index 00000000..55d3d83d --- /dev/null +++ b/tools/pip_service_impl.h @@ -0,0 +1,80 @@ +/* + * pip_service_impl.h: + * + * See the main source file 'xineliboutput.c' for copyright information and + * how to reach the author. + * + * $Id: pip_service_impl.h,v 1.1 2010-03-12 21:15:04 phintuka Exp $ + * + */ + +#ifndef PIP_SERVICE_IMPL_H +#define PIP_SERVICE_IMPL_H + +#include "../include/vdr-xineliboutput/service_pip.h" + +#ifndef TS_SIZE +# define TS_SIZE 188 +#endif + +#define PIP_TS_CHUNK_SIZE (8*TS_SIZE) + +class cPipServiceImpl : public cXineliboutputPipService +{ + private: + + cXinelibDevice *m_Dev; + int m_Id; + + uint8_t m_Data[PIP_TS_CHUNK_SIZE + TS_SIZE]; + uint m_DataLen; + + public: + + cPipServiceImpl(int Index, cXinelibDevice *Device) + { + m_Dev = Device; + m_Id = Index; + m_DataLen = 0; + + int X = 5 + 22 * (Index % 4); + int Y = 5 + 22 * (Index / 4); + int W = 20; + int H = 20; + + m_Dev->Pip_Config(m_Id, X, Y, W, H); + } + + private: + + virtual void SetPosition(uint X, uint Y, uint W, uint H) + { + m_Dev->Pip_Config(m_Id, X, Y, W, H); + } + + virtual int PlayTs(const uint8_t *Data) + { + if (Data) { + /* accumulate data */ + memcpy(m_Data + m_DataLen, Data, TS_SIZE); + m_DataLen += TS_SIZE; + + if (m_DataLen < PIP_TS_CHUNK_SIZE) + return TS_SIZE; + } + + /* flush to device */ + m_Dev->Pip_Play(m_Id, m_Data, m_DataLen); + m_DataLen = 0; + + return TS_SIZE; + } + + virtual ~cPipServiceImpl() + { + m_Dev->Pip_Close(m_Id); + } +}; + + +#endif /* PIP_SERVICE_IMPL_H */ |