summaryrefslogtreecommitdiffstats
path: root/gst
diff options
context:
space:
mode:
authorSebastian Dröge <slomo@circular-chaos.org>2009-01-22 11:44:46 +0100
committerSebastian Dröge <slomo@circular-chaos.org>2009-01-22 13:13:00 +0100
commit52028f2e11e5facd539616d29aff0c7098a057bc (patch)
tree3c704417d516340d77066b12b79ba190dfe53b0b /gst
parentfc4be0acca6c07c36c31fd33bd9f159e83dc6ae5 (diff)
downloadgst-plugins-bad-52028f2e11e5facd539616d29aff0c7098a057bc.tar.gz
gst-plugins-bad-52028f2e11e5facd539616d29aff0c7098a057bc.tar.bz2
gst-plugins-bad-52028f2e11e5facd539616d29aff0c7098a057bc.zip
Build the random index pack while parsing
If the file contains no random index pack or just an invalid one build the random index pack while parsing.
Diffstat (limited to 'gst')
-rw-r--r--gst/mxf/mxfdemux.c49
-rw-r--r--gst/mxf/mxfdemux.h1
2 files changed, 40 insertions, 10 deletions
diff --git a/gst/mxf/mxfdemux.c b/gst/mxf/mxfdemux.c
index 5db0851c..e798365a 100644
--- a/gst/mxf/mxfdemux.c
+++ b/gst/mxf/mxfdemux.c
@@ -293,6 +293,7 @@ gst_mxf_demux_reset (GstMXFDemux * demux)
g_array_free (demux->partition_index, TRUE);
demux->partition_index = NULL;
}
+ demux->parsed_random_index_pack = FALSE;
if (demux->index_table) {
guint i;
@@ -416,6 +417,32 @@ gst_mxf_demux_handle_partition_pack (GstMXFDemux * demux, const MXFUL * key,
if (demux->partition.type == MXF_PARTITION_PACK_HEADER)
demux->footer_partition_pack_offset = demux->partition.footer_partition;
+ if (!demux->parsed_random_index_pack) {
+ MXFRandomIndexPackEntry entry, *last_entry = NULL;
+
+ GST_DEBUG_OBJECT (demux, "Adding partition pack to index");
+
+ if (demux->partition_index && demux->partition_index->len > 0) {
+ last_entry =
+ &g_array_index (demux->partition_index, MXFRandomIndexPackEntry,
+ demux->partition_index->len - 1);
+ } else if (!demux->partition_index) {
+ demux->partition_index =
+ g_array_new (FALSE, FALSE, sizeof (MXFRandomIndexPackEntry));
+ }
+
+ if (last_entry && last_entry->offset >= demux->offset) {
+ GST_DEBUG_OBJECT (demux,
+ "Not adding partition pack to index because it's before the last indexed one");
+ return GST_FLOW_OK;
+ }
+
+ entry.offset = demux->offset;
+ entry.body_sid = demux->partition.body_sid;
+
+ g_array_append_val (demux->partition_index, entry);
+ }
+
return GST_FLOW_OK;
}
@@ -558,11 +585,11 @@ gst_mxf_demux_choose_package (GstMXFDemux * demux)
for (i = 0; i < demux->preface->content_storage->n_packages; i++) {
if (demux->preface->content_storage->packages[i] &&
- MXF_IS_METADATA_MATERIAL_PACKAGE (demux->preface->
- content_storage->packages[i])) {
+ MXF_IS_METADATA_MATERIAL_PACKAGE (demux->preface->content_storage->
+ packages[i])) {
ret =
- MXF_METADATA_GENERIC_PACKAGE (demux->preface->
- content_storage->packages[i]);
+ MXF_METADATA_GENERIC_PACKAGE (demux->preface->content_storage->
+ packages[i]);
break;
}
}
@@ -985,8 +1012,8 @@ gst_mxf_demux_pad_next_component (GstMXFDemux * demux, GstMXFDemuxPad * pad)
GST_DEBUG_OBJECT (demux, "Switching to component %u", pad->current_component);
pad->component =
- MXF_METADATA_SOURCE_CLIP (sequence->
- structural_components[pad->current_component]);
+ MXF_METADATA_SOURCE_CLIP (sequence->structural_components[pad->
+ current_component]);
if (pad->component == NULL) {
GST_ERROR_OBJECT (demux, "No such structural component");
return GST_FLOW_ERROR;
@@ -994,8 +1021,8 @@ gst_mxf_demux_pad_next_component (GstMXFDemux * demux, GstMXFDemuxPad * pad)
if (!pad->component->source_package
|| !pad->component->source_package->top_level
- || !MXF_METADATA_GENERIC_PACKAGE (pad->component->source_package)->
- tracks) {
+ || !MXF_METADATA_GENERIC_PACKAGE (pad->component->
+ source_package)->tracks) {
GST_ERROR_OBJECT (demux, "Invalid component");
return GST_FLOW_ERROR;
}
@@ -1272,7 +1299,7 @@ gst_mxf_demux_handle_random_index_pack (GstMXFDemux * demux, const MXFUL * key,
"Handling random index pack of size %u at offset %"
G_GUINT64_FORMAT, GST_BUFFER_SIZE (buffer), demux->offset);
- if (demux->partition_index) {
+ if (demux->partition_index || demux->parsed_random_index_pack) {
GST_DEBUG_OBJECT (demux, "Already parsed random index pack");
return GST_FLOW_OK;
}
@@ -1283,6 +1310,8 @@ gst_mxf_demux_handle_random_index_pack (GstMXFDemux * demux, const MXFUL * key,
return GST_FLOW_ERROR;
}
+ demux->parsed_random_index_pack = TRUE;
+
return GST_FLOW_OK;
}
@@ -1691,7 +1720,7 @@ gst_mxf_demux_handle_klv_packet (GstMXFDemux * demux, const MXFUL * key,
&& demux->partition.type == MXF_PARTITION_PACK_HEADER
&& (!demux->partition.closed || !demux->partition.complete)
&& (demux->footer_partition_pack_offset != 0 ||
- demux->partition_index->len > 0)) {
+ demux->parsed_random_index_pack)) {
GST_DEBUG_OBJECT (demux,
"Open or incomplete header partition, trying to get final metadata from the last partitions");
gst_mxf_demux_parse_footer_metadata (demux);
diff --git a/gst/mxf/mxfdemux.h b/gst/mxf/mxfdemux.h
index 6e0bbb7b..847e93a1 100644
--- a/gst/mxf/mxfdemux.h
+++ b/gst/mxf/mxfdemux.h
@@ -71,6 +71,7 @@ struct _GstMXFDemux
MXFPartitionPack partition;
MXFPrimerPack primer;
+ gboolean parsed_random_index_pack;
GArray *partition_index;
GArray *index_table;