Created
January 20, 2016 14:54
-
-
Save anonymous/a597469e1da108009508 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 351bf517987a62cafebb20b5eb408b41e4f1ba4f Mon Sep 17 00:00:00 2001 | |
From: mx3L <mx3ldev@gmail.com> | |
Date: Wed, 20 Jan 2016 15:49:26 +0100 | |
Subject: [PATCH] servicemp3: http timeout improvements | |
--- | |
lib/service/servicemp3.cpp | 64 ++++++++++++++-------------------------------- | |
lib/service/servicemp3.h | 1 - | |
2 files changed, 19 insertions(+), 46 deletions(-) | |
diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp | |
index 8100222..7559042 100644 | |
--- a/lib/service/servicemp3.cpp | |
+++ b/lib/service/servicemp3.cpp | |
@@ -401,7 +401,6 @@ eServiceMP3::eServiceMP3(eServiceReference ref): | |
m_pump(eApp, 1) | |
{ | |
m_subtitle_sync_timer = eTimer::create(eApp); | |
- m_streamingsrc_timeout = 0; | |
m_stream_tags = 0; | |
m_currentAudioStream = -1; | |
m_currentSubtitleStream = -1; | |
@@ -524,8 +523,6 @@ eServiceMP3::eServiceMP3(eServiceReference ref): | |
if ( m_sourceinfo.is_streaming ) | |
{ | |
uri = g_strdup_printf ("%s", filename); | |
- m_streamingsrc_timeout = eTimer::create(eApp);; | |
- CONNECT(m_streamingsrc_timeout->timeout, eServiceMP3::sourceTimeout); | |
if ( m_ref.getData(7) & BUFFERING_ENABLED ) | |
{ | |
@@ -776,13 +773,6 @@ RESULT eServiceMP3::start() | |
return 0; | |
} | |
-void eServiceMP3::sourceTimeout() | |
-{ | |
- eDebug("[eServiceMP3] http source timeout! issuing eof..."); | |
- stop(); | |
- m_event((iPlayableService*)this, evEOF); | |
-} | |
- | |
RESULT eServiceMP3::stop() | |
{ | |
if (!m_gst_playbin || m_state == stStopped) | |
@@ -806,8 +796,6 @@ RESULT eServiceMP3::stop() | |
saveCuesheet(); | |
m_nownext_timer->stop(); | |
- if (m_streamingsrc_timeout) | |
- m_streamingsrc_timeout->stop(); | |
return 0; | |
} | |
@@ -1749,8 +1737,6 @@ void eServiceMP3::gstBusCall(GstMessage *msg) | |
} break; | |
case GST_STATE_CHANGE_PAUSED_TO_PLAYING: | |
{ | |
- if ( m_sourceinfo.is_streaming && m_streamingsrc_timeout ) | |
- m_streamingsrc_timeout->stop(); | |
m_paused = false; | |
if (m_seek_paused) | |
{ | |
@@ -1800,6 +1786,13 @@ void eServiceMP3::gstBusCall(GstMessage *msg) | |
m_event((iPlayableService*)this, evUser+10); | |
} | |
} | |
+ else if ( err->domain == GST_RESOURCE_ERROR ) | |
+ { | |
+ if ( err->code == GST_RESOURCE_ERROR_OPEN_READ || err->code == GST_RESOURCE_ERROR_READ ) | |
+ { | |
+ stop(); | |
+ } | |
+ } | |
g_error_free(err); | |
break; | |
} | |
@@ -2131,37 +2124,6 @@ void eServiceMP3::gstBusCall(GstMessage *msg) | |
} | |
} | |
break; | |
- case GST_MESSAGE_STREAM_STATUS: | |
- { | |
- GstStreamStatusType type; | |
- GstElement *owner; | |
- gst_message_parse_stream_status (msg, &type, &owner); | |
- if ( type == GST_STREAM_STATUS_TYPE_CREATE && m_sourceinfo.is_streaming ) | |
- { | |
- if ( GST_IS_PAD(source) ) | |
- owner = gst_pad_get_parent_element(GST_PAD(source)); | |
- else if ( GST_IS_ELEMENT(source) ) | |
- owner = GST_ELEMENT(source); | |
- else | |
- owner = 0; | |
- if ( owner ) | |
- { | |
- GstState state; | |
- gst_element_get_state(m_gst_playbin, &state, NULL, 0LL); | |
- GstElementFactory *factory = gst_element_get_factory(GST_ELEMENT(owner)); | |
- const gchar *name = gst_plugin_feature_get_name(GST_PLUGIN_FEATURE(factory)); | |
- if (!strcmp(name, "souphttpsrc") && (state == GST_STATE_READY) && !m_streamingsrc_timeout->isActive()) | |
- { | |
- m_streamingsrc_timeout->start(HTTP_TIMEOUT*1000, true); | |
- g_object_set (G_OBJECT (owner), "timeout", HTTP_TIMEOUT, NULL); | |
- eDebug("[eServiceMP3] GST_STREAM_STATUS_TYPE_CREATE -> setting timeout on %s to %is", name, HTTP_TIMEOUT); | |
- } | |
- } | |
- if ( GST_IS_PAD(source) ) | |
- gst_object_unref(owner); | |
- } | |
- break; | |
- } | |
default: | |
break; | |
} | |
@@ -2259,6 +2221,18 @@ void eServiceMP3::playbinNotifySource(GObject *object, GParamSpec *unused, gpoin | |
g_object_get(object, "source", &source, NULL); | |
if (source) | |
{ | |
+ if (g_object_class_find_property(G_OBJECT_GET_CLASS(source), "timeout") != 0) | |
+ { | |
+ GstElementFactory *factory = gst_element_get_factory(source); | |
+ if (factory) | |
+ { | |
+ const gchar *sourcename = gst_plugin_feature_get_name(GST_PLUGIN_FEATURE(factory)); | |
+ if (!strcmp(sourcename, "souphttpsrc")) | |
+ { | |
+ g_object_set(G_OBJECT(source), "timeout", HTTP_TIMEOUT, NULL); | |
+ } | |
+ } | |
+ } | |
if (g_object_class_find_property(G_OBJECT_GET_CLASS(source), "ssl-strict") != 0) | |
{ | |
g_object_set(G_OBJECT(source), "ssl-strict", FALSE, NULL); | |
diff --git a/lib/service/servicemp3.h b/lib/service/servicemp3.h | |
index adf081a..132e3b3 100644 | |
--- a/lib/service/servicemp3.h | |
+++ b/lib/service/servicemp3.h | |
@@ -360,7 +360,6 @@ private: | |
subtitle_pages_map_t m_subtitle_pages; | |
ePtr<eTimer> m_subtitle_sync_timer; | |
- ePtr<eTimer> m_streamingsrc_timeout; | |
pts_t m_prev_decoder_time; | |
int m_decoder_time_valid_state; | |
-- | |
1.9.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment