From 59b783ebcdd871129087219a6ee1929e46e7a2e6 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Thu, 27 Jan 2011 17:02:54 +0100 Subject: implement native e2 audio and subtitle track selection interfaces to enable AudioSelection Dialog for DVDPlayer (#440) [needs libdreamdvd update] --- .../Extensions/DVDPlayer/src/servicedvd.cpp | 82 +++++++++++++++++++++- .../Plugins/Extensions/DVDPlayer/src/servicedvd.h | 13 +++- 2 files changed, 90 insertions(+), 5 deletions(-) (limited to 'lib/python/Plugins/Extensions/DVDPlayer/src') diff --git a/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp b/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp index 5fbfb0aa..da9c0bb7 100644 --- a/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp +++ b/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp @@ -397,6 +397,64 @@ 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); + eDebug("getNumberOfTracks returns %i", 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); + eDebug("getCurrentTrack returns %i", audio_id); + return audio_id; +} + +RESULT eServiceDVD::selectTrack(unsigned int i) +{ + ddvd_set_audio(m_ddvdconfig, i); + eDebug("selectTrack %i", 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; @@ -659,8 +717,28 @@ RESULT eServiceDVD::disableSubtitles(eWidget */*parent*/) PyObject *eServiceDVD::getSubtitleList() { - eDebug("eServiceDVD::getSubtitleList nyi"); - Py_RETURN_NONE; + eDebug("eServiceMP3::getSubtitleList"); + + 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(0)); + 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() diff --git a/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.h b/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.h index c751a394..80cfcf0c 100644 --- a/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.h +++ b/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.h @@ -26,7 +26,7 @@ public: RESULT offlineOperations(const eServiceReference &, ePtr &ptr); }; -class eServiceDVD: public iPlayableService, public iPauseableService, public iSeekableService, +class eServiceDVD: public iPlayableService, public iPauseableService, public iSeekableService, public iAudioTrackSelection, public iServiceInformation, public iSubtitleOutput, public iServiceKeys, public iCueSheet, public eThread, public Object { friend class eServiceFactoryDVD; @@ -35,7 +35,7 @@ public: virtual ~eServiceDVD(); // not implemented (yet) RESULT audioChannel(ePtr &ptr) { ptr = 0; return -1; } - RESULT audioTracks(ePtr &ptr) { ptr = 0; return -1; } + RESULT audioTracks(ePtr &ptr); RESULT frontendInfo(ePtr &ptr) { ptr = 0; return -1; } RESULT subServices(ePtr &ptr) { ptr = 0; return -1; } RESULT timeshift(ePtr &ptr) { ptr = 0; return -1; } @@ -89,8 +89,15 @@ public: void setCutList(SWIG_PYOBJECT(ePyObject)); void setCutListEnable(int enable); - // iServiceKeys + // iAudioTrackSelection + int getNumberOfTracks(); + RESULT selectTrack(unsigned int i); + RESULT getTrackInfo(struct iAudioTrackInfo &, unsigned int n); + int getCurrentTrack(); + + // iServiceKeys RESULT keyPressed(int key); + private: eServiceDVD(eServiceReference ref); -- cgit v1.2.3 From ca7333ab52acb1fd4cb19dc2b2817507a8ae9d75 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Fri, 28 Jan 2011 10:59:51 +0100 Subject: DVDPlayer subtitle stream selection through enigma2 AudioSelection dialog (#441) --- .../Extensions/DVDPlayer/src/servicedvd.cpp | 34 ++++++++++++++++------ lib/python/Screens/AudioSelection.py | 4 +-- 2 files changed, 27 insertions(+), 11 deletions(-) (limited to 'lib/python/Plugins/Extensions/DVDPlayer/src') diff --git a/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp b/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp index da9c0bb7..b960ed67 100644 --- a/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp +++ b/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp @@ -407,7 +407,6 @@ int eServiceDVD::getNumberOfTracks() { int i = 0; ddvd_get_audio_count(m_ddvdconfig, &i); - eDebug("getNumberOfTracks returns %i", i); return i; } @@ -416,14 +415,12 @@ int eServiceDVD::getCurrentTrack() int audio_id,audio_type; uint16_t audio_lang; ddvd_get_last_audio(m_ddvdconfig, &audio_id, &audio_lang, &audio_type); - eDebug("getCurrentTrack returns %i", audio_id); return audio_id; } RESULT eServiceDVD::selectTrack(unsigned int i) { ddvd_set_audio(m_ddvdconfig, i); - eDebug("selectTrack %i", i); return 0; } @@ -681,14 +678,32 @@ 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); + } + eDebug("eServiceDVD::enableSubtitles %i", pid); if (!m_pixmap) { @@ -706,6 +721,9 @@ RESULT eServiceDVD::enableSubtitles(eWidget *parent, SWIG_PYOBJECT(ePyObject) /* m_subtitle_widget->show(); return 0; + +error_out: + return -1; } RESULT eServiceDVD::disableSubtitles(eWidget */*parent*/) @@ -717,8 +735,6 @@ RESULT eServiceDVD::disableSubtitles(eWidget */*parent*/) PyObject *eServiceDVD::getSubtitleList() { - eDebug("eServiceMP3::getSubtitleList"); - ePyObject l = PyList_New(0); unsigned int spu_count = 0; ddvd_get_spu_count(m_ddvdconfig, &spu_count); @@ -731,7 +747,7 @@ PyObject *eServiceDVD::getSubtitleList() ePyObject tuple = PyTuple_New(5); PyTuple_SetItem(tuple, 0, PyInt_FromLong(2)); - PyTuple_SetItem(tuple, 1, PyInt_FromLong(0)); + 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)); diff --git a/lib/python/Screens/AudioSelection.py b/lib/python/Screens/AudioSelection.py index 576fd381..b3b82b46 100644 --- a/lib/python/Screens/AudioSelection.py +++ b/lib/python/Screens/AudioSelection.py @@ -84,7 +84,7 @@ class AudioSelection(Screen, ConfigListScreen): conflist.append(getConfigListEntry(_("Channel"), self.settings.channelmode)) self["key_green"].setBoolean(True) else: - conflist.append(getConfigListEntry("", ConfigNothing())) + conflist.append(('',)) self["key_green"].setBoolean(False) selectedAudio = self.audioTracks.getCurrentTrack() for x in range(n): @@ -141,7 +141,7 @@ class AudioSelection(Screen, ConfigListScreen): language = _("") selected = "" - if sel and x[:4] == sel[:4]: + if sel and x == sel: selected = _("Running") selectedidx = idx -- cgit v1.2.3 From f3060d26bbb98713b901794b6e47bf7f064a9073 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Fri, 28 Jan 2011 11:29:51 +0100 Subject: DVDPlayer: AudioSelection integration (#441) --- lib/python/Plugins/Extensions/DVDPlayer/keymap.xml | 3 ++- lib/python/Plugins/Extensions/DVDPlayer/plugin.py | 7 +++++-- lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'lib/python/Plugins/Extensions/DVDPlayer/src') diff --git a/lib/python/Plugins/Extensions/DVDPlayer/keymap.xml b/lib/python/Plugins/Extensions/DVDPlayer/keymap.xml index 7b7f2054..bf57e753 100644 --- a/lib/python/Plugins/Extensions/DVDPlayer/keymap.xml +++ b/lib/python/Plugins/Extensions/DVDPlayer/keymap.xml @@ -8,7 +8,8 @@ - + + diff --git a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py index 259e52b8..d14a6238 100755 --- a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py @@ -356,6 +356,7 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP "prevTitle": (self.prevTitle, _("jump back to the previous title")), "tv": (self.askLeavePlayer, _("exit DVD player or return to file browser")), "dvdAudioMenu": (self.enterDVDAudioMenu, _("(show optional DVD audio menu)")), + "AudioSelection": (self.enterAudioSelection, _("Select audio track")), "nextAudioTrack": (self.nextAudioTrack, _("switch to the next audio track")), "nextSubtitleTrack": (self.nextSubtitleTrack, _("switch to the next subtitle language")), "nextAngle": (self.nextAngle, _("switch to the next angle")), @@ -548,6 +549,9 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP keys.keyPressed(key) return keys + def enterAudioSelection(self): + self.audioSelection() + def nextAudioTrack(self): self.sendKey(iServiceKeys.keyUser) @@ -555,8 +559,7 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP self.sendKey(iServiceKeys.keyUser+1) def enterDVDAudioMenu(self): - self.audioSelection() - #self.sendKey(iServiceKeys.keyUser+2) + self.sendKey(iServiceKeys.keyUser+2) def nextChapter(self): self.sendKey(iServiceKeys.keyUser+3) diff --git a/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp b/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp index b960ed67..ccacf3c0 100644 --- a/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp +++ b/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp @@ -685,7 +685,7 @@ RESULT eServiceDVD::enableSubtitles(eWidget *parent, ePyObject tuple) m_subtitle_widget = new eSubtitleWidget(parent); m_subtitle_widget->resize(parent->size()); - + int pid = -1; if ( tuple != Py_None ) @@ -702,6 +702,7 @@ RESULT eServiceDVD::enableSubtitles(eWidget *parent, ePyObject tuple) pid = PyInt_AsLong(entry)-1; ddvd_set_spu(m_ddvdconfig, pid); + m_event(this, evUser+7); } eDebug("eServiceDVD::enableSubtitles %i", pid); -- cgit v1.2.3