X-Git-Url: http://code.vuplus.com/gitweb/?a=blobdiff_plain;f=lib%2Fdvb%2Fpmt.cpp;h=d44766f1d74bad6bf2f256d9727f303b94a884bb;hb=070b9256befecb72bbdc7052aef61e5f2f0b9515;hp=55ce6d49a45477fc18b805ec95cc0df62c75168e;hpb=a5b2405cf17234cf9396f6b45f3e10a44a5eceaf;p=vuplus_dvbapp diff --git a/lib/dvb/pmt.cpp b/lib/dvb/pmt.cpp index 55ce6d4..d44766f 100644 --- a/lib/dvb/pmt.cpp +++ b/lib/dvb/pmt.cpp @@ -75,6 +75,9 @@ void eDVBServicePMTHandler::channelEvent(iDVBChannel *channel, int event) { switch (event) { + case iDVBChannel::evtPreStart: + serviceEvent(eventPreStart); + break; case iDVBChannel::evtEOF: serviceEvent(eventEOF); break; @@ -128,15 +131,31 @@ void eDVBServicePMTHandler::PATready(int) ePtr > ptr; if (!m_PAT.getCurrent(ptr)) { + int service_id_single = -1; + int pmtpid_single = -1; int pmtpid = -1; std::vector::const_iterator i; - for (i = ptr->getSections().begin(); i != ptr->getSections().end(); ++i) + for (i = ptr->getSections().begin(); pmtpid == -1 && i != ptr->getSections().end(); ++i) { const ProgramAssociationSection &pat = **i; ProgramAssociationConstIterator program; - for (program = pat.getPrograms()->begin(); program != pat.getPrograms()->end(); ++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); @@ -184,6 +203,7 @@ int eDVBServicePMTHandler::getProgramInfo(struct program &program) int first_ac3 = -1; program.defaultAudioStream = 0; + audioStream *prev_audio = 0; if ( m_service && !m_service->cacheEmpty() ) { @@ -209,19 +229,39 @@ 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) { int isaudio = 0, isvideo = 0, issubtitle = 0, forced_video = 0, forced_audio = 0, isteletext = 0; + int streamtype = (*es)->getType(); videoStream video; audioStream audio; audio.component_tag=video.component_tag=-1; video.type = videoStream::vtMPEG2; audio.type = audioStream::atMPEG; + audio.rdsPid = -1; - switch ((*es)->getType()) + switch (streamtype) { case 0x1b: // AVC Video Stream (MPEG4 H264) video.type = videoStream::vtMPEG4_H264; @@ -264,32 +304,44 @@ 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 + { + int num_descriptors = 0; for (DescriptorConstIterator desc = (*es)->getDescriptors()->begin(); desc != (*es)->getDescriptors()->end(); ++desc) { uint8_t tag = (*desc)->getTag(); /* check descriptors to get the exakt stream type. */ + ++num_descriptors; if (!forced_video && !forced_audio) { switch (tag) @@ -400,9 +452,9 @@ int eDVBServicePMTHandler::getProgramInfo(struct program &program) case 0x56432d31: // == 'VC-1' { const AdditionalIdentificationInfoVector *vec = d->getAdditionalIdentificationInfo(); - if (vec->size() > 1 && (*vec)[1] == 0x01) // subdescriptor tag + if (vec->size() > 1 && (*vec)[0] == 0x01) // subdescriptor tag { - if ((*vec)[2] >= 0x90) // profile_level + if ((*vec)[1] >= 0x90) // profile_level video.type = videoStream::vtVC1; // advanced profile else video.type = videoStream::vtVC1_SM; // simple main @@ -458,12 +510,19 @@ int eDVBServicePMTHandler::getProgramInfo(struct program &program) break; } } + if (!num_descriptors && streamtype == 0x06 && prev_audio) + { + prev_audio->rdsPid = (*es)->getPid(); + eDebug("Rds PID %04x detected ? ! ?", prev_audio->rdsPid); + } + prev_audio = 0; + } default: break; } - if (isteletext != -1 && (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)) @@ -496,19 +555,11 @@ int eDVBServicePMTHandler::getProgramInfo(struct program &program) first_ac3 = program.audioStreams.size(); program.audioStreams.push_back(audio); + prev_audio = &program.audioStreams.back(); } 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; @@ -548,6 +599,7 @@ int eDVBServicePMTHandler::getProgramInfo(struct program &program) audioStream s; s.type = audioStream::atAC3; s.pid = cached_apid_ac3; + s.rdsPid = -1; program.audioStreams.push_back(s); ++cnt; } @@ -556,6 +608,7 @@ int eDVBServicePMTHandler::getProgramInfo(struct program &program) audioStream s; s.type = audioStream::atMPEG; s.pid = cached_apid_mpeg; + s.rdsPid = -1; program.audioStreams.push_back(s); ++cnt; } @@ -656,6 +709,12 @@ void eDVBServicePMTHandler::SDTScanEvent(int event) int eDVBServicePMTHandler::tune(eServiceReferenceDVB &ref, int use_decode_demux, eCueSheet *cue, bool simulate, eDVBService *service) { + ePtr s; + return tuneExt(ref, use_decode_demux, s, NULL, cue, simulate, service); +} + +int eDVBServicePMTHandler::tuneExt(eServiceReferenceDVB &ref, int use_decode_demux, ePtr &source, const char *streaminfo_file, eCueSheet *cue, bool simulate, eDVBService *service) +{ RESULT res=0; m_reference = ref; @@ -681,14 +740,13 @@ int eDVBServicePMTHandler::tune(eServiceReferenceDVB &ref, int use_decode_demux, eDVBCIInterfaces::getInstance()->addPMTHandler(this); } else if (!simulate) // no simulation of playback services { - eDVBMetaParser parser; - - int ret=parser.parseFile(ref.path); - if (ret || !parser.m_ref.getServiceID().get() /* incorrect sid in meta file or recordings.epl*/ ) + if (!ref.getServiceID().get() /* incorrect sid in meta file or recordings.epl*/ ) { 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 { @@ -700,9 +758,7 @@ int eDVBServicePMTHandler::tune(eServiceReferenceDVB &ref, int use_decode_demux, m_pmt_pid = pmt_pid; } } - } else - m_reference = parser.m_ref; - + } eDebug("alloc PVR"); /* allocate PVR */ res = m_resourceManager->allocatePVRChannel(m_pvr_channel); @@ -743,7 +799,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()); } }