From 6f03be23acf7aef3f03a310ea1c6cae4f854221e Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Wed, 26 Oct 2005 16:34:57 +0000 Subject: [PATCH] *** empty log message *** --- mvpreceiver.c | 18 +++++++++--------- remux/ts2ps.c | 26 ++++++++++++++++---------- remux/ts2ps.h | 2 ++ remux/tsremux.c | 48 +++++++++++++++++++++++++++--------------------- remux/tsremux.h | 7 +++++-- 5 files changed, 59 insertions(+), 42 deletions(-) diff --git a/mvpreceiver.c b/mvpreceiver.c index 56337c0..6614304 100755 --- a/mvpreceiver.c +++ b/mvpreceiver.c @@ -40,16 +40,16 @@ MVPReceiver::MVPReceiver(cChannel* channel, cDevice* device) // Get the remuxer for audio or video #if VDRVERSNUM < 10300 - if ((channel->Vpid() == 0) || (channel->Vpid() == 1) || (channel->Vpid() == 0x1FFF)) - { - remuxer = new cTS2ESRemux(channel->Apid1()); - logger->log("MVPReceiver", Log::DEBUG, "Created new < 1.3 TS->ES"); - } - else - { +// if ((channel->Vpid() == 0) || (channel->Vpid() == 1) || (channel->Vpid() == 0x1FFF)) +// { +// remuxer = new cTS2ESRemux(channel->Apid1()); +// logger->log("MVPReceiver", Log::DEBUG, "Created new < 1.3 TS->ES"); +// } +// else +// { remuxer = new cTS2PSRemux(channel->Vpid(), channel->Apid1(), 0, 0, 0, 0); logger->log("MVPReceiver", Log::DEBUG, "Created new < 1.3 TS->PS"); - } +// } #else if ((channel->Vpid() == 0) || (channel->Vpid() == 1) || (channel->Vpid() == 0x1FFF)) { @@ -145,7 +145,7 @@ void MVPReceiver::threadMethod() processed.put(remuxedData, outputSize); pthread_mutex_unlock(&processedRingLock); -// printf("Got from unprocessed: %i, Got from remux: %p %i, consumed: %i\n", +// logger->log("MVPReceiver", Log::DEBUG, "Got from unprocessed: %i, Got from remux: %p %i, consumed: %i", // amountGot, remuxedData, outputSize, remuxTook); } else diff --git a/remux/ts2ps.c b/remux/ts2ps.c index e23fdca..f7f0f99 100644 --- a/remux/ts2ps.c +++ b/remux/ts2ps.c @@ -73,13 +73,18 @@ void cTS2PS::PutTSPacket(const uint8_t *Buffer) { } cTS2PSRemux::cTS2PSRemux(int VPid, int APid1, int APid2, int DPid1, - int DPid2, bool PS) { - m_VPid = VPid; - m_APid1 = APid1; - m_APid2 = APid2; - m_DPid1 = DPid1; - m_DPid2 = DPid2; - m_VRemux = new cTS2PS(m_ResultBuffer, &m_ResultCount, 0x00, PS); + int DPid2, bool PS) +{ + m_VPid = VPid; + m_APid1 = APid1; + m_APid2 = APid2; + m_DPid1 = DPid1; + m_DPid2 = DPid2; + + if (!m_VPid) m_Sync = 0; // CJT + + m_VRemux = VPid ? new cTS2PS(m_ResultBuffer, &m_ResultCount, 0x00, PS) + : NULL; // CJT edit to allow 0 APid m_ARemux1 = new cTS2PS(m_ResultBuffer, &m_ResultCount, 0xC0, PS); m_ARemux2 = APid2 ? new cTS2PS(m_ResultBuffer, &m_ResultCount, 0xC1, PS) : NULL; @@ -93,14 +98,15 @@ cTS2PSRemux::cTS2PSRemux(int VPid, int APid1, int APid2, int DPid1, cTS2PSRemux::~cTS2PSRemux() { if (m_DRemux2) delete m_DRemux2; if (m_DRemux1) delete m_DRemux1; + if (m_VRemux) delete m_VRemux; // CJT if (m_ARemux2) delete m_ARemux2; delete m_ARemux1; - delete m_VRemux; +// delete m_VRemux; } void cTS2PSRemux::PutTSPacket(int Pid, const uint8_t *Data) { - if (Pid == m_VPid) m_VRemux->PutTSPacket(Data); - else if (Pid == m_APid1) m_ARemux1->PutTSPacket(Data); + if (Pid == m_VPid && m_VRemux /* CJT */ ) m_VRemux->PutTSPacket(Data); + else if (Pid == m_APid1) m_ARemux1->PutTSPacket(Data); else if (Pid == m_APid2 && m_ARemux2) m_ARemux2->PutTSPacket(Data); else if (Pid == m_DPid1 && m_DRemux1) m_DRemux1->PutTSPacket(Data); else if (Pid == m_DPid2 && m_DRemux2) m_DRemux2->PutTSPacket(Data); diff --git a/remux/ts2ps.h b/remux/ts2ps.h index 5760f09..add96aa 100644 --- a/remux/ts2ps.h +++ b/remux/ts2ps.h @@ -3,6 +3,8 @@ #include "tsremux.h" +#include "../log.h" + class cTS2PS; class cTS2PSRemux: public cTSRemux { diff --git a/remux/tsremux.c b/remux/tsremux.c index 895a435..490c250 100644 --- a/remux/tsremux.c +++ b/remux/tsremux.c @@ -17,38 +17,43 @@ cTSRemux::cTSRemux(bool Sync) { cTSRemux::~cTSRemux(void) { } -uchar *cTSRemux::Process(const uchar *Data, int &Count, int &Result) { +uchar *cTSRemux::Process(const uchar *Data, int &Count, int &Result) +{ // Remove any previously delivered data from the result buffer: - if (m_ResultDelivered) { + if (m_ResultDelivered) + { if (m_ResultDelivered < m_ResultCount) - memmove(m_ResultBuffer, m_ResultBuffer + m_ResultDelivered, m_ResultCount - - m_ResultDelivered); + memmove(m_ResultBuffer, m_ResultBuffer + m_ResultDelivered, m_ResultCount - m_ResultDelivered); + m_ResultCount -= m_ResultDelivered; m_ResultDelivered = 0; - } + } int used = 0; // Make sure we are looking at a TS packet: - while (Count > TS_SIZE) { - if (Data[0] == 0x47 && Data[TS_SIZE] == 0x47) - break; + while (Count > TS_SIZE) + { + if (Data[0] == 0x47 && Data[TS_SIZE] == 0x47) break; Data++; Count--; used++; } - if (used) - esyslog("ERROR: skipped %d byte to sync on TS packet", used); - // Convert incoming TS data - for (int i = 0; i < Count; i += TS_SIZE) { - if (Count - i < TS_SIZE) - break; - if (Data[i] != 0x47) - break; + if (used) esyslog("ERROR: skipped %d byte to sync on TS packet", used); + + // Convert incoming TS data + for (int i = 0; i < Count; i += TS_SIZE) + { + if (Count - i < TS_SIZE) break; + if (Data[i] != 0x47) break; + int pid = get_pid((uint8_t*)(Data + i + 1)); - if (Data[i + 3] & 0x10) // got payload - PutTSPacket(pid, Data + i); + if (Data[i + 3] & 0x10) + { + // got payload + PutTSPacket(pid, Data + i); + } /*if (pid == m_VPid) m_VRemux->ConvertTSPacket(Data + i); else if (pid == m_APid1) m_ARemux1->ConvertTSPacket(Data + i); else if (pid == m_APid2 && m_ARemux2) m_ARemux2->ConvertTSPacket(Data + i); @@ -79,13 +84,14 @@ uchar *cTSRemux::Process(const uchar *Data, int &Count, int &Result) { } Count = used; - // When we don't need to sync, we don't need to sync :-) - if (!m_Sync) { + // When we don't need to sync, we don't need to sync :-) + if (!m_Sync) + { Result = m_ResultDelivered = m_ResultCount; return Result ? m_ResultBuffer : NULL; } - // Check if we're getting anywhere here: + // Check if we're getting anywhere here: if (!m_Synced && m_Skipped >= 0) { if (m_Skipped > MAXNONUSEFULDATA) { diff --git a/remux/tsremux.h b/remux/tsremux.h index 2a28a35..a4255f2 100644 --- a/remux/tsremux.h +++ b/remux/tsremux.h @@ -4,6 +4,8 @@ #include "transform.h" #include +#include "../log.h" + #define IPACKS 2048 #define PROTECTIONSIZE 32768 @@ -23,7 +25,6 @@ protected: int m_ResultDelivered; int m_Synced; int m_Skipped; - int m_Sync; int GetPacketLength(const uchar *Data, int Count, int Offset); int ScanVideoPacket(const uchar *Data, int Count, int Offset, uchar &PictureType); @@ -31,9 +32,11 @@ protected: virtual void PutTSPacket(int Pid, const uint8_t *Data) = 0; public: + int m_Sync;// CJT moved from protected + cTSRemux(bool Sync = true); virtual ~cTSRemux(); - + virtual uchar *Process(const uchar *Data, int &Count, int &Result); static void SetBrokenLink(uchar *Data, int Length); -- 2.39.5