X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/8c4f4f7e0f535267ddd6761fa148c9e0bd9c4dd4..9511adb1e0b28923cd05f5bcb74575d49e57f650:/lib/service/servicedvb.cpp diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp index 89301de4..71c2ae60 100644 --- a/lib/service/servicedvb.cpp +++ b/lib/service/servicedvb.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include // access to python config @@ -26,8 +27,6 @@ #include #include -#define INTERNAL_TELETEXT - #ifndef BYTE_ORDER #error no byte order defined! #endif @@ -211,6 +210,8 @@ std::string eStaticServiceDVBPVRInformation::getInfoString(const eServiceReferen return m_parser.m_description; case iServiceInformation::sServiceref: return m_parser.m_ref.toString(); + case iServiceInformation::sTags: + return m_parser.m_tags; default: return ""; } @@ -381,7 +382,7 @@ RESULT eDVBServiceList::getContent(std::list &list, bool sort if (!m_query) return -1; - + while (!m_query->getNextResult(ref)) list.push_back(ref); @@ -488,11 +489,6 @@ RESULT eDVBServiceList::getNext(eServiceReference &ref) return m_query->getNextResult((eServiceReferenceDVB&)ref); } -int eDVBServiceList::compareLessEqual(const eServiceReference &a, const eServiceReference &b) -{ - return m_query->compareLessEqual((const eServiceReferenceDVB&)a, (const eServiceReferenceDVB&)b); -} - RESULT eDVBServiceList::startEdit(ePtr &res) { if (m_parent.flags & eServiceReference::flagDirectory) // bouquet @@ -1337,6 +1333,8 @@ int eDVBServicePlay::selectAudioStream(int i) } } + h.resetCachedProgram(); + return 0; } @@ -1362,7 +1360,7 @@ std::string eDVBServicePlay::getRadioText(int x) switch(x) { case 0: - return m_radiotext_parser->getCurrentText(); + return convertLatin1UTF8(m_radiotext_parser->getCurrentText()); } return ""; } @@ -1758,10 +1756,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); } @@ -1988,54 +1984,151 @@ 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; + + if (tuplesize < 1) + goto error_out; - m_subtitle_widget = new eSubtitleWidget(parent); - m_subtitle_widget->resize(parent->size()); /* full size */ + entry = PyTuple_GET_ITEM(tuple, 0); - if (page > 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, pid; + 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; + } + + 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; + 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); + if (m_dvb_service) + m_dvb_service->setCacheEntry(eDVBService::cSUBTITLE,((pid&0xFFFF)<<16)|((page&0xFF)<<8)|(magazine&0xFF)); } - else + else if (type == 0) { - int pid = -page; - eDebug("start dvb subtitles on pid %04x", pid); - 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); + if (m_dvb_service) + m_dvb_service->setCacheEntry(eDVBService::cSUBTITLE, ((pid&0xFFFF)<<16)|((composition_page_id&0xFF)<<8)|(ancillary_page_id&0xFF)); } - + 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) { delete m_subtitle_widget; m_subtitle_widget = 0; + if (m_subtitle_parser) + { + m_subtitle_parser->stop(); + m_dvb_subtitle_pages.clear(); + } + if (m_teletext_parser) + { + m_teletext_parser->setPageAndMagazine(-1, -1); + m_subtitle_pages.clear(); + } + if (m_dvb_service) + m_dvb_service->setCacheEntry(eDVBService::cSUBTITLE, -1); return 0; } +PyObject *eDVBServicePlay::getCachedSubtitle() +{ + if (m_dvb_service) + { + int tmp = m_dvb_service->getCacheEntry(eDVBService::cSUBTITLE); + if (tmp != -1) + { + unsigned int data = (unsigned int)tmp; + int pid = (data&0xFFFF0000)>>16; + PyObject *tuple = PyTuple_New(4); + eDVBServicePMTHandler::program program; + eDVBServicePMTHandler &h = m_timeshift_active ? m_service_handler_timeshift : m_service_handler; + if (!h.getProgramInfo(program)) + { + if (program.textPid==pid) // teletext + PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(1)); // type teletext + else + PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(0)); // type dvb + PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong((data&0xFFFF0000)>>16)); // pid + PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong((data&0xFF00)>>8)); // composition_page / page + PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(data&0xFF)); // ancillary_page / magazine + return tuple; + } + } + } + Py_INCREF(Py_None); + return Py_None; +} + PyObject *eDVBServicePlay::getSubtitleList() { if (!m_teletext_parser) @@ -2045,17 +2138,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 %x", *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; @@ -2066,11 +2152,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); } @@ -2091,6 +2224,8 @@ void eDVBServicePlay::newSubtitlePage(const eDVBTeletextSubtitlePage &page) void eDVBServicePlay::checkSubtitleTiming() { // eDebug("checkSubtitleTiming"); + if (!m_subtitle_widget) + return; while (1) { enum { TELETEXT, DVB } type; @@ -2146,7 +2281,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; }