• Home
  • Raw
  • Download

Lines Matching refs:demux

76 gst_mxf_demux_peek_klv_packet (GstMXFDemux * demux, guint64 offset,
81 gst_mxf_demux_fill_klv (GstMXFDemux * demux, GstMXFKLV * klv);
85 static void gst_mxf_demux_consume_klv (GstMXFDemux * demux, GstMXFKLV * klv);
88 gst_mxf_demux_handle_index_table_segment (GstMXFDemux * demux, GstMXFKLV * klv);
90 static void collect_index_table_segments (GstMXFDemux * demux);
91 static gboolean find_entry_for_offset (GstMXFDemux * demux,
149 gst_mxf_demux_remove_pad (GstMXFDemuxPad * pad, GstMXFDemux * demux) in gst_mxf_demux_remove_pad() argument
151 gst_flow_combiner_remove_pad (demux->flowcombiner, GST_PAD_CAST (pad)); in gst_mxf_demux_remove_pad()
152 gst_element_remove_pad (GST_ELEMENT (demux), GST_PAD_CAST (pad)); in gst_mxf_demux_remove_pad()
156 gst_mxf_demux_remove_pads (GstMXFDemux * demux) in gst_mxf_demux_remove_pads() argument
158 g_ptr_array_foreach (demux->src, (GFunc) gst_mxf_demux_remove_pad, demux); in gst_mxf_demux_remove_pads()
159 g_ptr_array_foreach (demux->src, (GFunc) gst_object_unref, NULL); in gst_mxf_demux_remove_pads()
160 g_ptr_array_set_size (demux->src, 0); in gst_mxf_demux_remove_pads()
173 gst_mxf_demux_reset_mxf_state (GstMXFDemux * demux) in gst_mxf_demux_reset_mxf_state() argument
177 GST_DEBUG_OBJECT (demux, "Resetting MXF state"); in gst_mxf_demux_reset_mxf_state()
179 g_list_foreach (demux->partitions, (GFunc) gst_mxf_demux_partition_free, in gst_mxf_demux_reset_mxf_state()
181 g_list_free (demux->partitions); in gst_mxf_demux_reset_mxf_state()
182 demux->partitions = NULL; in gst_mxf_demux_reset_mxf_state()
184 demux->current_partition = NULL; in gst_mxf_demux_reset_mxf_state()
186 for (i = 0; i < demux->essence_tracks->len; i++) { in gst_mxf_demux_reset_mxf_state()
188 &g_array_index (demux->essence_tracks, GstMXFDemuxEssenceTrack, i); in gst_mxf_demux_reset_mxf_state()
201 g_array_set_size (demux->essence_tracks, 0); in gst_mxf_demux_reset_mxf_state()
205 gst_mxf_demux_reset_linked_metadata (GstMXFDemux * demux) in gst_mxf_demux_reset_linked_metadata() argument
209 for (i = 0; i < demux->src->len; i++) { in gst_mxf_demux_reset_linked_metadata()
210 GstMXFDemuxPad *pad = g_ptr_array_index (demux->src, i); in gst_mxf_demux_reset_linked_metadata()
217 for (i = 0; i < demux->essence_tracks->len; i++) { in gst_mxf_demux_reset_linked_metadata()
219 &g_array_index (demux->essence_tracks, GstMXFDemuxEssenceTrack, i); in gst_mxf_demux_reset_linked_metadata()
226 demux->current_package = NULL; in gst_mxf_demux_reset_linked_metadata()
230 gst_mxf_demux_reset_metadata (GstMXFDemux * demux) in gst_mxf_demux_reset_metadata() argument
232 GST_DEBUG_OBJECT (demux, "Resetting metadata"); in gst_mxf_demux_reset_metadata()
234 g_rw_lock_writer_lock (&demux->metadata_lock); in gst_mxf_demux_reset_metadata()
236 demux->update_metadata = TRUE; in gst_mxf_demux_reset_metadata()
237 demux->metadata_resolved = FALSE; in gst_mxf_demux_reset_metadata()
239 gst_mxf_demux_reset_linked_metadata (demux); in gst_mxf_demux_reset_metadata()
241 demux->preface = NULL; in gst_mxf_demux_reset_metadata()
243 if (demux->metadata) { in gst_mxf_demux_reset_metadata()
244 g_hash_table_destroy (demux->metadata); in gst_mxf_demux_reset_metadata()
246 demux->metadata = mxf_metadata_hash_table_new (); in gst_mxf_demux_reset_metadata()
248 if (demux->tags) { in gst_mxf_demux_reset_metadata()
249 gst_tag_list_unref (demux->tags); in gst_mxf_demux_reset_metadata()
250 demux->tags = NULL; in gst_mxf_demux_reset_metadata()
253 g_rw_lock_writer_unlock (&demux->metadata_lock); in gst_mxf_demux_reset_metadata()
257 gst_mxf_demux_reset (GstMXFDemux * demux) in gst_mxf_demux_reset() argument
259 GST_DEBUG_OBJECT (demux, "cleaning up MXF demuxer"); in gst_mxf_demux_reset()
261 demux->flushing = FALSE; in gst_mxf_demux_reset()
263 demux->state = GST_MXF_DEMUX_STATE_UNKNOWN; in gst_mxf_demux_reset()
265 demux->footer_partition_pack_offset = 0; in gst_mxf_demux_reset()
266 demux->offset = 0; in gst_mxf_demux_reset()
268 demux->pull_footer_metadata = TRUE; in gst_mxf_demux_reset()
270 demux->run_in = -1; in gst_mxf_demux_reset()
272 memset (&demux->current_package_uid, 0, sizeof (MXFUMID)); in gst_mxf_demux_reset()
274 gst_segment_init (&demux->segment, GST_FORMAT_TIME); in gst_mxf_demux_reset()
276 if (demux->close_seg_event) { in gst_mxf_demux_reset()
277 gst_event_unref (demux->close_seg_event); in gst_mxf_demux_reset()
278 demux->close_seg_event = NULL; in gst_mxf_demux_reset()
281 gst_adapter_clear (demux->adapter); in gst_mxf_demux_reset()
283 gst_mxf_demux_remove_pads (demux); in gst_mxf_demux_reset()
285 if (demux->random_index_pack) { in gst_mxf_demux_reset()
286 g_array_free (demux->random_index_pack, TRUE); in gst_mxf_demux_reset()
287 demux->random_index_pack = NULL; in gst_mxf_demux_reset()
290 if (demux->pending_index_table_segments) { in gst_mxf_demux_reset()
293 for (l = demux->pending_index_table_segments; l; l = l->next) { in gst_mxf_demux_reset()
298 g_list_free (demux->pending_index_table_segments); in gst_mxf_demux_reset()
299 demux->pending_index_table_segments = NULL; in gst_mxf_demux_reset()
302 if (demux->index_tables) { in gst_mxf_demux_reset()
305 for (l = demux->index_tables; l; l = l->next) { in gst_mxf_demux_reset()
311 g_list_free (demux->index_tables); in gst_mxf_demux_reset()
312 demux->index_tables = NULL; in gst_mxf_demux_reset()
315 demux->index_table_segments_collected = FALSE; in gst_mxf_demux_reset()
317 gst_mxf_demux_reset_mxf_state (demux); in gst_mxf_demux_reset()
318 gst_mxf_demux_reset_metadata (demux); in gst_mxf_demux_reset()
320 demux->have_group_id = FALSE; in gst_mxf_demux_reset()
321 demux->group_id = G_MAXUINT; in gst_mxf_demux_reset()
325 gst_mxf_demux_pull_range (GstMXFDemux * demux, guint64 offset, in gst_mxf_demux_pull_range() argument
330 ret = gst_pad_pull_range (demux->sinkpad, offset, size, buffer); in gst_mxf_demux_pull_range()
332 GST_WARNING_OBJECT (demux, in gst_mxf_demux_pull_range()
340 GST_WARNING_OBJECT (demux, in gst_mxf_demux_pull_range()
353 gst_mxf_demux_push_src_event (GstMXFDemux * demux, GstEvent * event) in gst_mxf_demux_push_src_event() argument
358 GST_DEBUG_OBJECT (demux, "Pushing '%s' event downstream", in gst_mxf_demux_push_src_event()
361 for (i = 0; i < demux->src->len; i++) { in gst_mxf_demux_push_src_event()
362 GstMXFDemuxPad *pad = GST_MXF_DEMUX_PAD (g_ptr_array_index (demux->src, i)); in gst_mxf_demux_push_src_event()
376 gst_mxf_demux_get_earliest_pad (GstMXFDemux * demux) in gst_mxf_demux_get_earliest_pad() argument
382 for (i = 0; i < demux->src->len; i++) { in gst_mxf_demux_get_earliest_pad()
383 GstMXFDemuxPad *p = g_ptr_array_index (demux->src, i); in gst_mxf_demux_get_earliest_pad()
410 gst_mxf_demux_partition_postcheck (GstMXFDemux * demux, in gst_mxf_demux_partition_postcheck() argument
414 GstMXFDemuxPartition *old_partition = demux->current_partition; in gst_mxf_demux_partition_postcheck()
420 for (i = 0; i < demux->essence_tracks->len; i++) { in gst_mxf_demux_partition_postcheck()
422 &g_array_index (demux->essence_tracks, GstMXFDemuxEssenceTrack, i); in gst_mxf_demux_partition_postcheck()
428 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_partition_postcheck()
442 if (gst_mxf_demux_peek_klv_packet (demux, in gst_mxf_demux_partition_postcheck()
449 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_partition_postcheck()
454 demux->current_partition = partition; in gst_mxf_demux_partition_postcheck()
455 find_entry_for_offset (demux, cand, in gst_mxf_demux_partition_postcheck()
457 demux->current_partition = old_partition; in gst_mxf_demux_partition_postcheck()
467 gst_mxf_demux_handle_partition_pack (GstMXFDemux * demux, GstMXFKLV * klv) in gst_mxf_demux_handle_partition_pack() argument
476 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_handle_partition_pack()
480 for (l = demux->partitions; l; l = l->next) { in gst_mxf_demux_handle_partition_pack()
483 if (tmp->partition.this_partition + demux->run_in == demux->offset && in gst_mxf_demux_handle_partition_pack()
485 GST_DEBUG_OBJECT (demux, "Partition already parsed"); in gst_mxf_demux_handle_partition_pack()
491 flowret = gst_mxf_demux_fill_klv (demux, klv); in gst_mxf_demux_handle_partition_pack()
499 GST_ERROR_OBJECT (demux, "Parsing partition pack failed"); in gst_mxf_demux_handle_partition_pack()
503 if (partition.this_partition != demux->offset + demux->run_in) { in gst_mxf_demux_handle_partition_pack()
504 GST_WARNING_OBJECT (demux, in gst_mxf_demux_handle_partition_pack()
507 partition.this_partition, demux->offset, demux->run_in); in gst_mxf_demux_handle_partition_pack()
508 partition.this_partition = demux->offset + demux->run_in; in gst_mxf_demux_handle_partition_pack()
512 demux->footer_partition_pack_offset = partition.footer_partition; in gst_mxf_demux_handle_partition_pack()
514 for (l = demux->partitions; l; l = l->next) { in gst_mxf_demux_handle_partition_pack()
517 if (tmp->partition.this_partition + demux->run_in == demux->offset) { in gst_mxf_demux_handle_partition_pack()
529 demux->partitions = in gst_mxf_demux_handle_partition_pack()
530 g_list_insert_sorted (demux->partitions, p, in gst_mxf_demux_handle_partition_pack()
534 gst_mxf_demux_partition_postcheck (demux, p); in gst_mxf_demux_handle_partition_pack()
536 for (l = demux->partitions; l; l = l->next) { in gst_mxf_demux_handle_partition_pack()
549 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_handle_partition_pack()
553 demux->current_partition = p; in gst_mxf_demux_handle_partition_pack()
559 gst_mxf_demux_handle_primer_pack (GstMXFDemux * demux, GstMXFKLV * klv) in gst_mxf_demux_handle_primer_pack() argument
565 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_handle_primer_pack()
569 if (G_UNLIKELY (!demux->current_partition)) { in gst_mxf_demux_handle_primer_pack()
570 GST_ERROR_OBJECT (demux, "Primer pack before partition pack"); in gst_mxf_demux_handle_primer_pack()
574 if (G_UNLIKELY (demux->current_partition->primer.mappings)) { in gst_mxf_demux_handle_primer_pack()
575 GST_DEBUG_OBJECT (demux, "Primer pack already exists"); in gst_mxf_demux_handle_primer_pack()
579 flowret = gst_mxf_demux_fill_klv (demux, klv); in gst_mxf_demux_handle_primer_pack()
584 ret = mxf_primer_pack_parse (&klv->key, &demux->current_partition->primer, in gst_mxf_demux_handle_primer_pack()
588 GST_ERROR_OBJECT (demux, "Parsing primer pack failed"); in gst_mxf_demux_handle_primer_pack()
592 demux->current_partition->primer.offset = demux->offset; in gst_mxf_demux_handle_primer_pack()
598 gst_mxf_demux_resolve_references (GstMXFDemux * demux) in gst_mxf_demux_resolve_references() argument
606 g_rw_lock_writer_lock (&demux->metadata_lock); in gst_mxf_demux_resolve_references()
608 GST_DEBUG_OBJECT (demux, "Resolve metadata references"); in gst_mxf_demux_resolve_references()
609 demux->update_metadata = FALSE; in gst_mxf_demux_resolve_references()
611 if (!demux->metadata) { in gst_mxf_demux_resolve_references()
612 GST_ERROR_OBJECT (demux, "No metadata yet"); in gst_mxf_demux_resolve_references()
613 g_rw_lock_writer_unlock (&demux->metadata_lock); in gst_mxf_demux_resolve_references()
617 g_hash_table_iter_init (&iter, demux->metadata); in gst_mxf_demux_resolve_references()
622 g_hash_table_iter_init (&iter, demux->metadata); in gst_mxf_demux_resolve_references()
626 resolved = mxf_metadata_base_resolve (m, demux->metadata); in gst_mxf_demux_resolve_references()
636 demux->metadata_resolved = TRUE; in gst_mxf_demux_resolve_references()
639 mxf_metadata_base_to_structure (MXF_METADATA_BASE (demux->preface)); in gst_mxf_demux_resolve_references()
640 if (!demux->tags) in gst_mxf_demux_resolve_references()
641 demux->tags = gst_tag_list_new_empty (); in gst_mxf_demux_resolve_references()
643 gst_tag_list_add (demux->tags, GST_TAG_MERGE_REPLACE, GST_TAG_MXF_STRUCTURE, in gst_mxf_demux_resolve_references()
649 for (i = 0; i < demux->preface->n_identifications; i++) { in gst_mxf_demux_resolve_references()
651 demux->preface->identifications[i]; in gst_mxf_demux_resolve_references()
653 GST_DEBUG_OBJECT (demux, "product:'%s' company:'%s'", in gst_mxf_demux_resolve_references()
659 GST_WARNING_OBJECT (demux, in gst_mxf_demux_resolve_references()
661 demux->temporal_order_misuse = TRUE; in gst_mxf_demux_resolve_references()
665 g_rw_lock_writer_unlock (&demux->metadata_lock); in gst_mxf_demux_resolve_references()
670 demux->metadata_resolved = FALSE; in gst_mxf_demux_resolve_references()
671 g_rw_lock_writer_unlock (&demux->metadata_lock); in gst_mxf_demux_resolve_references()
677 gst_mxf_demux_find_package (GstMXFDemux * demux, const MXFUMID * umid) in gst_mxf_demux_find_package() argument
682 if (demux->preface->content_storage in gst_mxf_demux_find_package()
683 && demux->preface->content_storage->packages) { in gst_mxf_demux_find_package()
684 for (i = 0; i < demux->preface->content_storage->n_packages; i++) { in gst_mxf_demux_find_package()
686 demux->preface->content_storage->packages[i]; in gst_mxf_demux_find_package()
702 gst_mxf_demux_choose_package (GstMXFDemux * demux) in gst_mxf_demux_choose_package() argument
707 if (demux->requested_package_string) { in gst_mxf_demux_choose_package()
711 if (!mxf_umid_from_string (demux->requested_package_string, &umid)) { in gst_mxf_demux_choose_package()
712 GST_ERROR_OBJECT (demux, "Invalid requested package"); in gst_mxf_demux_choose_package()
714 g_free (demux->requested_package_string); in gst_mxf_demux_choose_package()
715 demux->requested_package_string = NULL; in gst_mxf_demux_choose_package()
717 ret = gst_mxf_demux_find_package (demux, &umid); in gst_mxf_demux_choose_package()
720 if (!ret && !mxf_umid_is_zero (&demux->current_package_uid)) in gst_mxf_demux_choose_package()
721 ret = gst_mxf_demux_find_package (demux, &demux->current_package_uid); in gst_mxf_demux_choose_package()
728 GST_WARNING_OBJECT (demux, in gst_mxf_demux_choose_package()
730 else if (!mxf_umid_is_zero (&demux->current_package_uid)) in gst_mxf_demux_choose_package()
731 GST_WARNING_OBJECT (demux, in gst_mxf_demux_choose_package()
734 ret = demux->preface->primary_package; in gst_mxf_demux_choose_package()
741 for (i = 0; i < demux->preface->content_storage->n_packages; i++) { in gst_mxf_demux_choose_package()
742 if (demux->preface->content_storage->packages[i] && in gst_mxf_demux_choose_package()
743 MXF_IS_METADATA_MATERIAL_PACKAGE (demux->preface->content_storage-> in gst_mxf_demux_choose_package()
746 MXF_METADATA_GENERIC_PACKAGE (demux->preface->content_storage-> in gst_mxf_demux_choose_package()
753 GST_ERROR_OBJECT (demux, "No material package"); in gst_mxf_demux_choose_package()
758 if (mxf_umid_is_equal (&ret->package_uid, &demux->current_package_uid)) { in gst_mxf_demux_choose_package()
761 gst_mxf_demux_remove_pads (demux); in gst_mxf_demux_choose_package()
762 memcpy (&demux->current_package_uid, &ret->package_uid, 32); in gst_mxf_demux_choose_package()
765 demux->current_package_string = g_strdup (current_package_string); in gst_mxf_demux_choose_package()
766 g_object_notify (G_OBJECT (demux), "package"); in gst_mxf_demux_choose_package()
768 if (!demux->tags) in gst_mxf_demux_choose_package()
769 demux->tags = gst_tag_list_new_empty (); in gst_mxf_demux_choose_package()
770 gst_tag_list_add (demux->tags, GST_TAG_MERGE_REPLACE, GST_TAG_MXF_UMID, in gst_mxf_demux_choose_package()
771 demux->current_package_string, NULL); in gst_mxf_demux_choose_package()
773 demux->current_package = ret; in gst_mxf_demux_choose_package()
779 gst_mxf_demux_update_essence_tracks (GstMXFDemux * demux) in gst_mxf_demux_update_essence_tracks() argument
783 g_return_val_if_fail (demux->preface->content_storage, GST_FLOW_ERROR); in gst_mxf_demux_update_essence_tracks()
784 g_return_val_if_fail (demux->preface->content_storage->essence_container_data, in gst_mxf_demux_update_essence_tracks()
787 for (i = 0; i < demux->preface->content_storage->n_essence_container_data; in gst_mxf_demux_update_essence_tracks()
793 if (demux->preface->content_storage->essence_container_data[i] == NULL) in gst_mxf_demux_update_essence_tracks()
796 edata = demux->preface->content_storage->essence_container_data[i]; in gst_mxf_demux_update_essence_tracks()
799 GST_WARNING_OBJECT (demux, "Linked package not resolved"); in gst_mxf_demux_update_essence_tracks()
806 GST_WARNING_OBJECT (demux, "Linked package with no resolved tracks"); in gst_mxf_demux_update_essence_tracks()
818 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_update_essence_tracks()
827 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_update_essence_tracks()
835 GST_WARNING_OBJECT (demux, "Invalid edit rate"); in gst_mxf_demux_update_essence_tracks()
861 GST_ELEMENT_ERROR (demux, STREAM, WRONG_TYPE, (NULL), in gst_mxf_demux_update_essence_tracks()
867 for (k = 0; k < demux->essence_tracks->len; k++) { in gst_mxf_demux_update_essence_tracks()
869 &g_array_index (demux->essence_tracks, GstMXFDemuxEssenceTrack, in gst_mxf_demux_update_essence_tracks()
877 GST_ERROR_OBJECT (demux, "There already exists a different track " in gst_mxf_demux_update_essence_tracks()
897 if (demux->current_partition->partition.body_sid == edata->body_sid && in gst_mxf_demux_update_essence_tracks()
898 demux->current_partition->partition.body_offset == 0) in gst_mxf_demux_update_essence_tracks()
903 g_array_append_val (demux->essence_tracks, tmp); in gst_mxf_demux_update_essence_tracks()
905 &g_array_index (demux->essence_tracks, GstMXFDemuxEssenceTrack, in gst_mxf_demux_update_essence_tracks()
906 demux->essence_tracks->len - 1); in gst_mxf_demux_update_essence_tracks()
915 GST_WARNING_OBJECT (demux, "Source track has no sequence"); in gst_mxf_demux_update_essence_tracks()
920 GST_WARNING_OBJECT (demux, "Source track has no descriptors"); in gst_mxf_demux_update_essence_tracks()
941 GST_WARNING_OBJECT (demux, in gst_mxf_demux_update_essence_tracks()
991 GST_DEBUG_OBJECT (demux, "Created caps %" GST_PTR_FORMAT, caps); in gst_mxf_demux_update_essence_tracks()
994 GST_WARNING_OBJECT (demux, "No caps created, ignoring stream"); in gst_mxf_demux_update_essence_tracks()
1002 GST_WARNING_OBJECT (demux, "Couldn't create updated caps for stream"); in gst_mxf_demux_update_essence_tracks()
1022 GST_DEBUG_OBJECT (demux, "Seting miminum number of edit units to %u", in gst_mxf_demux_update_essence_tracks()
1035 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_update_essence_tracks()
1039 GST_ELEMENT_ERROR (demux, STREAM, WRONG_TYPE, (NULL), in gst_mxf_demux_update_essence_tracks()
1059 g_array_remove_index (demux->essence_tracks, in gst_mxf_demux_update_essence_tracks()
1060 demux->essence_tracks->len - 1); in gst_mxf_demux_update_essence_tracks()
1065 if (demux->essence_tracks->len == 0) { in gst_mxf_demux_update_essence_tracks()
1066 GST_ERROR_OBJECT (demux, "No valid essence tracks in this file"); in gst_mxf_demux_update_essence_tracks()
1070 for (i = 0; i < demux->essence_tracks->len; i++) { in gst_mxf_demux_update_essence_tracks()
1072 &g_array_index (demux->essence_tracks, GstMXFDemuxEssenceTrack, i); in gst_mxf_demux_update_essence_tracks()
1075 GST_ERROR_OBJECT (demux, "Failed to update essence track %u", i); in gst_mxf_demux_update_essence_tracks()
1100 gst_mxf_demux_show_topology (GstMXFDemux * demux) in gst_mxf_demux_show_topology() argument
1105 MXFMetadataContentStorage *storage = demux->preface->content_storage; in gst_mxf_demux_show_topology()
1110 GST_DEBUG_OBJECT (demux, "Topology"); in gst_mxf_demux_show_topology()
1119 GST_DEBUG_OBJECT (demux, "Unknown package type"); in gst_mxf_demux_show_topology()
1122 GST_DEBUG_OBJECT (demux, "Number of Material Package (i.e. output) : %d", in gst_mxf_demux_show_topology()
1126 GST_DEBUG_OBJECT (demux, " Package with %d tracks , UID:%s", in gst_mxf_demux_show_topology()
1131 GST_DEBUG_OBJECT (demux, " Unknown/Unhandled track UUID %s", in gst_mxf_demux_show_topology()
1135 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_show_topology()
1141 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_show_topology()
1148 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_show_topology()
1155 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_show_topology()
1160 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_show_topology()
1172 GST_DEBUG_OBJECT (demux, "Number of File Packages (i.e. input) : %d", in gst_mxf_demux_show_topology()
1179 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_show_topology()
1183 GST_DEBUG_OBJECT (demux, " Package descriptor : %s", in gst_mxf_demux_show_topology()
1191 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_show_topology()
1197 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_show_topology()
1204 GST_DEBUG_OBJECT (demux, " Descriptor %s %s", in gst_mxf_demux_show_topology()
1208 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_show_topology()
1215 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_show_topology()
1227 gst_mxf_demux_update_tracks (GstMXFDemux * demux) in gst_mxf_demux_update_tracks() argument
1237 g_rw_lock_writer_lock (&demux->metadata_lock); in gst_mxf_demux_update_tracks()
1238 GST_DEBUG_OBJECT (demux, "Updating tracks"); in gst_mxf_demux_update_tracks()
1240 gst_mxf_demux_show_topology (demux); in gst_mxf_demux_update_tracks()
1242 if ((ret = gst_mxf_demux_update_essence_tracks (demux)) != GST_FLOW_OK) { in gst_mxf_demux_update_tracks()
1246 current_package = gst_mxf_demux_choose_package (demux); in gst_mxf_demux_update_tracks()
1249 GST_ERROR_OBJECT (demux, "Unable to find current package"); in gst_mxf_demux_update_tracks()
1253 GST_ERROR_OBJECT (demux, "Current package has no (resolved) tracks"); in gst_mxf_demux_update_tracks()
1257 GST_ERROR_OBJECT (demux, "Current package has no essence tracks"); in gst_mxf_demux_update_tracks()
1262 first_run = (demux->src->len == 0); in gst_mxf_demux_update_tracks()
1275 GST_WARNING_OBJECT (demux, "Unresolved track"); in gst_mxf_demux_update_tracks()
1280 GST_DEBUG_OBJECT (demux, "Skipping Non-timeline track"); in gst_mxf_demux_update_tracks()
1328 GST_DEBUG_OBJECT (demux, "Handling track %u", i); in gst_mxf_demux_update_tracks()
1331 GST_WARNING_OBJECT (demux, "Unresolved track"); in gst_mxf_demux_update_tracks()
1336 GST_DEBUG_OBJECT (demux, "No timeline track"); in gst_mxf_demux_update_tracks()
1344 for (j = 0; j < demux->src->len; j++) { in gst_mxf_demux_update_tracks()
1345 GstMXFDemuxPad *tmp = g_ptr_array_index (demux->src, j); in gst_mxf_demux_update_tracks()
1360 GST_WARNING_OBJECT (demux, "Track with no sequence"); in gst_mxf_demux_update_tracks()
1372 GST_DEBUG_OBJECT (demux, "Playing source package"); in gst_mxf_demux_update_tracks()
1381 GST_DEBUG_OBJECT (demux, "Playing material package"); in gst_mxf_demux_update_tracks()
1387 GST_WARNING_OBJECT (demux, "NULL component in non-source package"); in gst_mxf_demux_update_tracks()
1415 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_update_tracks()
1429 GST_WARNING_OBJECT (demux, in gst_mxf_demux_update_tracks()
1439 for (k = 0; k < demux->essence_tracks->len; k++) { in gst_mxf_demux_update_tracks()
1441 &g_array_index (demux->essence_tracks, GstMXFDemuxEssenceTrack, k); in gst_mxf_demux_update_tracks()
1451 GST_WARNING_OBJECT (demux, "No essence track for this track found"); in gst_mxf_demux_update_tracks()
1462 GST_WARNING_OBJECT (demux, "Track has an invalid edit rate"); in gst_mxf_demux_update_tracks()
1472 GST_WARNING_OBJECT (demux, in gst_mxf_demux_update_tracks()
1483 GST_WARNING_OBJECT (demux, "Source package has no descriptors"); in gst_mxf_demux_update_tracks()
1493 GST_WARNING_OBJECT (demux, "No descriptor found for track"); in gst_mxf_demux_update_tracks()
1507 gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (demux), in gst_mxf_demux_update_tracks()
1520 if (demux->tags) in gst_mxf_demux_update_tracks()
1521 pad->tags = gst_tag_list_copy (demux->tags); in gst_mxf_demux_update_tracks()
1525 GST_WARNING_OBJECT (demux, in gst_mxf_demux_update_tracks()
1597 GST_ELEMENT_CAST (demux), "%03u", pad->track_id); in gst_mxf_demux_update_tracks()
1600 gst_pad_get_sticky_event (demux->sinkpad, GST_EVENT_STREAM_START, 0); in gst_mxf_demux_update_tracks()
1602 if (gst_event_parse_group_id (event, &demux->group_id)) in gst_mxf_demux_update_tracks()
1603 demux->have_group_id = TRUE; in gst_mxf_demux_update_tracks()
1605 demux->have_group_id = FALSE; in gst_mxf_demux_update_tracks()
1607 } else if (!demux->have_group_id) { in gst_mxf_demux_update_tracks()
1608 demux->have_group_id = TRUE; in gst_mxf_demux_update_tracks()
1609 demux->group_id = gst_util_group_id_next (); in gst_mxf_demux_update_tracks()
1612 if (demux->have_group_id) in gst_mxf_demux_update_tracks()
1613 gst_event_set_group_id (event, demux->group_id); in gst_mxf_demux_update_tracks()
1622 g_ptr_array_add (demux->src, pad); in gst_mxf_demux_update_tracks()
1629 if (demux->src->len > 0) { in gst_mxf_demux_update_tracks()
1630 for (i = 0; i < demux->src->len; i++) { in gst_mxf_demux_update_tracks()
1631 GstMXFDemuxPad *pad = g_ptr_array_index (demux->src, i); in gst_mxf_demux_update_tracks()
1634 GST_ERROR_OBJECT (demux, "Unable to update existing pad"); in gst_mxf_demux_update_tracks()
1640 GST_ERROR_OBJECT (demux, "Couldn't create any streams"); in gst_mxf_demux_update_tracks()
1645 g_rw_lock_writer_unlock (&demux->metadata_lock); in gst_mxf_demux_update_tracks()
1648 gst_flow_combiner_add_pad (demux->flowcombiner, l->data); in gst_mxf_demux_update_tracks()
1649 gst_element_add_pad (GST_ELEMENT_CAST (demux), l->data); in gst_mxf_demux_update_tracks()
1654 gst_element_no_more_pads (GST_ELEMENT_CAST (demux)); in gst_mxf_demux_update_tracks()
1658 for (l = demux->partitions; l; l = l->next) in gst_mxf_demux_update_tracks()
1659 gst_mxf_demux_partition_postcheck (demux, (GstMXFDemuxPartition *) l->data); in gst_mxf_demux_update_tracks()
1664 g_rw_lock_writer_unlock (&demux->metadata_lock); in gst_mxf_demux_update_tracks()
1669 gst_mxf_demux_handle_metadata (GstMXFDemux * demux, GstMXFKLV * klv) in gst_mxf_demux_handle_metadata() argument
1678 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_handle_metadata()
1682 if (G_UNLIKELY (!demux->current_partition)) { in gst_mxf_demux_handle_metadata()
1683 GST_ERROR_OBJECT (demux, "Partition pack doesn't exist"); in gst_mxf_demux_handle_metadata()
1687 if (G_UNLIKELY (!demux->current_partition->primer.mappings)) { in gst_mxf_demux_handle_metadata()
1688 GST_ERROR_OBJECT (demux, "Primer pack doesn't exists"); in gst_mxf_demux_handle_metadata()
1692 if (demux->current_partition->parsed_metadata) { in gst_mxf_demux_handle_metadata()
1693 GST_DEBUG_OBJECT (demux, "Metadata of this partition was already parsed"); in gst_mxf_demux_handle_metadata()
1699 ret = gst_mxf_demux_fill_klv (demux, klv); in gst_mxf_demux_handle_metadata()
1705 mxf_metadata_new (type, &demux->current_partition->primer, demux->offset, in gst_mxf_demux_handle_metadata()
1710 GST_WARNING_OBJECT (demux, in gst_mxf_demux_handle_metadata()
1716 g_hash_table_lookup (demux->metadata, in gst_mxf_demux_handle_metadata()
1724 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_handle_metadata()
1739 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_handle_metadata()
1746 g_rw_lock_writer_lock (&demux->metadata_lock); in gst_mxf_demux_handle_metadata()
1747 demux->update_metadata = TRUE; in gst_mxf_demux_handle_metadata()
1750 demux->preface = MXF_METADATA_PREFACE (metadata); in gst_mxf_demux_handle_metadata()
1753 gst_mxf_demux_reset_linked_metadata (demux); in gst_mxf_demux_handle_metadata()
1755 g_hash_table_replace (demux->metadata, in gst_mxf_demux_handle_metadata()
1757 g_rw_lock_writer_unlock (&demux->metadata_lock); in gst_mxf_demux_handle_metadata()
1763 gst_mxf_demux_handle_descriptive_metadata (GstMXFDemux * demux, GstMXFKLV * klv) in gst_mxf_demux_handle_descriptive_metadata() argument
1774 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_handle_descriptive_metadata()
1779 if (G_UNLIKELY (!demux->current_partition)) { in gst_mxf_demux_handle_descriptive_metadata()
1780 GST_ERROR_OBJECT (demux, "Partition pack doesn't exist"); in gst_mxf_demux_handle_descriptive_metadata()
1784 if (G_UNLIKELY (!demux->current_partition->primer.mappings)) { in gst_mxf_demux_handle_descriptive_metadata()
1785 GST_ERROR_OBJECT (demux, "Primer pack doesn't exists"); in gst_mxf_demux_handle_descriptive_metadata()
1789 if (demux->current_partition->parsed_metadata) { in gst_mxf_demux_handle_descriptive_metadata()
1790 GST_DEBUG_OBJECT (demux, "Metadata of this partition was already parsed"); in gst_mxf_demux_handle_descriptive_metadata()
1794 ret = gst_mxf_demux_fill_klv (demux, klv); in gst_mxf_demux_handle_descriptive_metadata()
1800 &demux->current_partition->primer, demux->offset, map.data, map.size); in gst_mxf_demux_handle_descriptive_metadata()
1804 GST_WARNING_OBJECT (demux, in gst_mxf_demux_handle_descriptive_metadata()
1811 g_hash_table_lookup (demux->metadata, in gst_mxf_demux_handle_descriptive_metadata()
1819 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_handle_descriptive_metadata()
1833 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_handle_descriptive_metadata()
1840 g_rw_lock_writer_lock (&demux->metadata_lock); in gst_mxf_demux_handle_descriptive_metadata()
1842 demux->update_metadata = TRUE; in gst_mxf_demux_handle_descriptive_metadata()
1843 gst_mxf_demux_reset_linked_metadata (demux); in gst_mxf_demux_handle_descriptive_metadata()
1845 g_hash_table_replace (demux->metadata, &MXF_METADATA_BASE (m)->instance_uid, in gst_mxf_demux_handle_descriptive_metadata()
1848 g_rw_lock_writer_unlock (&demux->metadata_lock); in gst_mxf_demux_handle_descriptive_metadata()
1854 gst_mxf_demux_handle_generic_container_system_item (GstMXFDemux * demux, in gst_mxf_demux_handle_generic_container_system_item() argument
1857 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_handle_generic_container_system_item()
1861 if (demux->current_partition->essence_container_offset == 0) in gst_mxf_demux_handle_generic_container_system_item()
1862 demux->current_partition->essence_container_offset = in gst_mxf_demux_handle_generic_container_system_item()
1863 demux->offset - demux->current_partition->partition.this_partition - in gst_mxf_demux_handle_generic_container_system_item()
1864 demux->run_in; in gst_mxf_demux_handle_generic_container_system_item()
1871 gst_mxf_demux_pad_set_component (GstMXFDemux * demux, GstMXFDemuxPad * pad, in gst_mxf_demux_pad_set_component() argument
1887 GST_DEBUG_OBJECT (demux, "After last structural component"); in gst_mxf_demux_pad_set_component()
1892 GST_DEBUG_OBJECT (demux, "Switching to component %u", in gst_mxf_demux_pad_set_component()
1899 GST_ERROR_OBJECT (demux, "No such structural component"); in gst_mxf_demux_pad_set_component()
1907 GST_ERROR_OBJECT (demux, "Invalid component"); in gst_mxf_demux_pad_set_component()
1923 GST_ERROR_OBJECT (demux, "No source track found"); in gst_mxf_demux_pad_set_component()
1929 for (k = 0; k < demux->essence_tracks->len; k++) { in gst_mxf_demux_pad_set_component()
1931 &g_array_index (demux->essence_tracks, GstMXFDemuxEssenceTrack, k); in gst_mxf_demux_pad_set_component()
1941 GST_ERROR_OBJECT (demux, "No corresponding essence track found"); in gst_mxf_demux_pad_set_component()
1946 GST_ERROR_OBJECT (demux, "Source package has no descriptors"); in gst_mxf_demux_pad_set_component()
1951 GST_ERROR_OBJECT (demux, "No descriptor found for track"); in gst_mxf_demux_pad_set_component()
1956 GST_ERROR_OBJECT (demux, "Source track has invalid edit rate"); in gst_mxf_demux_pad_set_component()
2019 get_partition_for_stream_offset (GstMXFDemux * demux, in get_partition_for_stream_offset() argument
2025 for (tmp = demux->partitions; tmp; tmp = tmp->next) { in get_partition_for_stream_offset()
2044 GST_DEBUG_OBJECT (demux, in get_partition_for_stream_offset()
2057 GST_DEBUG_OBJECT (demux, in get_partition_for_stream_offset()
2063 GST_WARNING_OBJECT (demux, in get_partition_for_stream_offset()
2076 get_track_index_table (GstMXFDemux * demux, GstMXFDemuxEssenceTrack * etrack) in get_track_index_table() argument
2081 for (l = demux->index_tables; l; l = l->next) { in get_track_index_table()
2094 get_track_max_temporal_offset (GstMXFDemux * demux, in get_track_max_temporal_offset() argument
2102 table = get_track_index_table (demux, etrack); in get_track_max_temporal_offset()
2173 find_edit_entry (GstMXFDemux * demux, GstMXFDemuxEssenceTrack * etrack, in find_edit_entry() argument
2182 GST_DEBUG_OBJECT (demux, in find_edit_entry()
2196 GST_LOG_OBJECT (demux, "Found entry in track offsets"); in find_edit_entry()
2199 GST_LOG_OBJECT (demux, "Didn't find entry in track offsets"); in find_edit_entry()
2203 index_table = get_track_index_table (demux, etrack); in find_edit_entry()
2206 GST_DEBUG_OBJECT (demux, in find_edit_entry()
2212 GST_DEBUG_OBJECT (demux, in find_edit_entry()
2228 GST_DEBUG_OBJECT (demux, "Look for entry in %d segments", in find_edit_entry()
2236 GST_DEBUG_OBJECT (demux, in find_edit_entry()
2244 GST_DEBUG_OBJECT (demux, in find_edit_entry()
2253 GST_LOG_OBJECT (demux, in find_edit_entry()
2257 GST_LOG_OBJECT (demux, "keyframe search"); in find_edit_entry()
2266 GST_LOG_OBJECT (demux, "Found keyframe at position %" G_GINT64_FORMAT, in find_edit_entry()
2275 GST_DEBUG_OBJECT (demux, "Using keyframe offset %d", in find_edit_entry()
2279 GST_DEBUG_OBJECT (demux, "keyframe info is in previous segment"); in find_edit_entry()
2287 GST_LOG_OBJECT (demux, in find_edit_entry()
2296 GST_LOG_OBJECT (demux, "Looping with new position %" G_GINT64_FORMAT, in find_edit_entry()
2312 GST_LOG_OBJECT (demux, in find_edit_entry()
2318 GST_LOG_OBJECT (demux, "Handling minimum edit unit %u", in find_edit_entry()
2340 GST_LOG_OBJECT (demux, in find_edit_entry()
2359 GST_WARNING_OBJECT (demux, in find_edit_entry()
2363 if (demux->temporal_order_misuse) { in find_edit_entry()
2364 GST_DEBUG_OBJECT (demux, "Handling temporal order misuse"); in find_edit_entry()
2370 GST_LOG_OBJECT (demux, in find_edit_entry()
2378 GST_WARNING_OBJECT (demux, in find_edit_entry()
2385 get_partition_for_stream_offset (demux, etrack, stream_offset); in find_edit_entry()
2388 GST_WARNING_OBJECT (demux, in find_edit_entry()
2393 GST_DEBUG_OBJECT (demux, "Entry is in partition %" G_GUINT64_FORMAT, in find_edit_entry()
2403 GST_LOG_OBJECT (demux, in find_edit_entry()
2429 find_entry_for_offset (GstMXFDemux * demux, GstMXFDemuxEssenceTrack * etrack, in find_entry_for_offset() argument
2432 GstMXFDemuxIndexTable *index_table = get_track_index_table (demux, etrack); in find_entry_for_offset()
2435 GstMXFDemuxPartition *partition = demux->current_partition; in find_entry_for_offset()
2442 GST_DEBUG_OBJECT (demux, in find_entry_for_offset()
2458 GST_DEBUG_OBJECT (demux, in find_entry_for_offset()
2467 GST_WARNING_OBJECT (demux, "No index table or entries to search in"); in find_entry_for_offset()
2472 GST_WARNING_OBJECT (demux, "No current partition for search"); in find_entry_for_offset()
2485 GST_LOG_OBJECT (demux, in find_entry_for_offset()
2494 GST_LOG_OBJECT (demux, "stream offset %" G_GUINT64_FORMAT, offset); in find_entry_for_offset()
2501 GST_DEBUG_OBJECT (demux, in find_entry_for_offset()
2506 GST_LOG_OBJECT (demux, "Found"); in find_entry_for_offset()
2511 GST_WARNING_OBJECT (demux, in find_entry_for_offset()
2530 GST_WARNING_OBJECT (demux, in find_entry_for_offset()
2547 GST_DEBUG_OBJECT (demux, in find_entry_for_offset()
2566 GST_WARNING_OBJECT (demux, in find_entry_for_offset()
2576 GST_DEBUG_OBJECT (demux, in find_entry_for_offset()
2581 GST_DEBUG_OBJECT (demux, "Index table has no delta entries, ignoring"); in find_entry_for_offset()
2586 GST_LOG_OBJECT (demux, in find_entry_for_offset()
2591 GST_DEBUG_OBJECT (demux, "Matched to delta %d", delta); in find_entry_for_offset()
2608 GST_DEBUG_OBJECT (demux, "Matched to delta %d", delta); in find_entry_for_offset()
2618 GST_WARNING_OBJECT (demux, in find_entry_for_offset()
2628 if (!demux->temporal_order_misuse) in find_entry_for_offset()
2634 GST_LOG_OBJECT (demux, in find_entry_for_offset()
2641 GST_LOG_OBJECT (demux, "Found in index table. position:%" G_GINT64_FORMAT, in find_entry_for_offset()
2651 gst_mxf_demux_handle_generic_container_essence_element (GstMXFDemux * demux, in gst_mxf_demux_handle_generic_container_essence_element() argument
2666 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_handle_generic_container_essence_element()
2671 GST_DEBUG_OBJECT (demux, " type = 0x%02x", klv->key.u[12]); in gst_mxf_demux_handle_generic_container_essence_element()
2672 GST_DEBUG_OBJECT (demux, " essence element count = 0x%02x", klv->key.u[13]); in gst_mxf_demux_handle_generic_container_essence_element()
2673 GST_DEBUG_OBJECT (demux, " essence element type = 0x%02x", klv->key.u[14]); in gst_mxf_demux_handle_generic_container_essence_element()
2674 GST_DEBUG_OBJECT (demux, " essence element number = 0x%02x", klv->key.u[15]); in gst_mxf_demux_handle_generic_container_essence_element()
2676 if (demux->current_partition->essence_container_offset == 0) { in gst_mxf_demux_handle_generic_container_essence_element()
2677 demux->current_partition->essence_container_offset = in gst_mxf_demux_handle_generic_container_essence_element()
2678 demux->offset - demux->current_partition->partition.this_partition - in gst_mxf_demux_handle_generic_container_essence_element()
2679 demux->run_in; in gst_mxf_demux_handle_generic_container_essence_element()
2680 if (demux->current_partition->single_track in gst_mxf_demux_handle_generic_container_essence_element()
2681 && demux->current_partition->single_track->wrapping != in gst_mxf_demux_handle_generic_container_essence_element()
2683 demux->current_partition->essence_container_offset += klv->data_offset; in gst_mxf_demux_handle_generic_container_essence_element()
2684 demux->current_partition->clip_klv = *klv; in gst_mxf_demux_handle_generic_container_essence_element()
2687 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_handle_generic_container_essence_element()
2689 G_GUINT64_FORMAT, demux->current_partition->essence_container_offset); in gst_mxf_demux_handle_generic_container_essence_element()
2693 if (!demux->current_package) { in gst_mxf_demux_handle_generic_container_essence_element()
2694 GST_ERROR_OBJECT (demux, "No package selected yet"); in gst_mxf_demux_handle_generic_container_essence_element()
2698 if (demux->src->len == 0) { in gst_mxf_demux_handle_generic_container_essence_element()
2699 GST_ERROR_OBJECT (demux, "No streams created yet"); in gst_mxf_demux_handle_generic_container_essence_element()
2703 if (demux->essence_tracks->len == 0) { in gst_mxf_demux_handle_generic_container_essence_element()
2704 GST_ERROR_OBJECT (demux, "No essence streams found in the metadata"); in gst_mxf_demux_handle_generic_container_essence_element()
2711 etrack = demux->current_partition->single_track; in gst_mxf_demux_handle_generic_container_essence_element()
2713 for (i = 0; i < demux->essence_tracks->len; i++) { in gst_mxf_demux_handle_generic_container_essence_element()
2715 &g_array_index (demux->essence_tracks, GstMXFDemuxEssenceTrack, i); in gst_mxf_demux_handle_generic_container_essence_element()
2717 if (tmp->body_sid == demux->current_partition->partition.body_sid && in gst_mxf_demux_handle_generic_container_essence_element()
2725 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_handle_generic_container_essence_element()
2731 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_handle_generic_container_essence_element()
2752 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_handle_generic_container_essence_element()
2754 if (!find_entry_for_offset (demux, etrack, offset - demux->run_in, in gst_mxf_demux_handle_generic_container_essence_element()
2756 GST_WARNING_OBJECT (demux, "Essence track position not in index"); in gst_mxf_demux_handle_generic_container_essence_element()
2762 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_handle_generic_container_essence_element()
2764 if (!find_entry_for_offset (demux, etrack, offset - demux->run_in, in gst_mxf_demux_handle_generic_container_essence_element()
2767 GST_WARNING_OBJECT (demux, "Essence track position not in index"); in gst_mxf_demux_handle_generic_container_essence_element()
2769 GST_ERROR_OBJECT (demux, in gst_mxf_demux_handle_generic_container_essence_element()
2775 if (!find_edit_entry (demux, etrack, etrack->position, FALSE, &index_entry)) { in gst_mxf_demux_handle_generic_container_essence_element()
2776 GST_DEBUG_OBJECT (demux, "Couldn't find entry"); in gst_mxf_demux_handle_generic_container_essence_element()
2780 GST_ERROR_OBJECT (demux, in gst_mxf_demux_handle_generic_container_essence_element()
2787 GST_ERROR_OBJECT (demux, in gst_mxf_demux_handle_generic_container_essence_element()
2797 GST_ELEMENT_ERROR (demux, STREAM, WRONG_TYPE, (NULL), in gst_mxf_demux_handle_generic_container_essence_element()
2802 if (!demux->random_access) { in gst_mxf_demux_handle_generic_container_essence_element()
2803 GST_ELEMENT_ERROR (demux, STREAM, WRONG_TYPE, (NULL), in gst_mxf_demux_handle_generic_container_essence_element()
2813 GST_DEBUG_OBJECT (demux, "Should only grab %" G_GUINT64_FORMAT " bytes", in gst_mxf_demux_handle_generic_container_essence_element()
2816 gst_mxf_demux_pull_range (demux, index_entry.offset, index_entry.size, in gst_mxf_demux_handle_generic_container_essence_element()
2824 if (klv != &demux->current_partition->clip_klv) in gst_mxf_demux_handle_generic_container_essence_element()
2825 demux->current_partition->clip_klv = *klv; in gst_mxf_demux_handle_generic_container_essence_element()
2826 GST_LOG_OBJECT (demux, in gst_mxf_demux_handle_generic_container_essence_element()
2832 demux->state = GST_MXF_DEMUX_STATE_KLV; in gst_mxf_demux_handle_generic_container_essence_element()
2834 demux->state = GST_MXF_DEMUX_STATE_ESSENCE; in gst_mxf_demux_handle_generic_container_essence_element()
2837 ret = gst_mxf_demux_fill_klv (demux, klv); in gst_mxf_demux_handle_generic_container_essence_element()
2849 GST_DEBUG_OBJECT (demux, "Got entry dts:%" G_GINT64_FORMAT " keyframe:%d", in gst_mxf_demux_handle_generic_container_essence_element()
2868 GST_ERROR_OBJECT (demux, "Failed to handle essence element"); in gst_mxf_demux_handle_generic_container_essence_element()
2879 index_entry.offset = demux->offset - demux->run_in; in gst_mxf_demux_handle_generic_container_essence_element()
2885 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_handle_generic_container_essence_element()
2903 GST_DEBUG_OBJECT (demux, "No output buffer created"); in gst_mxf_demux_handle_generic_container_essence_element()
2910 max_temporal_offset = get_track_max_temporal_offset (demux, etrack); in gst_mxf_demux_handle_generic_container_essence_element()
2912 for (i = 0; i < demux->src->len; i++) { in gst_mxf_demux_handle_generic_container_essence_element()
2913 GstMXFDemuxPad *pad = g_ptr_array_index (demux->src, i); in gst_mxf_demux_handle_generic_container_essence_element()
2932 GstMXFDemuxPad *earliest = gst_mxf_demux_get_earliest_pad (demux); in gst_mxf_demux_handle_generic_container_essence_element()
2935 pad->position - earliest->position > demux->max_drift) { in gst_mxf_demux_handle_generic_container_essence_element()
3024 if (demux->close_seg_event) in gst_mxf_demux_handle_generic_container_essence_element()
3026 gst_event_ref (demux->close_seg_event)); in gst_mxf_demux_handle_generic_container_essence_element()
3034 gst_segment_copy_into (&demux->segment, &shift_segment); in gst_mxf_demux_handle_generic_container_essence_element()
3047 e = gst_event_new_segment (&demux->segment); in gst_mxf_demux_handle_generic_container_essence_element()
3049 gst_event_set_seqnum (e, demux->seqnum); in gst_mxf_demux_handle_generic_container_essence_element()
3092 ret = gst_flow_combiner_update_flow (demux->flowcombiner, ret); in gst_mxf_demux_handle_generic_container_essence_element()
3095 if (pad->position > demux->segment.position) in gst_mxf_demux_handle_generic_container_essence_element()
3096 demux->segment.position = pad->position; in gst_mxf_demux_handle_generic_container_essence_element()
3107 GST_DEBUG_OBJECT (demux, "Switching to next component"); in gst_mxf_demux_handle_generic_container_essence_element()
3110 gst_mxf_demux_pad_set_component (demux, pad, in gst_mxf_demux_handle_generic_container_essence_element()
3116 GST_ERROR_OBJECT (demux, "Switching component failed"); in gst_mxf_demux_handle_generic_container_essence_element()
3120 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_handle_generic_container_essence_element()
3126 GST_DEBUG_OBJECT (demux, "At the end of the essence track"); in gst_mxf_demux_handle_generic_container_essence_element()
3136 gst_event_set_seqnum (e, demux->seqnum); in gst_mxf_demux_handle_generic_container_essence_element()
3168 read_partition_header (GstMXFDemux * demux) in read_partition_header() argument
3172 if (gst_mxf_demux_peek_klv_packet (demux, demux->offset, &klv) != GST_FLOW_OK in read_partition_header()
3177 if (gst_mxf_demux_handle_partition_pack (demux, &klv) != GST_FLOW_OK) { in read_partition_header()
3182 gst_mxf_demux_consume_klv (demux, &klv); in read_partition_header()
3184 if (gst_mxf_demux_peek_klv_packet (demux, demux->offset, &klv) != GST_FLOW_OK) in read_partition_header()
3188 gst_mxf_demux_consume_klv (demux, &klv); in read_partition_header()
3189 if (gst_mxf_demux_peek_klv_packet (demux, demux->offset, in read_partition_header()
3195 && demux->current_partition->partition.header_byte_count) { in read_partition_header()
3196 demux->offset += demux->current_partition->partition.header_byte_count; in read_partition_header()
3197 if (gst_mxf_demux_peek_klv_packet (demux, demux->offset, in read_partition_header()
3203 gst_mxf_demux_consume_klv (demux, &klv); in read_partition_header()
3204 if (gst_mxf_demux_peek_klv_packet (demux, demux->offset, in read_partition_header()
3209 if (demux->current_partition->partition.index_byte_count in read_partition_header()
3212 demux->offset + demux->current_partition->partition.index_byte_count; in read_partition_header()
3214 while (demux->offset < index_end_offset) { in read_partition_header()
3216 gst_mxf_demux_handle_index_table_segment (demux, &klv); in read_partition_header()
3217 gst_mxf_demux_consume_klv (demux, &klv); in read_partition_header()
3219 if (gst_mxf_demux_peek_klv_packet (demux, demux->offset, in read_partition_header()
3226 gst_mxf_demux_consume_klv (demux, &klv); in read_partition_header()
3227 if (gst_mxf_demux_peek_klv_packet (demux, demux->offset, in read_partition_header()
3235 if (demux->current_partition->essence_container_offset == 0) in read_partition_header()
3236 demux->current_partition->essence_container_offset = in read_partition_header()
3237 demux->offset - demux->current_partition->partition.this_partition - in read_partition_header()
3238 demux->run_in; in read_partition_header()
3243 gst_mxf_demux_handle_random_index_pack (GstMXFDemux * demux, GstMXFKLV * klv) in gst_mxf_demux_handle_random_index_pack() argument
3251 GST_DEBUG_OBJECT (demux, in gst_mxf_demux_handle_random_index_pack()
3255 if (demux->random_index_pack) { in gst_mxf_demux_handle_random_index_pack()
3256 GST_DEBUG_OBJECT (demux, "Already parsed random index pack"); in gst_mxf_demux_handle_random_index_pack()
3260 flowret = gst_mxf_demux_fill_klv (demux, klv); in gst_mxf_demux_handle_random_index_pack()
3267 &demux->random_index_pack); in gst_mxf_demux_handle_random_index_pack()
3271 GST_ERROR_OBJECT (demux, "Parsing random index pack failed"); in gst_mxf_demux_handle_random_index_pack()
3275 for (i = 0; i < demux->random_index_pack->len; i++) { in gst_mxf_demux_handle_random_index_pack()
3278 &g_array_index (demux->random_index_pack, MXFRandomIndexPackEntry, i); in gst_mxf_demux_handle_random_index_pack()
3280 if (e->offset < demux->run_in) { in gst_mxf_demux_handle_random_index_pack()
3281 GST_ERROR_OBJECT (demux, "Invalid random index pack entry"); in gst_mxf_demux_handle_random_index_pack()
3285 for (l = demux->partitions; l; l = l->next) { in gst_mxf_demux_handle_random_index_pack()
3288 if (tmp->partition.this_partition + demux->run_in == e->offset) { in gst_mxf_demux_handle_random_index_pack()
3296 p->partition.this_partition = e->offset - demux->run_in; in gst_mxf_demux_handle_random_index_pack()
3298 demux->partitions = in gst_mxf_demux_handle_random_index_pack()
3299 g_list_insert_sorted (demux->partitions, p, in gst_mxf_demux_handle_random_index_pack()
3304 for (l = demux->partitions; l; l = l->next) { in gst_mxf_demux_handle_random_index_pack()
3357 gst_mxf_demux_handle_index_table_segment (GstMXFDemux * demux, GstMXFKLV * klv) argument
3365 flowret = gst_mxf_demux_fill_klv (demux, klv);
3369 GST_DEBUG_OBJECT (demux,
3380 GST_ERROR_OBJECT (demux, "Parsing index table segment failed");
3387 if (g_list_find_custom (demux->pending_index_table_segments, segment,
3389 GST_DEBUG_OBJECT (demux, "Already in pending list");
3393 for (tmp = demux->index_tables; tmp; tmp = tmp->next) {
3401 GST_DEBUG_OBJECT (demux, "Already handled");
3407 demux->pending_index_table_segments =
3408 g_list_insert_sorted (demux->pending_index_table_segments, segment,
3415 gst_mxf_demux_peek_klv_packet (GstMXFDemux * demux, guint64 offset, argument
3431 gst_mxf_demux_pull_range (demux, offset, 17, &buffer)) != GST_FLOW_OK)
3453 GST_ERROR_OBJECT (demux, "Invalid KLV packet length: %u", slen);
3459 if ((ret = gst_mxf_demux_pull_range (demux, offset + 17, slen,
3481 GST_ERROR_OBJECT (demux,
3487 GST_DEBUG_OBJECT (demux,
3500 gst_mxf_demux_fill_klv (GstMXFDemux * demux, GstMXFKLV * klv) argument
3504 GST_DEBUG_OBJECT (demux,
3507 return gst_mxf_demux_pull_range (demux, klv->offset + klv->data_offset,
3515 gst_mxf_demux_consume_klv (GstMXFDemux * demux, GstMXFKLV * klv) argument
3521 GST_DEBUG_OBJECT (demux,
3527 demux->offset = klv->offset + klv->consumed;
3529 demux->offset += klv->data_offset + klv->length;
3533 gst_mxf_demux_pull_random_index_pack (GstMXFDemux * demux) argument
3539 guint64 old_offset = demux->offset;
3544 if (!gst_pad_peer_query_duration (demux->sinkpad, fmt, &filesize) ||
3546 GST_DEBUG_OBJECT (demux, "Can't query upstream size");
3553 if (gst_mxf_demux_pull_range (demux, filesize - 4, 4, &buffer) != GST_FLOW_OK) {
3554 GST_DEBUG_OBJECT (demux, "Failed pulling last 4 bytes");
3565 GST_DEBUG_OBJECT (demux, "Too small pack size (%u bytes)", pack_size);
3568 GST_DEBUG_OBJECT (demux, "Too large pack size (%u bytes)", pack_size);
3573 if (gst_mxf_demux_peek_klv_packet (demux, filesize - pack_size,
3575 GST_DEBUG_OBJECT (demux, "Failed pulling random index pack key");
3580 GST_DEBUG_OBJECT (demux, "No random index pack");
3584 demux->offset = filesize - pack_size;
3585 flow_ret = gst_mxf_demux_handle_random_index_pack (demux, &klv);
3588 demux->offset = old_offset;
3590 if (flow_ret == GST_FLOW_OK && !demux->index_table_segments_collected) {
3591 collect_index_table_segments (demux);
3592 demux->index_table_segments_collected = TRUE;
3597 gst_mxf_demux_parse_footer_metadata (GstMXFDemux * demux) argument
3599 guint64 old_offset = demux->offset;
3602 GstMXFDemuxPartition *old_partition = demux->current_partition;
3604 GST_DEBUG_OBJECT (demux, "Parsing footer metadata");
3606 demux->current_partition = NULL;
3608 gst_mxf_demux_reset_metadata (demux);
3610 if (demux->footer_partition_pack_offset != 0) {
3611 demux->offset = demux->run_in + demux->footer_partition_pack_offset;
3614 &g_array_index (demux->random_index_pack, MXFRandomIndexPackEntry,
3615 demux->random_index_pack->len - 1);
3616 demux->offset = entry->offset;
3620 GST_LOG_OBJECT (demux, "Peeking partition pack at offset %" G_GUINT64_FORMAT,
3621 demux->offset);
3624 flow = gst_mxf_demux_peek_klv_packet (demux, demux->offset, &klv);
3631 if (gst_mxf_demux_handle_partition_pack (demux, &klv) != GST_FLOW_OK) {
3637 gst_mxf_demux_consume_klv (demux, &klv);
3641 if (demux->current_partition->partition.header_byte_count == 0) {
3643 if (demux->current_partition->partition.this_partition == 0)
3646 demux->offset =
3647 demux->run_in + demux->current_partition->partition.prev_partition;
3653 flow = gst_mxf_demux_peek_klv_packet (demux, demux->offset, &klv);
3656 if (!demux->current_partition->partition.prev_partition)
3658 demux->offset =
3659 demux->run_in + demux->current_partition->partition.prev_partition;
3664 gst_mxf_demux_consume_klv (demux, &klv);
3667 if (!demux->current_partition->primer.mappings) {
3668 if (gst_mxf_demux_handle_primer_pack (demux, &klv) != GST_FLOW_OK) {
3669 gst_mxf_demux_consume_klv (demux, &klv);
3670 if (!demux->current_partition->partition.prev_partition)
3672 demux->offset =
3673 demux->run_in +
3674 demux->current_partition->partition.prev_partition;
3678 gst_mxf_demux_consume_klv (demux, &klv);
3681 if (!demux->current_partition->partition.prev_partition)
3683 demux->offset =
3684 demux->run_in + demux->current_partition->partition.prev_partition;
3690 while (demux->offset <
3691 demux->run_in + demux->current_partition->primer.offset +
3692 demux->current_partition->partition.header_byte_count) {
3693 flow = gst_mxf_demux_peek_klv_packet (demux, demux->offset, &klv);
3695 if (!demux->current_partition->partition.prev_partition)
3697 demux->offset =
3698 demux->run_in + demux->current_partition->partition.prev_partition;
3703 flow = gst_mxf_demux_handle_metadata (demux, &klv);
3704 gst_mxf_demux_consume_klv (demux, &klv);
3707 gst_mxf_demux_reset_metadata (demux);
3708 if (!demux->current_partition->partition.prev_partition)
3710 demux->offset =
3711 demux->run_in + demux->current_partition->partition.prev_partition;
3715 gst_mxf_demux_handle_descriptive_metadata (demux, &klv);
3716 gst_mxf_demux_consume_klv (demux, &klv);
3718 gst_mxf_demux_consume_klv (demux, &klv);
3723 if (!demux->preface || gst_mxf_demux_resolve_references (demux) !=
3724 GST_FLOW_OK || gst_mxf_demux_update_tracks (demux) != GST_FLOW_OK) {
3726 demux->current_partition->parsed_metadata = TRUE;
3728 if (!demux->current_partition->partition.prev_partition)
3730 demux->offset =
3731 demux->run_in + demux->current_partition->partition.prev_partition;
3736 demux->offset = old_offset;
3737 demux->current_partition = old_partition;
3741 gst_mxf_demux_handle_klv_packet (GstMXFDemux * demux, GstMXFKLV * klv, argument
3750 if (demux->update_metadata
3751 && demux->preface
3752 && (demux->offset >=
3753 demux->run_in + demux->current_partition->primer.offset +
3754 demux->current_partition->partition.header_byte_count ||
3758 demux->current_partition->parsed_metadata = TRUE;
3759 if ((ret = gst_mxf_demux_resolve_references (demux)) != GST_FLOW_OK ||
3760 (ret = gst_mxf_demux_update_tracks (demux)) != GST_FLOW_OK) {
3763 } else if (demux->metadata_resolved && demux->requested_package_string) {
3764 if ((ret = gst_mxf_demux_update_tracks (demux)) != GST_FLOW_OK) {
3770 GST_WARNING_OBJECT (demux,
3773 demux->offset, mxf_ul_to_string (key, key_str));
3775 ret = gst_mxf_demux_handle_partition_pack (demux, klv);
3777 ret = gst_mxf_demux_handle_primer_pack (demux, klv);
3779 ret = gst_mxf_demux_handle_metadata (demux, klv);
3781 ret = gst_mxf_demux_handle_descriptive_metadata (demux, klv);
3783 if (demux->pending_index_table_segments)
3784 collect_index_table_segments (demux);
3785 ret = gst_mxf_demux_handle_generic_container_system_item (demux, klv);
3788 if (demux->pending_index_table_segments)
3789 collect_index_table_segments (demux);
3791 gst_mxf_demux_handle_generic_container_essence_element (demux, klv,
3794 ret = gst_mxf_demux_handle_random_index_pack (demux, klv);
3796 if (ret == GST_FLOW_OK && demux->random_access
3797 && !demux->index_table_segments_collected) {
3798 collect_index_table_segments (demux);
3799 demux->index_table_segments_collected = TRUE;
3802 ret = gst_mxf_demux_handle_index_table_segment (demux, klv);
3804 GST_DEBUG_OBJECT (demux,
3806 G_GUINT64_FORMAT, klv->length, demux->offset);
3808 GST_DEBUG_OBJECT (demux,
3811 demux->offset, mxf_ul_to_string (key, key_str));
3819 gst_mxf_demux_set_partition_for_offset (GstMXFDemux * demux, guint64 offset) argument
3823 GST_LOG_OBJECT (demux, "offset %" G_GUINT64_FORMAT, offset);
3827 for (l = demux->partitions; l; l = l->next) {
3830 if (p->partition.this_partition + demux->run_in <= offset)
3831 demux->current_partition = p;
3833 if (demux->current_partition)
3834 GST_DEBUG_OBJECT (demux,
3836 G_GUINT64_FORMAT ")", demux->current_partition,
3837 demux->current_partition->partition.body_sid,
3838 demux->current_partition->partition.index_sid,
3839 demux->current_partition->partition.this_partition);
3841 GST_DEBUG_OBJECT (demux, "Haven't found partition for offset yet");
3872 gst_mxf_demux_find_essence_element (GstMXFDemux * demux, argument
3876 guint64 old_offset = demux->offset;
3877 GstMXFDemuxPartition *old_partition = demux->current_partition;
3883 GST_DEBUG_OBJECT (demux, "Trying to find essence element %" G_GINT64_FORMAT
3888 if (find_edit_entry (demux, etrack, *position, keyframe, &index_entry)) {
3889 GST_DEBUG_OBJECT (demux,
3896 GST_DEBUG_OBJECT (demux, "Not found in index table");
3900 if (!demux->random_access) {
3904 GST_DEBUG_OBJECT (demux,
3912 GST_WARNING_OBJECT (demux, "Position after end of essence track");
3920 demux->offset = demux->run_in;
3924 demux->offset = offset + demux->run_in;
3925 GST_DEBUG_OBJECT (demux,
3933 gst_mxf_demux_set_partition_for_offset (demux, demux->offset);
3935 for (i = 0; i < demux->essence_tracks->len; i++) {
3937 &g_array_index (demux->essence_tracks, GstMXFDemuxEssenceTrack, i);
3942 t->position = (demux->offset == demux->run_in) ? 0 : -1;
3943 GST_LOG_OBJECT (demux, "Setting track %d position to %" G_GINT64_FORMAT,
3953 GST_LOG_OBJECT (demux, "Pulling from offset %" G_GINT64_FORMAT,
3954 demux->offset);
3955 ret = gst_mxf_demux_peek_klv_packet (demux, demux->offset, &klv);
3959 for (i = 0; i < demux->essence_tracks->len; i++) {
3961 &g_array_index (demux->essence_tracks, GstMXFDemuxEssenceTrack,
3970 for (i = 0; i < demux->src->len; i++) {
3971 GstMXFDemuxPad *p = g_ptr_array_index (demux->src, i);
3980 gst_event_set_seqnum (e, demux->seqnum);
3986 GST_LOG_OBJECT (demux,
3990 demux->offset = old_offset;
3991 demux->current_partition = old_partition;
3994 ret = gst_mxf_demux_handle_klv_packet (demux, &klv, TRUE);
3995 gst_mxf_demux_consume_klv (demux, &klv);
3998 GST_LOG_OBJECT (demux,
4009 GST_DEBUG_OBJECT (demux, "Found at offset %" G_GUINT64_FORMAT,
4010 demux->offset);
4011 demux->offset = old_offset;
4012 demux->current_partition = old_partition;
4013 if (find_edit_entry (demux, etrack, *position, keyframe, &index_entry)) {
4014 GST_DEBUG_OBJECT (demux,
4023 demux->offset = old_offset;
4024 demux->current_partition = old_partition;
4026 GST_DEBUG_OBJECT (demux, "Not found in this file");
4032 gst_mxf_demux_pull_and_handle_klv_packet (GstMXFDemux * demux) argument
4038 if (demux->src->len > 0) {
4039 if (!gst_mxf_demux_get_earliest_pad (demux)) {
4041 GST_DEBUG_OBJECT (demux, "All tracks are EOS");
4046 if (demux->state == GST_MXF_DEMUX_STATE_ESSENCE) {
4047 g_assert (demux->current_partition->single_track
4048 && demux->current_partition->single_track->wrapping !=
4052 gst_mxf_demux_handle_generic_container_essence_element (demux,
4053 &demux->current_partition->clip_klv, FALSE);
4054 gst_mxf_demux_consume_klv (demux, &demux->current_partition->clip_klv);
4056 && demux->current_partition->single_track->position >=
4057 demux->current_partition->single_track->duration) {
4060 GST_DEBUG_OBJECT (demux, "Single track EOS, switch");
4066 ret = gst_mxf_demux_peek_klv_packet (demux, demux->offset, &klv);
4072 if (ret == GST_FLOW_EOS && demux->src->len > 0) {
4076 GST_DEBUG_OBJECT (demux, "EOS HANDLING");
4078 for (i = 0; i < demux->src->len; i++) {
4079 GstMXFDemuxPad *p = g_ptr_array_index (demux->src, i);
4094 gst_event_set_seqnum (e, demux->seqnum);
4099 while ((p = gst_mxf_demux_get_earliest_pad (demux))) {
4108 gst_mxf_demux_find_essence_element (demux, p->current_essence_track,
4113 GST_ERROR_OBJECT (demux, "Failed to find offset for essence track");
4116 gst_event_set_seqnum (e, demux->seqnum);
4121 demux->offset = offset + demux->run_in;
4122 gst_mxf_demux_set_partition_for_offset (demux, demux->offset);
4125 demux->state = GST_MXF_DEMUX_STATE_ESSENCE;
4126 demux->current_partition->clip_klv.consumed =
4127 offset - demux->current_partition->clip_klv.offset;
4129 demux->state = GST_MXF_DEMUX_STATE_KLV;
4139 ret = gst_mxf_demux_handle_klv_packet (demux, &klv, FALSE);
4140 gst_mxf_demux_consume_klv (demux, &klv);
4144 GstMXFDemuxPartition *partition = demux->current_partition;
4148 if (demux->pull_footer_metadata
4151 && (demux->footer_partition_pack_offset != 0
4152 || demux->random_index_pack)) {
4153 GST_DEBUG_OBJECT (demux,
4155 gst_mxf_demux_parse_footer_metadata (demux);
4156 demux->pull_footer_metadata = FALSE;
4162 GST_DEBUG_OBJECT (demux,
4172 GST_DEBUG_OBJECT (demux,
4176 GST_ERROR_OBJECT (demux,
4184 GST_DEBUG_OBJECT (demux,
4187 if (find_edit_entry (demux, partition->single_track,
4192 GST_DEBUG_OBJECT (demux, "Track fully consumed, partition done");
4198 for (i = 0; i < demux->essence_tracks->len; i++) {
4200 &g_array_index (demux->essence_tracks, GstMXFDemuxEssenceTrack,
4206 GST_DEBUG_OBJECT (demux, "Resetting track %d to position 0",
4212 if (find_edit_entry (demux, etrack,
4224 GList *cur_part = g_list_find (demux->partitions, partition);
4231 GST_DEBUG_OBJECT (demux,
4233 demux->offset = next_partition->partition.this_partition;
4235 GST_DEBUG_OBJECT (demux,
4237 G_GUINT64_FORMAT ")", lowest_offset, demux->offset);
4238 demux->offset = lowest_offset;
4242 demux->state = GST_MXF_DEMUX_STATE_ESSENCE;
4243 demux->current_partition->clip_klv.consumed =
4244 demux->offset - demux->current_partition->clip_klv.offset;
4252 if (ret == GST_FLOW_OK && demux->src->len > 0
4253 && demux->essence_tracks->len > 0) {
4256 while ((earliest = gst_mxf_demux_get_earliest_pad (demux)) && (force_switch
4257 || demux->segment.position - earliest->position >
4258 demux->max_drift)) {
4262 GST_DEBUG_OBJECT (demux,
4274 gst_mxf_demux_find_essence_element (demux,
4279 GST_WARNING_OBJECT (demux,
4283 gst_event_set_seqnum (e, demux->seqnum);
4288 demux->offset = offset + demux->run_in;
4289 gst_mxf_demux_set_partition_for_offset (demux, demux->offset);
4290 GST_DEBUG_OBJECT (demux,
4293 demux->offset, position, earliest->current_essence_track->track_id,
4296 if (demux->current_partition->single_track
4297 && demux->current_partition->single_track->wrapping !=
4299 demux->state = GST_MXF_DEMUX_STATE_ESSENCE;
4300 demux->current_partition->clip_klv.consumed =
4301 offset - demux->current_partition->clip_klv.offset;
4303 demux->state = GST_MXF_DEMUX_STATE_KLV;
4318 GstMXFDemux *demux = NULL; local
4321 demux = GST_MXF_DEMUX (gst_pad_get_parent (pad));
4323 if (demux->state == GST_MXF_DEMUX_STATE_UNKNOWN) {
4328 while (demux->offset < 64 * 1024) {
4330 gst_mxf_demux_peek_klv_packet (demux, demux->offset,
4335 GST_DEBUG_OBJECT (demux,
4337 demux->offset);
4338 demux->state = GST_MXF_DEMUX_STATE_KLV;
4339 demux->run_in = demux->offset;
4342 demux->offset++;
4345 if (G_UNLIKELY (demux->run_in == -1)) {
4346 GST_ERROR_OBJECT (demux, "No valid header partition pack found");
4352 gst_mxf_demux_pull_random_index_pack (demux);
4356 flow = gst_mxf_demux_pull_and_handle_klv_packet (demux);
4363 if ((demux->segment.stop != -1) &&
4364 (demux->segment.position >= demux->segment.stop)) {
4368 for (i = 0; i < demux->src->len; i++) {
4369 GstMXFDemuxPad *p = g_ptr_array_index (demux->src, i);
4371 if (!p->eos && p->position < demux->segment.stop) {
4383 gst_object_unref (demux);
4391 GST_LOG_OBJECT (demux, "pausing task, reason %s", reason);
4396 if (demux->src->len == 0) {
4397 GST_ELEMENT_ERROR (demux, STREAM, WRONG_TYPE,
4400 } else if (demux->segment.flags & GST_SEEK_FLAG_SEGMENT) {
4407 if ((stop = demux->segment.stop) == -1)
4408 stop = demux->segment.duration;
4410 GST_LOG_OBJECT (demux, "Sending segment done, at end of segment");
4411 m = gst_message_new_segment_done (GST_OBJECT_CAST (demux),
4413 gst_message_set_seqnum (m, demux->seqnum);
4414 gst_element_post_message (GST_ELEMENT_CAST (demux), m);
4416 gst_event_set_seqnum (e, demux->seqnum);
4417 gst_mxf_demux_push_src_event (demux, e);
4422 GST_LOG_OBJECT (demux, "Sending EOS, at end of stream");
4424 gst_event_set_seqnum (e, demux->seqnum);
4425 if (!gst_mxf_demux_push_src_event (demux, e)) {
4426 GST_WARNING_OBJECT (demux, "failed pushing EOS on streams");
4432 GST_ELEMENT_FLOW_ERROR (demux, flow);
4434 gst_event_set_seqnum (e, demux->seqnum);
4435 gst_mxf_demux_push_src_event (demux, e);
4437 gst_object_unref (demux);
4446 GstMXFDemux *demux = NULL; local
4454 demux = GST_MXF_DEMUX (parent);
4456 GST_LOG_OBJECT (demux,
4460 if (demux->src->len > 0) {
4461 if (!gst_mxf_demux_get_earliest_pad (demux)) {
4463 GST_DEBUG_OBJECT (demux, "All tracks are EOS");
4469 GST_DEBUG_OBJECT (demux, "beginning of file, expect header");
4470 demux->run_in = -1;
4471 demux->offset = 0;
4472 demux->state = GST_MXF_DEMUX_STATE_UNKNOWN;
4475 if (G_UNLIKELY (demux->offset == 0 && GST_BUFFER_OFFSET (inbuf) != 0)) {
4476 GST_DEBUG_OBJECT (demux, "offset was zero, synchronizing with buffer's");
4478 demux->offset = GST_BUFFER_OFFSET (inbuf);
4479 gst_mxf_demux_set_partition_for_offset (demux, demux->offset);
4480 } else if (demux->current_partition == NULL) {
4481 gst_mxf_demux_set_partition_for_offset (demux, demux->offset);
4484 gst_adapter_push (demux->adapter, inbuf);
4488 if (G_UNLIKELY (demux->flushing)) {
4489 GST_DEBUG_OBJECT (demux, "we are now flushing, exiting parser loop");
4494 if (gst_adapter_available (demux->adapter) < 16)
4497 if (demux->state == GST_MXF_DEMUX_STATE_UNKNOWN) {
4501 while (demux->offset < 64 * 1024
4502 && gst_adapter_available (demux->adapter) >= 16) {
4503 data = gst_adapter_map (demux->adapter, 16);
4505 gst_adapter_unmap (demux->adapter);
4508 GST_DEBUG_OBJECT (demux,
4510 demux->offset);
4511 demux->run_in = demux->offset;
4512 demux->state = GST_MXF_DEMUX_STATE_KLV;
4515 gst_adapter_flush (demux->adapter, 1);
4516 demux->offset++;
4518 } else if (demux->offset < demux->run_in) {
4519 guint64 flush = MIN (gst_adapter_available (demux->adapter),
4520 demux->run_in - demux->offset);
4521 gst_adapter_flush (demux->adapter, flush);
4522 demux->offset += flush;
4526 if (demux->state == GST_MXF_DEMUX_STATE_UNKNOWN) {
4528 if (demux->offset < 64 * 1024)
4531 GST_ERROR_OBJECT (demux, "No valid header partition pack found");
4536 if (gst_adapter_available (demux->adapter) < 17)
4540 g_assert (demux->state == GST_MXF_DEMUX_STATE_KLV);
4546 data = gst_adapter_map (demux->adapter, 17);
4550 GST_DEBUG_OBJECT (demux, "Got KLV packet with key %s",
4562 gst_adapter_unmap (demux->adapter);
4567 GST_ERROR_OBJECT (demux, "Invalid KLV packet length: %u", slen);
4572 if (gst_adapter_available (demux->adapter) < 17 + slen)
4575 data = gst_adapter_map (demux->adapter, 17 + slen);
4586 gst_adapter_unmap (demux->adapter);
4591 GST_ERROR_OBJECT (demux,
4597 GST_DEBUG_OBJECT (demux, "KLV packet with key %s has length "
4600 if (gst_adapter_available (demux->adapter) < klv.data_offset + klv.length)
4603 gst_adapter_flush (demux->adapter, klv.data_offset);
4606 klv.data = gst_adapter_take_buffer (demux->adapter, klv.length);
4608 ret = gst_mxf_demux_handle_klv_packet (demux, &klv, FALSE);
4610 gst_mxf_demux_consume_klv (demux, &klv);
4621 gst_mxf_demux_pad_to_track_and_position (GstMXFDemux * demux, argument
4670 for (i = 0; i < demux->essence_tracks->len; i++) {
4672 &g_array_index (demux->essence_tracks, GstMXFDemuxEssenceTrack, i);
4693 gst_mxf_demux_pad_get_stream_time (GstMXFDemux * demux, argument
4737 gst_mxf_demux_pad_set_position (GstMXFDemux * demux, GstMXFDemuxPad * p, argument
4788 gst_mxf_demux_pad_set_component (demux, p, i);
4799 gst_mxf_demux_pad_set_component (demux, p, i);
4831 gst_mxf_demux_seek_push (GstMXFDemux * demux, GstEvent * event) argument
4857 memcpy (&seeksegment, &demux->segment, sizeof (GstSegment));
4859 GST_DEBUG_OBJECT (demux, "segment before configure %" GST_SEGMENT_FORMAT,
4860 &demux->segment);
4866 GST_DEBUG_OBJECT (demux, "segment configured %" GST_SEGMENT_FORMAT,
4869 if (flush || seeksegment.position != demux->segment.position) {
4874 if (!demux->metadata_resolved || demux->update_metadata) {
4875 if (gst_mxf_demux_resolve_references (demux) != GST_FLOW_OK ||
4876 gst_mxf_demux_update_tracks (demux) != GST_FLOW_OK) {
4882 for (i = 0; i < demux->src->len; i++) {
4883 GstMXFDemuxPad *p = g_ptr_array_index (demux->src, i);
4889 gst_mxf_demux_pad_set_position (demux, p, start);
4892 off = gst_mxf_demux_find_essence_element (demux, p->current_essence_track,
4901 new_offset += demux->run_in;
4903 GST_DEBUG_OBJECT (demux, "generating an upstream seek at position %"
4909 ret = gst_pad_push_event (demux->sinkpad, e);
4917 for (i = 0; i < demux->src->len; i++) {
4918 GstMXFDemuxPad *p = g_ptr_array_index (demux->src, i);
4922 for (i = 0; i < demux->essence_tracks->len; i++) {
4924 &g_array_index (demux->essence_tracks, GstMXFDemuxEssenceTrack, i);
4929 memcpy (&demux->segment, &seeksegment, sizeof (GstSegment));
4936 GST_WARNING_OBJECT (demux, "seeking only supported in TIME format");
4937 return gst_pad_push_event (demux->sinkpad, gst_event_ref (event));
4941 GST_WARNING_OBJECT (demux, "only rates > 0.0 are allowed");
4946 GST_WARNING_OBJECT (demux, "metadata can't be resolved");
4947 return gst_pad_push_event (demux->sinkpad, gst_event_ref (event));
4951 GST_WARNING_OBJECT (demux, "upstream seek failed");
4952 return gst_pad_push_event (demux->sinkpad, gst_event_ref (event));
4956 GST_WARNING_OBJECT (demux, "can't find new offset");
4957 return gst_pad_push_event (demux->sinkpad, gst_event_ref (event));
4962 collect_index_table_segments (GstMXFDemux * demux) argument
4966 guint64 old_offset = demux->offset;
4967 GstMXFDemuxPartition *old_partition = demux->current_partition;
4971 if (demux->random_index_pack) {
4972 for (i = 0; i < demux->random_index_pack->len; i++) {
4974 &g_array_index (demux->random_index_pack, MXFRandomIndexPackEntry, i);
4976 if (e->offset < demux->run_in) {
4977 GST_ERROR_OBJECT (demux, "Invalid random index pack entry");
4981 demux->offset = e->offset;
4982 read_partition_header (demux);
4985 demux->offset = old_offset;
4986 demux->current_partition = old_partition;
4989 if (demux->pending_index_table_segments == NULL) {
4990 GST_DEBUG_OBJECT (demux, "No pending index table segments to collect");
4994 GST_LOG_OBJECT (demux, "Collecting pending index table segments");
4996 for (l = demux->pending_index_table_segments; l; l = l->next) {
5005 GST_LOG_OBJECT (demux,
5010 for (k = demux->index_tables; k; k = k->next) {
5030 demux->index_tables = g_list_prepend (demux->index_tables, t);
5041 GST_WARNING_OBJECT (demux,
5054 for (l = demux->index_tables; l; l = l->next) {
5062 GST_DEBUG_OBJECT (demux,
5085 GST_ERROR_OBJECT (demux,
5096 GST_LOG_OBJECT (demux,
5106 g_list_free_full (demux->pending_index_table_segments, g_free);
5107 demux->pending_index_table_segments = NULL;
5109 GST_DEBUG_OBJECT (demux, "Done collecting segments");
5113 gst_mxf_demux_seek_pull (GstMXFDemux * demux, GstEvent * event) argument
5131 if (seqnum == demux->seqnum) {
5132 GST_DEBUG_OBJECT (demux, "Already handled requested seek");
5136 GST_DEBUG_OBJECT (demux, "Seek %" GST_PTR_FORMAT, event);
5147 if (!demux->index_table_segments_collected) {
5148 collect_index_table_segments (demux);
5149 demux->index_table_segments_collected = TRUE;
5159 gst_mxf_demux_push_src_event (demux, gst_event_ref (e));
5160 gst_pad_push_event (demux->sinkpad, e);
5163 gst_pad_pause_task (demux->sinkpad);
5167 GST_PAD_STREAM_LOCK (demux->sinkpad);
5175 gst_pad_push_event (demux->sinkpad, e);
5179 memcpy (&seeksegment, &demux->segment, sizeof (GstSegment));
5181 GST_DEBUG_OBJECT (demux, "segment before configure %" GST_SEGMENT_FORMAT,
5182 &demux->segment);
5188 GST_DEBUG_OBJECT (demux,
5192 if (flush || seeksegment.position != demux->segment.position) {
5194 if (!demux->metadata_resolved || demux->update_metadata) {
5195 if (gst_mxf_demux_resolve_references (demux) != GST_FLOW_OK ||
5196 gst_mxf_demux_update_tracks (demux) != GST_FLOW_OK) {
5202 for (tmp = demux->partitions; tmp; tmp = tmp->next) {
5214 for (i = 0; i < demux->src->len; i++) {
5215 GstMXFDemuxPad *p = g_ptr_array_index (demux->src, i);
5220 if (!gst_mxf_demux_pad_to_track_and_position (demux, p,
5230 if (gst_mxf_demux_find_essence_element (demux, etrack, &seeked_pos,
5243 if (!gst_mxf_demux_pad_get_stream_time (demux, p, etrack, seeked_pos,
5253 GST_INFO_OBJECT (demux, "key unit seek, adjusting segment start to "
5260 if (flush || keyunit_ts != demux->segment.position) {
5264 for (i = 0; i < demux->src->len; i++) {
5265 GstMXFDemuxPad *p = g_ptr_array_index (demux->src, i);
5271 gst_mxf_demux_pad_set_position (demux, p, seeksegment.position);
5276 gst_mxf_demux_find_essence_element (demux, p->current_essence_track,
5279 GST_DEBUG_OBJECT (demux, "Unable to find offset for pad %s",
5304 gst_flow_combiner_reset (demux->flowcombiner);
5306 GST_WARNING_OBJECT (demux, "No new offset found");
5309 demux->offset = new_offset + demux->run_in;
5311 gst_mxf_demux_set_partition_for_offset (demux, demux->offset);
5313 if (demux->current_partition->single_track
5314 && demux->current_partition->single_track->wrapping !=
5316 demux->state = GST_MXF_DEMUX_STATE_ESSENCE;
5318 demux->state = GST_MXF_DEMUX_STATE_KLV;
5321 if (G_UNLIKELY (demux->close_seg_event)) {
5322 gst_event_unref (demux->close_seg_event);
5323 demux->close_seg_event = NULL;
5332 gst_mxf_demux_push_src_event (demux, e);
5334 GST_DEBUG_OBJECT (demux, "closing running segment %" GST_SEGMENT_FORMAT,
5335 &demux->segment);
5338 demux->close_seg_event = gst_event_new_segment (&demux->segment);
5339 gst_event_set_seqnum (demux->close_seg_event, demux->seqnum);
5343 memcpy (&demux->segment, &seeksegment, sizeof (GstSegment));
5346 if (demux->segment.flags & GST_SEEK_FLAG_SEGMENT) {
5349 m = gst_message_new_segment_start (GST_OBJECT (demux),
5350 demux->segment.format, demux->segment.position);
5352 gst_element_post_message (GST_ELEMENT (demux), m);
5356 for (i = 0; i < demux->src->len; i++) {
5357 GstMXFDemuxPad *p = g_ptr_array_index (demux->src, i);
5361 for (i = 0; i < demux->essence_tracks->len; i++) {
5363 &g_array_index (demux->essence_tracks, GstMXFDemuxEssenceTrack, i);
5367 demux->seqnum = seqnum;
5369 gst_pad_start_task (demux->sinkpad,
5370 (GstTaskFunction) gst_mxf_demux_loop, demux->sinkpad, NULL);
5372 GST_PAD_STREAM_UNLOCK (demux->sinkpad);
5379 GST_WARNING_OBJECT (demux, "seeking only supported in TIME format");
5384 GST_WARNING_OBJECT (demux, "only rates > 0.0 are allowed");
5389 gst_pad_start_task (demux->sinkpad,
5390 (GstTaskFunction) gst_mxf_demux_loop, demux->sinkpad, NULL);
5391 GST_PAD_STREAM_UNLOCK (demux->sinkpad);
5392 GST_WARNING_OBJECT (demux, "metadata can't be resolved");
5404 gst_mxf_demux_push_src_event (demux, e);
5406 gst_pad_start_task (demux->sinkpad,
5407 (GstTaskFunction) gst_mxf_demux_loop, demux->sinkpad, NULL);
5408 GST_PAD_STREAM_UNLOCK (demux->sinkpad);
5409 GST_WARNING_OBJECT (demux, "Requested seek position is not valid");
5417 GstMXFDemux *demux = GST_MXF_DEMUX (parent); local
5424 if (demux->random_access)
5425 ret = gst_mxf_demux_seek_pull (demux, event);
5427 ret = gst_mxf_demux_seek_push (demux, event);
5431 ret = gst_pad_push_event (demux->sinkpad, event);
5441 GstMXFDemux *demux = GST_MXF_DEMUX (parent); local
5480 g_rw_lock_reader_lock (&demux->metadata_lock);
5482 g_rw_lock_reader_unlock (&demux->metadata_lock);
5493 g_rw_lock_reader_unlock (&demux->metadata_lock);
5502 g_rw_lock_reader_unlock (&demux->metadata_lock);
5528 if (demux->random_access) {
5534 seekable = gst_pad_peer_query (demux->sinkpad, peerquery);
5551 format = demux->segment.format;
5554 gst_segment_to_stream_time (&demux->segment, format,
5555 demux->segment.start);
5556 if ((stop = demux->segment.stop) == -1)
5557 stop = demux->segment.duration;
5559 stop = gst_segment_to_stream_time (&demux->segment, format, stop);
5561 gst_query_set_segment (query, demux->segment.rate, format, start, stop);
5607 GstMXFDemux *demux; local
5609 demux = GST_MXF_DEMUX (parent);
5612 demux->random_access = FALSE;
5615 demux->random_access = TRUE;
5619 demux->random_access = FALSE;
5630 GstMXFDemux *demux; local
5633 demux = GST_MXF_DEMUX (parent);
5639 demux->flushing = TRUE;
5643 GST_DEBUG_OBJECT (demux, "flushing queued data in the MXF demuxer");
5645 gst_adapter_clear (demux->adapter);
5646 demux->flushing = FALSE;
5647 demux->offset = 0;
5654 if (demux->src->len == 0) {
5655 GST_ELEMENT_ERROR (demux, STREAM, WRONG_TYPE,
5660 for (i = 0; i < demux->essence_tracks->len; i++) {
5662 &g_array_index (demux->essence_tracks, GstMXFDemuxEssenceTrack, i);
5668 for (i = 0; i < demux->src->len; i++) {
5669 GstMXFDemuxPad *p = g_ptr_array_index (demux->src, i);
5679 while ((p = gst_mxf_demux_get_earliest_pad (demux))) {
5686 gst_mxf_demux_find_essence_element (demux, p->current_essence_track,
5689 GST_ERROR_OBJECT (demux, "Failed to find offset for essence track");
5695 if (gst_pad_push_event (demux->sinkpad,
5696 gst_event_new_seek (demux->segment.rate, GST_FORMAT_BYTES,
5697 demux->segment.flags | GST_SEEK_FLAG_ACCURATE,
5698 GST_SEEK_TYPE_SET, offset + demux->run_in,
5701 for (i = 0; i < demux->essence_tracks->len; i++) {
5703 &g_array_index (demux->essence_tracks, GstMXFDemuxEssenceTrack,
5710 GST_WARNING_OBJECT (demux,
5720 ret = (demux->src->len > 0);
5726 for (i = 0; i < demux->essence_tracks->len; i++) {
5728 &g_array_index (demux->essence_tracks, GstMXFDemuxEssenceTrack,
5732 demux->current_partition = NULL;
5733 demux->seqnum = gst_event_get_seqnum (event);
5751 GstMXFDemux *demux = GST_MXF_DEMUX (element); local
5754 GST_DEBUG_OBJECT (demux, "handling query %s",
5767 pos = demux->segment.position;
5769 GST_DEBUG_OBJECT (demux,
5787 if (demux->src->len == 0)
5790 g_rw_lock_reader_lock (&demux->metadata_lock);
5791 for (i = 0; i < demux->src->len; i++) {
5792 GstMXFDemuxPad *pad = g_ptr_array_index (demux->src, i);
5809 g_rw_lock_reader_unlock (&demux->metadata_lock);
5812 GST_DEBUG_OBJECT (demux, "No duration known (yet)");
5816 GST_DEBUG_OBJECT (demux,
5834 if (demux->random_access) {
5840 seekable = gst_pad_peer_query (demux->sinkpad, peerquery);
5855 format = demux->segment.format;
5858 gst_segment_to_stream_time (&demux->segment, format,
5859 demux->segment.start);
5860 if ((stop = demux->segment.stop) == -1)
5861 stop = demux->segment.duration;
5863 stop = gst_segment_to_stream_time (&demux->segment, format, stop);
5865 gst_query_set_segment (query, demux->segment.rate, format, start, stop);
5871 ret = gst_pad_peer_query (demux->sinkpad, query);
5881 GST_DEBUG_OBJECT (demux, "query failed");
5889 GstMXFDemux *demux = GST_MXF_DEMUX (element); local
5894 demux->seqnum = gst_util_seqnum_next ();
5906 gst_mxf_demux_reset (demux);
5919 GstMXFDemux *demux = GST_MXF_DEMUX (object); local
5923 g_free (demux->requested_package_string);
5924 demux->requested_package_string = g_value_dup_string (value);
5927 demux->max_drift = g_value_get_uint64 (value);
5939 GstMXFDemux *demux = GST_MXF_DEMUX (object); local
5943 g_value_set_string (value, demux->current_package_string);
5946 g_value_set_uint64 (value, demux->max_drift);
5951 g_rw_lock_reader_lock (&demux->metadata_lock);
5952 if (demux->preface &&
5953 MXF_METADATA_BASE (demux->preface)->resolved ==
5955 s = mxf_metadata_base_to_structure (MXF_METADATA_BASE (demux->preface));
5964 g_rw_lock_reader_unlock (&demux->metadata_lock);
5976 GstMXFDemux *demux = GST_MXF_DEMUX (object); local
5978 gst_mxf_demux_reset (demux);
5980 if (demux->adapter) {
5981 g_object_unref (demux->adapter);
5982 demux->adapter = NULL;
5985 if (demux->flowcombiner) {
5986 gst_flow_combiner_free (demux->flowcombiner);
5987 demux->flowcombiner = NULL;
5990 if (demux->close_seg_event) {
5991 gst_event_unref (demux->close_seg_event);
5992 demux->close_seg_event = NULL;
5995 g_free (demux->current_package_string);
5996 demux->current_package_string = NULL;
5997 g_free (demux->requested_package_string);
5998 demux->requested_package_string = NULL;
6000 g_ptr_array_free (demux->src, TRUE);
6001 demux->src = NULL;
6002 g_array_free (demux->essence_tracks, TRUE);
6003 demux->essence_tracks = NULL;
6005 g_hash_table_destroy (demux->metadata);
6007 g_rw_lock_clear (&demux->metadata_lock);
6056 gst_mxf_demux_init (GstMXFDemux * demux) argument
6058 demux->sinkpad =
6061 gst_pad_set_event_function (demux->sinkpad,
6063 gst_pad_set_chain_function (demux->sinkpad,
6065 gst_pad_set_activate_function (demux->sinkpad,
6067 gst_pad_set_activatemode_function (demux->sinkpad,
6070 gst_element_add_pad (GST_ELEMENT (demux), demux->sinkpad);
6072 demux->max_drift = DEFAULT_MAX_DRIFT;
6074 demux->adapter = gst_adapter_new ();
6075 demux->flowcombiner = gst_flow_combiner_new ();
6076 g_rw_lock_init (&demux->metadata_lock);
6078 demux->src = g_ptr_array_new ();
6079 demux->essence_tracks =
6082 gst_segment_init (&demux->segment, GST_FORMAT_TIME);
6084 gst_mxf_demux_reset (demux);