2010-12-02 08:53:01 +01:00
|
|
|
/*
|
2010-12-02 08:59:14 +01:00
|
|
|
* $Id: livefilter.c,v 1.4 2007/04/24 11:06:12 schmirl Exp $
|
2010-12-02 08:53:01 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "server/livefilter.h"
|
2010-12-02 08:59:14 +01:00
|
|
|
#include "server/streamer.h"
|
2010-12-02 08:53:01 +01:00
|
|
|
#include "common.h"
|
|
|
|
|
2010-12-02 08:59:14 +01:00
|
|
|
#ifndef TS_SIZE
|
|
|
|
# define TS_SIZE 188
|
|
|
|
#endif
|
|
|
|
#ifndef TS_SYNC_BYTE
|
|
|
|
# define TS_SYNC_BYTE 0x47
|
|
|
|
#endif
|
|
|
|
|
2010-12-02 08:53:01 +01:00
|
|
|
#if VDRVERSNUM >= 10300
|
|
|
|
|
2010-12-02 08:59:14 +01:00
|
|
|
cStreamdevLiveFilter::cStreamdevLiveFilter(cStreamdevStreamer *Streamer) {
|
2010-12-02 08:53:01 +01:00
|
|
|
m_Streamer = Streamer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cStreamdevLiveFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length)
|
|
|
|
{
|
|
|
|
uchar buffer[TS_SIZE];
|
|
|
|
int length = Length;
|
|
|
|
int pos = 0;
|
|
|
|
|
|
|
|
while (length > 0) {
|
|
|
|
int chunk = min(length, TS_SIZE - 5);
|
|
|
|
buffer[0] = TS_SYNC_BYTE;
|
2010-12-02 08:59:14 +01:00
|
|
|
buffer[1] = ((Pid >> 8) & 0x3f) | (pos==0 ? 0x40 : 0); /* bit 6: payload unit start indicator (PUSI) */
|
2010-12-02 08:53:01 +01:00
|
|
|
buffer[2] = Pid & 0xff;
|
|
|
|
buffer[3] = Tid;
|
|
|
|
buffer[4] = (uchar)chunk;
|
|
|
|
memcpy(buffer + 5, Data + pos, chunk);
|
|
|
|
length -= chunk;
|
|
|
|
pos += chunk;
|
|
|
|
|
|
|
|
int p = m_Streamer->Put(buffer, TS_SIZE);
|
|
|
|
if (p != TS_SIZE)
|
|
|
|
m_Streamer->ReportOverflow(TS_SIZE - p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // VDRVERSNUM >= 10300
|