vdr-plugin-streamdev/server/livefilter.c

40 lines
975 B
C
Raw Permalink Normal View History

2004-12-30 23:43:55 +01:00
/*
* $Id: livefilter.c,v 1.5.2.2 2009/02/13 13:02:34 schmirl Exp $
2004-12-30 23:43:55 +01:00
*/
#include "server/livefilter.h"
#include "server/streamer.h"
2004-12-30 23:43:55 +01:00
#include "common.h"
#ifndef TS_SYNC_BYTE
# define TS_SYNC_BYTE 0x47
#endif
cStreamdevLiveFilter::cStreamdevLiveFilter(cStreamdevStreamer *Streamer) {
2004-12-30 23:43:55 +01:00
m_Streamer = Streamer;
}
2005-02-08 14:59:16 +01:00
void cStreamdevLiveFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length)
{
2004-12-30 23:43:55 +01:00
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;
buffer[1] = ((Pid >> 8) & 0x3f) | (pos==0 ? 0x40 : 0); /* bit 6: payload unit start indicator (PUSI) */
2004-12-30 23:43:55 +01:00
buffer[2] = Pid & 0xff;
buffer[3] = Tid;
// this makes it a proprietary stream
2004-12-30 23:43:55 +01:00
buffer[4] = (uchar)chunk;
memcpy(buffer + 5, Data + pos, chunk);
length -= chunk;
pos += chunk;
int p = m_Streamer->Put(buffer, TS_SIZE);
2005-02-08 14:59:16 +01:00
if (p != TS_SIZE)
m_Streamer->ReportOverflow(TS_SIZE - p);
2004-12-30 23:43:55 +01:00
}
}