X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/4039e9f6ae8e20a8440bf1d1cbaaddcf8f140c29..b23e0f70b3b0e6815b784f29cbe7d09982116c41:/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 a756e751..ea1afec4 100644 --- a/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp +++ b/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp @@ -87,34 +87,56 @@ DEFINE_REF(eServiceDVD); eServiceDVD::eServiceDVD(const char *filename): m_filename(filename), m_ddvdconfig(ddvd_create()), - m_pixmap(new gPixmap(eSize(720, 576), 32)), m_subtitle_widget(0), m_state(stIdle), m_current_trick(0), - m_sn(eApp, ddvd_get_messagepipe_fd(m_ddvdconfig), eSocketNotifier::Read|eSocketNotifier::Priority|eSocketNotifier::Error|eSocketNotifier::Hungup), m_pump(eApp, 1) { - std::string aspect; + int aspect = DDVD_16_9; + int policy = DDVD_PAN_SCAN; + + char tmp[255]; + ssize_t rd; + + m_sn = eSocketNotifier::create(eApp, ddvd_get_messagepipe_fd(m_ddvdconfig), eSocketNotifier::Read|eSocketNotifier::Priority|eSocketNotifier::Error|eSocketNotifier::Hungup); eDebug("SERVICEDVD construct!"); // create handle ddvd_set_dvd_path(m_ddvdconfig, filename); ddvd_set_ac3thru(m_ddvdconfig, 0); - ddvd_set_language(m_ddvdconfig, "de"); - - 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); + std::string ddvd_language; + if (!ePythonConfigQuery::getConfigValue("config.osd.language", ddvd_language)) + ddvd_set_language(m_ddvdconfig, (ddvd_language.substr(0,2)).c_str()); + + int fd = open("/proc/stb/video/aspect", O_RDONLY); + if (fd > -1) + { + rd = read(fd, tmp, 255); + if (rd > 2 && !strncmp(tmp, "4:3", 3)) + aspect = DDVD_4_3; + else if (rd > 4 && !strncmp(tmp, "16:10", 5)) + aspect = DDVD_16_10; + close(fd); + } + + fd = open("/proc/stb/video/policy", O_RDONLY); + if (fd > -1) + { + rd = read(fd, tmp, 255); + if (rd > 6 && !strncmp(tmp, "bestfit", 7)) + policy = DDVD_JUSTSCALE; + else if (rd > 8 && !strncmp(tmp, "letterbox", 9)) + policy = DDVD_LETTERBOX; + close(fd); + } + + ddvd_set_video(m_ddvdconfig, aspect, policy, DDVD_PAL /*unused*/); + + CONNECT(m_sn->activated, eServiceDVD::gotMessage); CONNECT(m_pump.recv_msg, eServiceDVD::gotThreadMessage); strcpy(m_ddvd_titlestring,""); m_cue_pts = 0; + pause(); } void eServiceDVD::gotThreadMessage(const int &msg) @@ -157,8 +179,11 @@ void eServiceDVD::gotMessage(int /*what*/) } case DDVD_SCREEN_UPDATE: eDebug("DVD_SCREEN_UPDATE!"); - if (m_subtitle_widget) - m_subtitle_widget->setPixmap(m_pixmap, eRect(0, 0, 720, 576)); + 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)); + } break; case DDVD_SHOWOSD_STATE_PLAY: { @@ -212,6 +237,14 @@ void eServiceDVD::gotMessage(int /*what*/) eDebug("DVD_SOF_REACHED!"); m_event(this, evSOF); break; + case DDVD_SHOWOSD_ANGLE: + { + int current, num; + ddvd_get_angle_info(m_ddvdconfig, ¤t, &num); + eDebug("DVD_ANGLE_INFO: %d / %d", current, num); + m_event(this, evUser+13); + break; + } case DDVD_SHOWOSD_TIME: { static struct ddvd_time last_info; @@ -230,6 +263,8 @@ void eServiceDVD::gotMessage(int /*what*/) ddvd_get_title_string(m_ddvdconfig, m_ddvd_titlestring); eDebug("DDVD_SHOWOSD_TITLESTRING: %s",m_ddvd_titlestring); loadCuesheet(); + if (!m_cue_pts) + unpause(); m_event(this, evStart); break; } @@ -256,6 +291,7 @@ eServiceDVD::~eServiceDVD() kill(); saveCuesheet(); ddvd_close(m_ddvdconfig); + disableSubtitles(0); } RESULT eServiceDVD::connectEvent(const Slot2 &event, ePtr &connection) @@ -266,17 +302,16 @@ RESULT eServiceDVD::connectEvent(const Slot2 &event, RESULT eServiceDVD::start() { - assert(m_state == stIdle); + ASSERT(m_state == stIdle); m_state = stRunning; eDebug("eServiceDVD starting"); - run(); // m_event(this, evStart); return 0; } RESULT eServiceDVD::stop() { - assert(m_state != stIdle); + ASSERT(m_state != stIdle); if (m_state == stStopped) return -1; eDebug("DVD: stop %s", m_filename.c_str()); @@ -434,6 +469,7 @@ int eServiceDVD::getInfo(int w) } case sUser+6: case sUser+7: + case sUser+8: return resIsPyObject; default: return resNA; @@ -503,6 +539,16 @@ PyObject *eServiceDVD::getInfoObject(int w) } return tuple; } + case sUser+8: + { + ePyObject tuple = PyTuple_New(2); + int current, num; + ddvd_get_angle_info(m_ddvdconfig, ¤t, &num); + PyTuple_SetItem(tuple, 0, PyInt_FromLong(current)); + PyTuple_SetItem(tuple, 1, PyInt_FromLong(num)); + + return tuple; + } default: eDebug("unhandled getInfoObject(%d)", w); } @@ -511,13 +557,23 @@ PyObject *eServiceDVD::getInfoObject(int w) RESULT eServiceDVD::enableSubtitles(eWidget *parent, SWIG_PYOBJECT(ePyObject) /*entry*/) { - if (m_subtitle_widget) - delete m_subtitle_widget; + delete m_subtitle_widget; + m_subtitle_widget = new eSubtitleWidget(parent); m_subtitle_widget->resize(parent->size()); - m_subtitle_widget->setPixmap(m_pixmap, eRect(0, 0, 720, 576)); + + eSize size = eSize(720, 576); + + if (!m_pixmap) + { + m_pixmap = new gPixmap(size, 32, 1); /* allocate accel surface (if possible) */ + ddvd_set_lfb(m_ddvdconfig, (unsigned char *)m_pixmap->surface->data, size.width(), size.height(), 4, size.width()*4); + run(); // start the thread + } + m_subtitle_widget->setZPosition(-1); m_subtitle_widget->show(); + return 0; } @@ -652,6 +708,9 @@ RESULT eServiceDVD::keyPressed(int key) case iServiceKeys::keyUser+7: ddvd_send_key(m_ddvdconfig, DDVD_KEY_MENU); break; + case iServiceKeys::keyUser+8: + ddvd_send_key(m_ddvdconfig, DDVD_KEY_ANGLE); + break; default: return -1; } @@ -739,21 +798,26 @@ void eServiceDVD::saveCuesheet() { eDebug("eServiceDVD::saveCuesheet()"); - struct ddvd_time info; - ddvd_get_last_time(m_ddvdconfig, &info); - if ( info.pos_chapter < info.end_chapter ) + struct ddvd_resume resume_info; + ddvd_get_resume_pos(m_ddvdconfig, &resume_info); + + if (resume_info.title) { + struct ddvd_time info; + ddvd_get_last_time(m_ddvdconfig, &info); pts_t pos; pos = info.pos_hours * 3600; pos += info.pos_minutes * 60; pos += info.pos_seconds; pos *= 90000; m_cue_pts = pos; + eDebug("ddvd_get_resume_pos resume_info.title=%d, chapter=%d, block=%lu, audio_id=%d, audio_lock=%d, spu_id=%d, spu_lock=%d (pts=%llu)",resume_info.title,resume_info.chapter,resume_info.block,resume_info.audio_id, resume_info.audio_lock, resume_info.spu_id, resume_info.spu_lock,m_cue_pts); + } + else + { + eDebug("we're in a menu or somewhere else funny. so save cuesheet with pts=0"); + m_cue_pts = 0; } - - struct ddvd_resume resume_info; - ddvd_get_resume_pos(m_ddvdconfig, &resume_info); - eDebug("ddvd_get_resume_pos resume_info.title=%d, chapter=%d, block=%lu, audio_id=%d, audio_lock=%d, spu_id=%d, spu_lock=%d (pts=%llu)",resume_info.title,resume_info.chapter,resume_info.block,resume_info.audio_id, resume_info.audio_lock, resume_info.spu_id, resume_info.spu_lock,m_cue_pts); char filename[128]; if ( m_ddvd_titlestring[0] != '\0' )