mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 17:20:36 +00:00
mxfmux: port to GstCollectPads2
Only tested with audio, I can't get it to accept video (before the port).
This commit is contained in:
parent
1029619766
commit
f4ccc7dff8
2 changed files with 44 additions and 41 deletions
|
@ -65,7 +65,7 @@ static void gst_mxf_mux_set_property (GObject * object,
|
||||||
static void gst_mxf_mux_get_property (GObject * object,
|
static void gst_mxf_mux_get_property (GObject * object,
|
||||||
guint prop_id, GValue * value, GParamSpec * pspec);
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
||||||
|
|
||||||
static GstFlowReturn gst_mxf_mux_collected (GstCollectPads * pads,
|
static GstFlowReturn gst_mxf_mux_collected (GstCollectPads2 * pads,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
static gboolean gst_mxf_mux_handle_src_event (GstPad * pad, GstEvent * event);
|
static gboolean gst_mxf_mux_handle_src_event (GstPad * pad, GstEvent * event);
|
||||||
|
@ -145,9 +145,9 @@ gst_mxf_mux_init (GstMXFMux * mux, GstMXFMuxClass * g_class)
|
||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
gst_element_add_pad (GST_ELEMENT (mux), mux->srcpad);
|
gst_element_add_pad (GST_ELEMENT (mux), mux->srcpad);
|
||||||
|
|
||||||
mux->collect = gst_collect_pads_new ();
|
mux->collect = gst_collect_pads2_new ();
|
||||||
gst_collect_pads_set_function (mux->collect,
|
gst_collect_pads2_set_function (mux->collect,
|
||||||
(GstCollectPadsFunction) GST_DEBUG_FUNCPTR (gst_mxf_mux_collected), mux);
|
(GstCollectPads2Function) GST_DEBUG_FUNCPTR (gst_mxf_mux_collected), mux);
|
||||||
|
|
||||||
gst_mxf_mux_reset (mux);
|
gst_mxf_mux_reset (mux);
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ gst_mxf_mux_reset (GstMXFMux * mux)
|
||||||
g_object_unref (cpad->adapter);
|
g_object_unref (cpad->adapter);
|
||||||
g_free (cpad->mapping_data);
|
g_free (cpad->mapping_data);
|
||||||
|
|
||||||
gst_collect_pads_remove_pad (mux->collect, cpad->collect.pad);
|
gst_collect_pads2_remove_pad (mux->collect, cpad->collect.pad);
|
||||||
}
|
}
|
||||||
|
|
||||||
mux->state = GST_MXF_MUX_STATE_HEADER;
|
mux->state = GST_MXF_MUX_STATE_HEADER;
|
||||||
|
@ -267,7 +267,7 @@ gst_mxf_mux_handle_sink_event (GstPad * pad, GstEvent * event)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now GstCollectPads can take care of the rest, e.g. EOS */
|
/* now GstCollectPads2 can take care of the rest, e.g. EOS */
|
||||||
if (ret)
|
if (ret)
|
||||||
ret = mux->collect_event (pad, event);
|
ret = mux->collect_event (pad, event);
|
||||||
gst_object_unref (mux);
|
gst_object_unref (mux);
|
||||||
|
@ -337,13 +337,13 @@ gst_mxf_mux_setcaps (GstPad * pad, GstCaps * caps)
|
||||||
for (i = 0; i < mux->preface->content_storage->n_packages; i++) {
|
for (i = 0; i < mux->preface->content_storage->n_packages; i++) {
|
||||||
MXFMetadataSourcePackage *package;
|
MXFMetadataSourcePackage *package;
|
||||||
|
|
||||||
if (!MXF_IS_METADATA_SOURCE_PACKAGE (mux->preface->content_storage->
|
if (!MXF_IS_METADATA_SOURCE_PACKAGE (mux->preface->
|
||||||
packages[i]))
|
content_storage->packages[i]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
package =
|
package =
|
||||||
MXF_METADATA_SOURCE_PACKAGE (mux->preface->content_storage->
|
MXF_METADATA_SOURCE_PACKAGE (mux->preface->
|
||||||
packages[i]);
|
content_storage->packages[i]);
|
||||||
|
|
||||||
if (!package->descriptor)
|
if (!package->descriptor)
|
||||||
continue;
|
continue;
|
||||||
|
@ -419,13 +419,13 @@ gst_mxf_mux_request_new_pad (GstElement * element,
|
||||||
pad = gst_pad_new_from_template (templ, name);
|
pad = gst_pad_new_from_template (templ, name);
|
||||||
g_free (name);
|
g_free (name);
|
||||||
cpad = (GstMXFMuxPad *)
|
cpad = (GstMXFMuxPad *)
|
||||||
gst_collect_pads_add_pad (mux->collect, pad, sizeof (GstMXFMuxPad));
|
gst_collect_pads2_add_pad (mux->collect, pad, sizeof (GstMXFMuxPad));
|
||||||
cpad->last_timestamp = 0;
|
cpad->last_timestamp = 0;
|
||||||
cpad->adapter = gst_adapter_new ();
|
cpad->adapter = gst_adapter_new ();
|
||||||
cpad->writer = writer;
|
cpad->writer = writer;
|
||||||
|
|
||||||
/* FIXME: hacked way to override/extend the event function of
|
/* FIXME: hacked way to override/extend the event function of
|
||||||
* GstCollectPads; because it sets its own event function giving the
|
* GstCollectPads2; because it sets its own event function giving the
|
||||||
* element no access to events.
|
* element no access to events.
|
||||||
*/
|
*/
|
||||||
mux->collect_event = (GstPadEventFunction) GST_PAD_EVENTFUNC (pad);
|
mux->collect_event = (GstPadEventFunction) GST_PAD_EVENTFUNC (pad);
|
||||||
|
@ -449,7 +449,7 @@ gst_mxf_mux_release_pad (GstElement * element, GstPad * pad)
|
||||||
g_object_unref (cpad->adapter);
|
g_object_unref (cpad->adapter);
|
||||||
g_free (cpad->mapping_data);
|
g_free (cpad->mapping_data);
|
||||||
|
|
||||||
gst_collect_pads_remove_pad (mux->collect, pad);
|
gst_collect_pads2_remove_pad (mux->collect, pad);
|
||||||
gst_element_remove_pad (element, pad); */
|
gst_element_remove_pad (element, pad); */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -705,8 +705,8 @@ gst_mxf_mux_create_metadata (GstMXFMux * mux)
|
||||||
if (p->parent.n_tracks == 1) {
|
if (p->parent.n_tracks == 1) {
|
||||||
p->descriptor = (MXFMetadataGenericDescriptor *) cpad->descriptor;
|
p->descriptor = (MXFMetadataGenericDescriptor *) cpad->descriptor;
|
||||||
} else {
|
} else {
|
||||||
MXF_METADATA_MULTIPLE_DESCRIPTOR (p->descriptor)->
|
MXF_METADATA_MULTIPLE_DESCRIPTOR (p->
|
||||||
sub_descriptors[n] =
|
descriptor)->sub_descriptors[n] =
|
||||||
(MXFMetadataGenericDescriptor *) cpad->descriptor;
|
(MXFMetadataGenericDescriptor *) cpad->descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -928,8 +928,8 @@ gst_mxf_mux_create_metadata (GstMXFMux * mux)
|
||||||
g_new0 (MXFMetadataEssenceContainerData *, 1);
|
g_new0 (MXFMetadataEssenceContainerData *, 1);
|
||||||
cstorage->essence_container_data[0] = (MXFMetadataEssenceContainerData *)
|
cstorage->essence_container_data[0] = (MXFMetadataEssenceContainerData *)
|
||||||
gst_mini_object_new (MXF_TYPE_METADATA_ESSENCE_CONTAINER_DATA);
|
gst_mini_object_new (MXF_TYPE_METADATA_ESSENCE_CONTAINER_DATA);
|
||||||
mxf_uuid_init (&MXF_METADATA_BASE (cstorage->essence_container_data[0])->
|
mxf_uuid_init (&MXF_METADATA_BASE (cstorage->
|
||||||
instance_uid, mux->metadata);
|
essence_container_data[0])->instance_uid, mux->metadata);
|
||||||
g_hash_table_insert (mux->metadata,
|
g_hash_table_insert (mux->metadata,
|
||||||
&MXF_METADATA_BASE (cstorage->essence_container_data[0])->instance_uid,
|
&MXF_METADATA_BASE (cstorage->essence_container_data[0])->instance_uid,
|
||||||
cstorage->essence_container_data[0]);
|
cstorage->essence_container_data[0]);
|
||||||
|
@ -1098,9 +1098,8 @@ gst_mxf_mux_handle_buffer (GstMXFMux * mux, GstMXFMuxPad * cpad)
|
||||||
GstBuffer *packet;
|
GstBuffer *packet;
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
guint8 slen, ber[9];
|
guint8 slen, ber[9];
|
||||||
gboolean flush =
|
gboolean flush = ((cpad->collect.state & GST_COLLECT_PADS2_STATE_EOS)
|
||||||
(cpad->collect.abidata.ABI.eos && !cpad->have_complete_edit_unit
|
&& !cpad->have_complete_edit_unit && cpad->collect.buffer == NULL);
|
||||||
&& cpad->collect.buffer == NULL);
|
|
||||||
|
|
||||||
if (cpad->have_complete_edit_unit) {
|
if (cpad->have_complete_edit_unit) {
|
||||||
GST_DEBUG_OBJECT (cpad->collect.pad,
|
GST_DEBUG_OBJECT (cpad->collect.pad,
|
||||||
|
@ -1108,7 +1107,7 @@ gst_mxf_mux_handle_buffer (GstMXFMux * mux, GstMXFMuxPad * cpad)
|
||||||
cpad->source_track->parent.track_id, cpad->pos);
|
cpad->source_track->parent.track_id, cpad->pos);
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
} else if (!flush) {
|
} else if (!flush) {
|
||||||
buf = gst_collect_pads_pop (mux->collect, &cpad->collect);
|
buf = gst_collect_pads2_pop (mux->collect, &cpad->collect);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf) {
|
if (buf) {
|
||||||
|
@ -1246,22 +1245,23 @@ gst_mxf_mux_handle_eos (GstMXFMux * mux)
|
||||||
|
|
||||||
/* Update durations */
|
/* Update durations */
|
||||||
cpad->source_track->parent.sequence->duration = cpad->pos;
|
cpad->source_track->parent.sequence->duration = cpad->pos;
|
||||||
MXF_METADATA_SOURCE_CLIP (cpad->source_track->parent.sequence->
|
MXF_METADATA_SOURCE_CLIP (cpad->source_track->parent.
|
||||||
structural_components[0])->parent.duration = cpad->pos;
|
sequence->structural_components[0])->parent.duration = cpad->pos;
|
||||||
for (i = 0; i < mux->preface->content_storage->packages[0]->n_tracks; i++) {
|
for (i = 0; i < mux->preface->content_storage->packages[0]->n_tracks; i++) {
|
||||||
MXFMetadataTimelineTrack *track;
|
MXFMetadataTimelineTrack *track;
|
||||||
|
|
||||||
if (!MXF_IS_METADATA_TIMELINE_TRACK (mux->preface->content_storage->
|
if (!MXF_IS_METADATA_TIMELINE_TRACK (mux->preface->
|
||||||
packages[0]->tracks[i])
|
content_storage->packages[0]->tracks[i])
|
||||||
|| !MXF_IS_METADATA_SOURCE_CLIP (mux->preface->content_storage->
|
|| !MXF_IS_METADATA_SOURCE_CLIP (mux->preface->
|
||||||
packages[0]->tracks[i]->sequence->structural_components[0]))
|
content_storage->packages[0]->tracks[i]->sequence->
|
||||||
|
structural_components[0]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
track =
|
track =
|
||||||
MXF_METADATA_TIMELINE_TRACK (mux->preface->content_storage->
|
MXF_METADATA_TIMELINE_TRACK (mux->preface->
|
||||||
packages[0]->tracks[i]);
|
content_storage->packages[0]->tracks[i]);
|
||||||
if (MXF_METADATA_SOURCE_CLIP (track->parent.sequence->
|
if (MXF_METADATA_SOURCE_CLIP (track->parent.
|
||||||
structural_components[0])->source_track_id ==
|
sequence->structural_components[0])->source_track_id ==
|
||||||
cpad->source_track->parent.track_id) {
|
cpad->source_track->parent.track_id) {
|
||||||
track->parent.sequence->structural_components[0]->duration = cpad->pos;
|
track->parent.sequence->structural_components[0]->duration = cpad->pos;
|
||||||
track->parent.sequence->duration = cpad->pos;
|
track->parent.sequence->duration = cpad->pos;
|
||||||
|
@ -1272,8 +1272,8 @@ gst_mxf_mux_handle_eos (GstMXFMux * mux)
|
||||||
/* Update timecode track duration */
|
/* Update timecode track duration */
|
||||||
{
|
{
|
||||||
MXFMetadataTimelineTrack *track =
|
MXFMetadataTimelineTrack *track =
|
||||||
MXF_METADATA_TIMELINE_TRACK (mux->preface->content_storage->
|
MXF_METADATA_TIMELINE_TRACK (mux->preface->
|
||||||
packages[0]->tracks[0]);
|
content_storage->packages[0]->tracks[0]);
|
||||||
MXFMetadataSequence *sequence = track->parent.sequence;
|
MXFMetadataSequence *sequence = track->parent.sequence;
|
||||||
MXFMetadataTimecodeComponent *component =
|
MXFMetadataTimecodeComponent *component =
|
||||||
MXF_METADATA_TIMECODE_COMPONENT (sequence->structural_components[0]);
|
MXF_METADATA_TIMECODE_COMPONENT (sequence->structural_components[0]);
|
||||||
|
@ -1368,7 +1368,7 @@ _sort_mux_pads (gconstpointer a, gconstpointer b)
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_mxf_mux_collected (GstCollectPads * pads, gpointer user_data)
|
gst_mxf_mux_collected (GstCollectPads2 * pads, gpointer user_data)
|
||||||
{
|
{
|
||||||
GstMXFMux *mux = GST_MXF_MUX (user_data);
|
GstMXFMux *mux = GST_MXF_MUX (user_data);
|
||||||
GstMXFMuxPad *best = NULL;
|
GstMXFMuxPad *best = NULL;
|
||||||
|
@ -1423,14 +1423,17 @@ gst_mxf_mux_collected (GstCollectPads * pads, gpointer user_data)
|
||||||
|
|
||||||
do {
|
do {
|
||||||
for (sl = mux->collect->data; sl; sl = sl->next) {
|
for (sl = mux->collect->data; sl; sl = sl->next) {
|
||||||
|
gboolean pad_eos;
|
||||||
GstMXFMuxPad *cpad = sl->data;
|
GstMXFMuxPad *cpad = sl->data;
|
||||||
GstClockTime next_gc_timestamp =
|
GstClockTime next_gc_timestamp =
|
||||||
gst_util_uint64_scale ((mux->last_gc_position + 1) * GST_SECOND,
|
gst_util_uint64_scale ((mux->last_gc_position + 1) * GST_SECOND,
|
||||||
mux->min_edit_rate.d, mux->min_edit_rate.n);
|
mux->min_edit_rate.d, mux->min_edit_rate.n);
|
||||||
|
|
||||||
eos &= cpad->collect.abidata.ABI.eos;
|
pad_eos = cpad->collect.state & GST_COLLECT_PADS2_STATE_EOS;
|
||||||
|
if (!pad_eos)
|
||||||
|
eos = FALSE;
|
||||||
|
|
||||||
if ((!cpad->collect.abidata.ABI.eos || cpad->have_complete_edit_unit ||
|
if ((!pad_eos || cpad->have_complete_edit_unit ||
|
||||||
gst_adapter_available (cpad->adapter) > 0 || cpad->collect.buffer)
|
gst_adapter_available (cpad->adapter) > 0 || cpad->collect.buffer)
|
||||||
&& cpad->last_timestamp < next_gc_timestamp) {
|
&& cpad->last_timestamp < next_gc_timestamp) {
|
||||||
best = cpad;
|
best = cpad;
|
||||||
|
@ -1478,12 +1481,12 @@ gst_mxf_mux_change_state (GstElement * element, GstStateChange transition)
|
||||||
case GST_STATE_CHANGE_NULL_TO_READY:
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
||||||
gst_collect_pads_start (mux->collect);
|
gst_collect_pads2_start (mux->collect);
|
||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||||
gst_collect_pads_stop (mux->collect);
|
gst_collect_pads2_stop (mux->collect);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/base/gstadapter.h>
|
#include <gst/base/gstadapter.h>
|
||||||
#include <gst/base/gstcollectpads.h>
|
#include <gst/base/gstcollectpads2.h>
|
||||||
|
|
||||||
#include "mxfessence.h"
|
#include "mxfessence.h"
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ G_BEGIN_DECLS
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
GstCollectData collect;
|
GstCollectData2 collect;
|
||||||
|
|
||||||
guint64 pos;
|
guint64 pos;
|
||||||
GstClockTime last_timestamp;
|
GstClockTime last_timestamp;
|
||||||
|
@ -71,7 +71,7 @@ typedef struct _GstMXFMux {
|
||||||
GstElement element;
|
GstElement element;
|
||||||
|
|
||||||
GstPad *srcpad;
|
GstPad *srcpad;
|
||||||
GstCollectPads *collect;
|
GstCollectPads2 *collect;
|
||||||
|
|
||||||
/* <private> */
|
/* <private> */
|
||||||
GstPadEventFunction collect_event;
|
GstPadEventFunction collect_event;
|
||||||
|
|
Loading…
Reference in a new issue