From c69bb079fef352b7b34eac8739b0dc051629cb7b Mon Sep 17 00:00:00 2001 From: Andreas Frisch Date: Wed, 15 Oct 2008 14:38:38 +0000 Subject: [PATCH] allow gstreamer to signalize missing plugins to the gui (requires reconfiguring enigma2) and add support for flac files (requires libflac7, gst-plugin-flac) --- configure.ac | 5 ++-- lib/python/Components/Scanner.py | 3 +++ .../Plugins/Extensions/MediaPlayer/plugin.py | 23 ++++++++++++------- lib/service/servicemp3.cpp | 18 +++++++++++++++ lib/service/servicemp3.h | 1 + main/Makefile.am | 1 + 6 files changed, 41 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index fd3dc63c..b870075e 100644 --- a/configure.ac +++ b/configure.ac @@ -40,6 +40,7 @@ TUXBOX_APPS_LIB_PKGCONFIG(PNG,libpng) TUXBOX_APPS_LIB_PKGCONFIG(SIGC,sigc++-1.2) TUXBOX_APPS_LIB_PKGCONFIG(DVBSI,libdvbsi++) _TUXBOX_APPS_LIB_PKGCONFIG_OPTIONAL(GSTREAMER,gstreamer,HAVE_GSTREAMER) +_TUXBOX_APPS_LIB_PKGCONFIG_OPTIONAL(GSTREAMERPBUTILS,gstreamer-pbutils,HAVE_GSTSTREAMERPBUTILS) AC_CHECK_LIB(jpeg, jpeg_set_defaults, HAVE_JPEG="yes", HAVE_JPEG="no") JPEG_LIBS="-ljpeg" AC_SUBST(JPEG_LIBS) @@ -68,10 +69,10 @@ fi AM_CONDITIONAL(WITH_SDL, test "$WITH_SDL" = "yes") CPPFLAGS="$CPPFLAGS "'-I$(top_srcdir)' -CPPFLAGS="$CPPFLAGS -D_REENTRANT $PYTHON_CPPFLAGS $MD5SUM_CFLAGS $FREETYPE_CFLAGS $FRIBIDI_CFLAGS $ID3TAG_CFLAGS $MAD_CFLAGS $PLUGINS_CFLAGS $PNG_CFLAGS $SDL_CFLAGS $SIGC_CFLAGS $XMLTREE_CFLAGS $DVBSI_CFLAGS $GSTREAMER_CFLAGS $LIBUNGIF_CLFAGS" +CPPFLAGS="$CPPFLAGS -D_REENTRANT $PYTHON_CPPFLAGS $MD5SUM_CFLAGS $FREETYPE_CFLAGS $FRIBIDI_CFLAGS $ID3TAG_CFLAGS $MAD_CFLAGS $PLUGINS_CFLAGS $PNG_CFLAGS $SDL_CFLAGS $SIGC_CFLAGS $XMLTREE_CFLAGS $DVBSI_CFLAGS $GSTREAMER_CFLAGS $GSTREAMERPBUTILS_CFLAGS $LIBUNGIF_CLFAGS" #CPPFLAGS="$CPPFLAGS -DMEMLEAK_CHECK" CXXFLAGS="$CXXFLAGS -fno-rtti -fno-exceptions -Wall" -LDFLAGS="$LDFLAGS -pthread $PYTHON_LDFLAGS $SDL_LDFLAGS $GSTREAMER_LDFLAGS $LIBUNGIF_LDFLAGS" +LDFLAGS="$LDFLAGS -pthread $PYTHON_LDFLAGS $SDL_LDFLAGS $GSTREAMER_LDFLAGS $GSTREAMERPBUTILS_LDFLAGS $LIBUNGIF_LDFLAGS" #LDFLAGS="-rdynamic $LDFLAGS" TUXBOX_APPS_GETTEXT diff --git a/lib/python/Components/Scanner.py b/lib/python/Components/Scanner.py index e13370b5..5a26a7d4 100644 --- a/lib/python/Components/Scanner.py +++ b/lib/python/Components/Scanner.py @@ -16,6 +16,7 @@ def getExtension(file): def getType(file): (type, _) = guess_type(file) + print "guessed type:", type if type is None: # Detect some mimetypes unknown to dm7025 # TODO: do mimetypes.add_type once should be better @@ -24,6 +25,8 @@ def getType(file): return "application/x-debian-package" elif ext == "ogg": return "application/ogg" + elif ext == "flac": + return "audio/x-flac" elif ext == "dmpkg": return "application/x-dream-package" elif ext == "ts": diff --git a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py index 6495e992..66f95fcb 100644 --- a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py @@ -64,7 +64,7 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB self.addPlaylistParser(PlaylistIOInternal, "e2pls") # 'None' is magic to start at the list of mountpoints - self.filelist = FileList(None, matchingPattern = "(?i)^.*\.(mp3|ogg|ts|wav|wave|m3u|pls|e2pls|mpg|vob|avi|mkv|dat)", useServiceRef = True, additionalExtensions = "4098:m3u 4098:e2pls 4098:pls") + self.filelist = FileList(None, matchingPattern = "(?i)^.*\.(mp3|ogg|ts|wav|wave|m3u|pls|e2pls|mpg|vob|avi|mkv|dat|flac)", useServiceRef = True, additionalExtensions = "4098:m3u 4098:e2pls 4098:pls") self["filelist"] = self.filelist self.playlist = MyPlayList() @@ -179,7 +179,8 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB self.__event_tracker = ServiceEventTracker(screen=self, eventmap= { iPlayableService.evUpdatedInfo: self.__evUpdatedInfo, - iPlayableService.evUser+11: self.__evDecodeError + iPlayableService.evUser+11: self.__evDecodeError, + iPlayableService.evUser+12: self.__evPluginError }) def doNothing(self): @@ -224,7 +225,13 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB currPlay = self.session.nav.getCurrentService() sVideoType = currPlay.info().getInfoString(iServiceInformation.sVideoType) print "[__evDecodeError] video-codec %s can't be decoded by hardware" % (sVideoType) - self.session.open(MessageBox, _("This Dreambox can't decode %s video streams!") % sVideoType, type = MessageBox.TYPE_INFO,timeout = 10 ) + self.session.open(MessageBox, _("This Dreambox can't decode %s video streams!") % sVideoType, type = MessageBox.TYPE_INFO,timeout = 20 ) + + def __evPluginError(self): + currPlay = self.session.nav.getCurrentService() + message = currPlay.info().getInfoString(iServiceInformation.sUser+12) + print "[__evPluginError]" , message + self.session.open(MessageBox, ("GStreamer Error: missing %s") % message, type = MessageBox.TYPE_INFO,timeout = 20 ) def delMPTimer(self): del self.rightKeyTimer @@ -684,10 +691,10 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB currref = self.playlist.getServiceRefList()[idx] text = self.getIdentifier(currref) text = ">"+text - ext = text[-3:].lower() + ext = text[-4:].lower() # FIXME: the information if the service contains video (and we should hide our window) should com from the service instead - if ext not in ["mp3", "wav", "ogg"] and not self.isAudioCD: + if ext not in [".mp3", ".wav", ".ogg", "flac"] and not self.isAudioCD: self.hide() else: needsInfoUpdate = True @@ -713,8 +720,8 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB idx = self.playlist.getCurrentIndex() currref = self.playlist.getServiceRefList()[idx] text = currref.getPath() - ext = text[-3:].lower() - if ext not in ["mp3", "wav", "ogg"] and not self.isAudioCD: + ext = text[-4:].lower() + if ext not in [".mp3", ".wav", ".ogg", "flac"] and not self.isAudioCD: self.hide() else: needsInfoUpdate = True @@ -852,7 +859,7 @@ def filescan(**kwargs): description = "View Video CD...", openfnc = filescan_open, ), - Scanner(mimetypes = ["audio/mpeg", "audio/x-wav", "application/ogg"], + Scanner(mimetypes = ["audio/mpeg", "audio/x-wav", "application/ogg", "audio/x-flac"], paths_to_scan = [ ScanPath(path = "", with_subdirs = False), diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp index 4e56496a..e435863c 100644 --- a/lib/service/servicemp3.cpp +++ b/lib/service/servicemp3.cpp @@ -12,6 +12,7 @@ #include #include #include +#include find #include /* for subtitles */ #include @@ -35,6 +36,7 @@ eServiceFactoryMP3::eServiceFactoryMP3() extensions.push_back("mkv"); extensions.push_back("avi"); extensions.push_back("dat"); + extensions.push_back("flac"); sc->addServiceFactory(eServiceFactoryMP3::id, this, extensions); } @@ -679,6 +681,7 @@ int eServiceMP3::getInfo(int w) case sTracknumber: case sGenre: case sVideoType: + case sUser+12: return resIsString; case sCurrentTitle: tag = GST_TAG_TRACK_NUMBER; @@ -727,6 +730,8 @@ std::string eServiceMP3::getInfoString(int w) case sVideoType: tag = GST_TAG_VIDEO_CODEC; break; + case sUser+12: + return m_error_message; default: return ""; } @@ -947,6 +952,19 @@ void eServiceMP3::gstBusCall(GstBus *bus, GstMessage *msg) } } } + case GST_MESSAGE_ELEMENT: + { + if ( gst_is_missing_plugin_message(msg) ) + { + gchar *description = gst_missing_plugin_message_get_description(msg); + if ( description ) + { + m_error_message = description; + g_free(description); + m_event((iPlayableService*)this, evUser+12); + } + } + } default: break; } diff --git a/lib/service/servicemp3.h b/lib/service/servicemp3.h index fc3c85ff..823fb799 100644 --- a/lib/service/servicemp3.h +++ b/lib/service/servicemp3.h @@ -153,6 +153,7 @@ private: GstElement *m_gst_pipeline; GstTagList *m_stream_tags; eFixedMessagePump m_pump; + std::string m_error_message; audiotype_t gstCheckAudioPad(GstStructure* structure); void gstBusCall(GstBus *bus, GstMessage *msg); diff --git a/main/Makefile.am b/main/Makefile.am index 67d84660..91606de6 100644 --- a/main/Makefile.am +++ b/main/Makefile.am @@ -48,6 +48,7 @@ enigma2_LDADD = \ @DVBSI_LIBS@ \ @FRIBIDI_LIBS@ \ @GSTREAMER_LIBS@ \ + @GSTREAMERPBUTILS_LIBS@ \ @JPEG_LIBS@ \ @LIBUNGIF_LIBS@ \ @XML2_LIBS@ \ -- 2.30.2