summaryrefslogtreecommitdiffstats
path: root/gst
diff options
context:
space:
mode:
authorSebastian Dröge <slomo@circular-chaos.org>2008-11-26 11:30:28 +0000
committerSebastian Dröge <slomo@circular-chaos.org>2008-11-26 11:30:28 +0000
commit1f99f89e59590047496c50897760b110a15a4ad0 (patch)
tree20a97b557834da1d87f8f4605ecd53636e6be225 /gst
parent0be182446746b7b03026b6baf667ef5cfe4ef860 (diff)
downloadgst-plugins-bad-1f99f89e59590047496c50897760b110a15a4ad0.tar.gz
gst-plugins-bad-1f99f89e59590047496c50897760b110a15a4ad0.tar.bz2
gst-plugins-bad-1f99f89e59590047496c50897760b110a15a4ad0.zip
gst/mxf/mxfdemux.c: Properly combine flow returns of the source pads.
Original commit message from CVS: * gst/mxf/mxfdemux.c: (gst_mxf_pad_init), (gst_mxf_demux_reset_metadata), (gst_mxf_demux_combine_flows), (gst_mxf_demux_handle_generic_container_essence_element): Properly combine flow returns of the source pads. Improve debugging and reset pad fields together with the metadata to prevent invalid memory references. * gst/mxf/mxfparse.c: (mxf_metadata_preface_parse): Fix typo.
Diffstat (limited to 'gst')
-rw-r--r--gst/mxf/mxfdemux.c61
-rw-r--r--gst/mxf/mxfparse.c3
2 files changed, 58 insertions, 6 deletions
diff --git a/gst/mxf/mxfdemux.c b/gst/mxf/mxfdemux.c
index d02e5ade..198aa284 100644
--- a/gst/mxf/mxfdemux.c
+++ b/gst/mxf/mxfdemux.c
@@ -76,6 +76,8 @@ typedef struct
MXFMetadataTrackType track_type;
gboolean need_segment;
+ GstFlowReturn last_flow;
+
guint64 essence_element_count;
MXFEssenceElementHandler handle_essence_element;
gpointer mapping_data;
@@ -130,7 +132,7 @@ gst_mxf_pad_class_init (GstMXFPadClass * klass)
static void
gst_mxf_pad_init (GstMXFPad * pad)
{
-
+ pad->last_flow = GST_FLOW_OK;
}
static gboolean gst_mxf_demux_sink_event (GstPad * pad, GstEvent * event);
@@ -182,6 +184,18 @@ gst_mxf_demux_reset_metadata (GstMXFDemux * demux)
demux->current_package = NULL;
+ if (demux->src) {
+ for (i = 0; i < demux->src->len; i++) {
+ GstMXFPad *pad = g_ptr_array_index (demux->src, i);
+
+ pad->material_track = NULL;
+ pad->material_package = NULL;
+ pad->component = NULL;
+ pad->source_track = NULL;
+ pad->source_package = NULL;
+ }
+ }
+
mxf_metadata_preface_reset (&demux->preface);
if (demux->identification) {
@@ -377,6 +391,40 @@ gst_mxf_demux_reset (GstMXFDemux * demux)
}
static GstFlowReturn
+gst_mxf_demux_combine_flows (GstMXFDemux * demux,
+ GstMXFPad * pad, GstFlowReturn ret)
+{
+ guint i;
+
+ /* store the value */
+ pad->last_flow = ret;
+
+ /* any other error that is not-linked can be returned right away */
+ if (ret != GST_FLOW_NOT_LINKED)
+ goto done;
+
+ /* only return NOT_LINKED if all other pads returned NOT_LINKED */
+ g_assert (demux->src->len != 0);
+ for (i = 0; i < demux->src->len; i++) {
+ GstMXFPad *opad = g_ptr_array_index (demux->src, i);
+
+ if (opad == NULL)
+ continue;
+
+ ret = opad->last_flow;
+ /* some other return value (must be SUCCESS but we can return
+ * other values as well) */
+ if (ret != GST_FLOW_NOT_LINKED)
+ goto done;
+ }
+ /* if we get here, all other pads were unlinked and we return
+ * NOT_LINKED then */
+done:
+ GST_LOG_OBJECT (demux, "combined return %s", gst_flow_get_name (ret));
+ return ret;
+}
+
+static GstFlowReturn
gst_mxf_demux_pull_range (GstMXFDemux * demux, guint64 offset,
guint size, GstBuffer ** buffer)
{
@@ -1224,9 +1272,8 @@ gst_mxf_demux_handle_header_metadata_resolve_references (GstMXFDemux * demux)
MXFMetadataEssenceContainerData, i);
for (j = 0; j < demux->content_storage.n_essence_container_data; j++) {
- if (mxf_ul_is_equal (&demux->
- content_storage.essence_container_data_uids[j],
- &data->instance_uid)) {
+ if (mxf_ul_is_equal (&demux->content_storage.
+ essence_container_data_uids[j], &data->instance_uid)) {
demux->content_storage.essence_container_data[j] = data;
break;
}
@@ -1964,6 +2011,11 @@ gst_mxf_demux_handle_generic_container_essence_element (GstMXFDemux * demux,
"Handling generic container essence element of size %u"
" at offset %" G_GUINT64_FORMAT, GST_BUFFER_SIZE (buffer), demux->offset);
+ GST_DEBUG_OBJECT (demux, " type = 0x%02x", key->u[12]);
+ GST_DEBUG_OBJECT (demux, " essence element count = 0x%02x", key->u[13]);
+ GST_DEBUG_OBJECT (demux, " essence element type = 0x%02x", key->u[14]);
+ GST_DEBUG_OBJECT (demux, " essence element number = 0x%02x", key->u[15]);
+
if (!demux->current_package) {
GST_ERROR_OBJECT (demux, "No package selected yet");
return GST_FLOW_ERROR;
@@ -2055,6 +2107,7 @@ gst_mxf_demux_handle_generic_container_essence_element (GstMXFDemux * demux,
if (outbuf) {
ret = gst_pad_push (GST_PAD_CAST (pad), outbuf);
+ ret = gst_mxf_demux_combine_flows (demux, pad, ret);
}
return ret;
diff --git a/gst/mxf/mxfparse.c b/gst/mxf/mxfparse.c
index 533e2561..3d6587ff 100644
--- a/gst/mxf/mxfparse.c
+++ b/gst/mxf/mxfparse.c
@@ -769,8 +769,7 @@ mxf_metadata_preface_parse (const MXFUL * key,
if (tag_size < 8)
goto error;
len = GST_READ_UINT32_BE (tag_data);
- GST_DEBUG (" number of identifications = %u",
- preface->n_identifications);
+ GST_DEBUG (" number of identifications = %u", len);
if (len == 0)
break;
if (GST_READ_UINT32_BE (tag_data + 4) != 16)