From 0e3e7773e5d8e7ff159316db3de7fcfad57bb9e8 Mon Sep 17 00:00:00 2001 From: Andreas Monzner Date: Mon, 30 Oct 2006 16:04:21 +0000 Subject: [PATCH] move subtitles selection to mainmenu, some subtitle fixes --- data/menu.xml | 1 + data/skin_default.xml | 3 + lib/dvb/pmt.cpp | 28 +++- lib/dvb/pmt.h | 25 +++- lib/dvb/subtitle.cpp | 29 +++-- lib/dvb/subtitle.h | 7 +- lib/dvb/teletext.cpp | 33 +++-- lib/dvb/teletext.h | 10 +- lib/python/Screens/InfoBar.py | 11 +- lib/python/Screens/InfoBarGenerics.py | 45 ++----- lib/service/servicedvb.cpp | 179 +++++++++++++++++++------- 11 files changed, 244 insertions(+), 127 deletions(-) diff --git a/data/menu.xml b/data/menu.xml index 2762c2e8..4c530fe0 100644 --- a/data/menu.xml +++ b/data/menu.xml @@ -17,6 +17,7 @@ self.openSetup("network")--> + self.session.scart.VCRSbChanged(3) diff --git a/data/skin_default.xml b/data/skin_default.xml index 1ecb0998..9d397b43 100644 --- a/data/skin_default.xml +++ b/data/skin_default.xml @@ -126,6 +126,9 @@ + + + diff --git a/lib/dvb/pmt.cpp b/lib/dvb/pmt.cpp index 2ab6777f..bdb10b18 100644 --- a/lib/dvb/pmt.cpp +++ b/lib/dvb/pmt.cpp @@ -13,6 +13,7 @@ #include #include #include +#include eDVBServicePMTHandler::eDVBServicePMTHandler() :m_ca_servicePtr(0), m_dvb_scan(0), m_decode_demux_num(0xFF) @@ -245,15 +246,36 @@ int eDVBServicePMTHandler::getProgramInfo(struct program &program) s.composition_page_id = (*it)->getCompositionPageId(); s.ancillary_page_id = (*it)->getAncillaryPageId(); s.language_code = (*it)->getIso639LanguageCode(); - eDebug("add subtitle %s PID %04x, type %d, composition page %d, ancillary_page %d", - s.language_code.c_str(), s.pid, s.subtitling_type, s.composition_page_id, s.ancillary_page_id); +// eDebug("add dvb subtitle %s PID %04x, type %d, composition page %d, ancillary_page %d", +// s.language_code.c_str(), s.pid, s.subtitling_type, s.composition_page_id, s.ancillary_page_id); program.subtitleStreams.push_back(s); } break; } case TELETEXT_DESCRIPTOR: if ( program.textPid == -1 || (*es)->getPid() == cached_tpid ) - program.textPid = (*es)->getPid(); + { + subtitleStream s; + s.subtitling_type = 0x01; // EBU TELETEXT SUBTITLES + s.pid = program.textPid = (*es)->getPid(); + TeletextDescriptor *d = (TeletextDescriptor*)(*desc); + const VbiTeletextList *list = d->getVbiTeletexts(); + for (VbiTeletextConstIterator it(list->begin()); it != list->end(); ++it) + { + switch((*it)->getTeletextType()) + { + case 0x02: // Teletext subtitle page + case 0x05: // Teletext subtitle page for hearing impaired pepople + s.language_code = (*it)->getIso639LanguageCode(); + s.teletext_page_number = (*it)->getTeletextPageNumber(); + s.teletext_magazine_number = (*it)->getTeletextMagazineNumber(); +// eDebug("add teletext subtitle %s PID %04x, page number %d, magazine number %d", +// s.language_code.c_str(), s.pid, s.teletext_page_number, s.teletext_magazine_number); + program.subtitleStreams.push_back(s); + break; + } + } + } break; case DTS_DESCRIPTOR: isaudio = 1; diff --git a/lib/dvb/pmt.h b/lib/dvb/pmt.h index e5b02752..185000d9 100644 --- a/lib/dvb/pmt.h +++ b/lib/dvb/pmt.h @@ -117,10 +117,29 @@ public: struct subtitleStream { int pid; - int subtitling_type; - int composition_page_id; - int ancillary_page_id; + int subtitling_type; /* see ETSI EN 300 468 table 26 component_type + when stream_content is 0x03 + 0x10..0x13, 0x20..0x23 is used for dvb subtitles + 0x01 is used for teletext subtitles */ + union + { + int composition_page_id; // used for dvb subtitles + int teletext_page_number; // used for teletext subtitles + }; + union + { + int ancillary_page_id; // used for dvb subtitles + int teletext_magazine_number; // used for teletext subtitles + }; std::string language_code; + bool operator<(const subtitleStream &s) + { + if (pid != s.pid) + return pid < s.pid; + if (teletext_page_number != s.teletext_page_number) + return teletext_page_number < s.teletext_page_number; + return teletext_magazine_number < s.teletext_magazine_number; + } }; struct program diff --git a/lib/dvb/subtitle.cpp b/lib/dvb/subtitle.cpp index 0058a51c..f9666bc0 100644 --- a/lib/dvb/subtitle.cpp +++ b/lib/dvb/subtitle.cpp @@ -287,13 +287,15 @@ int eDVBSubtitleParser::subtitle_process_segment(__u8 *segment) segment_length |= *segment++; if (segment_type == 0xFF) return segment_length + 6; + if (page_id != m_composition_page_id && page_id != m_ancillary_page_id) + return segment_length + 6; // //eDebug("have %d bytes of segment data", segment_length); // //eDebug("page_id %d, segtype %02x", page_id, segment_type); subtitle_page *page, **ppage; - page = this->pages; ppage = &this->pages; + page = m_pages; ppage = &m_pages; while (page) { @@ -727,7 +729,7 @@ int eDVBSubtitleParser::subtitle_process_segment(__u8 *segment) void eDVBSubtitleParser::subtitle_process_pes(__u8 *pkt, int len) { // eDebug("subtitle_process_pes"); - if (!extract_pts(show_time, pkt)) + if (!extract_pts(m_show_time, pkt)) { pkt += 6; len -= 6; // skip PES header @@ -770,14 +772,14 @@ void eDVBSubtitleParser::subtitle_process_pes(__u8 *pkt, int len) void eDVBSubtitleParser::subtitle_redraw_all() { #if 1 - subtitle_page *page = this->pages; + subtitle_page *page = m_pages; while(page) { subtitle_redraw(page->page_id); page = page->next; } #else - subtitle_page *page = this->pages; + subtitle_page *page = m_pages; //eDebug("----------- end of display set"); //eDebug("active pages:"); while (page) @@ -819,7 +821,7 @@ void eDVBSubtitleParser::subtitle_redraw_all() void eDVBSubtitleParser::subtitle_reset() { - while (subtitle_page *page = this->pages) + while (subtitle_page *page = m_pages) { /* free page regions */ while (page->page_regions) @@ -859,14 +861,14 @@ void eDVBSubtitleParser::subtitle_reset() delete clut; } - this->pages = page->next; + m_pages = page->next; delete page; } } void eDVBSubtitleParser::subtitle_redraw(int page_id) { - subtitle_page *page = this->pages; + subtitle_page *page = m_pages; //eDebug("displaying page id %d", page_id); @@ -887,7 +889,7 @@ void eDVBSubtitleParser::subtitle_redraw(int page_id) subtitle_page_region *region = page->page_regions; eDVBSubtitlePage Page; - Page.m_show_time = show_time; + Page.m_show_time = m_show_time; for (; region; region=region->next) { // eDebug("region %d", region->region_id); @@ -905,8 +907,6 @@ void eDVBSubtitleParser::subtitle_redraw(int page_id) int x0 = region->region_horizontal_address; int y0 = region->region_vertical_address; - int x1 = x0 + reg->region_width; - int y1 = y0 + reg->region_height; if ((x0 < 0) || (y0 < 0)) { @@ -1098,7 +1098,7 @@ void eDVBSubtitleParser::subtitle_redraw(int page_id) DEFINE_REF(eDVBSubtitleParser); eDVBSubtitleParser::eDVBSubtitleParser(iDVBDemux *demux) - :pages(0) + :m_pages(0) { setStreamID(0xBD); @@ -1123,11 +1123,14 @@ int eDVBSubtitleParser::stop() return -1; } -int eDVBSubtitleParser::start(int pid) +int eDVBSubtitleParser::start(int pid, int composition_page_id, int ancillary_page_id) { if (m_pes_reader) { - eDebug("start dvb subtitles on pid 0x%04x", pid); + eDebug("start dvb subtitles on pid 0x%04x with composition_page_id %d and ancillary_page_id %d", + pid, composition_page_id, ancillary_page_id); + m_composition_page_id = composition_page_id; + m_ancillary_page_id = ancillary_page_id; return m_pes_reader->start(pid); } return -1; diff --git a/lib/dvb/subtitle.h b/lib/dvb/subtitle.h index 44cdd4cb..6335a337 100644 --- a/lib/dvb/subtitle.h +++ b/lib/dvb/subtitle.h @@ -108,15 +108,16 @@ class eDVBSubtitleParser :public iObject, public ePESParser, public Object { DECLARE_REF(eDVBSubtitleParser); - subtitle_page *pages; + subtitle_page *m_pages; ePtr m_pes_reader; ePtr m_read_connection; - pts_t show_time; + pts_t m_show_time; Signal1 m_new_subtitle_page; + int m_composition_page_id, m_ancillary_page_id; public: eDVBSubtitleParser(iDVBDemux *demux); virtual ~eDVBSubtitleParser(); - int start(int pid); + int start(int pid, int composition_page_id, int ancillary_page_id); int stop(); void connectNewPage(const Slot1 &slot, ePtr &connection); private: diff --git a/lib/dvb/teletext.cpp b/lib/dvb/teletext.cpp index ecfdb086..7128000d 100644 --- a/lib/dvb/teletext.cpp +++ b/lib/dvb/teletext.cpp @@ -135,7 +135,7 @@ eDVBTeletextParser::eDVBTeletextParser(iDVBDemux *demux) { setStreamID(0xBD); /* as per en 300 472 */ - setPage(-1); + setPageAndMagazine(0,0); if (demux->createPESReader(eApp, m_pes_reader)) eDebug("failed to create teletext subtitle PES reader!"); @@ -228,7 +228,7 @@ void eDVBTeletextParser::processPESPacket(__u8 *pkt, int len) int serial_mode = m_C & (1<<11); /* page on the same magazine? end current page. */ - if ((serial_mode || (m_M == m_page_M)) && (m_page_open)) + if ((serial_mode || m_M == m_page_M) && m_page_open) { handlePageEnd(have_pts, pts); m_page_open = 0; @@ -237,10 +237,17 @@ void eDVBTeletextParser::processPESPacket(__u8 *pkt, int len) m_X = decode_hamming_84(data+1) * 0x10 + decode_hamming_84(data); if ((m_C & (1<<6)) && (m_X != 0xFF)) /* scan for pages with subtitle bit set */ - m_found_subtitle_pages.insert((m_M << 8) | m_X); - + { + eDVBServicePMTHandler::subtitleStream s; + s.pid = m_pid; + s.subtitling_type = 0x01; // ebu teletext subtitle + s.teletext_page_number = m_X & 0xFF; + s.teletext_magazine_number = m_M & 7; + m_found_subtitle_pages.insert(s); + } + /* correct page on correct magazine? open page. */ - if ((m_M == m_page_M) && (m_X == m_page_X)) + if (m_M == m_page_M && m_X == m_page_X) { handlePageStart(); m_page_open = 1; @@ -248,8 +255,8 @@ void eDVBTeletextParser::processPESPacket(__u8 *pkt, int len) } } else { - /* data for the selected page? */ - if ((m_M == m_page_M) && m_page_open) + /* data for the selected page ? */ + if (m_M == m_page_M && m_page_open) handleLine(data, 40); } } @@ -260,7 +267,10 @@ int eDVBTeletextParser::start(int pid) m_page_open = 0; if (m_pes_reader) + { + m_pid = pid; return m_pes_reader->start(pid); + } else return -1; } @@ -340,19 +350,18 @@ void eDVBTeletextParser::handlePageEnd(int have_pts, const pts_t &pts) m_subtitle_page.m_have_pts = have_pts; m_subtitle_page.m_pts = pts; m_subtitle_page.m_timeout = 90000 * 20; /* 20s */ - if (m_page_number != -1) + if (m_page_X != 0) sendSubtitlePage(); /* send assembled subtitle page to display */ } -void eDVBTeletextParser::setPage(int page) +void eDVBTeletextParser::setPageAndMagazine(int page, int magazine) { if (page > 0) eDebug("enable teletext subtitle page %d", page); else eDebug("disable teletext subtitles"); - m_page_number = page; - m_page_M = (page >> 8) & 7; /* magazine to look for */ - m_page_X = page & 0xFF; /* page number */ + m_page_M = magazine&7; /* magazine to look for */ + m_page_X = page&0xFF; /* page number */ } void eDVBTeletextParser::connectNewPage(const Slot1 &slot, ePtr &connection) diff --git a/lib/dvb/teletext.h b/lib/dvb/teletext.h index 8c5dfa3e..fcabb90c 100644 --- a/lib/dvb/teletext.h +++ b/lib/dvb/teletext.h @@ -4,6 +4,7 @@ #include #include #include +#include #include struct eDVBTeletextSubtitlePageElement @@ -34,11 +35,10 @@ public: eDVBTeletextParser(iDVBDemux *demux); virtual ~eDVBTeletextParser(); int start(int pid); - void setPage(int page); - + void setPageAndMagazine(int page, int magazine); + void setMagazine(int magazine); void connectNewPage(const Slot1 &slot, ePtr &connection); - - std::set m_found_subtitle_pages; + std::set m_found_subtitle_pages; private: void processPESPacket(__u8 *pkt, int len); @@ -49,7 +49,7 @@ private: int m_M, m_Y, m_X, m_S1, m_S2, m_S3, m_S4, m_C; - int m_page_number, m_page_M, m_page_X, m_page_open, m_double_height; + int m_pid, m_page_M, m_page_X, m_page_open, m_double_height; void handlePageStart(); void handleLine(unsigned char *line, int len); diff --git a/lib/python/Screens/InfoBar.py b/lib/python/Screens/InfoBar.py index 6ee49522..c4ae6fa9 100644 --- a/lib/python/Screens/InfoBar.py +++ b/lib/python/Screens/InfoBar.py @@ -19,7 +19,7 @@ from Screens.InfoBarGenerics import InfoBarShowHide, \ InfoBarSubserviceSelection, InfoBarTuner, InfoBarShowMovies, InfoBarTimeshift, \ InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarSimpleEventView, \ InfoBarSummarySupport, InfoBarTimeshiftState, InfoBarTeletextPlugin, InfoBarExtensions, \ - InfoBarSubtitleSupport, InfoBarPiP, InfoBarSubtitles, InfoBarPlugins + InfoBarSubtitleSupport, InfoBarPiP, InfoBarPlugins from Screens.HelpMenu import HelpableScreen, HelpMenu @@ -33,8 +33,7 @@ class InfoBar(InfoBarShowHide, HelpableScreen, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, InfoBarSubserviceSelection, InfoBarTuner, InfoBarTimeshift, InfoBarSeek, InfoBarSummarySupport, InfoBarTimeshiftState, InfoBarTeletextPlugin, InfoBarExtensions, - InfoBarPiP, InfoBarSubtitles, InfoBarPlugins, - InfoBarSubtitleSupport, Screen): + InfoBarPiP, InfoBarPlugins, InfoBarSubtitleSupport, Screen): ALLOW_SUSPEND = True @@ -56,7 +55,7 @@ class InfoBar(InfoBarShowHide, InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, \ InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, InfoBarSubserviceSelection, \ InfoBarTuner, InfoBarTimeshift, InfoBarSeek, InfoBarSummarySupport, InfoBarTimeshiftState, \ - InfoBarTeletextPlugin, InfoBarExtensions, InfoBarPiP, InfoBarSubtitles, InfoBarSubtitleSupport, \ + InfoBarTeletextPlugin, InfoBarExtensions, InfoBarPiP, InfoBarSubtitleSupport, \ InfoBarPlugins: x.__init__(self) @@ -85,7 +84,7 @@ class MoviePlayer(InfoBarShowHide, \ InfoBarMenu, \ InfoBarServiceName, InfoBarSeek, InfoBarShowMovies, InfoBarAudioSelection, HelpableScreen, InfoBarNotifications, InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarSimpleEventView, - InfoBarSummarySupport, InfoBarTeletextPlugin, InfoBarSubtitleSupport, Screen): + InfoBarSummarySupport, InfoBarSubtitleSupport, Screen, InfoBarExtensions): ENABLE_RESUME_SUPPORT = True ALLOW_SUSPEND = True @@ -102,7 +101,7 @@ class MoviePlayer(InfoBarShowHide, \ InfoBarServiceName, InfoBarSeek, InfoBarShowMovies, \ InfoBarAudioSelection, InfoBarNotifications, InfoBarSimpleEventView, \ InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, \ - InfoBarSummarySupport, InfoBarTeletextPlugin, InfoBarSubtitleSupport: + InfoBarSummarySupport, InfoBarSubtitleSupport, InfoBarExtensions: x.__init__(self) self.lastservice = self.session.nav.getCurrentlyPlayingServiceReference() diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index e3caa6e8..b69ef4e1 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -344,12 +344,21 @@ class InfoBarMenu: { "mainMenu": (self.mainMenu, _("Enter main menu...")), }) + self.session.infobar = None def mainMenu(self): print "loading mainmenu XML..." menu = mdom.childNodes[0] assert menu.tagName == "menu", "root element in menu must be 'menu'!" - self.session.open(MainMenu, menu, menu.childNodes) + + self.session.infobar = self + # so we can access the currently active infobar from screens opened from within the mainmenu + # at the moment used from the SubserviceSelection + + self.session.openWithCallback(self.mainMenuClosed, MainMenu, menu, menu.childNodes) + + def mainMenuClosed(self, *val): + self.session.infobar = None class InfoBarSimpleEventView: """ Opens the Eventview for now/next """ @@ -1124,40 +1133,6 @@ class InfoBarPlugins: def runPlugin(self, plugin): plugin(session = self.session) -# depends on InfoBarExtensions and InfoBarSubtitleSupport -class InfoBarSubtitles: - def __init__(self): - self.addExtension((self.getDisableSubtitleName, self.disableSubtitles, self.subtitlesEnabled), "4") - self.addExtension(extension = self.getSubtitleList, type = InfoBarExtensions.EXTENSION_LIST) - - def getDisableSubtitleName(self): - return _("Disable subtitles") - - def getSubtitleList(self): - list = [] - s = self.getCurrentServiceSubtitle() - l = s and s.getSubtitleList() or [ ] - - for x in l: - list.append(((boundFunction(self.getSubtitleEntryName, x[0]), boundFunction(self.enableSubtitle, x[1]), lambda: True), None)) - return list - - def getSubtitleEntryName(self, name): - return "Enable Subtitles: " + name - - def enableSubtitle(self, subtitles): - if self.selected_subtitle != subtitles: - print "enable subtitles", subtitles - self.subtitles_enabled = False - self.selected_subtitle = subtitles - self.subtitles_enabled = True - - def subtitlesEnabled(self): - return self.subtitles_enabled - - def disableSubtitles(self): - self.subtitles_enabled = False - # depends on InfoBarExtensions class InfoBarPiP: def __init__(self): diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp index 6c980c76..e6a21439 100644 --- a/lib/service/servicedvb.cpp +++ b/lib/service/servicedvb.cpp @@ -27,8 +27,6 @@ #include #include -#define INTERNAL_TELETEXT - #ifndef BYTE_ORDER #error no byte order defined! #endif @@ -1763,10 +1761,8 @@ void eDVBServicePlay::updateDecoder() m_decode_demux->getMPEGDecoder(m_decoder, m_is_primary); if (m_cue) m_cue->setDecodingDemux(m_decode_demux, m_decoder); -#ifdef INTERNAL_TELETEXT m_teletext_parser = new eDVBTeletextParser(m_decode_demux); m_teletext_parser->connectNewPage(slot(*this, &eDVBServicePlay::newSubtitlePage), m_new_subtitle_page_connection); -#endif m_subtitle_parser = new eDVBSubtitleParser(m_decode_demux); m_subtitle_parser->connectNewPage(slot(*this, &eDVBServicePlay::newDVBSubtitlePage), m_new_dvb_subtitle_page_connection); } @@ -1993,44 +1989,93 @@ void eDVBServicePlay::cutlistToCuesheet() m_cue->commitSpans(); } -RESULT eDVBServicePlay::enableSubtitles(eWidget *parent, PyObject *entry) +RESULT eDVBServicePlay::enableSubtitles(eWidget *parent, PyObject *tuple) { if (m_subtitle_widget) disableSubtitles(parent); - - if (!PyInt_Check(entry)) - return -1; - int page = PyInt_AsLong(entry); + PyObject *entry = 0; + int tuplesize = PyTuple_Size(tuple); + int type = 0; - if (page > 0 && !m_teletext_parser) - return -1; - if (page < 0 && !m_subtitle_parser) - return -1; + if (!PyTuple_Check(tuple)) + goto error_out; - m_subtitle_widget = new eSubtitleWidget(parent); - m_subtitle_widget->resize(parent->size()); /* full size */ + if (tuplesize < 1) + goto error_out; - if (page > 0) + entry = PyTuple_GET_ITEM(tuple, 0); + + if (!PyInt_Check(entry)) + goto error_out; + + type = PyInt_AsLong(entry); + + if (type == 1) // teletext subtitles { -/* eDVBServicePMTHandler &h = m_timeshift_active ? m_service_handler_timeshift : m_service_handler; - eDVBServicePMTHandler::program program; - if (h.getProgramInfo(program)) - eDebug("getting program info failed."); - else + int page, magazine; + if (tuplesize < 4) + goto error_out; + + if (!m_teletext_parser) { - eDebug("start teletext on pid %04x, page %d", program.textPid, page); - m_teletext_parser->start(program.textPid);*/ - m_teletext_parser->setPage(page); -// } + eDebug("enable teletext subtitles.. no parser !!!"); + return -1; + } + + // PyTuple_GET_ITEM(tuple, 1); //we dont need pid yet + entry = PyTuple_GET_ITEM(tuple, 2); + if (!PyInt_Check(entry)) + goto error_out; + page = PyInt_AsLong(entry); + + entry = PyTuple_GET_ITEM(tuple, 3); + if (!PyInt_Check(entry)) + goto error_out; + magazine = PyInt_AsLong(entry); + + m_subtitle_widget = new eSubtitleWidget(parent); + m_subtitle_widget->resize(parent->size()); /* full size */ + m_teletext_parser->setPageAndMagazine(page, magazine); } - else + else if (type == 0) { - int pid = -page; - m_subtitle_parser->start(pid); - } + int pid = 0, composition_page_id = 0, ancillary_page_id = 0; + if (!m_subtitle_parser) + { + eDebug("enable dvb subtitles.. no parser !!!"); + return -1; + } + if (tuplesize < 4) + goto error_out; + + entry = PyTuple_GET_ITEM(tuple, 1); + if (!PyInt_Check(entry)) + goto error_out; + pid = PyInt_AsLong(entry); + + entry = PyTuple_GET_ITEM(tuple, 2); + if (!PyInt_Check(entry)) + goto error_out; + composition_page_id = PyInt_AsLong(entry); + entry = PyTuple_GET_ITEM(tuple, 3); + if (!PyInt_Check(entry)) + goto error_out; + ancillary_page_id = PyInt_AsLong(entry); + + m_subtitle_widget = new eSubtitleWidget(parent); + m_subtitle_widget->resize(parent->size()); /* full size */ + m_subtitle_parser->start(pid, composition_page_id, ancillary_page_id); + } + else + goto error_out; return 0; +error_out: + eDebug("enableSubtitles needs a tuple as 2nd argument!\n" + "for teletext subtitles (0, pid, teletext_page, teletext_magazine)\n" + "for dvb subtitles (1, pid, composition_page_id, ancillary_page_id)"); + return -1; } RESULT eDVBServicePlay::disableSubtitles(eWidget *parent) @@ -2044,7 +2089,7 @@ RESULT eDVBServicePlay::disableSubtitles(eWidget *parent) } if (m_teletext_parser) { - m_teletext_parser->setPage(-1); + m_teletext_parser->setPageAndMagazine(0,0); m_subtitle_pages.clear(); } return 0; @@ -2059,17 +2104,10 @@ PyObject *eDVBServicePlay::getSubtitleList() } PyObject *l = PyList_New(0); - - for (std::set::iterator i(m_teletext_parser->m_found_subtitle_pages.begin()); i != m_teletext_parser->m_found_subtitle_pages.end(); ++i) - { - PyObject *tuple = PyTuple_New(2); - char desc[20]; - sprintf(desc, "Page %d", *i); - PyTuple_SetItem(tuple, 0, PyString_FromString(desc)); - PyTuple_SetItem(tuple, 1, PyInt_FromLong(*i)); - PyList_Append(l, tuple); - Py_DECREF(tuple); - } + std::set added_ttx_pages; + + std::set &subs = + m_teletext_parser->m_found_subtitle_pages; eDVBServicePMTHandler &h = m_timeshift_active ? m_service_handler_timeshift : m_service_handler; eDVBServicePMTHandler::program program; @@ -2080,11 +2118,58 @@ PyObject *eDVBServicePlay::getSubtitleList() for (std::vector::iterator it(program.subtitleStreams.begin()); it != program.subtitleStreams.end(); ++it) { - PyObject *tuple = PyTuple_New(2); - char desc[20]; - sprintf(desc, "DVB %s", it->language_code.c_str()); - PyTuple_SetItem(tuple, 0, PyString_FromString(desc)); - PyTuple_SetItem(tuple, 1, PyInt_FromLong(-it->pid)); + switch(it->subtitling_type) + { + case 0x01: // ebu teletext subtitles + { + int page_number = it->teletext_page_number & 0xFF; + int magazine_number = it->teletext_magazine_number & 7; + int hash = magazine_number << 8 | page_number; + if (added_ttx_pages.find(hash) == added_ttx_pages.end()) + { + PyObject *tuple = PyTuple_New(5); + PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(1)); + PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(it->pid)); + PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(page_number)); + PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(magazine_number)); + PyTuple_SET_ITEM(tuple, 4, PyString_FromString(it->language_code.c_str())); + PyList_Append(l, tuple); + Py_DECREF(tuple); + added_ttx_pages.insert(hash); + } + break; + } + case 0x10 ... 0x13: + case 0x20 ... 0x23: // dvb subtitles + { + PyObject *tuple = PyTuple_New(5); + PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(0)); + PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(it->pid)); + PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(it->composition_page_id)); + PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(it->ancillary_page_id)); + PyTuple_SET_ITEM(tuple, 4, PyString_FromString(it->language_code.c_str())); + PyList_Insert(l, 0, tuple); + Py_DECREF(tuple); + break; + } + } + } + } + + for (std::set::iterator it(subs.begin()); + it != subs.end(); ++it) + { + int page_number = it->teletext_page_number & 0xFF; + int magazine_number = it->teletext_magazine_number & 7; + int hash = magazine_number << 8 | page_number; + if (added_ttx_pages.find(hash) == added_ttx_pages.end()) + { + PyObject *tuple = PyTuple_New(5); + PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(1)); + PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(it->pid)); + PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(page_number)); + PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(magazine_number)); + PyTuple_SET_ITEM(tuple, 4, PyString_FromString("und")); // undetermined PyList_Append(l, tuple); Py_DECREF(tuple); } @@ -2162,7 +2247,7 @@ void eDVBServicePlay::checkSubtitleTiming() } } else { - eDebug("start subtitle delay %d", diff / 90); +// eDebug("start subtitle delay %d", diff / 90); m_subtitle_sync_timer.start(diff / 90, 1); break; } -- 2.30.2