summaryrefslogtreecommitdiffstats
path: root/gst/icydemux
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.net>2006-09-14 10:38:42 +0000
committerTim-Philipp Müller <tim@centricular.net>2006-09-14 10:38:42 +0000
commite73ddd490e67ef375586cb5c668bd8fb2c8b802a (patch)
tree26d3e753191cda4d6fa405d0bdd6b8bd82f0ebc1 /gst/icydemux
parent13a332da30057c942738ba68298c77ae1d20f1ed (diff)
gst/icydemux/gsticydemux.*: When we merge/collect multiple incoming buffers for typefinding purposes, keep an initial...
Original commit message from CVS: * gst/icydemux/gsticydemux.c: (gst_icydemux_reset), (gst_icydemux_typefind_or_forward): * gst/icydemux/gsticydemux.h: When we merge/collect multiple incoming buffers for typefinding purposes, keep an initial 0 offset on the first outgoing buffer as well (otherwise id3demux won't work right). Fixes #345449. Also Make buffer metadata writable before setting buffer caps. * tests/check/elements/icydemux.c: (typefind_succeed), (cleanup_icydemux), (push_data), (GST_START_TEST), (icydemux_suite): Small test case for the above.
Diffstat (limited to 'gst/icydemux')
-rw-r--r--gst/icydemux/gsticydemux.c60
-rw-r--r--gst/icydemux/gsticydemux.h2
2 files changed, 26 insertions, 36 deletions
diff --git a/gst/icydemux/gsticydemux.c b/gst/icydemux/gsticydemux.c
index 1518b261..f2ba6e33 100644
--- a/gst/icydemux/gsticydemux.c
+++ b/gst/icydemux/gsticydemux.c
@@ -177,10 +177,9 @@ gst_icydemux_reset (GstICYDemux * icydemux)
icydemux->meta_adapter = NULL;
}
- if (icydemux->typefind_adapter) {
- gst_adapter_clear (icydemux->typefind_adapter);
- g_object_unref (icydemux->typefind_adapter);
- icydemux->typefind_adapter = NULL;
+ if (icydemux->typefind_buf) {
+ gst_buffer_unref (icydemux->typefind_buf);
+ icydemux->typefind_buf = NULL;
}
}
@@ -427,49 +426,38 @@ static GstFlowReturn
gst_icydemux_typefind_or_forward (GstICYDemux * icydemux, GstBuffer * buf)
{
if (icydemux->typefinding) {
- GstBuffer *typefind_buf;
- const guint8 *data;
+ GstBuffer *tf_buf;
GstCaps *caps;
- int size;
guint prob;
- if (!icydemux->typefind_adapter)
- icydemux->typefind_adapter = gst_adapter_new ();
-
- gst_adapter_push (icydemux->typefind_adapter, buf);
-
- size = gst_adapter_available (icydemux->typefind_adapter);
- typefind_buf = gst_buffer_new ();
-
- data = gst_adapter_peek (icydemux->typefind_adapter, size);
-
- GST_BUFFER_DATA (typefind_buf) = (guint8 *) data;
- GST_BUFFER_SIZE (typefind_buf) = size;
+ if (icydemux->typefind_buf) {
+ icydemux->typefind_buf = gst_buffer_join (icydemux->typefind_buf, buf);
+ } else {
+ icydemux->typefind_buf = buf;
+ }
caps = gst_type_find_helper_for_buffer (GST_OBJECT (icydemux),
- typefind_buf, &prob);
+ icydemux->typefind_buf, &prob);
if (caps == NULL) {
- if (size < ICY_TYPE_FIND_MAX_SIZE) {
- gst_buffer_unref (typefind_buf);
+ if (GST_BUFFER_SIZE (icydemux->typefind_buf) < ICY_TYPE_FIND_MAX_SIZE) {
/* Just break for more data */
return GST_FLOW_OK;
}
/* We failed typefind */
- GST_ELEMENT_ERROR (icydemux, CORE, CAPS,
- ("Could not determine the mime type of the file"),
+ GST_ELEMENT_ERROR (icydemux, STREAM, TYPE_NOT_FOUND, (NULL),
("No caps found for contents within an ICY stream"));
- gst_buffer_unref (typefind_buf);
- gst_adapter_clear (icydemux->typefind_adapter);
+ gst_buffer_unref (icydemux->typefind_buf);
+ icydemux->typefind_buf = NULL;
return GST_FLOW_ERROR;
}
if (!gst_icydemux_add_srcpad (icydemux, caps)) {
GST_DEBUG_OBJECT (icydemux, "Failed to add srcpad");
gst_caps_unref (caps);
- gst_buffer_unref (typefind_buf);
- gst_adapter_clear (icydemux->typefind_adapter);
+ gst_buffer_unref (icydemux->typefind_buf);
+ icydemux->typefind_buf = NULL;
return GST_FLOW_ERROR;
}
gst_caps_unref (caps);
@@ -487,21 +475,23 @@ gst_icydemux_typefind_or_forward (GstICYDemux * icydemux, GstBuffer * buf)
* to get that forwarded. */
icydemux->typefinding = FALSE;
- data = gst_adapter_take (icydemux->typefind_adapter, size);
- GST_BUFFER_DATA (typefind_buf) = (guint8 *) data;
- GST_BUFFER_MALLOCDATA (typefind_buf) = (guint8 *) data;
-
- return gst_icydemux_typefind_or_forward (icydemux, typefind_buf);
+ tf_buf = icydemux->typefind_buf;
+ icydemux->typefind_buf = NULL;
+ return gst_icydemux_typefind_or_forward (icydemux, tf_buf);
} else {
if (G_UNLIKELY (icydemux->srcpad == NULL)) {
gst_buffer_unref (buf);
return GST_FLOW_ERROR;
}
+ buf = gst_buffer_make_metadata_writable (buf);
gst_buffer_set_caps (buf, icydemux->src_caps);
- /* Most things don't care, and it's a pain to track */
- GST_BUFFER_OFFSET (buf) = GST_BUFFER_OFFSET_NONE;
+ /* Most things don't care, and it's a pain to track (we should preserve a
+ * 0 offset on the first buffer though if it's there, for id3demux etc.) */
+ if (GST_BUFFER_OFFSET (buf) != 0) {
+ GST_BUFFER_OFFSET (buf) = GST_BUFFER_OFFSET_NONE;
+ }
return gst_pad_push (icydemux->srcpad, buf);
}
diff --git a/gst/icydemux/gsticydemux.h b/gst/icydemux/gsticydemux.h
index aea88828..3e676d12 100644
--- a/gst/icydemux/gsticydemux.h
+++ b/gst/icydemux/gsticydemux.h
@@ -69,7 +69,7 @@ struct _GstICYDemux
GstAdapter *meta_adapter;
- GstAdapter *typefind_adapter;
+ GstBuffer *typefind_buf;
};
struct _GstICYDemuxClass