X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/17be24380f07656d14b88baf5af0d9ef3d8eddfd..9020b3132d25acc5058f8cba754d63cc440815f7:/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp diff --git a/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp b/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp index 016e16a1..bbcb1f2b 100644 --- a/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp +++ b/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -10,13 +11,11 @@ #include #include -#ifdef cue #include #include #ifndef BYTE_ORDER #error no byte order defined! #endif -#endif //cue extern "C" { #include @@ -56,7 +55,7 @@ RESULT eServiceFactoryDVD::play(const eServiceReference &ref, ePtr &ptr) +RESULT eServiceFactoryDVD::record(const eServiceReference &/*ref*/, ePtr &ptr) { ptr=0; return -1; @@ -69,7 +68,7 @@ RESULT eServiceFactoryDVD::list(const eServiceReference &, ePtr &ptr) +RESULT eServiceFactoryDVD::info(const eServiceReference &/*ref*/, ePtr &ptr) { ptr=0; return -1; @@ -95,21 +94,27 @@ eServiceDVD::eServiceDVD(const char *filename): m_sn(eApp, ddvd_get_messagepipe_fd(m_ddvdconfig), eSocketNotifier::Read|eSocketNotifier::Priority|eSocketNotifier::Error|eSocketNotifier::Hungup), m_pump(eApp, 1) { + std::string aspect; eDebug("SERVICEDVD construct!"); // create handle ddvd_set_dvd_path(m_ddvdconfig, filename); ddvd_set_ac3thru(m_ddvdconfig, 0); ddvd_set_language(m_ddvdconfig, "de"); - ddvd_set_video(m_ddvdconfig, DDVD_16_9, DDVD_PAL); + + if (ePythonConfigQuery::getConfigValue("config.av.aspect", aspect) != 0) + aspect = "16_9"; + if (aspect == "4_3_letterbox") + ddvd_set_video(m_ddvdconfig, DDVD_4_3_LETTERBOX, DDVD_PAL); + else if (aspect == "4_3_panscan") + ddvd_set_video(m_ddvdconfig, DDVD_4_3_PAN_SCAN, DDVD_PAL); + else + ddvd_set_video(m_ddvdconfig, DDVD_16_9, DDVD_PAL); + ddvd_set_lfb(m_ddvdconfig, (unsigned char *)m_pixmap->surface->data, 720, 576, 4, 720*4); CONNECT(m_sn.activated, eServiceDVD::gotMessage); CONNECT(m_pump.recv_msg, eServiceDVD::gotThreadMessage); strcpy(m_ddvd_titlestring,""); - m_doSeekTo = 0; - m_seekTitle = 0; -#ifdef cue m_cue_pts = 0; -#endif } void eServiceDVD::gotThreadMessage(const int &msg) @@ -123,7 +128,7 @@ void eServiceDVD::gotThreadMessage(const int &msg) } } -void eServiceDVD::gotMessage(int what) +void eServiceDVD::gotMessage(int /*what*/) { switch(ddvd_get_next_message(m_ddvdconfig,1)) { @@ -203,7 +208,6 @@ void eServiceDVD::gotMessage(int what) eDebug("DVD_EOF_REACHED!"); m_event(this, evEOF); break; - case DDVD_SOF_REACHED: eDebug("DVD_SOF_REACHED!"); m_event(this, evSOF); @@ -212,26 +216,13 @@ void eServiceDVD::gotMessage(int what) { static struct ddvd_time last_info; struct ddvd_time info; +// eDebug("DVD_SHOWOSD_TIME!"); ddvd_get_last_time(m_ddvdconfig, &info); - int spu_id; - uint16_t spu_lang; - ddvd_get_last_spu(m_ddvdconfig, &spu_id, &spu_lang); if ( info.pos_chapter != last_info.pos_chapter ) - { - eDebug("DVD_SHOWOSD_TIME!"); m_event(this, evUser+8); // chapterUpdated - } - if ( info.pos_title != last_info.pos_title ) - { + if ( info.pos_title != last_info.pos_title ) m_event(this, evUser+9); // titleUpdated - } - if ( info.pos_title == m_seekTitle && m_doSeekTo ) - { - seekRelative( +1, m_doSeekTo ); - m_doSeekTo = 0; - m_seekTitle = 0; - } - ddvd_get_last_time(m_ddvdconfig, &last_info); + memcpy(&last_info, &info, sizeof(struct ddvd_time)); break; } case DDVD_SHOWOSD_TITLESTRING: @@ -240,16 +231,18 @@ void eServiceDVD::gotMessage(int what) eDebug("DDVD_SHOWOSD_TITLESTRING: %s",m_ddvd_titlestring); loadCuesheet(); m_event(this, evStart); -// m_event((iPlayableService*)this, evUpdatedEventInfo); -// m_event(this, evUser+10); break; } case DDVD_MENU_OPENED: eDebug("DVD_MENU_OPENED!"); + m_state = stMenu; + m_event(this, evSeekableStatusChanged); m_event(this, evUser+11); break; case DDVD_MENU_CLOSED: eDebug("DVD_MENU_CLOSED!"); + m_state = stRunning; + m_event(this, evSeekableStatusChanged); m_event(this, evUser+12); break; default: @@ -288,7 +281,6 @@ RESULT eServiceDVD::stop() eDebug("DVD: stop %s", m_filename.c_str()); m_state = stStopped; ddvd_send_key(m_ddvdconfig, DDVD_KEY_EXIT); -#ifdef cue struct ddvd_time info; ddvd_get_last_time(m_ddvdconfig, &info); if ( info.pos_chapter < info.end_chapter ) @@ -298,16 +290,16 @@ RESULT eServiceDVD::stop() pos += info.pos_minutes * 60; pos += info.pos_seconds; pos *= 90000; + pos += info.pos_title * 256; + pos += info.pos_chapter; m_cue_pts = pos; + eDebug("POS %llu\n", m_cue_pts); } - else // last chapter - usually credits, don't save cue - m_cue_pts = 0; saveCuesheet(); -#endif return 0; } -RESULT eServiceDVD::setTarget(int target) +RESULT eServiceDVD::setTarget(int /*target*/) { return -1; } @@ -337,7 +329,7 @@ RESULT eServiceDVD::keys(ePtr &ptr) } // iPausableService -RESULT eServiceDVD::setSlowMotion(int ratio) +RESULT eServiceDVD::setSlowMotion(int /*ratio*/) { return -1; } @@ -378,12 +370,14 @@ RESULT eServiceDVD::setFastForward(int trick) RESULT eServiceDVD::pause() { + eDebug("set pause!\n"); ddvd_send_key(m_ddvdconfig, DDVD_KEY_PAUSE); return 0; } RESULT eServiceDVD::unpause() { + eDebug("set unpause!\n"); ddvd_send_key(m_ddvdconfig, DDVD_KEY_PLAY); return 0; } @@ -428,32 +422,30 @@ int eServiceDVD::getInfo(int w) case sTracknumber: case sGenre: return resIsString; // then getInfoString should be called - case evUser+8: + case sUser+8: { struct ddvd_time info; ddvd_get_last_time(m_ddvdconfig, &info); return info.pos_chapter; } - case evUser+80: + case sUser+80: { struct ddvd_time info; ddvd_get_last_time(m_ddvdconfig, &info); return info.end_chapter; } - - case evUser+9: + case sUser+9: { struct ddvd_time info; ddvd_get_last_time(m_ddvdconfig, &info); return info.pos_title; } - case evUser+90: + case sUser+90: { struct ddvd_time info; ddvd_get_last_time(m_ddvdconfig, &info); return info.end_title; } - case sTXTPID: // we abuse HAS_TELEXT icon in InfoBar to signalize subtitles status { int spu_id; @@ -470,7 +462,7 @@ std::string eServiceDVD::getInfoString(int w) { switch(w) { - case evUser+7: { + case sUser+7: { int spu_id; uint16_t spu_lang; ddvd_get_last_spu(m_ddvdconfig, &spu_id, &spu_lang); @@ -483,7 +475,7 @@ std::string eServiceDVD::getInfoString(int w) // lbo_changed=1; return osd; } - case evUser+6: + case sUser+6: { int audio_id,audio_type; uint16_t audio_lang; @@ -527,7 +519,7 @@ PyObject *eServiceDVD::getInfoObject(int w) Py_RETURN_NONE; } -RESULT eServiceDVD::enableSubtitles(eWidget *parent, SWIG_PYOBJECT(ePyObject) entry) +RESULT eServiceDVD::enableSubtitles(eWidget *parent, SWIG_PYOBJECT(ePyObject) /*entry*/) { if (m_subtitle_widget) delete m_subtitle_widget; @@ -539,7 +531,7 @@ RESULT eServiceDVD::enableSubtitles(eWidget *parent, SWIG_PYOBJECT(ePyObject) en return 0; } -RESULT eServiceDVD::disableSubtitles(eWidget *parent) +RESULT eServiceDVD::disableSubtitles(eWidget */*parent*/) { delete m_subtitle_widget; m_subtitle_widget = 0; @@ -570,26 +562,17 @@ RESULT eServiceDVD::getLength(pts_t &len) return 0; } -// RESULT eServiceDVD::seekTo(pts_t to) -// { -// struct ddvd_time info; -// to /= 90000; -// int cur; -// ddvd_get_last_time(m_ddvdconfig, &info); -// cur = info.pos_hours * 3600; -// cur += info.pos_minutes * 60; -// cur += info.pos_seconds; -// eDebug("seekTo %lld, cur %d, diff %lld", to, cur, cur - to); -// ddvd_skip_seconds(m_ddvdconfig, cur - to); -// return 0; -// } - RESULT eServiceDVD::seekTo(pts_t to) { - m_seekTitle = 1; - eDebug("seekTo %lld", to); - ddvd_set_title(m_ddvdconfig, m_seekTitle); - m_doSeekTo = to; + struct ddvd_time info; + to /= 90000; + int cur; + ddvd_get_last_time(m_ddvdconfig, &info); + cur = info.pos_hours * 3600; + cur += info.pos_minutes * 60; + cur += info.pos_seconds; + eDebug("seekTo %lld, cur %d, diff %lld", to, cur, to - cur); + ddvd_skip_seconds(m_ddvdconfig, to - cur); return 0; } @@ -614,6 +597,13 @@ RESULT eServiceDVD::getPlayPosition(pts_t &pos) return 0; } +RESULT eServiceDVD::seekTitle(int title) +{ + eDebug("setTitle %d", title); + ddvd_set_title(m_ddvdconfig, title); + return 0; +} + RESULT eServiceDVD::seekChapter(int chapter) { eDebug("setChapter %d", chapter); @@ -622,14 +612,14 @@ RESULT eServiceDVD::seekChapter(int chapter) return 0; } -RESULT eServiceDVD::setTrickmode(int trick) +RESULT eServiceDVD::setTrickmode(int /*trick*/) { return -1; } RESULT eServiceDVD::isCurrentlySeekable() { - return 1; + return m_state == stRunning; } RESULT eServiceDVD::keyPressed(int key) @@ -681,7 +671,6 @@ RESULT eServiceDVD::keyPressed(int key) return 0; } -#ifdef cue RESULT eServiceDVD::cueSheet(ePtr &ptr) { if (m_cue_pts) @@ -695,74 +684,22 @@ RESULT eServiceDVD::cueSheet(ePtr &ptr) PyObject *eServiceDVD::getCutList() { - ePyObject list = PyList_New(0); - -// for (std::multiset::iterator i(m_cue_entries.begin()); i != m_cue_entries.end(); ++i) -// { - ePyObject tuple = PyTuple_New(2); -// PyTuple_SetItem(tuple, 0, PyLong_FromLongLong(i->where)); - PyTuple_SetItem(tuple, 0, PyLong_FromLongLong(m_cue_pts)); -// PyTuple_SetItem(tuple, 1, PyInt_FromLong(i->what)); - PyTuple_SetItem(tuple, 1, PyInt_FromLong(3)); - PyList_Append(list, tuple); - Py_DECREF(tuple); -// } - -// eDebug("eServiceDVD::getCutList() pts=%lld",m_cue_pts); - + ePyObject list = PyList_New(1); + ePyObject tuple = PyTuple_New(2); + PyTuple_SetItem(tuple, 0, PyLong_FromLongLong(m_cue_pts)); + PyTuple_SetItem(tuple, 1, PyInt_FromLong(3)); + PyList_SetItem(list, 0, tuple); return list; } -void eServiceDVD::setCutList(ePyObject list) +void eServiceDVD::setCutList(ePyObject /*list*/) { - eDebug("eServiceDVD::setCutList()"); - - if (!PyList_Check(list)) - return; - int size = PyList_Size(list); - int i; - -// m_cue_entries.clear(); - - for (i=0; i 3) -// break; + what = ntohl(what); - m_cue_pts = where; - -// m_cue_entries.insert(cueEntry(where, what)); - } + m_cue_pts = where; fclose(f); -// eDebug("%d entries", m_cue_entries.size()); } else eDebug("cutfile not found!"); - - m_cuesheet_changed = 0; -// cutlistToCuesheet(); + eDebug("eServiceDVD::loadCuesheet() pts=%lld",m_cue_pts); if (m_cue_pts) @@ -827,27 +753,19 @@ void eServiceDVD::saveCuesheet() unsigned long long where; int what; -// for (std::multiset::iterator i(m_cue_entries.begin()); i != m_cue_entries.end(); ++i) { #if BYTE_ORDER == BIG_ENDIAN where = m_cue_pts; -// where = i->where; #else -// where = bswap_64(i->where); where = bswap_64(m_cue_pts); #endif -// what = htonl(i->what); what = 3; fwrite(&where, sizeof(where), 1, f); fwrite(&what, sizeof(what), 1, f); - } fclose(f); } - - m_cuesheet_changed = 0; } -#endif eAutoInitPtr init_eServiceFactoryDVD(eAutoInitNumbers::service+1, "eServiceFactoryDVD");