diff options
| author | Fraxinas <andreas.frisch@multimedia-labs.de> | 2011-01-28 11:42:26 +0100 |
|---|---|---|
| committer | Fraxinas <andreas.frisch@multimedia-labs.de> | 2011-01-28 11:46:53 +0100 |
| commit | c0a60ca49ae1b2384c9bfbeccb1a15e97133d1b2 (patch) | |
| tree | e5502aa00319c1895209eef07f03ef7a212c4a10 /lib | |
| parent | f32b288b3236e41686e67eda2bccf2f083223bca (diff) | |
| parent | f3060d26bbb98713b901794b6e47bf7f064a9073 (diff) | |
| download | enigma2-c0a60ca49ae1b2384c9bfbeccb1a15e97133d1b2.tar.gz enigma2-c0a60ca49ae1b2384c9bfbeccb1a15e97133d1b2.zip | |
Merge branch 'bug_440_dvdplayer_audioselection' into experimental [fixes ##440+441, requires libdreamdvd >=0.10 20110128]experimental-2011.02
Conflicts:
lib/python/Screens/AudioSelection.py
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/python/Plugins/Extensions/DVDPlayer/keymap.xml | 3 | ||||
| -rwxr-xr-x | lib/python/Plugins/Extensions/DVDPlayer/plugin.py | 10 | ||||
| -rw-r--r-- | lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp | 103 | ||||
| -rw-r--r-- | lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.h | 13 | ||||
| -rw-r--r-- | lib/python/Screens/AudioSelection.py | 18 |
5 files changed, 130 insertions, 17 deletions
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 @@ <key id="KEY_PREVIOUS" mapto="prevChapter" flags="m" /> <key id="KEY_NEXT" mapto="nextChapter" flags="m" /> <key id="KEY_TV" mapto="tv" flags="m" /> - <key id="KEY_AUDIO" mapto="dvdAudioMenu" flags="m" /> + <key id="KEY_AUDIO" mapto="AudioSelection" flags="m" /> + <key id="KEY_AUDIO" mapto="dvdAudioMenu" flags="l" /> <key id="KEY_RADIO" mapto="nextAudioTrack" flags="m" /> <key id="KEY_TEXT" mapto="nextSubtitleTrack" flags="m" /> <key id="KEY_VIDEO" mapto="nextAngle" flags="m" /> diff --git a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py index 7f330ebe..1f3de1ac 100755 --- a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py @@ -4,7 +4,7 @@ from Screens.Screen import Screen from Screens.MessageBox import MessageBox from Screens.ChoiceBox import ChoiceBox from Screens.HelpMenu import HelpableScreen -from Screens.InfoBarGenerics import InfoBarSeek, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarShowHide, InfoBarNotifications +from Screens.InfoBarGenerics import InfoBarSeek, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarShowHide, InfoBarNotifications, InfoBarAudioSelection, InfoBarSubtitleSupport from Components.ActionMap import ActionMap, NumberActionMap, HelpableActionMap from Components.Label import Label from Components.Sources.StaticText import StaticText @@ -195,7 +195,7 @@ class ChapterZap(Screen): self.Timer.callback.append(self.keyOK) self.Timer.start(3000, True) -class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarPVRState, InfoBarShowHide, HelpableScreen, InfoBarCueSheetSupport): +class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarPVRState, InfoBarShowHide, HelpableScreen, InfoBarCueSheetSupport, InfoBarAudioSelection, InfoBarSubtitleSupport): ALLOW_SUSPEND = Screen.SUSPEND_PAUSES ENABLE_RESUME_SUPPORT = True @@ -269,6 +269,8 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP InfoBarNotifications.__init__(self) InfoBarCueSheetSupport.__init__(self, actionmap = "MediaPlayerCueSheetActions") InfoBarShowHide.__init__(self) + InfoBarAudioSelection.__init__(self) + InfoBarSubtitleSupport.__init__(self) HelpableScreen.__init__(self) self.save_infobar_seek_config() self.change_infobar_seek_config() @@ -348,6 +350,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")), @@ -540,6 +543,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) diff --git a/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp b/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp index 5fbfb0aa..6d1397da 100644 --- a/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp +++ b/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp @@ -397,6 +397,61 @@ RESULT eServiceDVD::subtitle(ePtr<iSubtitleOutput> &ptr) return 0; } +RESULT eServiceDVD::audioTracks(ePtr<iAudioTrackSelection> &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<iServiceKeys> &ptr) { ptr=this; @@ -623,14 +678,33 @@ 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) { @@ -648,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*/) @@ -659,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(5)); + 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<iServiceOfflineOperations> &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<iAudioChannelSelection> &ptr) { ptr = 0; return -1; } - RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr) { ptr = 0; return -1; } + RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr); RESULT frontendInfo(ePtr<iFrontendInformation> &ptr) { ptr = 0; return -1; } RESULT subServices(ePtr<iSubserviceList> &ptr) { ptr = 0; return -1; } RESULT timeshift(ePtr<iTimeshiftService> &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); diff --git a/lib/python/Screens/AudioSelection.py b/lib/python/Screens/AudioSelection.py index 068da870..4c689620 100644 --- a/lib/python/Screens/AudioSelection.py +++ b/lib/python/Screens/AudioSelection.py @@ -76,11 +76,15 @@ class AudioSelection(Screen, ConfigListScreen): if n > 0: self.audioChannel = service.audioChannel() - choicelist = [("0",_("left")), ("1",_("stereo")), ("2", _("right"))] - self.settings.channelmode = ConfigSelection(choices = choicelist, default = str(self.audioChannel.getCurrentChannel())) - self.settings.channelmode.addNotifier(self.changeMode, initial_call = False) - conflist.append(getConfigListEntry(_("Channel"), self.settings.channelmode)) - self["key_green"].setBoolean(True) + if self.audioChannel: + choicelist = [("0",_("left")), ("1",_("stereo")), ("2", _("right"))] + self.settings.channelmode = ConfigSelection(choices = choicelist, default = str(self.audioChannel.getCurrentChannel())) + self.settings.channelmode.addNotifier(self.changeMode, initial_call = False) + conflist.append(getConfigListEntry(_("Channel"), self.settings.channelmode)) + self["key_green"].setBoolean(True) + else: + conflist.append(('',)) + self["key_green"].setBoolean(False) selectedAudio = self.audioTracks.getCurrentTrack() for x in range(n): number = str(x) @@ -136,7 +140,7 @@ class AudioSelection(Screen, ConfigListScreen): language = _("<unknown>") selected = "" - if sel and x[:4] == sel[:4]: + if sel and x == sel: selected = _("Running") selectedidx = idx @@ -218,7 +222,7 @@ class AudioSelection(Screen, ConfigListScreen): config.av.downmix_ac3.save() def changeMode(self, mode): - if mode is not None: + if mode is not None and self.audioChannel: self.audioChannel.selectChannel(int(mode.getValue())) def changeAudio(self, audio): |
