icydemux: Handle upstream Content-Type.

Allows us to handle ShoutCast TV (NSV) streams.

If the upstream caps have the 'content-type' field set to video/nsv, then
we shortcut the typefinding and set video/x-nsv directly.
This commit is contained in:
Edward Hervey 2010-03-23 19:46:43 +01:00
parent 9d77bcfb29
commit 66d9dbe49e
2 changed files with 49 additions and 21 deletions

View file

@ -180,6 +180,11 @@ gst_icydemux_reset (GstICYDemux * icydemux)
gst_buffer_unref (icydemux->typefind_buf);
icydemux->typefind_buf = NULL;
}
if (icydemux->content_type) {
g_free (icydemux->content_type);
icydemux->content_type = NULL;
}
}
static void
@ -206,17 +211,21 @@ gst_icydemux_sink_setcaps (GstPad * pad, GstCaps * caps)
{
GstICYDemux *icydemux = GST_ICYDEMUX (GST_PAD_PARENT (pad));
GstStructure *structure = gst_caps_get_structure (caps, 0);
const gchar *tmp;
if (!gst_structure_get_int (structure, "metadata-interval",
&icydemux->meta_interval))
return FALSE;
else {
/* If incoming caps have the HTTP Content-Type, copy that over */
if ((tmp = gst_structure_get_string (structure, "content-type")))
icydemux->content_type = g_strdup (tmp);
/* We have a meta interval, so initialise the rest */
icydemux->remaining = icydemux->meta_interval;
icydemux->meta_remaining = 0;
return TRUE;
}
}
static void
gst_icydemux_dispose (GObject * object)
@ -399,15 +408,30 @@ gst_icydemux_typefind_or_forward (GstICYDemux * icydemux, GstBuffer * buf)
{
if (icydemux->typefinding) {
GstBuffer *tf_buf;
GstCaps *caps;
GstCaps *caps = NULL;
GstTypeFindProbability prob;
/* If we have a content-type from upstream, let's see if we can shortcut
* typefinding */
if (G_UNLIKELY (icydemux->content_type)) {
if (!g_ascii_strcasecmp (icydemux->content_type, "video/nsv")) {
GST_DEBUG ("We have a NSV stream");
caps = gst_caps_new_simple ("video/x-nsv", NULL);
} else {
GST_DEBUG ("Upstream Content-Type isn't supported");
g_free (icydemux->content_type);
icydemux->content_type = NULL;
}
}
if (icydemux->typefind_buf) {
icydemux->typefind_buf = gst_buffer_join (icydemux->typefind_buf, buf);
} else {
icydemux->typefind_buf = buf;
}
/* Only typefind if we haven't already got some caps */
if (caps == NULL) {
caps = gst_type_find_helper_for_buffer (GST_OBJECT (icydemux),
icydemux->typefind_buf, &prob);
@ -424,6 +448,7 @@ gst_icydemux_typefind_or_forward (GstICYDemux * icydemux, GstBuffer * buf)
icydemux->typefind_buf = NULL;
return GST_FLOW_ERROR;
}
}
if (!gst_icydemux_add_srcpad (icydemux, caps)) {
GST_DEBUG_OBJECT (icydemux, "Failed to add srcpad");

View file

@ -70,6 +70,9 @@ struct _GstICYDemux
GstAdapter *meta_adapter;
GstBuffer *typefind_buf;
/* upstream HTTP Content-Type */
gchar *content_type;
};
struct _GstICYDemuxClass