{
switch (event)
{
+ case iDVBChannel::evtPreStart:
+ serviceEvent(eventPreStart);
+ break;
case iDVBChannel::evtEOF:
serviceEvent(eventEOF);
break;
{
int pmtpid = -1;
std::vector<ProgramAssociationSection*>::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();
}
serviceEvent(eventNoPAT);
}
-PyObject *eDVBServicePMTHandler::getCaIds()
+PyObject *eDVBServicePMTHandler::getCaIds(bool pair)
{
ePyObject ret;
if ( !getProgramInfo(prog) )
{
- int cnt=prog.caids.size();
- if (cnt)
+ if (pair)
+ {
+ int cnt=prog.caids.size();
+ if (cnt)
+ {
+ ret=PyList_New(cnt);
+ std::list<program::capid_pair>::iterator it(prog.caids.begin());
+ while(cnt--)
+ {
+ ePyObject tuple = PyTuple_New(2);
+ PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(it->caid));
+ PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong((it++)->capid));
+ PyList_SET_ITEM(ret, cnt, tuple);
+ }
+ }
+ }
+ else
{
+ std::set<program::capid_pair> set(prog.caids.begin(), prog.caids.end());
+ std::set<program::capid_pair>::iterator it(set.begin());
+ int cnt=set.size();
ret=PyList_New(cnt);
- std::set<uint16_t>::iterator it(prog.caids.begin());
while(cnt--)
- PyList_SET_ITEM(ret, cnt, PyInt_FromLong(*it++));
+ PyList_SET_ITEM(ret, cnt, PyInt_FromLong((it++)->caid));
}
}
return ret ? (PyObject*)ret : (PyObject*)PyList_New(0);
}
-int eDVBServicePMTHandler::getProgramInfo(struct program &program)
+int eDVBServicePMTHandler::getProgramInfo(program &program)
{
ePtr<eTable<ProgramMapSection> > ptr;
int cached_apid_ac3 = -1;
int first_ac3 = -1;
program.defaultAudioStream = 0;
+ audioStream *prev_audio = 0;
if ( m_service && !m_service->cacheEmpty() )
{
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;
+ 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;
}
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)
s.subtitling_type = 0x01; // EBU TELETEXT SUBTITLES
s.pid = program.textPid = (*es)->getPid();
TeletextDescriptor *d = (TeletextDescriptor*)(*desc);
+ isteletext = 1;
const VbiTeletextList *list = d->getVbiTeletexts();
for (VbiTeletextConstIterator it(list->begin()); it != list->end(); ++it)
{
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
case CA_DESCRIPTOR:
{
CaDescriptor *descr = (CaDescriptor*)(*desc);
- program.caids.insert(descr->getCaSystemId());
+ program::capid_pair pair;
+ pair.caid = descr->getCaSystemId();
+ pair.capid = descr->getCaPid();
+ program.caids.push_back(pair);
break;
}
default:
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 (issubtitle && (isaudio || isvideo))
+ if (isteletext && (isaudio || isvideo))
+ {
+ eDebug("ambiguous streamtype for PID %04x detected.. forced as teletext!", (*es)->getPid());
+ continue; // continue with next PID
+ }
+ else if (issubtitle && (isaudio || isvideo))
eDebug("ambiguous streamtype for PID %04x detected.. forced as subtitle!", (*es)->getPid());
else if (isaudio && isvideo)
eDebug("ambiguous streamtype for PID %04x detected.. forced as video!", (*es)->getPid());
- if (issubtitle)
+ if (issubtitle) // continue with next PID
continue;
else if (isvideo)
{
first_ac3 = program.audioStreams.size();
program.audioStreams.push_back(audio);
+ prev_audio = &program.audioStreams.back();
}
else
continue;
if ((*desc)->getTag() == CA_DESCRIPTOR)
{
CaDescriptor *descr = (CaDescriptor*)(*desc);
- program.caids.insert(descr->getCaSystemId());
+ program::capid_pair pair;
+ pair.caid = descr->getCaSystemId();
+ pair.capid = descr->getCaPid();
+ program.caids.push_back(pair);
}
}
}
audioStream s;
s.type = audioStream::atAC3;
s.pid = cached_apid_ac3;
+ s.rdsPid = -1;
program.audioStreams.push_back(s);
++cnt;
}
audioStream s;
s.type = audioStream::atMPEG;
s.pid = cached_apid_mpeg;
+ s.rdsPid = -1;
program.audioStreams.push_back(s);
++cnt;
}
program.textPid = cached_tpid;
}
CAID_LIST &caids = m_service->m_ca;
- for (CAID_LIST::iterator it(caids.begin()); it != caids.end(); ++it)
- program.caids.insert(*it);
+ for (CAID_LIST::iterator it(caids.begin()); it != caids.end(); ++it) {
+ program::capid_pair pair;
+ pair.caid = *it;
+ pair.capid = -1; // not known yet
+ program.caids.push_back(pair);
+ }
if ( cnt )
ret = 0;
}
}
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;
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
{
m_pmt_pid = pmt_pid;
}
}
- } else
- m_reference = parser.m_ref;
-
+ }
eDebug("alloc PVR");
/* allocate PVR */
res = m_resourceManager->allocatePVRChannel(m_pvr_channel);
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());
}
}