diff -u -r streamdev-orig/remux/ts2ps.c streamdev/remux/ts2ps.c --- streamdev-orig/remux/ts2ps.c 2005-11-06 18:43:58.000000000 +0200 +++ streamdev/remux/ts2ps.c 2009-01-16 10:55:49.000000000 +0200 @@ -3,209 +3,209 @@ #include #include -class cTS2PS { - friend void PutPES(uint8_t *Buffer, int Size, void *Data); +/* class cTS2PS { */ +/* friend void PutPES(uint8_t *Buffer, int Size, void *Data); */ -private: - ipack m_Ipack; - int m_Pid; - cRingBufferLinear *m_ResultBuffer; - -public: - cTS2PS(cRingBufferLinear *ResultBuffer, int Pid, uint8_t AudioCid = 0x00); - ~cTS2PS(); - - void PutTSPacket(const uint8_t *Buffer); - - int Pid(void) const { return m_Pid; } -}; - -void PutPES(uint8_t *Buffer, int Size, void *Data) -{ - cTS2PS *This = (cTS2PS*)Data; - int n = This->m_ResultBuffer->Put(Buffer, Size); - if (n != Size) - esyslog("ERROR: result buffer overflow, dropped %d out of %d byte", Size - n, Size); -} - -cTS2PS::cTS2PS(cRingBufferLinear *ResultBuffer, int Pid, uint8_t AudioCid) -{ - m_ResultBuffer = ResultBuffer; - m_Pid = Pid; - - init_ipack(&m_Ipack, IPACKS, PutPES, false); - m_Ipack.cid = AudioCid; - m_Ipack.data = (void*)this; -} - -cTS2PS::~cTS2PS() -{ - free_ipack(&m_Ipack); -} - -void cTS2PS::PutTSPacket(const uint8_t *Buffer) -{ - if (!Buffer) - return; - - if (Buffer[1] & 0x80) { // ts error - // TODO - } - - if (Buffer[1] & 0x40) { // payload start - if (m_Ipack.plength == MMAX_PLENGTH - 6 && m_Ipack.found > 6) { - m_Ipack.plength = m_Ipack.found - 6; - m_Ipack.found = 0; - send_ipack(&m_Ipack); - reset_ipack(&m_Ipack); - } - } - - uint8_t off = 0; - - if (Buffer[3] & 0x20) { // adaptation field? - off = Buffer[4] + 1; - if (off + 4 > TS_SIZE - 1) - return; - } - - instant_repack((uint8_t*)(Buffer + 4 + off), TS_SIZE - 4 - off, &m_Ipack); -} - -cTS2PSRemux::cTS2PSRemux(int VPid, const int *APids, const int *DPids, const int *SPids): - m_NumTracks(0), - m_ResultBuffer(new cRingBufferLinear(WRITERBUFSIZE, IPACKS)), - m_ResultSkipped(0), - m_Skipped(0), - m_Synced(false), - m_IsRadio(VPid == 0 || VPid == 1 || VPid == 0x1FFF) -{ - m_ResultBuffer->SetTimeouts(0, 100); - - if (VPid) - m_Remux[m_NumTracks++] = new cTS2PS(m_ResultBuffer, VPid); - if (APids) { - int n = 0; - while (*APids && m_NumTracks < MAXTRACKS && n < MAXAPIDS) - m_Remux[m_NumTracks++] = new cTS2PS(m_ResultBuffer, *APids++, 0xC0 + n++); - } - if (DPids) { - int n = 0; - while (*DPids && m_NumTracks < MAXTRACKS && n < MAXDPIDS) - m_Remux[m_NumTracks++] = new cTS2PS(m_ResultBuffer, *DPids++, 0x80 + n++); - } -} - -cTS2PSRemux::~cTS2PSRemux() { - for (int i = 0; i < m_NumTracks; ++i) - delete m_Remux[i]; - delete m_ResultBuffer; -} - -int cTS2PSRemux::Put(const uchar *Data, int Count) -{ - int used = 0; - - // Make sure we are looking at a TS packet: - while (Count > TS_SIZE) { - if (Data[0] == TS_SYNC_BYTE && Data[TS_SIZE] == TS_SYNC_BYTE) - break; - Data++; - Count--; - used++; - } - if (used) - esyslog("ERROR: m_Skipped %d byte to sync on TS packet", used); - - // Convert incoming TS data into multiplexed PS: - - for (int i = 0; i < Count; i += TS_SIZE) { - if (Count - i < TS_SIZE) - break; - if (Data[i] != TS_SYNC_BYTE) - break; - if (m_ResultBuffer->Free() < 2 * IPACKS) - break; // A cTS2PS might write one full packet and also a small rest - int pid = GetPid(Data + i + 1); - if (Data[i + 3] & 0x10) { // got payload - for (int t = 0; t < m_NumTracks; t++) { - if (m_Remux[t]->Pid() == pid) { - m_Remux[t]->PutTSPacket(Data + i); - break; - } - } - } - used += TS_SIZE; - } - - // Check if we're getting anywhere here: - if (!m_Synced && m_Skipped >= 0) - m_Skipped += used; - - return used; -} - -uchar *cTS2PSRemux::Get(int &Count) -{ - // Remove any previously skipped data from the result buffer: - - if (m_ResultSkipped > 0) { - m_ResultBuffer->Del(m_ResultSkipped); - m_ResultSkipped = 0; - } - - // Special VPID case to enable recording radio channels: - if (m_IsRadio) { - // Force syncing of radio channels to avoid "no useful data" error - m_Synced = true; - return m_ResultBuffer->Get(Count); - } - - // Check for frame borders: - Count = 0; - uchar *resultData = NULL; - int resultCount = 0; - uchar *data = m_ResultBuffer->Get(resultCount); - if (data) { - for (int i = 0; i < resultCount - 3; i++) { - if (data[i] == 0 && data[i + 1] == 0 && data[i + 2] == 1) { - int l = 0; - uchar StreamType = data[i + 3]; - if (VIDEO_STREAM_S <= StreamType && StreamType <= VIDEO_STREAM_E) { - uchar pt = NO_PICTURE; - l = ScanVideoPacket(data, resultCount, i, pt); - if (l < 0) - return resultData; - if (pt != NO_PICTURE) { - if (pt < I_FRAME || B_FRAME < pt) { - esyslog("ERROR: unknown picture type '%d'", pt); - } - else if (!m_Synced) { - if (pt == I_FRAME) { - m_ResultSkipped = i; // will drop everything before this position - SetBrokenLink(data + i, l); - m_Synced = true; - } - } - else if (Count) - return resultData; - } - } else { - l = GetPacketLength(data, resultCount, i); - if (l < 0) - return resultData; - } - if (m_Synced) { - if (!Count) - resultData = data + i; - Count += l; - } else - m_ResultSkipped = i + l; - if (l > 0) - i += l - 1; // the loop increments, too - } - } - } - return resultData; -} +/* private: */ +/* ipack m_Ipack; */ +/* int m_Pid; */ +/* cRingBufferLinear *m_ResultBuffer; */ + +/* public: */ +/* cTS2PS(cRingBufferLinear *ResultBuffer, int Pid, uint8_t AudioCid = 0x00); */ +/* ~cTS2PS(); */ + +/* void PutTSPacket(const uint8_t *Buffer); */ + +/* int Pid(void) const { return m_Pid; } */ +/* }; */ + +/* void PutPES(uint8_t *Buffer, int Size, void *Data) */ +/* { */ +/* cTS2PS *This = (cTS2PS*)Data; */ +/* int n = This->m_ResultBuffer->Put(Buffer, Size); */ +/* if (n != Size) */ +/* esyslog("ERROR: result buffer overflow, dropped %d out of %d byte", Size - n, Size); */ +/* } */ + +/* cTS2PS::cTS2PS(cRingBufferLinear *ResultBuffer, int Pid, uint8_t AudioCid) */ +/* { */ +/* m_ResultBuffer = ResultBuffer; */ +/* m_Pid = Pid; */ + +/* init_ipack(&m_Ipack, IPACKS, PutPES, false); */ +/* m_Ipack.cid = AudioCid; */ +/* m_Ipack.data = (void*)this; */ +/* } */ + +/* cTS2PS::~cTS2PS() */ +/* { */ +/* free_ipack(&m_Ipack); */ +/* } */ + +/* void cTS2PS::PutTSPacket(const uint8_t *Buffer) */ +/* { */ +/* if (!Buffer) */ +/* return; */ + +/* if (Buffer[1] & 0x80) { // ts error */ +/* // TODO */ +/* } */ + +/* if (Buffer[1] & 0x40) { // payload start */ +/* if (m_Ipack.plength == MMAX_PLENGTH - 6 && m_Ipack.found > 6) { */ +/* m_Ipack.plength = m_Ipack.found - 6; */ +/* m_Ipack.found = 0; */ +/* send_ipack(&m_Ipack); */ +/* reset_ipack(&m_Ipack); */ +/* } */ +/* } */ + +/* uint8_t off = 0; */ + +/* if (Buffer[3] & 0x20) { // adaptation field? */ +/* off = Buffer[4] + 1; */ +/* if (off + 4 > TS_SIZE - 1) */ +/* return; */ +/* } */ + +/* instant_repack((uint8_t*)(Buffer + 4 + off), TS_SIZE - 4 - off, &m_Ipack); */ +/* } */ + +/* cTS2PSRemux::cTS2PSRemux(int VPid, const int *APids, const int *DPids, const int *SPids): */ +/* m_NumTracks(0), */ +/* m_ResultBuffer(new cRingBufferLinear(WRITERBUFSIZE, IPACKS)), */ +/* m_ResultSkipped(0), */ +/* m_Skipped(0), */ +/* m_Synced(false), */ +/* m_IsRadio(VPid == 0 || VPid == 1 || VPid == 0x1FFF) */ +/* { */ +/* m_ResultBuffer->SetTimeouts(0, 100); */ + +/* if (VPid) */ +/* m_Remux[m_NumTracks++] = new cTS2PS(m_ResultBuffer, VPid); */ +/* if (APids) { */ +/* int n = 0; */ +/* while (*APids && m_NumTracks < MAXTRACKS && n < MAXAPIDS) */ +/* m_Remux[m_NumTracks++] = new cTS2PS(m_ResultBuffer, *APids++, 0xC0 + n++); */ +/* } */ +/* if (DPids) { */ +/* int n = 0; */ +/* while (*DPids && m_NumTracks < MAXTRACKS && n < MAXDPIDS) */ +/* m_Remux[m_NumTracks++] = new cTS2PS(m_ResultBuffer, *DPids++, 0x80 + n++); */ +/* } */ +/* } */ + +/* cTS2PSRemux::~cTS2PSRemux() { */ +/* for (int i = 0; i < m_NumTracks; ++i) */ +/* delete m_Remux[i]; */ +/* delete m_ResultBuffer; */ +/* } */ + +/* int cTS2PSRemux::Put(const uchar *Data, int Count) */ +/* { */ +/* int used = 0; */ + +/* // Make sure we are looking at a TS packet: */ +/* while (Count > TS_SIZE) { */ +/* if (Data[0] == TS_SYNC_BYTE && Data[TS_SIZE] == TS_SYNC_BYTE) */ +/* break; */ +/* Data++; */ +/* Count--; */ +/* used++; */ +/* } */ +/* if (used) */ +/* esyslog("ERROR: m_Skipped %d byte to sync on TS packet", used); */ + +/* // Convert incoming TS data into multiplexed PS: */ + +/* for (int i = 0; i < Count; i += TS_SIZE) { */ +/* if (Count - i < TS_SIZE) */ +/* break; */ +/* if (Data[i] != TS_SYNC_BYTE) */ +/* break; */ +/* if (m_ResultBuffer->Free() < 2 * IPACKS) */ +/* break; // A cTS2PS might write one full packet and also a small rest */ +/* int pid = GetPid(Data + i + 1); */ +/* if (Data[i + 3] & 0x10) { // got payload */ +/* for (int t = 0; t < m_NumTracks; t++) { */ +/* if (m_Remux[t]->Pid() == pid) { */ +/* m_Remux[t]->PutTSPacket(Data + i); */ +/* break; */ +/* } */ +/* } */ +/* } */ +/* used += TS_SIZE; */ +/* } */ + +/* // Check if we're getting anywhere here: */ +/* if (!m_Synced && m_Skipped >= 0) */ +/* m_Skipped += used; */ + +/* return used; */ +/* } */ + +/* uchar *cTS2PSRemux::Get(int &Count) */ +/* { */ +/* // Remove any previously skipped data from the result buffer: */ + +/* if (m_ResultSkipped > 0) { */ +/* m_ResultBuffer->Del(m_ResultSkipped); */ +/* m_ResultSkipped = 0; */ +/* } */ + +/* // Special VPID case to enable recording radio channels: */ +/* if (m_IsRadio) { */ +/* // Force syncing of radio channels to avoid "no useful data" error */ +/* m_Synced = true; */ +/* return m_ResultBuffer->Get(Count); */ +/* } */ + +/* // Check for frame borders: */ +/* Count = 0; */ +/* uchar *resultData = NULL; */ +/* int resultCount = 0; */ +/* uchar *data = m_ResultBuffer->Get(resultCount); */ +/* if (data) { */ +/* for (int i = 0; i < resultCount - 3; i++) { */ +/* if (data[i] == 0 && data[i + 1] == 0 && data[i + 2] == 1) { */ +/* int l = 0; */ +/* uchar StreamType = data[i + 3]; */ +/* if (VIDEO_STREAM_S <= StreamType && StreamType <= VIDEO_STREAM_E) { */ +/* uchar pt = NO_PICTURE; */ +/* l = ScanVideoPacket(data, resultCount, i, pt); */ +/* if (l < 0) */ +/* return resultData; */ +/* if (pt != NO_PICTURE) { */ +/* if (pt < I_FRAME || B_FRAME < pt) { */ +/* esyslog("ERROR: unknown picture type '%d'", pt); */ +/* } */ +/* else if (!m_Synced) { */ +/* if (pt == I_FRAME) { */ +/* m_ResultSkipped = i; // will drop everything before this position */ +/* SetBrokenLink(data + i, l); */ +/* m_Synced = true; */ +/* } */ +/* } */ +/* else if (Count) */ +/* return resultData; */ +/* } */ +/* } else { */ +/* l = GetPacketLength(data, resultCount, i); */ +/* if (l < 0) */ +/* return resultData; */ +/* } */ +/* if (m_Synced) { */ +/* if (!Count) */ +/* resultData = data + i; */ +/* Count += l; */ +/* } else */ +/* m_ResultSkipped = i + l; */ +/* if (l > 0) */ +/* i += l - 1; // the loop increments, too */ +/* } */ +/* } */ +/* } */ +/* return resultData; */ +/* } */ diff -u -r streamdev-orig/remux/ts2ps.h streamdev/remux/ts2ps.h --- streamdev-orig/remux/ts2ps.h 2005-02-11 18:44:15.000000000 +0200 +++ streamdev/remux/ts2ps.h 2009-01-16 10:37:02.000000000 +0200 @@ -5,25 +5,26 @@ #include #include -class cTS2PS; -class cTS2PSRemux: public cTSRemux { -private: - int m_NumTracks; - cTS2PS *m_Remux[MAXTRACKS]; - cRingBufferLinear *m_ResultBuffer; - int m_ResultSkipped; - int m_Skipped; - bool m_Synced; - bool m_IsRadio; +/* class cTS2PS; */ + +/* class cTS2PSRemux: public cTSRemux { */ +/* private: */ +/* int m_NumTracks; */ +/* cTS2PS *m_Remux[MAXTRACKS]; */ +/* cRingBufferLinear *m_ResultBuffer; */ +/* int m_ResultSkipped; */ +/* int m_Skipped; */ +/* bool m_Synced; */ +/* bool m_IsRadio; */ -public: - cTS2PSRemux(int VPid, const int *Apids, const int *Dpids, const int *Spids); - virtual ~cTS2PSRemux(); +/* public: */ +/* cTS2PSRemux(int VPid, const int *Apids, const int *Dpids, const int *Spids); */ +/* virtual ~cTS2PSRemux(); */ - int Put(const uchar *Data, int Count); - uchar *Get(int &Count); - void Del(int Count) { m_ResultBuffer->Del(Count); } -}; +/* int Put(const uchar *Data, int Count); */ +/* uchar *Get(int &Count); */ +/* void Del(int Count) { m_ResultBuffer->Del(Count); } */ +/* }; */ #endif // VDR_STREAMDEV_TS2PESREMUX_H diff -u -r streamdev-orig/remux/tsremux.c streamdev/remux/tsremux.c --- streamdev-orig/remux/tsremux.c 2008-10-13 14:30:06.000000000 +0300 +++ streamdev/remux/tsremux.c 2009-01-16 10:54:35.000000000 +0200 @@ -52,7 +52,7 @@ } } } - PictureType = NO_PICTURE; + return Length; } return -1; diff -u -r streamdev-orig/server/livestreamer.c streamdev/server/livestreamer.c --- streamdev-orig/server/livestreamer.c 2008-11-24 14:10:27.000000000 +0200 +++ streamdev/server/livestreamer.c 2009-01-16 10:52:36.000000000 +0200 @@ -329,9 +329,9 @@ m_Device(NULL), m_Receiver(NULL), m_PatFilter(NULL), - m_PESRemux(NULL), - m_ESRemux(NULL), - m_PSRemux(NULL), + //m_PESRemux(NULL), + //m_ESRemux(NULL), + //m_PSRemux(NULL), m_ExtRemux(NULL) { } @@ -345,9 +345,9 @@ DELETENULL(m_PatFilter); } DELETENULL(m_Receiver); - delete m_PESRemux; - delete m_ESRemux; - delete m_PSRemux; + //delete m_PESRemux; + //delete m_ESRemux; + //delete m_PSRemux; delete m_ExtRemux; } @@ -450,25 +450,25 @@ const int *Dpids = Apid ? NULL : m_Channel->Dpids(); switch (m_StreamType) { - case stES: - { - int pid = ISRADIO(m_Channel) ? m_Channel->Apid(0) : m_Channel->Vpid(); - if (Apid != 0) - pid = Apid; - m_ESRemux = new cTS2ESRemux(pid); - return SetPids(pid); - } - - case stPES: - m_PESRemux = new cRemux(m_Channel->Vpid(), m_Channel->Apids(), m_Channel->Dpids(), - m_Channel->Spids(), false); - return SetPids(m_Channel->Vpid(), Apids, Dpids, m_Channel->Spids()); - - case stPS: - m_PSRemux = new cTS2PSRemux(m_Channel->Vpid(), m_Channel->Apids(), m_Channel->Dpids(), - m_Channel->Spids()); - return SetPids(m_Channel->Vpid(), Apids, Dpids, m_Channel->Spids()); - + case stES: +/* { */ +/* int pid = ISRADIO(m_Channel) ? m_Channel->Apid(0) : m_Channel->Vpid(); */ +/* if (Apid != 0) */ +/* pid = Apid; */ +/* m_ESRemux = new cTS2ESRemux(pid); */ +/* return SetPids(pid); */ +/* } */ + + case stPES: +/* m_PESRemux = new cRemux(m_Channel->Vpid(), m_Channel->Apids(), m_Channel->Dpids(), */ +/* m_Channel->Spids(), false); */ +/* return SetPids(m_Channel->Vpid(), Apids, Dpids, m_Channel->Spids()); */ + + case stPS: +/* m_PSRemux = new cTS2PSRemux(m_Channel->Vpid(), m_Channel->Apids(), m_Channel->Dpids(), */ +/* m_Channel->Spids()); */ +/* return SetPids(m_Channel->Vpid(), Apids, Dpids, m_Channel->Spids()); */ + break; case stTS: // This should never happen, but ... if (m_PatFilter) { @@ -503,13 +503,14 @@ return cStreamdevStreamer::Put(Data, Count); case stPES: - return m_PESRemux->Put(Data, Count); + //return m_PESRemux->Put(Data, Count); case stES: - return m_ESRemux->Put(Data, Count); + // return m_ESRemux->Put(Data, Count); case stPS: - return m_PSRemux->Put(Data, Count); + // return m_PSRemux->Put(Data, Count); + return 0; case stExtern: return m_ExtRemux->Put(Data, Count); @@ -527,13 +528,14 @@ return cStreamdevStreamer::Get(Count); case stPES: - return m_PESRemux->Get(Count); + //return m_PESRemux->Get(Count); case stES: - return m_ESRemux->Get(Count); + //return m_ESRemux->Get(Count); case stPS: - return m_PSRemux->Get(Count); + //return m_PSRemux->Get(Count); + return 0; case stExtern: return m_ExtRemux->Get(Count); @@ -552,15 +554,15 @@ break; case stPES: - m_PESRemux->Del(Count); + //m_PESRemux->Del(Count); break; case stES: - m_ESRemux->Del(Count); + //m_ESRemux->Del(Count); break; case stPS: - m_PSRemux->Del(Count); + //m_PSRemux->Del(Count); break; case stExtern: diff -u -r streamdev-orig/server/livestreamer.h streamdev/server/livestreamer.h --- streamdev-orig/server/livestreamer.h 2008-04-07 17:27:31.000000000 +0300 +++ streamdev/server/livestreamer.h 2009-01-16 10:35:02.000000000 +0200 @@ -7,8 +7,8 @@ #include "server/streamer.h" #include "common.h" -class cTS2PSRemux; -class cTS2ESRemux; +//class cTS2PSRemux; +//class cTS2ESRemux; class cExternRemux; class cRemux; class cStreamdevPatFilter; @@ -28,8 +28,8 @@ cStreamdevLiveReceiver *m_Receiver; cStreamdevPatFilter *m_PatFilter; cRemux *m_PESRemux; - cTS2ESRemux *m_ESRemux; - cTS2PSRemux *m_PSRemux; + //cTS2ESRemux *m_ESRemux; + //cTS2PSRemux *m_PSRemux; cExternRemux *m_ExtRemux; void StartReceiver(void);