X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/b23e0f70b3b0e6815b784f29cbe7d09982116c41..5542743a96cff0772577e445a93384d07c291b91:/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 ea1afec4..ccacf3c0 100644 --- a/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp +++ b/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp @@ -32,6 +32,7 @@ eServiceFactoryDVD::eServiceFactoryDVD() { std::list extensions; extensions.push_back("iso"); + extensions.push_back("img"); sc->addServiceFactory(eServiceFactoryDVD::id, this, extensions); } } @@ -51,7 +52,7 @@ DEFINE_REF(eServiceFactoryDVD) RESULT eServiceFactoryDVD::play(const eServiceReference &ref, ePtr &ptr) { // check resources... - ptr = new eServiceDVD(ref.path.c_str()); + ptr = new eServiceDVD(ref); return 0; } @@ -84,16 +85,14 @@ RESULT eServiceFactoryDVD::offlineOperations(const eServiceReference &, ePtr -1) + { + rd = read(fd, tmp, 255); + if (rd > 6 && !strncmp(tmp, "bestfit", 7)) + policy2 = DDVD_JUSTSCALE; + else if (rd > 8 && !strncmp(tmp, "letterbox", 9)) + policy2 = DDVD_LETTERBOX; + close(fd); + } + ddvd_set_video_ex(m_ddvdconfig, aspect, policy, policy2, DDVD_PAL /*unused*/); +#else ddvd_set_video(m_ddvdconfig, aspect, policy, DDVD_PAL /*unused*/); +#warning please update libdreamdvd for 16:10 scaling support! +#endif CONNECT(m_sn->activated, eServiceDVD::gotMessage); CONNECT(m_pump.recv_msg, eServiceDVD::gotThreadMessage); @@ -182,7 +196,20 @@ void eServiceDVD::gotMessage(int /*what*/) if (m_subtitle_widget) { int x1,x2,y1,y2; ddvd_get_last_blit_area(m_ddvdconfig, &x1, &x2, &y1, &y2); - m_subtitle_widget->setPixmap(m_pixmap, eRect(x1, y1, (x2-x1)+1, (y2-y1)+1)); + + int x_offset = 0, y_offset = 0, width = 720, height = 576; + +#ifdef DDVD_SUPPORTS_GET_BLIT_DESTINATION + ddvd_get_blit_destination(m_ddvdconfig, &x_offset, &y_offset, &width, &height); + eDebug("values got from ddvd: %d %d %d %d", x_offset, y_offset, width, height); + y_offset = -y_offset; + width -= x_offset * 2; + height -= y_offset * 2; +#endif + eRect dest(x_offset, y_offset, width, height); + + if (dest.width() && dest.height()) + m_subtitle_widget->setPixmap(m_pixmap, eRect(x1, y1, (x2-x1)+1, (y2-y1)+1), dest); } break; case DDVD_SHOWOSD_STATE_PLAY: @@ -280,6 +307,32 @@ void eServiceDVD::gotMessage(int /*what*/) m_event(this, evSeekableStatusChanged); m_event(this, evUser+12); break; +#ifdef DDVD_SUPPORTS_PICTURE_INFO + case DDVD_SIZE_CHANGED: + { + int changed = m_width != -1 && m_height != -1 && m_aspect != -1; + ddvd_get_last_size(m_ddvdconfig, &m_width, &m_height, &m_aspect); + if (changed) + m_event((iPlayableService*)this, evVideoSizeChanged); + break; + } + case DDVD_PROGRESSIVE_CHANGED: + { + int changed = m_progressive != -1; + ddvd_get_last_progressive(m_ddvdconfig, &m_progressive); + if (changed) + m_event((iPlayableService*)this, evVideoProgressiveChanged); + break; + } + case DDVD_FRAMERATE_CHANGED: + { + int changed = m_framerate != -1; + ddvd_get_last_framerate(m_ddvdconfig, &m_framerate); + if (changed) + m_event((iPlayableService*)this, evVideoFramerateChanged); + break; + } +#endif default: break; } @@ -314,7 +367,7 @@ RESULT eServiceDVD::stop() ASSERT(m_state != stIdle); if (m_state == stStopped) return -1; - eDebug("DVD: stop %s", m_filename.c_str()); + eDebug("DVD: stop %s", m_ref.path.c_str()); m_state = stStopped; ddvd_send_key(m_ddvdconfig, DDVD_KEY_EXIT); @@ -344,6 +397,61 @@ RESULT eServiceDVD::subtitle(ePtr &ptr) return 0; } +RESULT eServiceDVD::audioTracks(ePtr &ptr) +{ + ptr = this; + return 0; +} + +int eServiceDVD::getNumberOfTracks() +{ + int i = 0; + ddvd_get_audio_count(m_ddvdconfig, &i); + return i; +} + +int eServiceDVD::getCurrentTrack() +{ + int audio_id,audio_type; + uint16_t audio_lang; + ddvd_get_last_audio(m_ddvdconfig, &audio_id, &audio_lang, &audio_type); + return audio_id; +} + +RESULT eServiceDVD::selectTrack(unsigned int i) +{ + ddvd_set_audio(m_ddvdconfig, i); + return 0; +} + +RESULT eServiceDVD::getTrackInfo(struct iAudioTrackInfo &info, unsigned int audio_id) +{ + int audio_type; + uint16_t audio_lang; + ddvd_get_audio_byid(m_ddvdconfig, audio_id, &audio_lang, &audio_type); + char audio_string[3]={audio_lang >> 8, audio_lang, 0}; + info.m_pid = audio_id+1; + info.m_language = audio_string; + switch(audio_type) + { + case DDVD_MPEG: + info.m_description = "MPEG"; + break; + case DDVD_AC3: + info.m_description = "AC3"; + break; + case DDVD_DTS: + info.m_description = "DTS"; + break; + case DDVD_LPCM: + info.m_description = "LPCM"; + break; + default: + info.m_description = "und"; + } + return 0; +} + RESULT eServiceDVD::keys(ePtr &ptr) { ptr=this; @@ -428,7 +536,10 @@ RESULT eServiceDVD::getName(std::string &name) if ( m_ddvd_titlestring[0] != '\0' ) name = m_ddvd_titlestring; else - name = m_filename; + if ( !m_ref.name.empty() ) + name = m_ref.name; + else + name = m_ref.path; return 0; } @@ -471,6 +582,18 @@ int eServiceDVD::getInfo(int w) case sUser+7: case sUser+8: return resIsPyObject; +#ifdef DDVD_SUPPORTS_PICTURE_INFO + case sVideoWidth: + return m_width; + case sVideoHeight: + return m_height; + case sAspect: + return m_aspect; + case sProgressive: + return m_progressive; + case sFrameRate: + return m_framerate; +#endif default: return resNA; } @@ -481,7 +604,7 @@ std::string eServiceDVD::getInfoString(int w) switch(w) { case sServiceref: - break; + return m_ref.toString(); default: eDebug("unhandled getInfoString(%d)", w); } @@ -555,19 +678,43 @@ PyObject *eServiceDVD::getInfoObject(int w) Py_RETURN_NONE; } -RESULT eServiceDVD::enableSubtitles(eWidget *parent, SWIG_PYOBJECT(ePyObject) /*entry*/) +RESULT eServiceDVD::enableSubtitles(eWidget *parent, ePyObject tuple) { delete m_subtitle_widget; + eSize size = eSize(720, 576); m_subtitle_widget = new eSubtitleWidget(parent); m_subtitle_widget->resize(parent->size()); - eSize size = eSize(720, 576); + int pid = -1; + + if ( tuple != Py_None ) + { + ePyObject entry; + int tuplesize = PyTuple_Size(tuple); + if (!PyTuple_Check(tuple)) + goto error_out; + if (tuplesize < 1) + goto error_out; + entry = PyTuple_GET_ITEM(tuple, 1); + if (!PyInt_Check(entry)) + goto error_out; + pid = PyInt_AsLong(entry)-1; + + ddvd_set_spu(m_ddvdconfig, pid); + m_event(this, evUser+7); + } + eDebug("eServiceDVD::enableSubtitles %i", pid); if (!m_pixmap) { m_pixmap = new gPixmap(size, 32, 1); /* allocate accel surface (if possible) */ +#ifdef DDVD_SUPPORTS_GET_BLIT_DESTINATION + ddvd_set_lfb_ex(m_ddvdconfig, (unsigned char *)m_pixmap->surface->data, size.width(), size.height(), 4, size.width()*4, 1); +#else ddvd_set_lfb(m_ddvdconfig, (unsigned char *)m_pixmap->surface->data, size.width(), size.height(), 4, size.width()*4); +#warning please update libdreamdvd for fast scaling +#endif run(); // start the thread } @@ -575,6 +722,9 @@ RESULT eServiceDVD::enableSubtitles(eWidget *parent, SWIG_PYOBJECT(ePyObject) /* m_subtitle_widget->show(); return 0; + +error_out: + return -1; } RESULT eServiceDVD::disableSubtitles(eWidget */*parent*/) @@ -586,8 +736,26 @@ RESULT eServiceDVD::disableSubtitles(eWidget */*parent*/) PyObject *eServiceDVD::getSubtitleList() { - eDebug("eServiceDVD::getSubtitleList nyi"); - Py_RETURN_NONE; + ePyObject l = PyList_New(0); + unsigned int spu_count = 0; + ddvd_get_spu_count(m_ddvdconfig, &spu_count); + + for ( unsigned int spu_id = 0; spu_id < spu_count; spu_id++ ) + { + uint16_t spu_lang; + ddvd_get_spu_byid(m_ddvdconfig, spu_id, &spu_lang); + char spu_string[3]={spu_lang >> 8, spu_lang, 0}; + + ePyObject tuple = PyTuple_New(5); + PyTuple_SetItem(tuple, 0, PyInt_FromLong(2)); + PyTuple_SetItem(tuple, 1, PyInt_FromLong(spu_id+1)); + PyTuple_SetItem(tuple, 2, PyInt_FromLong(3)); + PyTuple_SetItem(tuple, 3, PyInt_FromLong(0)); + PyTuple_SetItem(tuple, 4, PyString_FromString(spu_string)); + PyList_Append(l, tuple); + Py_DECREF(tuple); + } + return l; } PyObject *eServiceDVD::getCachedSubtitle() @@ -662,7 +830,7 @@ RESULT eServiceDVD::setTrickmode(int /*trick*/) RESULT eServiceDVD::isCurrentlySeekable() { - return m_state == stRunning; + return m_state == stRunning ? 3 : 0; } RESULT eServiceDVD::keyPressed(int key) @@ -752,7 +920,7 @@ void eServiceDVD::loadCuesheet() if ( m_ddvd_titlestring[0] != '\0' ) snprintf(filename, 128, "/home/root/dvd-%s.cuts", m_ddvd_titlestring); else - snprintf(filename, 128, "%s/dvd.cuts", m_filename.c_str()); + snprintf(filename, 128, "%s/dvd.cuts", m_ref.path.c_str()); eDebug("eServiceDVD::loadCuesheet() filename=%s",filename); @@ -823,7 +991,7 @@ void eServiceDVD::saveCuesheet() if ( m_ddvd_titlestring[0] != '\0' ) snprintf(filename, 128, "/home/root/dvd-%s.cuts", m_ddvd_titlestring); else - snprintf(filename, 128, "%s/dvd.cuts", m_filename.c_str()); + snprintf(filename, 128, "%s/dvd.cuts", m_ref.path.c_str()); FILE *f = fopen(filename, "wb");