Moved liveadder from gst-plugins-farsight to -bad

Re-indent liveadder in gst style and add it to configure
This commit is contained in:
Olivier Crête 2009-02-10 16:18:32 +00:00 committed by Edward Hervey
parent 4b33d319fc
commit 6edfec64ee
4 changed files with 208 additions and 193 deletions

View file

@ -252,6 +252,7 @@ AG_GST_CHECK_PLUGIN(flv)
AG_GST_CHECK_PLUGIN(freeze) AG_GST_CHECK_PLUGIN(freeze)
AG_GST_CHECK_PLUGIN(h264parse) AG_GST_CHECK_PLUGIN(h264parse)
AG_GST_CHECK_PLUGIN(librfb) AG_GST_CHECK_PLUGIN(librfb)
AG_GST_CHECK_PLUGIN(liveadder)
AG_GST_CHECK_PLUGIN(mpegdemux) AG_GST_CHECK_PLUGIN(mpegdemux)
AG_GST_CHECK_PLUGIN(mpegtsmux) AG_GST_CHECK_PLUGIN(mpegtsmux)
AG_GST_CHECK_PLUGIN(mpeg4videoparse) AG_GST_CHECK_PLUGIN(mpeg4videoparse)
@ -1412,6 +1413,7 @@ gst/aacparse/Makefile
gst/aiffparse/Makefile gst/aiffparse/Makefile
gst/amrparse/Makefile gst/amrparse/Makefile
gst/legacyresample/Makefile gst/legacyresample/Makefile
gst/liveadder/Makefile
gst/bayer/Makefile gst/bayer/Makefile
gst/camerabin/Makefile gst/camerabin/Makefile
gst/cdxaparse/Makefile gst/cdxaparse/Makefile

View file

@ -0,0 +1,34 @@
<plugin>
<name>liveadder</name>
<description>Adds multiple live discontinuous streams</description>
<filename>../../gst/liveadder/.libs/libgstliveadder.so</filename>
<basename>libgstliveadder.so</basename>
<version>0.10.10.1</version>
<license>LGPL</license>
<source>gst-plugins-bad</source>
<package>GStreamer Bad Plug-ins CVS/prerelease</package>
<origin>Unknown package origin</origin>
<elements>
<element>
<name>liveadder</name>
<longname>Live Adder element</longname>
<class>Generic/Audio</class>
<description>Mixes live/discontinuous audio streams</description>
<author>Olivier Crete &lt;olivier.crete@collabora.co.uk&gt;</author>
<pads>
<caps>
<name>sink%d</name>
<direction>sink</direction>
<presence>request</presence>
<details>audio/x-raw-int, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ], endianness=(int){ 1234, 4321 }, width=(int){ 8, 16, 24, 32 }, depth=(int)[ 1, 32 ], signed=(boolean){ true, false }; audio/x-raw-float, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ], endianness=(int){ 1234, 4321 }, width=(int){ 32, 64 }</details>
</caps>
<caps>
<name>src</name>
<direction>source</direction>
<presence>always</presence>
<details>audio/x-raw-int, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ], endianness=(int){ 1234, 4321 }, width=(int){ 8, 16, 24, 32 }, depth=(int)[ 1, 32 ], signed=(boolean){ true, false }; audio/x-raw-float, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ], endianness=(int){ 1234, 4321 }, width=(int){ 32, 64 }</details>
</caps>
</pads>
</element>
</elements>
</plugin>

View file

