mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-28 20:05:38 +00:00
qtmux: port to GstCollectPads2
This commit is contained in:
parent
3135cab5a3
commit
79a6e23c1f
2 changed files with 24 additions and 23 deletions
|
@ -226,7 +226,7 @@ static void gst_qt_mux_release_pad (GstElement * element, GstPad * pad);
|
|||
/* event */
|
||||
static gboolean gst_qt_mux_sink_event (GstPad * pad, GstEvent * event);
|
||||
|
||||
static GstFlowReturn gst_qt_mux_collected (GstCollectPads * pads,
|
||||
static GstFlowReturn gst_qt_mux_collected (GstCollectPads2 * pads,
|
||||
gpointer user_data);
|
||||
static GstFlowReturn gst_qt_mux_add_buffer (GstQTMux * qtmux, GstQTPad * pad,
|
||||
GstBuffer * buf);
|
||||
|
@ -482,9 +482,10 @@ gst_qt_mux_init (GstQTMux * qtmux, GstQTMuxClass * qtmux_klass)
|
|||
gst_element_add_pad (GST_ELEMENT (qtmux), qtmux->srcpad);
|
||||
|
||||
qtmux->sinkpads = NULL;
|
||||
qtmux->collect = gst_collect_pads_new ();
|
||||
gst_collect_pads_set_function (qtmux->collect,
|
||||
(GstCollectPadsFunction) GST_DEBUG_FUNCPTR (gst_qt_mux_collected), qtmux);
|
||||
qtmux->collect = gst_collect_pads2_new ();
|
||||
gst_collect_pads2_set_function (qtmux->collect,
|
||||
(GstCollectPads2Function) GST_DEBUG_FUNCPTR (gst_qt_mux_collected),
|
||||
qtmux);
|
||||
|
||||
/* properties set to default upon construction */
|
||||
|
||||
|
@ -1642,7 +1643,7 @@ gst_qt_mux_start_file (GstQTMux * qtmux)
|
|||
gst_buffer_unref (prefix);
|
||||
|
||||
for (walk = qtmux->sinkpads; walk && !fail; walk = g_slist_next (walk)) {
|
||||
GstCollectData *cdata = (GstCollectData *) walk->data;
|
||||
GstCollectData2 *cdata = (GstCollectData2 *) walk->data;
|
||||
GstQTPad *qpad = (GstQTPad *) cdata;
|
||||
/* write info for each stream */
|
||||
fail = atoms_recov_write_trak_info (qtmux->moov_recov_file, qpad->trak);
|
||||
|
@ -1742,7 +1743,7 @@ gst_qt_mux_stop_file (GstQTMux * qtmux)
|
|||
|
||||
/* pushing last buffers for each pad */
|
||||
for (walk = qtmux->collect->data; walk; walk = g_slist_next (walk)) {
|
||||
GstCollectData *cdata = (GstCollectData *) walk->data;
|
||||
GstCollectData2 *cdata = (GstCollectData2 *) walk->data;
|
||||
GstQTPad *qtpad = (GstQTPad *) cdata;
|
||||
|
||||
/* avoid add_buffer complaining if not negotiated
|
||||
|
@ -1835,7 +1836,7 @@ gst_qt_mux_stop_file (GstQTMux * qtmux)
|
|||
/* check for late streams */
|
||||
first_ts = GST_CLOCK_TIME_NONE;
|
||||
for (walk = qtmux->collect->data; walk; walk = g_slist_next (walk)) {
|
||||
GstCollectData *cdata = (GstCollectData *) walk->data;
|
||||
GstCollectData2 *cdata = (GstCollectData2 *) walk->data;
|
||||
GstQTPad *qtpad = (GstQTPad *) cdata;
|
||||
|
||||
if (!GST_CLOCK_TIME_IS_VALID (first_ts) ||
|
||||
|
@ -1848,7 +1849,7 @@ gst_qt_mux_stop_file (GstQTMux * qtmux)
|
|||
GST_TIME_ARGS (first_ts));
|
||||
/* add EDTSs for late streams */
|
||||
for (walk = qtmux->collect->data; walk; walk = g_slist_next (walk)) {
|
||||
GstCollectData *cdata = (GstCollectData *) walk->data;
|
||||
GstCollectData2 *cdata = (GstCollectData2 *) walk->data;
|
||||
GstQTPad *qtpad = (GstQTPad *) cdata;
|
||||
guint32 lateness;
|
||||
guint32 duration;
|
||||
|
@ -2501,7 +2502,7 @@ not_negotiated:
|
|||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_qt_mux_collected (GstCollectPads * pads, gpointer user_data)
|
||||
gst_qt_mux_collected (GstCollectPads2 * pads, gpointer user_data)
|
||||
{
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
GstQTMux *qtmux = GST_QT_MUX_CAST (user_data);
|
||||
|
@ -2524,14 +2525,14 @@ gst_qt_mux_collected (GstCollectPads * pads, gpointer user_data)
|
|||
walk = qtmux->collect->data;
|
||||
while (walk) {
|
||||
GstQTPad *pad;
|
||||
GstCollectData *data;
|
||||
GstCollectData2 *data;
|
||||
|
||||
data = (GstCollectData *) walk->data;
|
||||
data = (GstCollectData2 *) walk->data;
|
||||
pad = (GstQTPad *) data;
|
||||
|
||||
walk = g_slist_next (walk);
|
||||
|
||||
buf = gst_collect_pads_peek (pads, data);
|
||||
buf = gst_collect_pads2_peek (pads, data);
|
||||
if (buf == NULL) {
|
||||
GST_LOG_OBJECT (qtmux, "Pad %s has no buffers",
|
||||
GST_PAD_NAME (pad->collect.pad));
|
||||
|
@ -2547,7 +2548,7 @@ gst_qt_mux_collected (GstCollectPads * pads, gpointer user_data)
|
|||
if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (time))) {
|
||||
GST_DEBUG_OBJECT (qtmux, "clipping buffer on pad %s outside segment",
|
||||
GST_PAD_NAME (data->pad));
|
||||
buf = gst_collect_pads_pop (pads, data);
|
||||
buf = gst_collect_pads2_pop (pads, data);
|
||||
gst_buffer_unref (buf);
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
@ -2563,7 +2564,7 @@ gst_qt_mux_collected (GstCollectPads * pads, gpointer user_data)
|
|||
if (best_pad != NULL) {
|
||||
GST_LOG_OBJECT (qtmux, "selected pad %s with time %" GST_TIME_FORMAT,
|
||||
GST_PAD_NAME (best_pad->collect.pad), GST_TIME_ARGS (best_time));
|
||||
buf = gst_collect_pads_pop (pads, &best_pad->collect);
|
||||
buf = gst_collect_pads2_pop (pads, &best_pad->collect);
|
||||
buf = gst_buffer_make_metadata_writable (buf);
|
||||
GST_BUFFER_TIMESTAMP (buf) = best_time;
|
||||
ret = gst_qt_mux_add_buffer (qtmux, best_pad, buf);
|
||||
|
@ -3322,7 +3323,7 @@ gst_qt_mux_release_pad (GstElement * element, GstPad * pad)
|
|||
}
|
||||
}
|
||||
|
||||
gst_collect_pads_remove_pad (mux->collect, pad);
|
||||
gst_collect_pads2_remove_pad (mux->collect, pad);
|
||||
}
|
||||
|
||||
static GstPad *
|
||||
|
@ -3357,8 +3358,8 @@ gst_qt_mux_request_new_pad (GstElement * element,
|
|||
newpad = gst_pad_new_from_template (templ, name);
|
||||
g_free (name);
|
||||
collect_pad = (GstQTPad *)
|
||||
gst_collect_pads_add_pad_full (qtmux->collect, newpad, sizeof (GstQTPad),
|
||||
(GstCollectDataDestroyNotify) (gst_qt_mux_pad_reset));
|
||||
gst_collect_pads2_add_pad_full (qtmux->collect, newpad, sizeof (GstQTPad),
|
||||
(GstCollectData2DestroyNotify) (gst_qt_mux_pad_reset), TRUE);
|
||||
/* set up pad */
|
||||
gst_qt_mux_pad_reset (collect_pad);
|
||||
collect_pad->trak = atom_trak_new (qtmux->context);
|
||||
|
@ -3375,7 +3376,7 @@ gst_qt_mux_request_new_pad (GstElement * element,
|
|||
GST_DEBUG_FUNCPTR (gst_qt_mux_video_sink_set_caps));
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
qtmux->collect_event = (GstPadEventFunction) GST_PAD_EVENTFUNC (newpad);
|
||||
|
@ -3518,13 +3519,13 @@ gst_qt_mux_change_state (GstElement * element, GstStateChange transition)
|
|||
case GST_STATE_CHANGE_NULL_TO_READY:
|
||||
break;
|
||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
||||
gst_collect_pads_start (qtmux->collect);
|
||||
gst_collect_pads2_start (qtmux->collect);
|
||||
qtmux->state = GST_QT_MUX_STATE_STARTED;
|
||||
break;
|
||||
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
||||
break;
|
||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||
gst_collect_pads_stop (qtmux->collect);
|
||||
gst_collect_pads2_stop (qtmux->collect);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#define __GST_QT_MUX_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/base/gstcollectpads.h>
|
||||
#include <gst/base/gstcollectpads2.h>
|
||||
|
||||
#include "fourcc.h"
|
||||
#include "atoms.h"
|
||||
|
@ -82,7 +82,7 @@ typedef GstBuffer * (*GstQTPadPrepareBufferFunc) (GstQTPad * pad,
|
|||
|
||||
struct _GstQTPad
|
||||
{
|
||||
GstCollectData collect; /* we extend the CollectData */
|
||||
GstCollectData2 collect; /* we extend the CollectData2 */
|
||||
|
||||
/* fourcc id of stream */
|
||||
guint32 fourcc;
|
||||
|
@ -144,7 +144,7 @@ struct _GstQTMux
|
|||
GstElement element;
|
||||
|
||||
GstPad *srcpad;
|
||||
GstCollectPads *collect;
|
||||
GstCollectPads2 *collect;
|
||||
GSList *sinkpads;
|
||||
|
||||
/* state */
|
||||
|
|
Loading…
Reference in a new issue