Merge branch 'bug_615_replace_rawfile' into m2ts_test
[vuplus_dvbapp] / lib / dvb / pmt.cpp
index ea4b96c..e54601c 100644 (file)
@@ -131,6 +131,8 @@ void eDVBServicePMTHandler::PATready(int)
        ePtr<eTable<ProgramAssociationSection> > ptr;
        if (!m_PAT.getCurrent(ptr))
        {
+               int service_id_single = -1;
+               int pmtpid_single = -1;
                int pmtpid = -1;
                std::vector<ProgramAssociationSection*>::const_iterator i;
                for (i = ptr->getSections().begin(); pmtpid == -1 && i != ptr->getSections().end(); ++i)
@@ -138,8 +140,22 @@ void eDVBServicePMTHandler::PATready(int)
                        const ProgramAssociationSection &pat = **i;
                        ProgramAssociationConstIterator program;
                        for (program = pat.getPrograms()->begin(); pmtpid == -1 && program != pat.getPrograms()->end(); ++program)
+                       {
                                if (eServiceID((*program)->getProgramNumber()) == m_reference.getServiceID())
                                        pmtpid = (*program)->getProgramMapPid();
+                               if (pmtpid_single == -1 && pmtpid == -1)
+                               {
+                                       pmtpid_single = (*program)->getProgramMapPid();
+                                       service_id_single = (*program)->getProgramNumber();
+                               }
+                               else
+                                       pmtpid_single = service_id_single = -1;
+                       }
+               }
+               if (pmtpid_single != -1) // only one PAT entry .. so we use this one
+               {
+                       m_reference.setServiceID(eServiceID(service_id_single));
+                       pmtpid = pmtpid_single;
                }
                if (pmtpid == -1)
                        serviceEvent(eventNoPATEntry);
@@ -675,6 +691,12 @@ void eDVBServicePMTHandler::SDTScanEvent(int event)
 
 int eDVBServicePMTHandler::tune(eServiceReferenceDVB &ref, int use_decode_demux, eCueSheet *cue, bool simulate, eDVBService *service)
 {
+       ePtr<iTsSource> s;
+       return tuneExt(ref, use_decode_demux, s, NULL, cue, simulate, service);
+}
+
+int eDVBServicePMTHandler::tuneExt(eServiceReferenceDVB &ref, int use_decode_demux, ePtr<iTsSource> &source, const char *streaminfo_file, eCueSheet *cue, bool simulate, eDVBService *service)
+{
        RESULT res=0;
        m_reference = ref;
        
@@ -704,7 +726,9 @@ int eDVBServicePMTHandler::tune(eServiceReferenceDVB &ref, int use_decode_demux,
                {
                        eWarning("no .meta file found, trying to find PMT pid");
                        eDVBTSTools tstools;
-                       if (tstools.openFile(ref.path.c_str()))
+                       if (source)
+                               tstools.setSource(source, streaminfo_file ? streaminfo_file : ref.path.c_str());
+                       else if (tstools.openFile(ref.path.c_str()))
                                eWarning("failed to open file");
                        else
                        {
@@ -757,7 +781,10 @@ int eDVBServicePMTHandler::tune(eServiceReferenceDVB &ref, int use_decode_demux,
                if (m_pvr_channel)
                {
                        m_pvr_channel->setCueSheet(cue);
-                       m_pvr_channel->playFile(ref.path.c_str());
+                       if (source)
+                               m_pvr_channel->playSource(source, streaminfo_file);
+                       else
+                               m_pvr_channel->playFile(ref.path.c_str());
                }
        }