mpegtsmux: port to GstCollectPads2
I *think* the stream lock use is correct, not 100% sure.
This commit is contained in:
parent
c03c4d7fac
commit
1029619766
@ -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 release_buffer_cb (guint8 * data, void *user_data);
|
||||||
|
|
||||||
static void mpegtsdemux_prepare_srcpad (MpegTsMux * mux);
|
static void mpegtsdemux_prepare_srcpad (MpegTsMux * mux);
|
||||||
static GstFlowReturn mpegtsmux_collected (GstCollectPads * pads,
|
static GstFlowReturn mpegtsmux_collected (GstCollectPads2 * pads,
|
||||||
MpegTsMux * mux);
|
MpegTsMux * mux);
|
||||||
static GstPad *mpegtsmux_request_new_pad (GstElement * element,
|
static GstPad *mpegtsmux_request_new_pad (GstElement * element,
|
||||||
GstPadTemplate * templ, const gchar * name);
|
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_pad_set_event_function (mux->srcpad, mpegtsmux_src_event);
|
||||||
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 (mpegtsmux_collected), mux);
|
(GstCollectPads2Function) GST_DEBUG_FUNCPTR (mpegtsmux_collected), mux);
|
||||||
|
|
||||||
mux->tsmux = tsmux_new ();
|
mux->tsmux = tsmux_new ();
|
||||||
tsmux_set_write_func (mux->tsmux, new_packet_cb, mux);
|
tsmux_set_write_func (mux->tsmux, new_packet_cb, mux);
|
||||||
@ -516,7 +516,7 @@ mpegtsmux_create_streams (MpegTsMux * mux)
|
|||||||
|
|
||||||
/* Create the streams */
|
/* Create the streams */
|
||||||
while (walk) {
|
while (walk) {
|
||||||
GstCollectData *c_data = (GstCollectData *) walk->data;
|
GstCollectData2 *c_data = (GstCollectData2 *) walk->data;
|
||||||
MpegTsPadData *ts_data = (MpegTsPadData *) walk->data;
|
MpegTsPadData *ts_data = (MpegTsPadData *) walk->data;
|
||||||
gchar *name = NULL;
|
gchar *name = NULL;
|
||||||
|
|
||||||
@ -576,11 +576,11 @@ static MpegTsPadData *
|
|||||||
mpegtsmux_choose_best_stream (MpegTsMux * mux)
|
mpegtsmux_choose_best_stream (MpegTsMux * mux)
|
||||||
{
|
{
|
||||||
MpegTsPadData *best = NULL;
|
MpegTsPadData *best = NULL;
|
||||||
GstCollectData *c_best = NULL;
|
GstCollectData2 *c_best = NULL;
|
||||||
GSList *walk;
|
GSList *walk;
|
||||||
|
|
||||||
for (walk = mux->collect->data; walk != NULL; walk = g_slist_next (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;
|
MpegTsPadData *ts_data = (MpegTsPadData *) walk->data;
|
||||||
|
|
||||||
if (ts_data->eos == FALSE) {
|
if (ts_data->eos == FALSE) {
|
||||||
@ -588,7 +588,7 @@ mpegtsmux_choose_best_stream (MpegTsMux * mux)
|
|||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
|
|
||||||
ts_data->queued_buf = 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 (buf != NULL) {
|
||||||
if (ts_data->prepare_func) {
|
if (ts_data->prepare_func) {
|
||||||
@ -650,14 +650,14 @@ mpegtsmux_choose_best_stream (MpegTsMux * mux)
|
|||||||
}
|
}
|
||||||
if (c_best) {
|
if (c_best) {
|
||||||
GstBuffer *buffer;
|
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);
|
gst_buffer_unref (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return best;
|
return best;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define COLLECT_DATA_PAD(collect_data) (((GstCollectData *)(collect_data))->pad)
|
#define COLLECT_DATA_PAD(collect_data) (((GstCollectData2 *)(collect_data))->pad)
|
||||||
|
|
||||||
static MpegTsPadData *
|
static MpegTsPadData *
|
||||||
find_pad_data (MpegTsMux * mux, GstPad * pad)
|
find_pad_data (MpegTsMux * mux, GstPad * pad)
|
||||||
@ -665,17 +665,17 @@ find_pad_data (MpegTsMux * mux, GstPad * pad)
|
|||||||
GSList *walk;
|
GSList *walk;
|
||||||
MpegTsPadData *ts_data = NULL;
|
MpegTsPadData *ts_data = NULL;
|
||||||
|
|
||||||
GST_COLLECT_PADS_PAD_LOCK (mux->collect);
|
GST_COLLECT_PADS2_STREAM_LOCK (mux->collect);
|
||||||
walk = mux->collect->abidata.ABI.pad_list;
|
walk = mux->collect->pad_list;
|
||||||
while (walk) {
|
while (walk) {
|
||||||
if (((GstCollectData *) walk->data)->pad == pad) {
|
if (((GstCollectData2 *) walk->data)->pad == pad) {
|
||||||
ts_data = (MpegTsPadData *) walk->data;
|
ts_data = (MpegTsPadData *) walk->data;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
walk = g_slist_next (walk);
|
walk = g_slist_next (walk);
|
||||||
}
|
}
|
||||||
GST_COLLECT_PADS_PAD_UNLOCK (mux->collect);
|
GST_COLLECT_PADS2_STREAM_UNLOCK (mux->collect);
|
||||||
|
|
||||||
return ts_data;
|
return ts_data;
|
||||||
}
|
}
|
||||||
@ -855,7 +855,7 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
mpegtsmux_collected (GstCollectPads * pads, MpegTsMux * mux)
|
mpegtsmux_collected (GstCollectPads2 * pads, MpegTsMux * mux)
|
||||||
{
|
{
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
MpegTsPadData *best = NULL;
|
MpegTsPadData *best = NULL;
|
||||||
@ -997,7 +997,7 @@ mpegtsmux_request_new_pad (GstElement * element,
|
|||||||
pad = gst_pad_new_from_template (templ, pad_name);
|
pad = gst_pad_new_from_template (templ, pad_name);
|
||||||
g_free (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));
|
sizeof (MpegTsPadData));
|
||||||
if (pad_data == NULL)
|
if (pad_data == NULL)
|
||||||
goto pad_failure;
|
goto pad_failure;
|
||||||
@ -1026,7 +1026,7 @@ stream_exists:
|
|||||||
could_not_add:
|
could_not_add:
|
||||||
GST_ELEMENT_ERROR (element, STREAM, FAILED,
|
GST_ELEMENT_ERROR (element, STREAM, FAILED,
|
||||||
("Internal data stream error."), ("Could not add pad to element"));
|
("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);
|
gst_object_unref (pad);
|
||||||
return NULL;
|
return NULL;
|
||||||
pad_failure:
|
pad_failure:
|
||||||
@ -1044,7 +1044,7 @@ mpegtsmux_release_pad (GstElement * element, GstPad * pad)
|
|||||||
GST_DEBUG_OBJECT (mux, "Pad %" GST_PTR_FORMAT " being released", pad);
|
GST_DEBUG_OBJECT (mux, "Pad %" GST_PTR_FORMAT " being released", pad);
|
||||||
|
|
||||||
if (mux->collect) {
|
if (mux->collect) {
|
||||||
gst_collect_pads_remove_pad (mux->collect, pad);
|
gst_collect_pads2_remove_pad (mux->collect, pad);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* chain up */
|
/* chain up */
|
||||||
@ -1305,12 +1305,12 @@ mpegtsmux_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;
|
||||||
case GST_STATE_CHANGE_READY_TO_NULL:
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
||||||
if (mux->adapter)
|
if (mux->adapter)
|
||||||
|
@ -84,7 +84,7 @@
|
|||||||
#define __MPEGTSMUX_H__
|
#define __MPEGTSMUX_H__
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/base/gstcollectpads.h>
|
#include <gst/base/gstcollectpads2.h>
|
||||||
#include <gst/base/gstadapter.h>
|
#include <gst/base/gstadapter.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
@ -108,7 +108,7 @@ struct MpegTsMux {
|
|||||||
|
|
||||||
GstPad *srcpad;
|
GstPad *srcpad;
|
||||||
|
|
||||||
GstCollectPads *collect;
|
GstCollectPads2 *collect;
|
||||||
|
|
||||||
TsMux *tsmux;
|
TsMux *tsmux;
|
||||||
TsMuxProgram **programs;
|
TsMuxProgram **programs;
|
||||||
@ -139,7 +139,7 @@ struct MpegTsMuxClass {
|
|||||||
#define MPEG_TS_PAD_DATA(data) ((MpegTsPadData *)(data))
|
#define MPEG_TS_PAD_DATA(data) ((MpegTsPadData *)(data))
|
||||||
|
|
||||||
struct MpegTsPadData {
|
struct MpegTsPadData {
|
||||||
GstCollectData collect; /* Parent */
|
GstCollectData2 collect; /* Parent */
|
||||||
|
|
||||||
gint pid;
|
gint pid;
|
||||||
TsMuxStream *stream;
|
TsMuxStream *stream;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user