From: Fraxinas Date: Tue, 20 Jul 2010 08:06:11 +0000 (+0200) Subject: implement configurable http user-agent (fixes #224) X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=commitdiff_plain;h=675f9d0eeb82577252a68ee263049acc1ff80bcc implement configurable http user-agent (fixes #224) --- diff --git a/lib/python/Plugins/Extensions/MediaPlayer/settings.py b/lib/python/Plugins/Extensions/MediaPlayer/settings.py index 0b95812..7f42677 100755 --- a/lib/python/Plugins/Extensions/MediaPlayer/settings.py +++ b/lib/python/Plugins/Extensions/MediaPlayer/settings.py @@ -12,6 +12,8 @@ config.mediaplayer.repeat = ConfigYesNo(default=False) config.mediaplayer.savePlaylistOnExit = ConfigYesNo(default=True) config.mediaplayer.saveDirOnExit = ConfigYesNo(default=False) config.mediaplayer.defaultDir = ConfigDirectory() +config.mediaplayer.useAlternateUserAgent = ConfigYesNo(default=False) +config.mediaplayer.alternateUserAgent = ConfigText(default="") class DirectoryBrowser(Screen, HelpableScreen): diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp index b34b62f..b50b52d 100644 --- a/lib/service/servicemp3.cpp +++ b/lib/service/servicemp3.cpp @@ -290,8 +290,20 @@ eServiceMP3::eServiceMP3(eServiceReference ref) if ( m_sourceinfo.is_streaming ) { uri = g_strdup_printf ("%s", filename); +<<<<<<< HEAD m_streamingsrc_timeout = eTimer::create(eApp);; CONNECT(m_streamingsrc_timeout->timeout, eServiceMP3::sourceTimeout); +======= + + std::string config_str; + if( ePythonConfigQuery::getConfigValue("config.mediaplayer.useAlternateUserAgent", config_str) == 0 ) + { + if ( config_str == "True" ) + ePythonConfigQuery::getConfigValue("config.mediaplayer.alternateUserAgent", m_useragent); + } + if ( m_useragent.length() == 0 ) + m_useragent = "Dream Multimedia Dreambox Enigma2 Mediaplayer"; +>>>>>>> b08c138... implement configurable http user-agent (fixes #224) } else if ( m_sourceinfo.containertype == ctCDA ) { @@ -353,6 +365,10 @@ eServiceMP3::eServiceMP3(eServiceReference ref) subs.language_code = std::string("und"); m_subtitleStreams.push_back(subs); } + if ( sourceinfo.is_streaming ) + { + g_signal_connect (G_OBJECT (m_gst_playbin), "notify::source", G_CALLBACK (gstHTTPSourceSetAgent), this); + } } else { m_event((iPlayableService*)this, evUser+12); @@ -1410,6 +1426,15 @@ GstBusSyncReply eServiceMP3::gstBusSyncHandler(GstBus *bus, GstMessage *message, return GST_BUS_PASS; } +void eServiceMP3::gstHTTPSourceSetAgent(GObject *object, GParamSpec *unused, gpointer user_data) +{ + eServiceMP3 *_this = (eServiceMP3*)user_data; + GstElement *source; + g_object_get(_this->m_gst_playbin, "source", &source, NULL); + g_object_set (G_OBJECT (source), "user-agent", _this->m_useragent.c_str(), NULL); + gst_object_unref(source); +} + audiotype_t eServiceMP3::gstCheckAudioPad(GstStructure* structure) { if (!structure) diff --git a/lib/service/servicemp3.h b/lib/service/servicemp3.h index af68bd9..01f7cf7 100644 --- a/lib/service/servicemp3.h +++ b/lib/service/servicemp3.h @@ -208,6 +208,7 @@ private: static void gstCBsubtitleAvail(GstElement *element, gpointer user_data); GstPad* gstCreateSubtitleSink(eServiceMP3* _this, subtype_t type); void gstPoll(const int&); + static void gstHTTPSourceSetAgent(GObject *source, GParamSpec *unused, gpointer user_data); std::list m_subtitle_pages; ePtr m_subtitle_sync_timer; @@ -224,6 +225,7 @@ private: RESULT seekToImpl(pts_t to); gint m_aspect, m_width, m_height, m_framerate, m_progressive; + std::string m_useragent; RESULT trickSeek(gdouble ratio); }; #endif