@ -43,8 +43,7 @@ GST_DEBUG_CATEGORY_STATIC (live_adder_debug);
/* elementfactory information */ /* elementfactory information */
static const GstElementDetails gst_live_adder_details = static const GstElementDetails gst_live_adder_details =
GST_ELEMENT_DETAILS ( GST_ELEMENT_DETAILS ("Live Adder element",
"Live Adder element",
"Generic/Audio", "Generic/Audio",
"Mixes live/discontinuous audio streams", "Mixes live/discontinuous audio streams",
"Olivier Crete <olivier.crete@collabora.co.uk>"); "Olivier Crete <olivier.crete@collabora.co.uk>");
@ -92,8 +91,7 @@ typedef struct _GstLiveAdderPadPrivate
GST_BOILERPLATE (GstLiveAdder, gst_live_adder, GstElement, GST_TYPE_ELEMENT); GST_BOILERPLATE (GstLiveAdder, gst_live_adder, GstElement, GST_TYPE_ELEMENT);
static void static void gst_live_adder_finalize (GObject * object);
gst_live_adder_finalize (GObject * object);
static void static void
gst_live_adder_set_property (GObject * object, gst_live_adder_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec); guint prop_id, const GValue * value, GParamSpec * pspec);
@ -101,33 +99,24 @@ static void
gst_live_adder_get_property (GObject * object, gst_live_adder_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec); guint prop_id, GValue * value, GParamSpec * pspec);
static GstPad * static GstPad *gst_live_adder_request_new_pad (GstElement * element,
gst_live_adder_request_new_pad (GstElement * element, GstPadTemplate * templ, GstPadTemplate * templ, const gchar * unused);
const gchar * unused); static void gst_live_adder_release_pad (GstElement * element, GstPad * pad);
static void
gst_live_adder_release_pad (GstElement * element, GstPad * pad);
static GstStateChangeReturn static GstStateChangeReturn
gst_live_adder_change_state (GstElement * element, GstStateChange transition); gst_live_adder_change_state (GstElement * element, GstStateChange transition);
static gboolean static gboolean gst_live_adder_setcaps (GstPad * pad, GstCaps * caps);
gst_live_adder_setcaps (GstPad * pad, GstCaps * caps); static GstCaps *gst_live_adder_sink_getcaps (GstPad * pad);
static GstCaps *
gst_live_adder_sink_getcaps (GstPad * pad);
static gboolean static gboolean
gst_live_adder_src_activate_push (GstPad * pad, gboolean active); gst_live_adder_src_activate_push (GstPad * pad, gboolean active);
static gboolean static gboolean gst_live_adder_src_event (GstPad * pad, GstEvent * event);
gst_live_adder_src_event (GstPad * pad, GstEvent * event);
static void static void gst_live_adder_loop (gpointer data);
gst_live_adder_loop (gpointer data); static gboolean gst_live_adder_query (GstPad * pad, GstQuery * query);
static gboolean static gboolean gst_live_adder_sink_event (GstPad * pad, GstEvent * event);
gst_live_adder_query (GstPad * pad, GstQuery * query);
static gboolean
gst_live_adder_sink_event (GstPad * pad, GstEvent * event);
static void static void reset_pad_private (GstPad * pad);
reset_pad_private (GstPad *pad);
/* clipping versions */ /* clipping versions */
#define MAKE_FUNC(name,type,ttype,min,max) \ #define MAKE_FUNC(name,type,ttype,min,max) \
@ -193,8 +182,7 @@ gst_live_adder_class_init (GstLiveAdderClass * klass)
"Amount of data to buffer", 0, G_MAXUINT, DEFAULT_LATENCY_MS, "Amount of data to buffer", 0, G_MAXUINT, DEFAULT_LATENCY_MS,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
GST_DEBUG_CATEGORY_INIT GST_DEBUG_CATEGORY_INIT (live_adder_debug, "liveadder", 0, "Live Adder");
(live_adder_debug, "liveadder", 0, "Live Adder");
} }
@ -240,7 +228,8 @@ gst_live_adder_finalize (GObject * object)
g_cond_free (adder->not_empty_cond); g_cond_free (adder->not_empty_cond);
g_queue_foreach (adder->buffers, (GFunc) gst_mini_object_unref, NULL); g_queue_foreach (adder->buffers, (GFunc) gst_mini_object_unref, NULL);
while (g_queue_pop_head (adder->buffers)) {} while (g_queue_pop_head (adder->buffers)) {
}
g_queue_free (adder->buffers); g_queue_free (adder->buffers);
g_list_free (adder->sinkpads); g_list_free (adder->sinkpads);
@ -384,11 +373,13 @@ gst_live_adder_setcaps (GstPad * pad, GstCaps * caps)
break; break;
case 16: case 16:
adder->func = (adder->is_signed ? adder->func = (adder->is_signed ?
(GstLiveAdderFunction) add_int16 : (GstLiveAdderFunction) add_uint16); (GstLiveAdderFunction) add_int16 : (GstLiveAdderFunction)
add_uint16);
break; break;
case 32: case 32:
adder->func = (adder->is_signed ? adder->func = (adder->is_signed ?
(GstLiveAdderFunction) add_int32 : (GstLiveAdderFunction) add_uint32); (GstLiveAdderFunction) add_int32 : (GstLiveAdderFunction)
add_uint32);
break; break;
default: default:
goto not_supported; goto not_supported;
@ -440,7 +431,7 @@ gst_live_adder_flush_start (GstLiveAdder * adder)
/* Empty the queue */ /* Empty the queue */
g_queue_foreach (adder->buffers, (GFunc) gst_mini_object_unref, NULL); g_queue_foreach (adder->buffers, (GFunc) gst_mini_object_unref, NULL);
while (g_queue_pop_head (adder->buffers)) {} while (g_queue_pop_head (adder->buffers));
/* unlock clock, we just unschedule, the entry will be released by the /* unlock clock, we just unschedule, the entry will be released by the
* locking streaming thread. */ * locking streaming thread. */
@ -740,7 +731,8 @@ gst_live_adder_query (GstPad * pad, GstQuery * query)
GST_DEBUG_OBJECT (adder, "Peer latency for pad %s: min %" GST_DEBUG_OBJECT (adder, "Peer latency for pad %s: min %"
GST_TIME_FORMAT " max %" GST_TIME_FORMAT, GST_TIME_FORMAT " max %" GST_TIME_FORMAT,
GST_PAD_NAME (sinkpad), GST_PAD_NAME (sinkpad),
GST_TIME_ARGS (pad_min_latency), GST_TIME_ARGS (pad_max_latency)); GST_TIME_ARGS (pad_min_latency),
GST_TIME_ARGS (pad_max_latency));
min_latency = MAX (pad_min_latency, min_latency); min_latency = MAX (pad_min_latency, min_latency);
max_latency = MIN (pad_max_latency, max_latency); max_latency = MIN (pad_max_latency, max_latency);
@ -882,7 +874,8 @@ gst_live_adder_src_event (GstPad * pad, GstEvent * event)
} }
static guint static guint
gst_live_adder_length_from_duration (GstLiveAdder *adder, GstClockTime duration) gst_live_adder_length_from_duration (GstLiveAdder * adder,
GstClockTime duration)
{ {
guint64 ret = (duration * adder->rate / GST_SECOND) * adder->bps; guint64 ret = (duration * adder->rate / GST_SECOND) * adder->bps;
@ -903,12 +896,11 @@ gst_live_live_adder_chain (GstPad *pad, GstBuffer *buffer)
ret = adder->srcresult; ret = adder->srcresult;
GST_DEBUG ("Incoming buffer time:%"GST_TIME_FORMAT" duration:%"GST_TIME_FORMAT, GST_DEBUG ("Incoming buffer time:%" GST_TIME_FORMAT " duration:%"
GST_TIME_ARGS(GST_BUFFER_TIMESTAMP(buffer)), GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)),
GST_TIME_ARGS (GST_BUFFER_DURATION (buffer))); GST_TIME_ARGS (GST_BUFFER_DURATION (buffer)));
if (ret != GST_FLOW_OK) if (ret != GST_FLOW_OK) {
{
GST_DEBUG_OBJECT (adder, "Passing non-ok result from src: %s", GST_DEBUG_OBJECT (adder, "Passing non-ok result from src: %s",
gst_flow_get_name (ret)); gst_flow_get_name (ret));
gst_buffer_unref (buffer); gst_buffer_unref (buffer);
@ -917,15 +909,13 @@ gst_live_live_adder_chain (GstPad *pad, GstBuffer *buffer)
padprivate = gst_pad_get_element_private (pad); padprivate = gst_pad_get_element_private (pad);
if (!padprivate) if (!padprivate) {
{
ret = GST_FLOW_NOT_LINKED; ret = GST_FLOW_NOT_LINKED;
gst_buffer_unref (buffer); gst_buffer_unref (buffer);
goto out; goto out;
} }
if (padprivate->eos) if (padprivate->eos) {
{
GST_DEBUG_OBJECT (adder, "Received buffer after EOS"); GST_DEBUG_OBJECT (adder, "Received buffer after EOS");
ret = GST_FLOW_UNEXPECTED; ret = GST_FLOW_UNEXPECTED;
gst_buffer_unref (buffer); gst_buffer_unref (buffer);
@ -935,8 +925,7 @@ gst_live_live_adder_chain (GstPad *pad, GstBuffer *buffer)
if (!GST_BUFFER_TIMESTAMP_IS_VALID (buffer)) if (!GST_BUFFER_TIMESTAMP_IS_VALID (buffer))
goto invalid_timestamp; goto invalid_timestamp;
if (padprivate->segment.format == GST_FORMAT_UNDEFINED) if (padprivate->segment.format == GST_FORMAT_UNDEFINED) {
{
GST_WARNING_OBJECT (adder, "No new-segment received," GST_WARNING_OBJECT (adder, "No new-segment received,"
" initializing segment with time 0..-1"); " initializing segment with time 0..-1");
gst_segment_init (&padprivate->segment, GST_FORMAT_TIME); gst_segment_init (&padprivate->segment, GST_FORMAT_TIME);
@ -957,10 +946,9 @@ gst_live_live_adder_chain (GstPad *pad, GstBuffer *buffer)
(drift != 0)) { (drift != 0)) {
GST_LOG_OBJECT (adder, GST_LOG_OBJECT (adder,
"Timestamp discontinuity without the DISCONT flag set" "Timestamp discontinuity without the DISCONT flag set"
" (expected %" GST_TIME_FORMAT ", got %" GST_TIME_FORMAT" drift:%ldms)", " (expected %" GST_TIME_FORMAT ", got %" GST_TIME_FORMAT
GST_TIME_ARGS (padprivate->expected_timestamp), " drift:%ldms)", GST_TIME_ARGS (padprivate->expected_timestamp),
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)), drift / GST_MSECOND);
drift / GST_MSECOND);
/* We accept drifts of 10ms */ /* We accept drifts of 10ms */
if (ABS (drift) < (10 * GST_MSECOND)) { if (ABS (drift) < (10 * GST_MSECOND)) {
@ -1000,9 +988,9 @@ gst_live_live_adder_chain (GstPad *pad, GstBuffer *buffer)
/* /*
* Make sure all incoming buffers share the same timestamping * Make sure all incoming buffers share the same timestamping
*/ */
GST_BUFFER_TIMESTAMP (buffer) = gst_segment_to_running_time ( GST_BUFFER_TIMESTAMP (buffer) =
&padprivate->segment, padprivate->segment.format, gst_segment_to_running_time (&padprivate->segment,
GST_BUFFER_TIMESTAMP (buffer)); padprivate->segment.format, GST_BUFFER_TIMESTAMP (buffer));
if (GST_CLOCK_TIME_IS_VALID (adder->next_timestamp) && if (GST_CLOCK_TIME_IS_VALID (adder->next_timestamp) &&
@ -1018,8 +1006,7 @@ gst_live_live_adder_chain (GstPad *pad, GstBuffer *buffer)
} else { } else {
skip = adder->next_timestamp - GST_BUFFER_TIMESTAMP (buffer); skip = adder->next_timestamp - GST_BUFFER_TIMESTAMP (buffer);
GST_DEBUG_OBJECT (adder, "Buffer is partially late, skipping %" GST_DEBUG_OBJECT (adder, "Buffer is partially late, skipping %"
GST_TIME_FORMAT, GST_TIME_FORMAT, GST_TIME_ARGS (skip));
GST_TIME_ARGS (skip));
} }
} }
@ -1033,8 +1020,7 @@ gst_live_live_adder_chain (GstPad *pad, GstBuffer *buffer)
gst_clock_id_unschedule (adder->clock_id); gst_clock_id_unschedule (adder->clock_id);
for (item = g_queue_peek_head_link (adder->buffers); for (item = g_queue_peek_head_link (adder->buffers);
item; item; item = g_list_next (item)) {
item = g_list_next (item)) {
GstBuffer *oldbuffer = item->data; GstBuffer *oldbuffer = item->data;
GstClockTime old_skip = 0; GstClockTime old_skip = 0;
GstClockTime mix_duration = 0; GstClockTime mix_duration = 0;
@ -1054,8 +1040,7 @@ gst_live_live_adder_chain (GstPad *pad, GstBuffer *buffer)
/* if we reach this spot, we have overlap, so we must mix */ /* if we reach this spot, we have overlap, so we must mix */
/* First make a subbuffer with the non-overlapping part */ /* First make a subbuffer with the non-overlapping part */
if (GST_BUFFER_TIMESTAMP (buffer) + skip < if (GST_BUFFER_TIMESTAMP (buffer) + skip < GST_BUFFER_TIMESTAMP (oldbuffer)) {
GST_BUFFER_TIMESTAMP (oldbuffer)) {
GstBuffer *subbuffer = NULL; GstBuffer *subbuffer = NULL;
GstClockTime subbuffer_duration = GST_BUFFER_TIMESTAMP (oldbuffer) - GstClockTime subbuffer_duration = GST_BUFFER_TIMESTAMP (oldbuffer) -
(GST_BUFFER_TIMESTAMP (buffer) + skip); (GST_BUFFER_TIMESTAMP (buffer) + skip);
@ -1166,10 +1151,7 @@ check_eos_locked (GstLiveAdder *adder)
if (adder->sinkpads == NULL) if (adder->sinkpads == NULL)
return FALSE; return FALSE;
for (item = adder->sinkpads; for (item = adder->sinkpads; item; item = g_list_next (item)) {
item;
item = g_list_next (item))
{
GstPad *pad = item->data; GstPad *pad = item->data;
GstLiveAdderPadPrivate *padprivate = gst_pad_get_element_private (pad); GstLiveAdderPadPrivate *padprivate = gst_pad_get_element_private (pad);
@ -1197,8 +1179,7 @@ gst_live_adder_loop (gpointer data)
again: again:
for (;;) for (;;) {
{
if (adder->srcresult != GST_FLOW_OK) if (adder->srcresult != GST_FLOW_OK)
goto flushing; goto flushing;
if (!g_queue_is_empty (adder->buffers)) if (!g_queue_is_empty (adder->buffers))
@ -1299,8 +1280,7 @@ gst_live_adder_loop (gpointer data)
else else
adder->next_timestamp = GST_CLOCK_TIME_NONE; adder->next_timestamp = GST_CLOCK_TIME_NONE;
if (adder->segment_pending) if (adder->segment_pending) {
{
/* /*
* We set the start at 0, because we re-timestamps to the running time * We set the start at 0, because we re-timestamps to the running time
*/ */
@ -1553,4 +1533,4 @@ GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR, GST_VERSION_MINOR,
"liveadder", "liveadder",
"Adds multiple live discontinuous streams", "Adds multiple live discontinuous streams",
plugin_init, VERSION, "LGPL", "Farsight", "http://farsight.sf.net") plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)

View file

@ -30,18 +30,17 @@
#include <gst/gst.h> #include <gst/gst.h>
G_BEGIN_DECLS G_BEGIN_DECLS
#define GST_TYPE_LIVE_ADDER (gst_live_adder_get_type()) #define GST_TYPE_LIVE_ADDER (gst_live_adder_get_type())
#define GST_LIVE_ADDER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_LIVE_ADDER,GstLiveAdder)) #define GST_LIVE_ADDER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_LIVE_ADDER,GstLiveAdder))
#define GST_IS_LIVE_ADDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_LIVE_ADDER)) #define GST_IS_LIVE_ADDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_LIVE_ADDER))
#define GST_LIVE_ADDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass) ,GST_TYPE_LIVE_ADDER,GstLiveAdderClass)) #define GST_LIVE_ADDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass) ,GST_TYPE_LIVE_ADDER,GstLiveAdderClass))
#define GST_IS_LIVE_ADDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_LIVE_ADDER)) #define GST_IS_LIVE_ADDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_LIVE_ADDER))
#define GST_LIVE_ADDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_LIVE_ADDER,GstLiveAdderClass)) #define GST_LIVE_ADDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_LIVE_ADDER,GstLiveAdderClass))
typedef struct _GstLiveAdder GstLiveAdder; typedef struct _GstLiveAdder GstLiveAdder;
typedef struct _GstLiveAdderClass GstLiveAdderClass; typedef struct _GstLiveAdderClass GstLiveAdderClass;
typedef enum { typedef enum
{
GST_LIVE_ADDER_FORMAT_UNSET, GST_LIVE_ADDER_FORMAT_UNSET,
GST_LIVE_ADDER_FORMAT_INT, GST_LIVE_ADDER_FORMAT_INT,
GST_LIVE_ADDER_FORMAT_FLOAT GST_LIVE_ADDER_FORMAT_FLOAT
@ -54,7 +53,8 @@ typedef void (*GstLiveAdderFunction) (gpointer out, gpointer in, guint size);
* *
* The adder object structure. * The adder object structure.
*/ */
struct _GstLiveAdder { struct _GstLiveAdder
{
GstElement element; GstElement element;
GstPad *srcpad; GstPad *srcpad;
@ -96,13 +96,12 @@ struct _GstLiveAdder {
gboolean playing; gboolean playing;
}; };
struct _GstLiveAdderClass { struct _GstLiveAdderClass
{
GstElementClass parent_class; GstElementClass parent_class;
}; };
GType gst_live_adder_get_type (void); GType gst_live_adder_get_type (void);
G_END_DECLS G_END_DECLS
#endif /* __GST_LIVE_ADDER_H__ */ #endif /* __GST_LIVE_ADDER_H__ */