1 #include <lib/base/eerror.h>
2 #include <lib/dvb/pmt.h>
3 #include <lib/dvb/specs.h>
4 #include <lib/dvb/dvb.h>
5 #include <lib/dvb/metaparser.h>
6 #include <lib/dvb_ci/dvbci.h>
7 #include <lib/dvb/epgcache.h>
8 #include <lib/dvb/scan.h>
9 #include <dvbsi++/ca_descriptor.h>
10 #include <dvbsi++/ca_program_map_section.h>
11 #include <dvbsi++/teletext_descriptor.h>
12 #include <dvbsi++/descriptor_tag.h>
13 #include <dvbsi++/iso639_language_descriptor.h>
14 #include <dvbsi++/stream_identifier_descriptor.h>
15 #include <dvbsi++/subtitling_descriptor.h>
16 #include <dvbsi++/teletext_descriptor.h>
18 eDVBServicePMTHandler::eDVBServicePMTHandler()
19 :m_ca_servicePtr(0), m_dvb_scan(0), m_decode_demux_num(0xFF)
21 m_use_decode_demux = 0;
23 eDVBResourceManager::getInstance(m_resourceManager);
24 CONNECT(m_PMT.tableReady, eDVBServicePMTHandler::PMTready);
25 CONNECT(m_PAT.tableReady, eDVBServicePMTHandler::PATready);
28 eDVBServicePMTHandler::~eDVBServicePMTHandler()
33 void eDVBServicePMTHandler::channelStateChanged(iDVBChannel *channel)
36 channel->getState(state);
38 if ((m_last_channel_state != iDVBChannel::state_ok)
39 && (state == iDVBChannel::state_ok) && (!m_demux))
42 if (m_channel->getDemux(m_demux, (!m_use_decode_demux) ? 0 : iDVBChannel::capDecode))
43 eDebug("Allocating %s-decoding a demux for now tuned-in channel failed.", m_use_decode_demux ? "" : "non-");
45 serviceEvent(eventTuned);
49 eDebug("ok ... now we start!!");
52 m_PAT.begin(eApp, eDVBPATSpec(), m_demux);
54 m_PMT.begin(eApp, eDVBPMTSpec(m_pmt_pid, m_reference.getServiceID().get()), m_demux);
56 if ( m_service && !m_service->cacheEmpty() )
57 serviceEvent(eventNewProgramInfo);
59 } else if ((m_last_channel_state != iDVBChannel::state_failed) &&
60 (state == iDVBChannel::state_failed))
62 eDebug("tune failed.");
63 serviceEvent(eventTuneFailed);
67 void eDVBServicePMTHandler::channelEvent(iDVBChannel *channel, int event)
71 case iDVBChannel::evtEOF:
72 serviceEvent(eventEOF);
74 case iDVBChannel::evtSOF:
75 serviceEvent(eventSOF);
82 void eDVBServicePMTHandler::PMTready(int error)
85 serviceEvent(eventNoPMT);
88 m_have_cached_program = false;
89 serviceEvent(eventNewProgramInfo);
90 if (!m_pvr_channel) // don't send campmt to camd.socket for playbacked services
92 eEPGCache::getInstance()->PMTready(this);
95 int demuxes[2] = {0,0};
97 m_demux->getCADemuxID(tmp);
99 if (m_decode_demux_num != 0xFF)
100 demuxes[1]=m_decode_demux_num;
102 demuxes[1]=demuxes[0];
103 eDVBCAService::register_service(m_reference, demuxes, m_ca_servicePtr);
104 eDVBCIInterfaces::getInstance()->recheckPMTHandlers();
106 eDVBCIInterfaces::getInstance()->gotPMT(this);
110 ePtr<eTable<ProgramMapSection> > ptr;
111 if (!m_PMT.getCurrent(ptr))
112 m_ca_servicePtr->buildCAPMT(ptr);
114 eDebug("eDVBServicePMTHandler cannot call buildCAPMT");
119 void eDVBServicePMTHandler::PATready(int)
121 ePtr<eTable<ProgramAssociationSection> > ptr;
122 if (!m_PAT.getCurrent(ptr))
125 std::vector<ProgramAssociationSection*>::const_iterator i;
126 for (i = ptr->getSections().begin(); i != ptr->getSections().end(); ++i)
128 const ProgramAssociationSection &pat = **i;
129 ProgramAssociationConstIterator program;
130 for (program = pat.getPrograms()->begin(); program != pat.getPrograms()->end(); ++program)
131 if (eServiceID((*program)->getProgramNumber()) == m_reference.getServiceID())
132 pmtpid = (*program)->getProgramMapPid();
135 serviceEvent(eventNoPATEntry);
137 m_PMT.begin(eApp, eDVBPMTSpec(pmtpid, m_reference.getServiceID().get()), m_demux);
139 serviceEvent(eventNoPAT);
142 PyObject *eDVBServicePMTHandler::getCaIds()
148 if ( !getProgramInfo(prog) )
150 int cnt=prog.caids.size();
154 std::set<uint16_t>::iterator it(prog.caids.begin());
156 PyList_SET_ITEM(ret, cnt, PyInt_FromLong(*it++));
160 return ret ? (PyObject*)ret : (PyObject*)PyList_New(0);
163 int eDVBServicePMTHandler::getProgramInfo(struct program &program)
165 ePtr<eTable<ProgramMapSection> > ptr;
166 int cached_apid_ac3 = -1;
167 int cached_apid_mpeg = -1;
168 int cached_vpid = -1;
169 int cached_tpid = -1;
172 program.videoStreams.clear();
173 program.audioStreams.clear();
176 program.textPid = -1;
178 if ( m_service && !m_service->cacheEmpty() )
180 cached_vpid = m_service->getCacheEntry(eDVBService::cVPID);
181 cached_apid_mpeg = m_service->getCacheEntry(eDVBService::cAPID);
182 cached_apid_ac3 = m_service->getCacheEntry(eDVBService::cAC3PID);
183 cached_tpid = m_service->getCacheEntry(eDVBService::cTPID);
186 if ( ((m_service && m_service->usePMT()) || !m_service) && !m_PMT.getCurrent(ptr))
188 if (m_have_cached_program)
190 program = m_cached_program;
195 eDVBTableSpec table_spec;
196 ptr->getSpec(table_spec);
197 program.pmtPid = table_spec.pid < 0x1fff ? table_spec.pid : -1;
198 std::vector<ProgramMapSection*>::const_iterator i;
199 for (i = ptr->getSections().begin(); i != ptr->getSections().end(); ++i)
201 const ProgramMapSection &pmt = **i;
202 program.pcrPid = pmt.getPcrPid();
204 ElementaryStreamInfoConstIterator es;
205 for (es = pmt.getEsInfo()->begin(); es != pmt.getEsInfo()->end(); ++es)
207 int isaudio = 0, isvideo = 0;
210 audio.component_tag=video.component_tag=-1;
211 video.type = videoStream::vtMPEG2;
213 switch ((*es)->getType())
215 case 0x1b: // AVC Video Stream (MPEG4 H264)
216 video.type = videoStream::vtMPEG4_H264;
217 case 0x01: // MPEG 1 video
218 case 0x02: // MPEG 2 video
220 //break; fall through !!!
221 case 0x03: // MPEG 1 audio
222 case 0x04: // MPEG 2 audio:
226 audio.type = audioStream::atMPEG;
228 //break; fall through !!!
229 case 0x06: // PES Private
230 /* PES private can contain AC-3, DTS or lots of other stuff.
231 check descriptors to get the exact type. */
232 for (DescriptorConstIterator desc = (*es)->getDescriptors()->begin();
233 desc != (*es)->getDescriptors()->end(); ++desc)
235 switch ((*desc)->getTag())
237 case SUBTITLING_DESCRIPTOR:
239 SubtitlingDescriptor *d = (SubtitlingDescriptor*)(*desc);
240 const SubtitlingList *list = d->getSubtitlings();
242 s.pid = (*es)->getPid();
243 for (SubtitlingConstIterator it(list->begin()); it != list->end(); ++it)
245 s.subtitling_type = (*it)->getSubtitlingType();
246 s.composition_page_id = (*it)->getCompositionPageId();
247 s.ancillary_page_id = (*it)->getAncillaryPageId();
248 s.language_code = (*it)->getIso639LanguageCode();
249 // eDebug("add dvb subtitle %s PID %04x, type %d, composition page %d, ancillary_page %d",
250 // s.language_code.c_str(), s.pid, s.subtitling_type, s.composition_page_id, s.ancillary_page_id);
251 program.subtitleStreams.push_back(s);
255 case TELETEXT_DESCRIPTOR:
256 if ( program.textPid == -1 || (*es)->getPid() == cached_tpid )
259 s.subtitling_type = 0x01; // EBU TELETEXT SUBTITLES
260 s.pid = program.textPid = (*es)->getPid();
261 TeletextDescriptor *d = (TeletextDescriptor*)(*desc);
262 const VbiTeletextList *list = d->getVbiTeletexts();
263 for (VbiTeletextConstIterator it(list->begin()); it != list->end(); ++it)
265 switch((*it)->getTeletextType())
267 case 0x02: // Teletext subtitle page
268 case 0x05: // Teletext subtitle page for hearing impaired pepople
269 s.language_code = (*it)->getIso639LanguageCode();
270 s.teletext_page_number = (*it)->getTeletextPageNumber();
271 s.teletext_magazine_number = (*it)->getTeletextMagazineNumber();
272 // eDebug("add teletext subtitle %s PID %04x, page number %d, magazine number %d",
273 // s.language_code.c_str(), s.pid, s.teletext_page_number, s.teletext_magazine_number);
274 program.subtitleStreams.push_back(s);
282 audio.type = audioStream::atDTS;
286 audio.type = audioStream::atAAC;
290 audio.type = audioStream::atAC3;
292 case ISO_639_LANGUAGE_DESCRIPTOR:
295 const Iso639LanguageList *languages = ((Iso639LanguageDescriptor*)*desc)->getIso639Languages();
296 /* use last language code */
297 for (Iso639LanguageConstIterator i(languages->begin()); i != languages->end(); ++i)
298 audio.language_code = (*i)->getIso639LanguageCode();
301 case STREAM_IDENTIFIER_DESCRIPTOR:
302 audio.component_tag =
303 video.component_tag =
304 ((StreamIdentifierDescriptor*)*desc)->getComponentTag();
308 CaDescriptor *descr = (CaDescriptor*)(*desc);
309 program.caids.insert(descr->getCaSystemId());
318 audio.pid = (*es)->getPid();
319 if ( !program.audioStreams.empty() &&
320 ( audio.pid == cached_apid_ac3 || audio.pid == cached_apid_mpeg) )
322 program.audioStreams.push_back(program.audioStreams[0]);
323 program.audioStreams[0] = audio;
326 program.audioStreams.push_back(audio);
330 video.pid = (*es)->getPid();
331 if ( !program.videoStreams.empty() && video.pid == cached_vpid )
333 program.videoStreams.push_back(program.videoStreams[0]);
334 program.videoStreams[0] = video;
337 program.videoStreams.push_back(video);
342 for (DescriptorConstIterator desc = pmt.getDescriptors()->begin();
343 desc != pmt.getDescriptors()->end(); ++desc)
345 if ((*desc)->getTag() == CA_DESCRIPTOR)
347 CaDescriptor *descr = (CaDescriptor*)(*desc);
348 program.caids.insert(descr->getCaSystemId());
353 m_cached_program = program;
354 m_have_cached_program = true;
356 } else if ( m_service && !m_service->cacheEmpty() )
358 int cached_pcrpid = m_service->getCacheEntry(eDVBService::cPCRPID),
359 vpidtype = m_service->getCacheEntry(eDVBService::cVTYPE),
361 if ( vpidtype == -1 )
362 vpidtype = videoStream::vtMPEG2;
363 if ( cached_vpid != -1 )
368 program.videoStreams.push_back(s);
371 if ( cached_apid_ac3 != -1 )
374 s.type = audioStream::atAC3;
375 s.pid = cached_apid_ac3;
376 program.audioStreams.push_back(s);
379 if ( cached_apid_mpeg != -1 )
382 s.type = audioStream::atMPEG;
383 s.pid = cached_apid_mpeg;
384 program.audioStreams.push_back(s);
387 if ( cached_pcrpid != -1 )
390 program.pcrPid = cached_pcrpid;
392 if ( cached_tpid != -1 )
395 program.textPid = cached_tpid;
397 CAID_LIST &caids = m_service->m_ca;
398 for (CAID_LIST::iterator it(caids.begin()); it != caids.end(); ++it)
399 program.caids.insert(*it);
406 int eDVBServicePMTHandler::getChannel(eUsePtr<iDVBChannel> &channel)
415 int eDVBServicePMTHandler::getDataDemux(ePtr<iDVBDemux> &demux)
424 int eDVBServicePMTHandler::getDecodeDemux(ePtr<iDVBDemux> &demux)
427 /* if we're using the decoding demux as data source
428 (for example in pvr playbacks), return that one. */
429 if (m_use_decode_demux)
435 ASSERT(m_channel); /* calling without a previous ::tune is certainly bad. */
437 ret = m_channel->getDemux(demux, iDVBChannel::capDecode);
439 demux->getCADemuxID(m_decode_demux_num);
444 int eDVBServicePMTHandler::getPVRChannel(ePtr<iDVBPVRChannel> &pvr_channel)
446 pvr_channel = m_pvr_channel;
453 void eDVBServicePMTHandler::SDTScanEvent(int event)
457 case eDVBScan::evtFinish:
459 ePtr<iDVBChannelList> db;
460 if (m_resourceManager->getChannelList(db) != 0)
461 eDebug("no channel list");
464 m_dvb_scan->insertInto(db, true);
465 eDebug("sdt update done!");
475 int eDVBServicePMTHandler::tune(eServiceReferenceDVB &ref, int use_decode_demux, eCueSheet *cue)
480 m_use_decode_demux = use_decode_demux;
482 /* is this a normal (non PVR) channel? */
483 if (ref.path.empty())
486 ref.getChannelID(chid);
487 res = m_resourceManager->allocateChannel(chid, m_channel);
488 eDebug("allocate Channel: res %d", res);
490 ePtr<iDVBChannelList> db;
491 if (!m_resourceManager->getChannelList(db))
492 db->getService((eServiceReferenceDVB&)m_reference, m_service);
495 eDVBCIInterfaces::getInstance()->addPMTHandler(this);
498 eDVBMetaParser parser;
500 int ret=parser.parseFile(ref.path);
501 if (ret || !parser.m_ref.getServiceID().get() /* incorrect sid in meta file or recordings.epl*/ )
503 eWarning("no .meta file found, trying to find PMT pid");
505 if (tstools.openFile(ref.path.c_str()))
506 eWarning("failed to open file");
509 int service_id, pmt_pid;
510 if (!tstools.findPMT(pmt_pid, service_id))
512 eDebug("PMT pid found on pid %04x, service id %d", pmt_pid, service_id);
513 m_reference.setServiceID(service_id);
518 m_reference = parser.m_ref;
522 res = m_resourceManager->allocatePVRChannel(m_pvr_channel);
524 eDebug("allocatePVRChannel failed!\n");
525 m_channel = m_pvr_channel;
530 m_channel->connectStateChange(
531 slot(*this, &eDVBServicePMTHandler::channelStateChanged),
532 m_channelStateChanged_connection);
533 m_last_channel_state = -1;
534 channelStateChanged(m_channel);
536 m_channel->connectEvent(
537 slot(*this, &eDVBServicePMTHandler::channelEvent),
538 m_channelEvent_connection);
540 if (ref.path.empty())
543 m_dvb_scan = new eDVBScan(m_channel, false, false);
544 m_dvb_scan->connectEvent(slot(*this, &eDVBServicePMTHandler::SDTScanEvent), m_scan_event_connection);
548 serviceEvent(eventNoResources);
554 m_pvr_channel->setCueSheet(cue);
555 m_pvr_channel->playFile(ref.path.c_str());
561 void eDVBServicePMTHandler::free()
568 int demuxes[2] = {0,0};
570 m_demux->getCADemuxID(tmp);
572 if (m_decode_demux_num != 0xFF)
573 demuxes[1]=m_decode_demux_num;
575 demuxes[1]=demuxes[0];
576 ePtr<eTable<ProgramMapSection> > ptr;
577 m_PMT.getCurrent(ptr);
578 eDVBCAService::unregister_service(m_reference, demuxes, ptr);
583 eDVBCIInterfaces::getInstance()->removePMTHandler(this);
587 m_pvr_channel->stopFile();
588 m_pvr_channel->setCueSheet(0);
598 std::map<eServiceReferenceDVB, eDVBCAService*> eDVBCAService::exist;
600 eDVBCAService::eDVBCAService()
601 :m_prev_build_hash(0), m_sendstate(0), m_retryTimer(eApp)
603 memset(m_used_demux, 0xFF, sizeof(m_used_demux));
604 CONNECT(m_retryTimer.timeout, eDVBCAService::sendCAPMT);
608 eDVBCAService::~eDVBCAService()
610 eDebug("[eDVBCAService] free service %s", m_service.toString().c_str());
614 RESULT eDVBCAService::register_service( const eServiceReferenceDVB &ref, int demux_nums[2], eDVBCAService *&caservice )
616 CAServiceMap::iterator it = exist.find(ref);
617 if ( it != exist.end() )
618 caservice = it->second;
621 caservice = (exist[ref]=new eDVBCAService());
622 caservice->m_service = ref;
623 eDebug("[eDVBCAService] new service %s", ref.toString().c_str() );
626 int loops = demux_nums[0] != demux_nums[1] ? 2 : 1;
627 for (int i=0; i < loops; ++i)
629 // search free demux entry
630 int iter=0, max_demux_slots = sizeof(caservice->m_used_demux);
632 while ( iter < max_demux_slots && caservice->m_used_demux[iter] != 0xFF )
635 if ( iter < max_demux_slots )
637 caservice->m_used_demux[iter] = demux_nums[i] & 0xFF;
638 eDebug("[eDVBCAService] add demux %d to slot %d service %s", caservice->m_used_demux[iter], iter, ref.toString().c_str());
642 eDebug("[eDVBCAService] no more demux slots free for service %s!!", ref.toString().c_str());
649 RESULT eDVBCAService::unregister_service( const eServiceReferenceDVB &ref, int demux_nums[2], eTable<ProgramMapSection> *ptr )
651 CAServiceMap::iterator it = exist.find(ref);
652 if ( it == exist.end() )
654 eDebug("[eDVBCAService] try to unregister non registered %s", ref.toString().c_str());
659 eDVBCAService *caservice = it->second;
660 int loops = demux_nums[0] != demux_nums[1] ? 2 : 1;
661 for (int i=0; i < loops; ++i)
665 used_demux_slots = 0,
666 max_demux_slots = sizeof(caservice->m_used_demux)/sizeof(int);
667 while ( iter < max_demux_slots )
669 if ( caservice->m_used_demux[iter] != 0xFF )
671 if ( !freed && caservice->m_used_demux[iter] == demux_nums[i] )
673 eDebug("[eDVBCAService] free slot %d demux %d for service %s", iter, caservice->m_used_demux[iter], caservice->m_service.toString().c_str() );
674 caservice->m_used_demux[iter] = 0xFF;
683 eDebug("[eDVBCAService] couldn't free demux slot for demux %d", demux_nums[i]);
686 if (!used_demux_slots) // no more used.. so we remove it
694 it->second->buildCAPMT(ptr);
696 eDebug("[eDVBCAService] can not send updated demux info");
704 void eDVBCAService::Connect()
706 memset(&m_servaddr, 0, sizeof(struct sockaddr_un));
707 m_servaddr.sun_family = AF_UNIX;
708 strcpy(m_servaddr.sun_path, "/tmp/camd.socket");
709 m_clilen = sizeof(m_servaddr.sun_family) + strlen(m_servaddr.sun_path);
710 m_sock = socket(PF_UNIX, SOCK_STREAM, 0);
711 connect(m_sock, (struct sockaddr *) &m_servaddr, m_clilen);
712 fcntl(m_sock, F_SETFL, O_NONBLOCK);
714 setsockopt(m_sock, SOL_SOCKET, SO_REUSEADDR, &val, 4);
717 void eDVBCAService::buildCAPMT(eTable<ProgramMapSection> *ptr)
722 eDVBTableSpec table_spec;
723 ptr->getSpec(table_spec);
725 int pmtpid = table_spec.pid,
726 pmt_version = table_spec.version;
728 uint8_t demux_mask = 0;
731 int iter=0, max_demux_slots = sizeof(m_used_demux);
732 while ( iter < max_demux_slots )
734 if ( m_used_demux[iter] != 0xFF )
736 if ( m_used_demux[iter] > data_demux )
737 data_demux = m_used_demux[iter];
738 demux_mask |= (1 << m_used_demux[iter]);
743 if ( data_demux == -1 )
745 eDebug("[eDVBCAService] no data demux found for service %s", m_service.toString().c_str() );
749 eDebug("demux %d mask %02x prevhash %08x", data_demux, demux_mask, m_prev_build_hash);
751 unsigned int build_hash = (pmtpid << 16);
752 build_hash |= (demux_mask << 8);
753 build_hash |= (pmt_version&0xFF);
755 if ( build_hash == m_prev_build_hash )
757 eDebug("[eDVBCAService] don't build/send the same CA PMT twice");
761 std::vector<ProgramMapSection*>::const_iterator i=ptr->getSections().begin();
762 if ( i != ptr->getSections().end() )
764 CaProgramMapSection capmt(*i++, m_prev_build_hash ? 0x05 /*update*/ : 0x03 /*only*/, 0x01 );
766 while( i != ptr->getSections().end() )
772 // add our private descriptors to capmt
775 tmp[0]=0x84; // pmt pid
779 capmt.injectDescriptor(tmp, false);
781 tmp[0] = 0x82; // demux
783 tmp[2] = demux_mask; // descramble bitmask
784 tmp[3] = data_demux&0xFF; // read section data from demux number
785 capmt.injectDescriptor(tmp, false);
787 tmp[0] = 0x81; // dvbnamespace
789 tmp[2] = m_service.getDVBNamespace().get()>>24;
790 tmp[3]=(m_service.getDVBNamespace().get()>>16)&0xFF;
791 tmp[4]=(m_service.getDVBNamespace().get()>>8)&0xFF;
792 tmp[5]=m_service.getDVBNamespace().get()&0xFF;
793 tmp[6]=m_service.getTransportStreamID().get()>>8;
794 tmp[7]=m_service.getTransportStreamID().get()&0xFF;
795 tmp[8]=m_service.getOriginalNetworkID().get()>>8;
796 tmp[9]=m_service.getOriginalNetworkID().get()&0xFF;
797 capmt.injectDescriptor(tmp, false);
799 capmt.writeToBuffer(m_capmt);
802 m_prev_build_hash = build_hash;
804 if ( m_sendstate != 0xFFFFFFFF )
809 void eDVBCAService::sendCAPMT()
811 if ( m_sendstate && m_sendstate != 0xFFFFFFFF ) // broken pipe retry
818 if ( m_capmt[3] & 0x80 )
821 int lenbytes = m_capmt[3] & ~0x80;
823 wp = (wp << 8) | m_capmt[4 + i++];
833 if ( write(m_sock, m_capmt, wp) == wp )
835 m_sendstate=0xFFFFFFFF;
836 eDebug("[eDVBCAService] send %d bytes",wp);
838 for(int i=0;i<wp;i++)
839 eDebugNoNewLine("%02x ", m_capmt[i]);
849 m_retryTimer.start(0,true);
850 // eDebug("[eDVBCAService] send failed .. immediate retry");
853 m_retryTimer.start(5000,true);
854 // eDebug("[eDVBCAService] send failed .. retry in 5 sec");
861 static PyObject *createTuple(int pid, const char *type)
863 PyObject *r = PyTuple_New(2);
864 PyTuple_SetItem(r, 0, PyInt_FromLong(pid));
865 PyTuple_SetItem(r, 1, PyString_FromString(type));
869 static inline void PyList_AppendSteal(PyObject *list, PyObject *item)
871 PyList_Append(list, item);
875 PyObject *eDVBServicePMTHandler::program::createPythonObject()
877 PyObject *r = PyDict_New();
879 PyObject *l = PyList_New(0);
881 PyList_AppendSteal(l, createTuple(0, "pat"));
884 PyList_AppendSteal(l, createTuple(pmtPid, "pmt"));
886 for (std::vector<eDVBServicePMTHandler::videoStream>::const_iterator
887 i(videoStreams.begin());
888 i != videoStreams.end(); ++i)
889 PyList_AppendSteal(l, createTuple(i->pid, "video"));
891 for (std::vector<eDVBServicePMTHandler::audioStream>::const_iterator
892 i(audioStreams.begin());
893 i != audioStreams.end(); ++i)
894 PyList_AppendSteal(l, createTuple(i->pid, "audio"));
896 for (std::vector<eDVBServicePMTHandler::subtitleStream>::const_iterator
897 i(subtitleStreams.begin());
898 i != subtitleStreams.end(); ++i)
899 PyList_AppendSteal(l, createTuple(i->pid, "subtitle"));
901 PyList_AppendSteal(l, createTuple(pcrPid, "pcr"));
904 PyList_AppendSteal(l, createTuple(textPid, "text"));
906 PyDict_SetItemString(r, "pids", l);