fixes PMT pid searching for TS files without meta file and sid in servicref (this...
[vuplus_dvbapp] / lib / dvb / pmt.cpp
index e54601c..cb80b00 100644 (file)
@@ -229,8 +229,26 @@ int eDVBServicePMTHandler::getProgramInfo(struct program &program)
                        for (i = ptr->getSections().begin(); i != ptr->getSections().end(); ++i)
                        {
                                const ProgramMapSection &pmt = **i;
+                               int is_hdmv = 0;
+
                                program.pcrPid = pmt.getPcrPid();
 
+                               for (DescriptorConstIterator desc = pmt.getDescriptors()->begin();
+                                       desc != pmt.getDescriptors()->end(); ++desc)
+                               {
+                                       if ((*desc)->getTag() == CA_DESCRIPTOR)
+                                       {
+                                               CaDescriptor *descr = (CaDescriptor*)(*desc);
+                                               program.caids.insert(descr->getCaSystemId());
+                                       }
+                                       else if ((*desc)->getTag() == REGISTRATION_DESCRIPTOR)
+                                       {
+                                               RegistrationDescriptor *d = (RegistrationDescriptor*)(*desc);
+                                               if (d->getFormatIdentifier() == 0x48444d56) // HDMV
+                                                       is_hdmv = 1;
+                                       }
+                               }
+
                                ElementaryStreamInfoConstIterator es;
                                for (es = pmt.getEsInfo()->begin(); es != pmt.getEsInfo()->end(); ++es)
                                {
@@ -286,25 +304,34 @@ int eDVBServicePMTHandler::getProgramInfo(struct program &program)
                                                        audio.type = audioStream::atAACHE;
                                                        forced_audio = 1;
                                                }
-                                       case 0x80: // user private ... but blueray LPCM
-                                               if (!isvideo && !isaudio)
+                                       case 0x80: // user private ... but bluray LPCM
+                                       case 0xA0: // bluray secondary LPCM
+                                               if (!isvideo && !isaudio && is_hdmv)
                                                {
                                                        isaudio = 1;
                                                        audio.type = audioStream::atLPCM;
                                                }
-                                       case 0x81: // user private ... but blueray AC3
-                                               if (!isvideo && !isaudio)
+                                       case 0x81: // user private ... but bluray AC3
+                                       case 0xA1: // bluray secondary AC3
+                                               if (!isvideo && !isaudio && is_hdmv)
                                                {
                                                        isaudio = 1;
                                                        audio.type = audioStream::atAC3;
                                                }
-                                       case 0x82: // Blueray DTS (dvb user private...)
-                                       case 0xA2: // Blueray secondary DTS
-                                               if (!isvideo && !isaudio)
+                                       case 0x82: // bluray DTS (dvb user private...)
+                                       case 0xA2: // bluray secondary DTS
+                                               if (!isvideo && !isaudio && is_hdmv)
                                                {
                                                        isaudio = 1;
                                                        audio.type = audioStream::atDTS;
                                                }
+                                       case 0x86: // bluray DTS-HD (dvb user private...)
+                                       case 0xA6: // bluray secondary DTS-HD
+                                               if (!isvideo && !isaudio && is_hdmv)
+                                               {
+                                                       isaudio = 1;
+                                                       audio.type = audioStream::atDTSHD;
+                                               }
                                        case 0x06: // PES Private
                                        case 0xEA: // TS_PSI_ST_SMPTE_VC1
                                        {
@@ -493,9 +520,9 @@ int eDVBServicePMTHandler::getProgramInfo(struct program &program)
                                        default:
                                                break;
                                        }
-                                       if (isteletext && (isaudio || isvideo)) 
+                                       if (isteletext && (isaudio || isvideo))
                                        {
-                                               eDebug("ambiguous streamtype for PID %04x detected.. forced as teletext!", (*es)->getPid());                                    
+                                               eDebug("ambiguous streamtype for PID %04x detected.. forced as teletext!", (*es)->getPid());
                                                continue; // continue with next PID
                                        }
                                        else if (issubtitle && (isaudio || isvideo))
@@ -533,15 +560,6 @@ int eDVBServicePMTHandler::getProgramInfo(struct program &program)
                                        else
                                                continue;
                                }
-                               for (DescriptorConstIterator desc = pmt.getDescriptors()->begin();
-                                       desc != pmt.getDescriptors()->end(); ++desc)
-                               {
-                                       if ((*desc)->getTag() == CA_DESCRIPTOR)
-                                       {
-                                               CaDescriptor *descr = (CaDescriptor*)(*desc);
-                                               program.caids.insert(descr->getCaSystemId());
-                                       }
-                               }
                        }
                        ret = 0;
 
@@ -724,13 +742,12 @@ int eDVBServicePMTHandler::tuneExt(eServiceReferenceDVB &ref, int use_decode_dem
        {
                if (!ref.getServiceID().get() /* incorrect sid in meta file or recordings.epl*/ )
                {
-                       eWarning("no .meta file found, trying to find PMT pid");
                        eDVBTSTools tstools;
+                       bool b = source || !tstools.openFile(ref.path.c_str(), 1);
+                       eWarning("no .meta file found, trying to find PMT pid");
                        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
+                               tstools.setSource(source, NULL);
+                       if (b)
                        {
                                int service_id, pmt_pid;
                                if (!tstools.findPMT(pmt_pid, service_id))
@@ -740,6 +757,8 @@ int eDVBServicePMTHandler::tuneExt(eServiceReferenceDVB &ref, int use_decode_dem
                                        m_pmt_pid = pmt_pid;
                                }
                        }
+                       else
+                               eWarning("no valid source to find PMT pid!");
                }
                eDebug("alloc PVR");
                        /* allocate PVR */