From 9b0c3baf54f7a73972159675ddf78fc18995b21c Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sun, 17 Jul 2005 16:54:58 +0000 Subject: [PATCH] VDR 1.3 support --- mvpclient.c | 51 ++++++++++++++++++++++++++++++++++++++++++--------- transceiver.c | 40 ++++++++++++++++++++++++++++++++++++++-- transceiver.h | 4 +++- 3 files changed, 83 insertions(+), 12 deletions(-) diff --git a/mvpclient.c b/mvpclient.c index 18a9dd1..95ef07b 100644 --- a/mvpclient.c +++ b/mvpclient.c @@ -97,8 +97,11 @@ cChannel* MVPClient::channelFromNumber(unsigned long channelNumber) if (channel->Number() == (int)channelNumber) { int vpid = channel->Vpid(); +#if VDRVERSNUM < 10300 int apid1 = channel->Apid1(); - +#else + int apid1 = channel->Apid(0); +#endif printf("Found channel number %lu, vpid = %i, apid1 = %i\n", channelNumber, vpid, apid1); return channel; } @@ -315,7 +318,7 @@ void MVPClient::processGetSummary(unsigned char* data, int length) cRecordings Recordings; Recordings.Load(); // probably have to do this - cRecording* recording = Recordings.GetByName((char*)data); + cRecording *recording = Recordings.GetByName((char*)data); printf("recording pointer %p\n", recording); @@ -325,8 +328,11 @@ void MVPClient::processGetSummary(unsigned char* data, int length) int count = 4; // leave space for the packet length char* point; - +#if VDRVERSNUM < 10300 point = (char*)recording->Summary(); +#else + point = (char*)recording->Info()->ShortText(); +#endif strcpy((char*)&sendBuffer[count], point); count += strlen(point) + 1; *(unsigned long*)&sendBuffer[0] = htonl(count - 4); // -4 : take off the size field @@ -503,9 +509,13 @@ void MVPClient::processGetChannelSchedule(unsigned char* data, int length) return; } +#if VDRVERSNUM < 10300 cMutexLock MutexLock; - const cSchedules* Schedules = cSIProcessor::Schedules(MutexLock); -// const cSchedules* Schedules = cSchedules::Schedules(MutexLock); + const cSchedules *Schedules = cSIProcessor::Schedules(MutexLock); +#else + cSchedulesLock MutexLock; + const cSchedules *Schedules = cSchedules::Schedules(MutexLock); +#endif if (!Schedules) { unsigned char sendBuffer[8]; @@ -529,9 +539,13 @@ void MVPClient::testChannelSchedule(unsigned char* data, int length) { FILE* f = fopen("/tmp/s.txt", "w"); +#if VDRVERSNUM < 10300 cMutexLock MutexLock; - const cSchedules* Schedules = cSIProcessor::Schedules(MutexLock); -// const cSchedules* Schedules = cSchedules::Schedules(MutexLock); + const cSchedules *Schedules = cSIProcessor::Schedules(MutexLock); +#else + cSchedulesLock MutexLock; + const cSchedules *Schedules = cSchedules::Schedules(MutexLock); +#endif if (!Schedules) { fprintf(f, "Schedules = NULL\n"); @@ -549,8 +563,12 @@ void MVPClient::testChannelSchedule(unsigned char* data, int length) tChannelID tchid; cChannel *thisChannel; - const cEventInfo* event; +#if VDRVERSNUM < 10300 + const cEventInfo *event; int eventNumber = 0; +#else + const cEvent *event; +#endif // Schedule = Schedules->GetSchedule(channel->GetChannelID()); // Schedule = Schedules->GetSchedule(); @@ -567,9 +585,17 @@ void MVPClient::testChannelSchedule(unsigned char* data, int length) fprintf(f, "Schedule #%i\n", scheduleNumber); fprintf(f, "-------------\n\n"); +#if VDRVERSNUM < 10300 tchid = Schedule->GetChannelID(); +#else + tchid = Schedule->ChannelID(); +#endif +#if VDRVERSNUM < 10300 fprintf(f, "ChannelID.ToString() = %s\n", tchid.ToString()); fprintf(f, "NumEvents() = %i\n", Schedule->NumEvents()); +#else +// put the count at the end. +#endif thisChannel = Channels.GetByChannelID(tchid, true); if (thisChannel) { @@ -580,6 +606,7 @@ void MVPClient::testChannelSchedule(unsigned char* data, int length) fprintf(f, "thisChannel = NULL for tchid\n"); } +#if VDRVERSNUM < 10300 for (eventNumber = 0; eventNumber < Schedule->NumEvents(); eventNumber++) { event = Schedule->GetEventNumber(eventNumber); @@ -592,7 +619,13 @@ void MVPClient::testChannelSchedule(unsigned char* data, int length) event->Dump(f); fprintf(f, "\n\n"); } - +#else +// This whole section needs rewriting to walk the list. + event = Schedule->Events()->First(); + while (event) { + event = Schedule->Events()->Next(event); + } +#endif fprintf(f, "\nDump from object:\n"); diff --git a/transceiver.c b/transceiver.c index 8a87fd0..13bf886 100644 --- a/transceiver.c +++ b/transceiver.c @@ -38,11 +38,17 @@ #define BUFOVERTIME 5000 #define BUFOVERCOUNT 100 +#if VDRVERSNUM < 10300 cMediamvpTransceiver::cMediamvpTransceiver(const cChannel *Channel, int Priority, int Socket, cDevice *Device) : cReceiver(Channel->Ca(), Priority, 7, Channel->Vpid(), Channel->Ppid(), Channel->Apid1(), Channel->Apid2(), Channel->Dpid1(), Channel->Dpid2(), Channel->Tpid()) { - m_Active = false; +#else +cMediamvpTransceiver::cMediamvpTransceiver(const cChannel *Channel, int Priority, int Socket, cDevice *Device) : + cReceiver(Channel->Ca(), Priority, Channel->Vpid(), + Channel->Apids(), Channel->Dpids(), Channel->Spids()) { +#endif + m_Active = false; m_Socket = Socket; m_Remux = NULL; m_Device = Device; @@ -51,11 +57,19 @@ cMediamvpTransceiver::cMediamvpTransceiver(const cChannel *Channel, int Priority // m_RingBuffer = new cRingBufferLinear(VIDEOBUFSIZE, TS_SIZE * 20, true); /* Select the correct Muxing depending on whether it's video or not */ +#if VDRVERSNUM < 10300 if ( Channel->Vpid() == 0 || Channel->Vpid() == 1 || Channel->Vpid() == 0x1FFF ) { m_Remux = new cTS2ESRemux(Channel->Apid1()); } else { m_Remux = new cTS2PSRemux(Channel->Vpid(), Channel->Apid1(), 0, 0, 0, 0); } +#else + if ( Channel->Vpid() == 0 || Channel->Vpid() == 1 || Channel->Vpid() == 0x1FFF ) { + m_Remux = new cTS2ESRemux(Channel->Apid(0)); + } else { + m_Remux = new cTS2PSRemux(Channel->Vpid(), Channel->Apid(0), 0, 0, 0, 0); + } +#endif printf("Created transceiver at %p, remux @%p ringbuffer %p\n",this,m_Remux,m_RingBuffer); /* Suggested by Peter Wagner to assist single DVB card systems */ @@ -113,7 +127,8 @@ void cMediamvpTransceiver::Receive(uchar *Data, int Length) int p = m_RingBuffer->Put(Data, Length); if (p != Length) { ++errcnt; - if (showerr) { +#if VDRVERSNUM < 10300 + if (showerr) { if (firsterr == 0) firsterr = time_ms(); else if (firsterr + BUFOVERTIME > time_ms() && errcnt > BUFOVERCOUNT) { @@ -131,6 +146,27 @@ void cMediamvpTransceiver::Receive(uchar *Data, int Length) esyslog("ERROR: ring buffer overflow (%d bytes dropped)", Length - p); else firsterr = time_ms(); +#else + if (showerr) { + if (firsterr == 0) { + firsterr = 1; + lastTime.Set(); + } + else if (lastTime.Elapsed() > BUFOVERTIME && errcnt > BUFOVERCOUNT) { + esyslog("ERROR: too many buffer overflows, logging stopped"); + showerr = false; + } + } else if (lastTime.Elapsed() < BUFOVERTIME) { + showerr = true; + firsterr = 0; + errcnt = 0; + } + + if (showerr) + esyslog("ERROR: ring buffer overflow (%d bytes dropped)", Length - p); + else + firsterr = 1; +#endif } } } diff --git a/transceiver.h b/transceiver.h index e9b854c..cbfe50a 100644 --- a/transceiver.h +++ b/transceiver.h @@ -42,7 +42,9 @@ private: int m_Socket; bool m_Active; - +#if VDRVERSNUM >= 10300 + cTimeMs lastTime; +#endif // CJT Ringbuffer rb; pthread_mutex_t ringLock; -- 2.39.5