mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-30 12:49:40 +00:00
mpegtsmux: port to GstCollectPads2
I *think* the stream lock use is correct, not 100% sure.
This commit is contained in:
parent
c03c4d7fac
commit
1029619766
2 changed files with 23 additions and 23 deletions
|
@ -145,7 +145,7 @@ static gboolean new_packet_cb (guint8 * data, guint len, void *user_data,
|
|||
static void release_buffer_cb (guint8 * data, void *user_data);
|
||||
|
||||
static void mpegtsdemux_prepare_srcpad (MpegTsMux * mux);
|
||||
static GstFlowReturn mpegtsmux_collected (GstCollectPads * pads,
|
||||
static GstFlowReturn mpegtsmux_collected (GstCollectPads2 * pads,
|
||||
MpegTsMux * mux);
|
||||
static GstPad *mpegtsmux_request_new_pad (GstElement * element,
|
||||
GstPadTemplate * templ, const gchar * name);
|
||||
|
@ -222,9 +222,9 @@ mpegtsmux_init (MpegTsMux * mux, MpegTsMuxClass * g_class)
|
|||
gst_pad_set_event_function (mux->srcpad, mpegtsmux_src_event);
|
||||
gst_element_add_pad (GST_ELEMENT (mux), mux->srcpad);
|
||||
|
||||
mux->collect = gst_collect_pads_new ();
|
||||
gst_collect_pads_set_function (mux->collect,
|
||||
(GstCollectPadsFunction) GST_DEBUG_FUNCPTR (mpegtsmux_collected), mux);
|
||||
mux->collect = gst_collect_pads2_new ();
|
||||
gst_collect_pads2_set_function (mux->collect,
|
||||
(GstCollectPads2Function) GST_DEBUG_FUNCPTR (mpegtsmux_collected), mux);
|
||||
|
||||
mux->tsmux = tsmux_new ();
|
||||
tsmux_set_write_func (mux->tsmux, new_packet_cb, mux);
|
||||
|
@ -516,7 +516,7 @@ mpegtsmux_create_streams (MpegTsMux * mux)
|
|||
|
||||
/* Create the streams */
|
||||
while (walk) {
|
||||
GstCollectData *c_data = (GstCollectData *) walk->data;
|
||||
GstCollectData2 *c_data = (GstCollectData2 *) walk->data;
|
||||
MpegTsPadData *ts_data = (MpegTsPadData *) walk->data;
|
||||
gchar *name = NULL;
|
||||
|
||||
|
@ -576,11 +576,11 @@ static MpegTsPadData *
|
|||
mpegtsmux_choose_best_stream (MpegTsMux * mux)
|
||||
{
|
||||
MpegTsPadData *best = NULL;
|
||||
GstCollectData *c_best = NULL;
|
||||
GstCollectData2 *c_best = NULL;
|
||||
GSList *walk;
|
||||
|
||||
for (walk = mux->collect->data; walk != NULL; walk = g_slist_next (walk)) {
|
||||
GstCollectData *c_data = (GstCollectData *) walk->data;
|
||||
GstCollectData2 *c_data = (GstCollectData2 *) walk->data;
|
||||
MpegTsPadData *ts_data = (MpegTsPadData *) walk->data;
|
||||
|
||||
if (ts_data->eos == FALSE) {
|
||||
|
@ -588,7 +588,7 @@ mpegtsmux_choose_best_stream (MpegTsMux * mux)
|
|||
GstBuffer *buf;
|
||||
|
||||
ts_data->queued_buf = buf =
|
||||
gst_collect_pads_peek (mux->collect, c_data);
|
||||
gst_collect_pads2_peek (mux->collect, c_data);
|
||||
|
||||
if (buf != NULL) {
|
||||
if (ts_data->prepare_func) {
|
||||
|
@ -650,14 +650,14 @@ mpegtsmux_choose_best_stream (MpegTsMux * mux)
|
|||
}
|
||||
if (c_best) {
|
||||
GstBuffer *buffer;
|
||||
if ((buffer = gst_collect_pads_pop (mux->collect, c_best)))
|
||||
if ((buffer = gst_collect_pads2_pop (mux->collect, c_best)))
|
||||
gst_buffer_unref (buffer);
|
||||
}
|
||||
|
||||
return best;
|
||||
}
|
||||
|
||||
#define COLLECT_DATA_PAD(collect_data) (((GstCollectData *)(collect_data))->pad)
|
||||
#define COLLECT_DATA_PAD(collect_data) (((GstCollectData2 *)(collect_data))->pad)
|
||||
|
||||
static MpegTsPadData *
|
||||
find_pad_data (MpegTsMux * mux, GstPad * pad)
|
||||
|
@ -665,17 +665,17 @@ find_pad_data (MpegTsMux * mux, GstPad * pad)
|
|||
GSList *walk;
|
||||
MpegTsPadData *ts_data = NULL;
|
||||
|
||||
GST_COLLECT_PADS_PAD_LOCK (mux->collect);
|
||||
walk = mux->collect->abidata.ABI.pad_list;
|
||||
GST_COLLECT_PADS2_STREAM_LOCK (mux->collect);
|
||||
walk = mux->collect->pad_list;
|
||||
while (walk) {
|
||||
if (((GstCollectData *) walk->data)->pad == pad) {
|
||||
if (((GstCollectData2 *) walk->data)->pad == pad) {
|
||||
ts_data = (MpegTsPadData *) walk->data;
|
||||
break;
|
||||
}
|
||||
|
||||
walk = g_slist_next (walk);
|
||||
}
|
||||
GST_COLLECT_PADS_PAD_UNLOCK (mux->collect);
|
||||
GST_COLLECT_PADS2_STREAM_UNLOCK (mux->collect);
|
||||
|
||||
return ts_data;
|
||||
}
|
||||
|
@ -855,7 +855,7 @@ out:
|
|||
}
|
||||
|
||||
static GstFlowReturn
|
||||
mpegtsmux_collected (GstCollectPads * pads, MpegTsMux * mux)
|
||||
mpegtsmux_collected (GstCollectPads2 * pads, MpegTsMux * mux)
|
||||
{
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
MpegTsPadData *best = NULL;
|
||||
|
@ -997,7 +997,7 @@ mpegtsmux_request_new_pad (GstElement * element,
|
|||
pad = gst_pad_new_from_template (templ, pad_name);
|
||||
g_free (pad_name);
|
||||
|
||||
pad_data = (MpegTsPadData *) gst_collect_pads_add_pad (mux->collect, pad,
|
||||
pad_data = (MpegTsPadData *) gst_collect_pads2_add_pad (mux->collect, pad,
|
||||
sizeof (MpegTsPadData));
|
||||
if (pad_data == NULL)
|
||||
goto pad_failure;
|
||||
|
@ -1026,7 +1026,7 @@ stream_exists:
|
|||
could_not_add:
|
||||
GST_ELEMENT_ERROR (element, STREAM, FAILED,
|
||||
("Internal data stream error."), ("Could not add pad to element"));
|
||||
gst_collect_pads_remove_pad (mux->collect, pad);
|
||||
gst_collect_pads2_remove_pad (mux->collect, pad);
|
||||
gst_object_unref (pad);
|
||||
return NULL;
|
||||
pad_failure:
|
||||
|
@ -1044,7 +1044,7 @@ mpegtsmux_release_pad (GstElement * element, GstPad * pad)
|
|||
GST_DEBUG_OBJECT (mux, "Pad %" GST_PTR_FORMAT " being released", pad);
|
||||
|
||||
if (mux->collect) {
|
||||
gst_collect_pads_remove_pad (mux->collect, pad);
|
||||
gst_collect_pads2_remove_pad (mux->collect, pad);
|
||||
}
|
||||
|
||||
/* chain up */
|
||||
|
@ -1305,12 +1305,12 @@ mpegtsmux_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 (mux->collect);
|
||||
gst_collect_pads2_start (mux->collect);
|
||||
break;
|
||||
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
||||
break;
|
||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||
gst_collect_pads_stop (mux->collect);
|
||||
gst_collect_pads2_stop (mux->collect);
|
||||
break;
|
||||
case GST_STATE_CHANGE_READY_TO_NULL:
|
||||
if (mux->adapter)
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
#define __MPEGTSMUX_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/base/gstcollectpads.h>
|
||||
#include <gst/base/gstcollectpads2.h>
|
||||
#include <gst/base/gstadapter.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
@ -108,7 +108,7 @@ struct MpegTsMux {
|
|||
|
||||
GstPad *srcpad;
|
||||
|
||||
GstCollectPads *collect;
|
||||
GstCollectPads2 *collect;
|
||||
|
||||
TsMux *tsmux;
|
||||
TsMuxProgram **programs;
|
||||
|
@ -139,7 +139,7 @@ struct MpegTsMuxClass {
|
|||
#define MPEG_TS_PAD_DATA(data) ((MpegTsPadData *)(data))
|
||||
|
||||
struct MpegTsPadData {
|
||||
GstCollectData collect; /* Parent */
|
||||
GstCollectData2 collect; /* Parent */
|
||||
|
||||
gint pid;
|
||||
TsMuxStream *stream;
|
||||
|
|
Loading…
Reference in a new issue