abort radiotext parser when 20 seconds no ancillary data is received
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 15 Jan 2007 22:59:25 +0000 (22:59 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 15 Jan 2007 22:59:25 +0000 (22:59 +0000)
lib/dvb/radiotext.cpp
lib/dvb/radiotext.h

index c165907..34a5acd 100644 (file)
@@ -7,6 +7,7 @@ DEFINE_REF(eDVBRadioTextParser);
 
 eDVBRadioTextParser::eDVBRadioTextParser(iDVBDemux *demux)
        :bytesread(0), ptr(0), p1(-1), p2(-1), msgPtr(0), state(0)
 
 eDVBRadioTextParser::eDVBRadioTextParser(iDVBDemux *demux)
        :bytesread(0), ptr(0), p1(-1), p2(-1), msgPtr(0), state(0)
+       ,m_abortTimer(eApp)
 {
        setStreamID(0xC0, 0xC0);
 
 {
        setStreamID(0xC0, 0xC0);
 
@@ -14,6 +15,7 @@ eDVBRadioTextParser::eDVBRadioTextParser(iDVBDemux *demux)
                eDebug("failed to create PES reader!");
        else
                m_pes_reader->connectRead(slot(*this, &eDVBRadioTextParser::processData), m_read_connection);
                eDebug("failed to create PES reader!");
        else
                m_pes_reader->connectRead(slot(*this, &eDVBRadioTextParser::processData), m_read_connection);
+       CONNECT(m_abortTimer.timeout, eDVBRadioTextParser::abortNonAvail);
 }
 
 #define SWAP(x)        ((x<<8)|(x>>8))
 }
 
 #define SWAP(x)        ((x<<8)|(x>>8))
@@ -125,6 +127,7 @@ void eDVBRadioTextParser::processPESPacket(__u8 *data, int len)
 
                if (data[offs] == 0xFD)
                {
 
                if (data[offs] == 0xFD)
                {
+                       m_abortTimer.stop();
                        int ancillary_len = 1 + data[offs - 1];
                        offs -= ancillary_len;
                        while(offs < pos)
                        int ancillary_len = 1 + data[offs - 1];
                        offs -= ancillary_len;
                        while(offs < pos)
@@ -259,9 +262,15 @@ void eDVBRadioTextParser::gotAncillaryByte(__u8 data)
 
 int eDVBRadioTextParser::start(int pid)
 {
 
 int eDVBRadioTextParser::start(int pid)
 {
-       if (m_pes_reader)
-               return m_pes_reader->start(pid);
-       else
-               return -1;
+       int ret = -1;
+       if (m_pes_reader && !(ret = m_pes_reader->start(pid)))
+               m_abortTimer.startLongTimer(20);
+       return ret;
 }
 
 }
 
+void eDVBRadioTextParser::abortNonAvail()
+{
+       eDebug("no ancillary data in audio stream... abort radiotext pes parser");
+       if (m_pes_reader)
+               m_pes_reader->stop();
+}
index ba42ded..11fa7e4 100644 (file)
@@ -18,11 +18,13 @@ public:
        void connectUpdatedRadiotext(const Slot0<void> &slot, ePtr<eConnection> &connection);
        const char *getCurrentText() { return msgPtr ? (const char*)message : ""; }
 private:
        void connectUpdatedRadiotext(const Slot0<void> &slot, ePtr<eConnection> &connection);
        const char *getCurrentText() { return msgPtr ? (const char*)message : ""; }
 private:
+       void abortNonAvail();
        void processPESPacket(__u8 *pkt, int len);
        void gotAncillaryByte(__u8 data);
        ePtr<iDVBPESReader> m_pes_reader;
        ePtr<eConnection> m_read_connection;
        Signal0<void> m_updated_radiotext;
        void processPESPacket(__u8 *pkt, int len);
        void gotAncillaryByte(__u8 data);
        ePtr<iDVBPESReader> m_pes_reader;
        ePtr<eConnection> m_read_connection;
        Signal0<void> m_updated_radiotext;
+       eTimer m_abortTimer;
 };
 
 #endif
 };
 
 #endif