dashdemux: handle error messages from the sources

Set up a message handling function to be able to catch errors
from the source element and signal the cond to allow the download
loop to retry the download.
This commit is contained in:
Thiago Santos 2014-05-02 18:30:05 -03:00
parent 15952dcd8e
commit f09dd7e7a5
2 changed files with 51 additions and 0 deletions

View file

@ -195,6 +195,9 @@ static void gst_dash_demux_dispose (GObject * obj);
static GstStateChangeReturn
gst_dash_demux_change_state (GstElement * element, GstStateChange transition);
/* GstBin */
static void gst_dash_demux_handle_message (GstBin * bin, GstMessage * msg);
/* GstDashDemux */
static GstFlowReturn gst_dash_demux_pad (GstPad * pad, GstObject * parent,
GstBuffer * buf);
@ -258,9 +261,11 @@ gst_dash_demux_class_init (GstDashDemuxClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstBinClass *gstbin_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstbin_class = (GstBinClass *) klass;
gobject_class->set_property = gst_dash_demux_set_property;
gobject_class->get_property = gst_dash_demux_get_property;
@ -301,6 +306,8 @@ gst_dash_demux_class_init (GstDashDemuxClass * klass)
"David Corvoysier <david.corvoysier@orange.com>\n\
Hamid Zakari <hamid.zakari@gmail.com>\n\
Gianluca Gennari <gennarone@gmail.com>");
gstbin_class->handle_message = gst_dash_demux_handle_message;
}
static void
@ -399,6 +406,48 @@ gst_dash_demux_change_state (GstElement * element, GstStateChange transition)
return ret;
}
static void
gst_dash_demux_handle_message (GstBin * bin, GstMessage * msg)
{
GstDashDemux *demux = GST_DASH_DEMUX_CAST (bin);
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_ERROR:{
GSList *iter;
GstDashDemuxStream *stream;
GError *err = NULL;
gchar *debug = NULL;
for (iter = demux->streams; iter; iter = g_slist_next (iter)) {
stream = iter->data;
if (GST_OBJECT_CAST (stream->src) == GST_MESSAGE_SRC (msg)) {
gst_message_parse_error (msg, &err, &debug);
GST_WARNING_OBJECT (stream->pad, "Source posted error: %d:%d %s (%s)",
err->domain, err->code, err->message, debug);
/* error, but ask to retry */
stream->last_ret = GST_FLOW_CUSTOM_ERROR;
g_cond_signal (&stream->fragment_download_cond);
g_error_free (err);
g_free (debug);
break;
}
}
gst_message_unref (msg);
msg = NULL;
}
break;
default:
break;
}
if (msg)
GST_BIN_CLASS (parent_class)->handle_message (bin, msg);
}
static gboolean
gst_dash_demux_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
{

View file

@ -47,6 +47,8 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DASH_DEMUX))
#define GST_IS_DASH_DEMUX_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DASH_DEMUX))
#define GST_DASH_DEMUX_CAST(obj) \
((GstDashDemux *)obj)
typedef struct _GstDashDemuxStream GstDashDemuxStream;
typedef struct _GstDashDemux GstDashDemux;