diff options
author | Wim Taymans <wim.taymans@gmail.com> | 2004-12-20 17:54:16 +0000 |
---|---|---|
committer | Wim Taymans <wim.taymans@gmail.com> | 2004-12-20 17:54:16 +0000 |
commit | ecab2524ca570504923410a76316010f7e2029dd (patch) | |
tree | bd538590ee257b449dc5bbd2673805b630250412 | |
parent | fdbea2d6a7cc796f88c3f81dcf98b34c7e3d5173 (diff) | |
download | gstreamer-plugins-good-ecab2524ca570504923410a76316010f7e2029dd.tar.gz |
Various plugin updates to have something to play with.
Original commit message from CVS:
Various plugin updates to have something to play with.
-rw-r--r-- | ChangeLog | 84 | ||||
m--------- | common | 0 | ||||
-rw-r--r-- | examples/negotiation/Makefile.am | 7 | ||||
-rw-r--r-- | examples/negotiation/colorspace.c | 97 | ||||
-rw-r--r-- | examples/negotiation/queue.c | 147 | ||||
-rw-r--r-- | gst/effectv/gstaging.c | 6 | ||||
-rw-r--r-- | gst/effectv/gstdice.c | 6 | ||||
-rw-r--r-- | gst/effectv/gstquark.c | 36 | ||||
-rw-r--r-- | gst/effectv/gstrev.c | 6 | ||||
-rw-r--r-- | gst/effectv/gstvertigo.c | 6 | ||||
-rw-r--r-- | gst/effectv/gstwarp.c | 6 | ||||
-rw-r--r-- | gst/videofilter/gstgamma.c | 6 | ||||
-rw-r--r-- | gst/videofilter/gstvideobalance.c | 5 | ||||
-rw-r--r-- | gst/videofilter/gstvideofilter.c | 118 | ||||
-rw-r--r-- | gst/videofilter/gstvideoflip.c | 6 | ||||
-rw-r--r-- | sys/oss/gstosselement.c | 29 | ||||
-rw-r--r-- | sys/oss/gstossmixer.c | 8 | ||||
-rw-r--r-- | sys/oss/gstosssink.c | 162 | ||||
-rw-r--r-- | sys/oss/gstosssrc.c | 84 |
19 files changed, 573 insertions, 246 deletions
@@ -1,3 +1,87 @@ +2004-12-20 Wim Taymans <wim@fluendo.com> + + * configure.ac: + * examples/negotiation/Makefile.am: + * examples/negotiation/colorspace.c: (message_received), + (my_chain), (main): + * examples/negotiation/queue.c: (message_received), (block_done), + (do_block), (do_renegotiate), (main): + * ext/mad/gstid3tag.c: (gst_id3_tag_class_init), + (gst_id3_tag_init), (gst_id3_tag_sink_event), + (gst_id3_tag_do_caps_nego), (gst_id3_tag_src_link), + (gst_id3_tag_send_tag_event), (gst_id3_tag_chain), + (gst_id3_tag_change_state): + * ext/mad/gstmad.c: (gst_mad_init), (gst_mad_update_info), + (gst_mad_sink_event), (gst_mad_check_caps_reset), (gst_mad_chain): + * gst-libs/gst/Makefile.am: + * gst-libs/gst/audio/gstaudiofilter.c: (gst_audiofilter_link), + (gst_audiofilter_init), (gst_audiofilter_chain): + * gst-libs/gst/audio/testchannels.c: (main): + * gst-libs/gst/gconf/gconf.c: (gst_bin_find_unconnected_pad), + (gst_gconf_render_bin_from_description): + * gst-libs/gst/media-info/media-info-priv.c: (gmip_reset), + (gmip_find_type), (gmip_find_stream), (gmip_find_track_metadata), + (gmip_find_track_streaminfo), (gmip_find_track_format): + * gst-libs/gst/media-info/media-info.c: + (gst_media_info_read_idler): + * gst-libs/gst/riff/riff-read.c: (gst_riff_read_use_event), + (gst_riff_read_info): + * gst/ac3parse/gstac3parse.c: (gst_ac3parse_class_init), + (gst_ac3parse_init), (gst_ac3parse_chain): + * gst/effectv/gstaging.c: (gst_agingtv_class_init): + * gst/effectv/gstdice.c: (gst_dicetv_class_init): + * gst/effectv/gstquark.c: (gst_quarktv_class_init), + (gst_quarktv_link), (gst_quarktv_init), (gst_quarktv_chain): + * gst/effectv/gstrev.c: (gst_revtv_class_init): + * gst/effectv/gstvertigo.c: (gst_vertigotv_class_init): + * gst/effectv/gstwarp.c: (gst_warptv_class_init): + * gst/ffmpegcolorspace/gstffmpegcolorspace.c: + (gst_ffmpegcsp_getcaps), (gst_ffmpegcsp_configure_context), + (gst_ffmpegcsp_setcaps), (gst_ffmpegcsp_init), + (gst_ffmpegcsp_chain): + * gst/tags/gstvorbistag.c: (gst_vorbis_tag_chain): + * gst/typefind/gsttypefindfunctions.c: (aac_type_find), + (mp3_type_find), (mpeg2_sys_type_find), (mpeg1_sys_type_find), + (mpeg_video_type_find), (mpeg_video_stream_type_find), + (dv_type_find): + * gst/videofilter/gstgamma.c: (gst_gamma_class_init): + * gst/videofilter/gstvideobalance.c: (gst_videobalance_class_init): + * gst/videofilter/gstvideofilter.c: (gst_videofilter_getcaps), + (gst_videofilter_setcaps), (gst_videofilter_init), + (gst_videofilter_chain), (gst_videofilter_set_output_size): + * gst/videofilter/gstvideoflip.c: (gst_videoflip_class_init): + * gst/videotestsrc/gstvideotestsrc.c: + (gst_videotestsrc_class_init), (gst_videotestsrc_src_negotiate), + (gst_videotestsrc_src_link), (gst_videotestsrc_parse_caps), + (gst_videotestsrc_src_accept_caps), (gst_videotestsrc_setcaps), + (gst_videotestsrc_src_unlink), (gst_videotestsrc_activate), + (gst_videotestsrc_change_state), (gst_videotestsrc_getcaps), + (gst_videotestsrc_init), (gst_videotestsrc_src_query), + (gst_videotestsrc_handle_src_event), (gst_videotestsrc_loop): + * gst/videotestsrc/gstvideotestsrc.h: + * sys/oss/gstosselement.c: (gst_osselement_class_init), + (gst_osselement_parse_caps), (gst_osselement_open_audio), + (gst_osselement_close_audio), (gst_osselement_set_property): + * sys/oss/gstossmixer.c: (gst_ossmixer_build_list): + * sys/oss/gstosssink.c: (gst_osssink_class_init), + (gst_osssink_init), (gst_osssink_setcaps), (gst_osssink_getcaps), + (gst_osssink_handle_event), (gst_osssink_chain), + (gst_osssink_convert), (gst_osssink_sink_query), + (gst_osssink_change_state): + * sys/oss/gstosssrc.c: (gst_osssrc_class_init), (gst_osssrc_init), + (gst_osssrc_getcaps), (gst_osssrc_src_link), + (gst_osssrc_negotiate), (gst_osssrc_loop), (gst_osssrc_convert), + (gst_osssrc_src_event), (gst_osssrc_src_query): + * sys/xvimage/xvimagesink.c: (gst_xvimagesink_get_xv_support), + (gst_xvimagesink_xcontext_clear), (gst_xvimagesink_fixate), + (gst_xvimagesink_getcaps), (gst_xvimagesink_sink_link), + (gst_xvimagesink_parse_caps), (gst_xvimagesink_change_state), + (gst_xvimagesink_event), (gst_xvimagesink_chain), + (gst_xvimagesink_buffer_alloc), (gst_xvimagesink_init), + (gst_xvimagesink_class_init): + * sys/xvimage/xvimagesink.h: + Various plugin updates to have something to play with. + 2004-12-07 Christian Fredrik Kalager Schaller <set EMAIL_ADDRESS environment variable> Woooho Monoscope is now effectivly LGPL licensed diff --git a/common b/common -Subproject ded6dc5186cb7f8c64cb06a8591b9f787122c6f +Subproject b2638c100721f67b280c3b43b21f1ce1c9b5e31 diff --git a/examples/negotiation/Makefile.am b/examples/negotiation/Makefile.am new file mode 100644 index 000000000..ccd7e4b49 --- /dev/null +++ b/examples/negotiation/Makefile.am @@ -0,0 +1,7 @@ +examples = queue colorspace + +noinst_PROGRAMS = $(examples) + +# we have nothing but apps here, we can do this safely +LIBS = $(GST_LIBS) $(GTK_LIBS) $(GST_CONTROL_LIBS) +AM_CFLAGS = $(GST_CFLAGS) $(GTK_CFLAGS) diff --git a/examples/negotiation/colorspace.c b/examples/negotiation/colorspace.c new file mode 100644 index 000000000..b970a1c79 --- /dev/null +++ b/examples/negotiation/colorspace.c @@ -0,0 +1,97 @@ +/* + * colorspace.c + * + * demo application for negotiation of a simple plugin. + */ + +#include <string.h> +#include <gst/gst.h> + +static GstElement *pipeline; +static GstElement *space; + +static GstPad *src; +static GstPad *sink; +static GstPad *test; + +static gboolean caught_error = FALSE; +static GMainLoop *loop; + +static gboolean +message_received (GstBus * bus, GstMessage * message, gpointer data) +{ + switch (GST_MESSAGE_TYPE (message)) { + case GST_MESSAGE_EOS: + if (g_main_loop_is_running (loop)) + g_main_loop_quit (loop); + break; + case GST_MESSAGE_ERROR: + gst_object_default_error (GST_MESSAGE_SRC (message), + GST_MESSAGE_ERROR_GERROR (message), + GST_MESSAGE_ERROR_DEBUG (message)); + caught_error = TRUE; + if (g_main_loop_is_running (loop)) + g_main_loop_quit (loop); + break; + default: + break; + } + gst_message_unref (message); + + return TRUE; +} + +static GstFlowReturn +my_chain (GstPad * pad, GstBuffer * buffer) +{ + g_print ("got buffer\n"); + return GST_FLOW_OK; +} + +int +main (int argc, char *argv[]) +{ + GstBus *bus; + GstBuffer *buffer; + + gst_init (&argc, &argv); + + pipeline = gst_pipeline_new ("pipeline"); + bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); + loop = g_main_loop_new (NULL, FALSE); + gst_bus_add_watch (bus, message_received, pipeline); + + space = gst_element_factory_make ("ffmpegcolorspace", "space"); + + gst_bin_add (GST_BIN (pipeline), space); + + sink = gst_element_get_pad (space, "sink"); + src = gst_element_get_pad (space, "src"); + gst_element_set_state (pipeline, GST_STATE_PLAYING); + + test = gst_pad_new ("test", GST_PAD_SINK); + gst_pad_set_chain_function (test, my_chain); + + gst_pad_link (src, test); + gst_pad_set_active (test, TRUE); + + gst_pad_set_caps (sink, + gst_caps_new_simple ("video/x-raw-yuv", + "format", GST_TYPE_FOURCC, GST_STR_FOURCC ("YUY2"), + "width", G_TYPE_INT, 240, + "height", G_TYPE_INT, 120, "framerate", G_TYPE_DOUBLE, 30.0, NULL)); + + while (g_main_context_iteration (NULL, FALSE)); + + buffer = gst_buffer_new (); + + GST_REAL_PAD (sink)->chainfunc (sink, buffer); + + while (g_main_context_iteration (NULL, FALSE)); + + gst_element_set_state (pipeline, GST_STATE_NULL); + + gst_object_unref (GST_OBJECT (pipeline)); + + return 0; +} diff --git a/examples/negotiation/queue.c b/examples/negotiation/queue.c new file mode 100644 index 000000000..c7903d9e1 --- /dev/null +++ b/examples/negotiation/queue.c @@ -0,0 +1,147 @@ +/* + * queue.c + * + * demo application for negotiation over queues. + */ + +#include <string.h> +#include <gtk/gtk.h> +#include <gst/gst.h> + +static GstElement *pipeline; +static GstElement *src; +static GstElement *queue; +static GstElement *sink; + +static GstPad *pad1, *peer1; +static GstPad *pad2, *peer2; + +static gboolean caught_error = FALSE; +static GMainLoop *loop; + +static gboolean +message_received (GstBus * bus, GstMessage * message, gpointer data) +{ + switch (GST_MESSAGE_TYPE (message)) { + case GST_MESSAGE_EOS: + if (g_main_loop_is_running (loop)) + g_main_loop_quit (loop); + break; + case GST_MESSAGE_ERROR: + gst_object_default_error (GST_MESSAGE_SRC (message), + GST_MESSAGE_ERROR_GERROR (message), + GST_MESSAGE_ERROR_DEBUG (message)); + caught_error = TRUE; + if (g_main_loop_is_running (loop)) + g_main_loop_quit (loop); + break; + default: + break; + } + gst_message_unref (message); + + return TRUE; +} + +static void +block_done (GstPad * pad, gboolean blocked, gpointer data) +{ + if (blocked) { + g_print ("pad blocked\n"); + /* let's unlink to be cool too */ + gst_pad_unlink (pad2, peer2); + } else { + g_print ("pad unblocked\n"); + } +} + +static gboolean +do_block (GstPipeline * pipeline) +{ + static gint iter = 0; + + + if (iter++ % 2) { + g_print ("blocking pad.."); + if (!gst_pad_set_blocked_async (pad2, TRUE, block_done, NULL)) + g_print ("was blocked\n"); + } else { + /* and relink */ + gst_pad_link (pad2, peer2); + g_print ("unblocking pad.."); + if (!gst_pad_set_blocked_async (pad2, FALSE, block_done, NULL)) + g_print ("was unblocked\n"); + } + return TRUE; +} + +static gboolean +do_renegotiate (GstPipeline * pipeline) +{ + GstCaps *caps; + static gint iter = 0; + + g_print ("reneg\n"); + + if (iter++ % 2) { + caps = gst_caps_new_simple ("video/x-raw-yuv", + "format", GST_TYPE_FOURCC, GST_STR_FOURCC ("I420"), + "width", G_TYPE_INT, 320, + "height", G_TYPE_INT, 240, "framerate", G_TYPE_DOUBLE, 5.0, NULL); + } else { + caps = gst_caps_new_simple ("video/x-raw-yuv", + "format", GST_TYPE_FOURCC, GST_STR_FOURCC ("YUY2"), + "width", G_TYPE_INT, 240, + "height", G_TYPE_INT, 120, "framerate", G_TYPE_DOUBLE, 30.0, NULL); + } + + gst_pad_relink_filtered (pad1, peer1, caps); + gst_caps_unref (caps); + + return TRUE; +} + +int +main (int argc, char *argv[]) +{ + GstBus *bus; + + gtk_init (&argc, &argv); + gst_init (&argc, &argv); + + pipeline = gst_pipeline_new ("pipeline"); + bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); + loop = g_main_loop_new (NULL, FALSE); + gst_bus_add_watch (bus, message_received, pipeline); + + src = gst_element_factory_make ("videotestsrc", "src"); + queue = gst_element_factory_make ("queue", "queue"); + sink = gst_element_factory_make ("xvimagesink", "sink"); + + gst_bin_add (GST_BIN (pipeline), src); + gst_bin_add (GST_BIN (pipeline), queue); + gst_bin_add (GST_BIN (pipeline), sink); + + pad1 = gst_element_get_pad (src, "src"); + peer1 = gst_element_get_pad (queue, "sink"); + + pad2 = gst_element_get_pad (queue, "src"); + peer2 = gst_element_get_pad (sink, "sink"); + + gst_pad_link (pad1, peer1); + gst_pad_link (pad2, peer2); + + gst_element_set_state (pipeline, GST_STATE_PLAYING); + + g_timeout_add (1000, (GSourceFunc) do_block, pipeline); + + g_main_loop_run (loop); + + g_timeout_add (200, (GSourceFunc) do_renegotiate, pipeline); + + gst_element_set_state (pipeline, GST_STATE_NULL); + + gst_object_unref (GST_OBJECT (pipeline)); + + return 0; +} diff --git a/gst/effectv/gstaging.c b/gst/effectv/gstaging.c index e5ebed55d..886517ccd 100644 --- a/gst/effectv/gstaging.c +++ b/gst/effectv/gstaging.c @@ -172,15 +172,15 @@ gst_agingtv_class_init (gpointer g_class, gpointer class_data) gobject_class = G_OBJECT_CLASS (g_class); videofilter_class = GST_VIDEOFILTER_CLASS (g_class); + gobject_class->set_property = gst_agingtv_set_property; + gobject_class->get_property = gst_agingtv_get_property; + #if 0 g_object_class_install_property (gobject_class, ARG_METHOD, g_param_spec_enum ("method", "method", "method", GST_TYPE_AGINGTV_METHOD, GST_AGINGTV_METHOD_1, G_PARAM_READWRITE)); #endif - gobject_class->set_property = gst_agingtv_set_property; - gobject_class->get_property = gst_agingtv_get_property; - videofilter_class->setup = gst_agingtv_setup; } diff --git a/gst/effectv/gstdice.c b/gst/effectv/gstdice.c index 3a376eb4a..75c337728 100644 --- a/gst/effectv/gstdice.c +++ b/gst/effectv/gstdice.c @@ -173,13 +173,13 @@ gst_dicetv_class_init (gpointer g_class, gpointer class_data) dicetv_class->reset = gst_dicetv_reset_handler; + gobject_class->set_property = gst_dicetv_set_property; + gobject_class->get_property = gst_dicetv_get_property; + g_object_class_install_property (gobject_class, ARG_CUBE_BITS, g_param_spec_int ("square_bits", "Square Bits", "The size of the Squares", MIN_CUBE_BITS, MAX_CUBE_BITS, DEFAULT_CUBE_BITS, G_PARAM_READWRITE)); - gobject_class->set_property = gst_dicetv_set_property; - gobject_class->get_property = gst_dicetv_get_property; - videofilter_class->setup = gst_dicetv_setup; } diff --git a/gst/effectv/gstquark.c b/gst/effectv/gstquark.c index 23cfc6019..fa15e8adf 100644 --- a/gst/effectv/gstquark.c +++ b/gst/effectv/gstquark.c @@ -95,7 +95,7 @@ static void gst_quarktv_set_property (GObject * object, guint prop_id, static void gst_quarktv_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); -static void gst_quarktv_chain (GstPad * pad, GstData * _data); +static GstFlowReturn gst_quarktv_chain (GstPad * pad, GstBuffer * buffer); static GstElementClass *parent_class = NULL; @@ -158,30 +158,32 @@ gst_quarktv_class_init (GstQuarkTVClass * klass) parent_class = g_type_class_ref (GST_TYPE_ELEMENT); + gobject_class->set_property = gst_quarktv_set_property; + gobject_class->get_property = gst_quarktv_get_property; + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PLANES, g_param_spec_int ("planes", "Planes", "Number of frames in the buffer", 1, 32, PLANES, G_PARAM_READWRITE)); - gobject_class->set_property = gst_quarktv_set_property; - gobject_class->get_property = gst_quarktv_get_property; - gstelement_class->change_state = gst_quarktv_change_state; } static GstPadLinkReturn -gst_quarktv_link (GstPad * pad, const GstCaps * caps) +gst_quarktv_link (GstPad * pad, GstPad * peer) { GstQuarkTV *filter; GstPad *otherpad; - gint i; - GstStructure *structure; - GstPadLinkReturn res; + + //gint i; + //GstStructure *structure; + //GstPadLinkReturn res; filter = GST_QUARKTV (gst_pad_get_parent (pad)); g_return_val_if_fail (GST_IS_QUARKTV (filter), GST_PAD_LINK_REFUSED); otherpad = (pad == filter->srcpad ? filter->sinkpad : filter->srcpad); +#if 0 res = gst_pad_try_set_caps (otherpad, caps); if (GST_PAD_LINK_FAILED (res)) return res; @@ -198,6 +200,7 @@ gst_quarktv_link (GstPad * pad, const GstCaps * caps) gst_buffer_unref (filter->planetable[i]); filter->planetable[i] = NULL; } +#endif return GST_PAD_LINK_OK; } @@ -208,7 +211,7 @@ gst_quarktv_init (GstQuarkTV * filter) filter->sinkpad = gst_pad_new_from_template (gst_static_pad_template_get (&gst_effectv_sink_template), "sink"); - gst_pad_set_getcaps_function (filter->sinkpad, gst_pad_proxy_getcaps); + //gst_pad_set_getcaps_function (filter->sinkpad, gst_pad_proxy_getcaps); gst_pad_set_chain_function (filter->sinkpad, gst_quarktv_chain); gst_pad_set_link_function (filter->sinkpad, gst_quarktv_link); gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad); @@ -216,7 +219,7 @@ gst_quarktv_init (GstQuarkTV * filter) filter->srcpad = gst_pad_new_from_template (gst_static_pad_template_get (&gst_effectv_src_template), "src"); - gst_pad_set_getcaps_function (filter->srcpad, gst_pad_proxy_getcaps); + //gst_pad_set_getcaps_function (filter->srcpad, gst_pad_proxy_getcaps); gst_pad_set_link_function (filter->srcpad, gst_quarktv_link); gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad); @@ -227,10 +230,9 @@ gst_quarktv_init (GstQuarkTV * filter) memset (filter->planetable, 0, filter->planes * sizeof (GstBuffer *)); } -static void -gst_quarktv_chain (GstPad * pad, GstData * _data) +static GstFlowReturn +gst_quarktv_chain (GstPad * pad, GstBuffer * buf) { - GstBuffer *buf = GST_BUFFER (_data); GstQuarkTV *filter; guint32 *src, *dest; GstBuffer *outbuf; @@ -242,9 +244,7 @@ gst_quarktv_chain (GstPad * pad, GstData * _data) area = filter->area; - outbuf = gst_buffer_new (); - GST_BUFFER_SIZE (outbuf) = area * sizeof (guint32); - GST_BUFFER_DATA (outbuf) = g_malloc (GST_BUFFER_SIZE (outbuf)); + outbuf = gst_pad_alloc_buffer (filter->srcpad, 0, area, GST_PAD_CAPS (pad)); dest = (guint32 *) GST_BUFFER_DATA (outbuf); GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf); @@ -264,12 +264,14 @@ gst_quarktv_chain (GstPad * pad, GstData * _data) dest[area] = (rand ? ((guint32 *) GST_BUFFER_DATA (rand))[area] : 0); } - gst_pad_push (filter->srcpad, GST_DATA (outbuf)); + gst_pad_push (filter->srcpad, outbuf); filter->current_plane--; if (filter->current_plane < 0) filter->current_plane = filter->planes - 1; + + return GST_FLOW_OK; } static GstElementStateReturn diff --git a/gst/effectv/gstrev.c b/gst/effectv/gstrev.c index c385a058b..a7f5dd426 100644 --- a/gst/effectv/gstrev.c +++ b/gst/effectv/gstrev.c @@ -171,6 +171,9 @@ gst_revtv_class_init (gpointer klass, gpointer class_data) gobject_class = G_OBJECT_CLASS (klass); videofilter_class = GST_VIDEOFILTER_CLASS (klass); + gobject_class->set_property = gst_revtv_set_property; + gobject_class->get_property = gst_revtv_get_property; + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DELAY, g_param_spec_int ("delay", "Delay", "Delay in frames between updates", 1, 100, 1, G_PARAM_READWRITE)); @@ -181,9 +184,6 @@ gst_revtv_class_init (gpointer klass, gpointer class_data) g_param_spec_int ("gain", "Gain", "Control gain", 1, 200, 50, G_PARAM_READWRITE)); - gobject_class->set_property = gst_revtv_set_property; - gobject_class->get_property = gst_revtv_get_property; - videofilter_class->setup = gst_revtv_setup; } diff --git a/gst/effectv/gstvertigo.c b/gst/effectv/gstvertigo.c index e622eb572..cc3ed947a 100644 --- a/gst/effectv/gstvertigo.c +++ b/gst/effectv/gstvertigo.c @@ -169,6 +169,9 @@ gst_vertigotv_class_init (GstVertigoTVClass * klass, gpointer class_data) klass->reset = gst_vertigotv_reset_handler; + gobject_class->set_property = gst_vertigotv_set_property; + gobject_class->get_property = gst_vertigotv_get_property; + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SPEED, g_param_spec_float ("speed", "Speed", "Control the speed of movement", 0.01, 100.0, 0.02, G_PARAM_READWRITE)); @@ -176,9 +179,6 @@ gst_vertigotv_class_init (GstVertigoTVClass * klass, gpointer class_data) g_param_spec_float ("zoom_speed", "Zoom Speed", "Control the rate of zooming", 1.01, 1.1, 1.01, G_PARAM_READWRITE)); - gobject_class->set_property = gst_vertigotv_set_property; - gobject_class->get_property = gst_vertigotv_get_property; - videofilter_class->setup = gst_vertigotv_setup; } diff --git a/gst/effectv/gstwarp.c b/gst/effectv/gstwarp.c index e54e75205..00bd7d00c 100644 --- a/gst/effectv/gstwarp.c +++ b/gst/effectv/gstwarp.c @@ -173,15 +173,15 @@ gst_warptv_class_init (gpointer g_class, gpointer class_data) gobject_class = G_OBJECT_CLASS (g_class); videofilter_class = GST_VIDEOFILTER_CLASS (g_class); + gobject_class->set_property = gst_warptv_set_property; + gobject_class->get_property = gst_warptv_get_property; + #if 0 g_object_class_install_property (gobject_class, ARG_METHOD, g_param_spec_enum ("method", "method", "method", GST_TYPE_WARPTV_METHOD, GST_WARPTV_METHOD_1, G_PARAM_READWRITE)); #endif - gobject_class->set_property = gst_warptv_set_property; - gobject_class->get_property = gst_warptv_get_property; - videofilter_class->setup = gst_warptv_setup; } diff --git a/gst/videofilter/gstgamma.c b/gst/videofilter/gstgamma.c index 5a7edf2b2..025eeac62 100644 --- a/gst/videofilter/gstgamma.c +++ b/gst/videofilter/gstgamma.c @@ -164,6 +164,9 @@ gst_gamma_class_init (gpointer g_class, gpointer class_data) gobject_class = G_OBJECT_CLASS (g_class); videofilter_class = GST_VIDEOFILTER_CLASS (g_class); + gobject_class->set_property = gst_gamma_set_property; + gobject_class->get_property = gst_gamma_get_property; + g_object_class_install_property (gobject_class, ARG_GAMMA, g_param_spec_double ("gamma", "Gamma", "gamma", 0.01, 10, 1, G_PARAM_READWRITE)); @@ -177,9 +180,6 @@ gst_gamma_class_init (gpointer g_class, gpointer class_data) g_param_spec_double ("bluegamma", "Gamma_b", "gamma value for the blue channel", 0.01, 10, 1, G_PARAM_READWRITE)); - gobject_class->set_property = gst_gamma_set_property; - gobject_class->get_property = gst_gamma_get_property; - videofilter_class->setup = gst_gamma_setup; } diff --git a/gst/videofilter/gstvideobalance.c b/gst/videofilter/gstvideobalance.c index 338fb66d4..dbb61f5c6 100644 --- a/gst/videofilter/gstvideobalance.c +++ b/gst/videofilter/gstvideobalance.c @@ -198,6 +198,9 @@ gst_videobalance_class_init (gpointer g_class, gpointer class_data) parent_class = g_type_class_ref (GST_TYPE_VIDEOFILTER); + gobject_class->set_property = gst_videobalance_set_property; + gobject_class->get_property = gst_videobalance_get_property; + g_object_class_install_property (gobject_class, ARG_CONTRAST, g_param_spec_double ("contrast", "Contrast", "contrast", 0, 2, 1, G_PARAM_READWRITE)); @@ -210,8 +213,6 @@ gst_videobalance_class_init (gpointer g_class, gpointer class_data) g_param_spec_double ("saturation", "Saturation", "saturation", 0, 2, 1, G_PARAM_READWRITE)); - gobject_class->set_property = gst_videobalance_set_property; - gobject_class->get_property = gst_videobalance_get_property; gobject_class->dispose = gst_videobalance_dispose; videofilter_class->setup = gst_videobalance_setup; diff --git a/gst/videofilter/gstvideofilter.c b/gst/videofilter/gstvideofilter.c index 6ba77f5d2..ccc995c15 100644 --- a/gst/videofilter/gstvideofilter.c +++ b/gst/videofilter/gstvideofilter.c @@ -51,7 +51,7 @@ static void gst_videofilter_set_property (GObject * object, guint prop_id, static void gst_videofilter_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); -static void gst_videofilter_chain (GstPad * pad, GstData * _data); +static GstFlowReturn gst_videofilter_chain (GstPad * pad, GstBuffer * buffer); GstCaps *gst_videofilter_class_get_capslist (GstVideofilterClass * klass); static void gst_videofilter_setup (GstVideofilter * videofilter); @@ -172,70 +172,56 @@ gst_videofilter_getcaps (GstPad * pad) { GstVideofilter *videofilter; GstVideofilterClass *klass; - - //GstCaps *caps; - GstCaps *othercaps; - GstPad *otherpad; - - //int i; + GstCaps *caps; + GstPad *peer; + int i; GST_DEBUG ("gst_videofilter_getcaps"); - videofilter = GST_VIDEOFILTER (gst_pad_get_parent (pad)); + videofilter = GST_VIDEOFILTER (GST_PAD_PARENT (pad)); klass = GST_VIDEOFILTER_CLASS (G_OBJECT_GET_CLASS (videofilter)); - otherpad = (pad == videofilter->srcpad) ? videofilter->sinkpad : - videofilter->srcpad; - - othercaps = gst_pad_get_allowed_caps (otherpad); - - return othercaps; -#if 0 - /* FIXME videofilter doesn't allow passthru of video formats it - * doesn't understand. */ - /* Look through our list of caps and find those that match with - * the peer's formats. Create a list of them. */ - /* FIXME optimize if peercaps == NULL */ + /* we can handle anything that was registered */ caps = gst_caps_new_empty (); for (i = 0; i < klass->formats->len; i++) { - GstCaps *icaps; GstCaps *fromcaps; fromcaps = gst_caps_new_full (gst_videofilter_format_get_structure (g_ptr_array_index (klass->formats, i)), NULL); - icaps = gst_caps_intersect (fromcaps, peercaps); - if (icaps != NULL) { - gst_caps_append (caps, fromcaps); - } else { - gst_caps_free (fromcaps); + gst_caps_append (caps, fromcaps); + } + + peer = gst_pad_get_peer (pad); + if (peer) { + GstCaps *peercaps; + + peercaps = gst_pad_get_caps (peer); + if (peercaps) { + GstCaps *icaps; + + icaps = gst_caps_intersect (peercaps, caps); + gst_caps_unref (peercaps); + gst_caps_unref (caps); + caps = icaps; } - if (icaps) - gst_caps_free (icaps); + //gst_object_unref (peer); } - gst_caps_free (peercaps); return caps; -#endif } -static GstPadLinkReturn -gst_videofilter_link (GstPad * pad, const GstCaps * caps) +static gboolean +gst_videofilter_setcaps (GstPad * pad, GstCaps * caps) { GstVideofilter *videofilter; GstStructure *structure; - gboolean ret; int width, height; double framerate; - GstPadLinkReturn lret; - GstPad *otherpad; - - GST_DEBUG ("gst_videofilter_src_link"); - videofilter = GST_VIDEOFILTER (gst_pad_get_parent (pad)); + int ret; - otherpad = (pad == videofilter->srcpad) ? videofilter->sinkpad : - videofilter->srcpad; + videofilter = GST_VIDEOFILTER (GST_PAD_PARENT (pad)); structure = gst_caps_get_structure (caps, 0); @@ -248,11 +234,9 @@ gst_videofilter_link (GstPad * pad, const GstCaps * caps) ret &= gst_structure_get_double (structure, "framerate", &framerate); if (!ret) - return GST_PAD_LINK_REFUSED; + return FALSE; - lret = gst_pad_try_set_caps (otherpad, caps); - if (GST_PAD_LINK_FAILED (lret)) - return lret; + gst_pad_set_caps (videofilter->srcpad, caps); GST_DEBUG ("width %d height %d", width, height); @@ -273,7 +257,7 @@ gst_videofilter_link (GstPad * pad, const GstCaps * caps) gst_videofilter_setup (videofilter); - return GST_PAD_LINK_OK; + return TRUE; } static void @@ -290,7 +274,7 @@ gst_videofilter_init (GTypeInstance * instance, gpointer g_class) videofilter->sinkpad = gst_pad_new_from_template (pad_template, "sink"); gst_element_add_pad (GST_ELEMENT (videofilter), videofilter->sinkpad); gst_pad_set_chain_function (videofilter->sinkpad, gst_videofilter_chain); - gst_pad_set_link_function (videofilter->sinkpad, gst_videofilter_link); + gst_pad_set_setcaps_function (videofilter->sinkpad, gst_videofilter_setcaps); gst_pad_set_getcaps_function (videofilter->sinkpad, gst_videofilter_getcaps); pad_template = @@ -298,16 +282,14 @@ gst_videofilter_init (GTypeInstance * instance, gpointer g_class) g_return_if_fail (pad_template != NULL); videofilter->srcpad = gst_pad_new_from_template (pad_template, "src"); gst_element_add_pad (GST_ELEMENT (videofilter), videofilter->srcpad); - gst_pad_set_link_function (videofilter->srcpad, gst_videofilter_link); gst_pad_set_getcaps_function (videofilter->srcpad, gst_videofilter_getcaps); videofilter->inited = FALSE; } -static void -gst_videofilter_chain (GstPad * pad, GstData * _data) +static GstFlowReturn +gst_videofilter_chain (GstPad * pad, GstBuffer * buf) { - GstBuffer *buf = GST_BUFFER (_data); GstVideofilter *videofilter; guchar *data; gulong size; @@ -315,19 +297,21 @@ gst_videofilter_chain (GstPad * pad, GstData * _data) GST_DEBUG ("gst_videofilter_chain"); - g_return_if_fail (pad != NULL); - g_return_if_fail (GST_IS_PAD (pad)); - g_return_if_fail (buf != NULL); + g_return_val_if_fail (pad != NULL, GST_FLOW_ERROR); + g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_ERROR); + g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR); - videofilter = GST_VIDEOFILTER (gst_pad_get_parent (pad)); - //g_return_if_fail (videofilter->inited); + videofilter = GST_VIDEOFILTER (GST_PAD_PARENT (pad)); data = GST_BUFFER_DATA (buf); size = GST_BUFFER_SIZE (buf); if (videofilter->passthru) { - gst_pad_push (videofilter->srcpad, GST_DATA (buf)); - return; + return gst_pad_push (videofilter->srcpad, buf); + } + + if (GST_PAD_CAPS (pad) == NULL) { + return GST_FLOW_NOT_NEGOTIATED; } GST_DEBUG ("gst_videofilter_chain: got buffer of %ld bytes in '%s'", size, @@ -339,19 +323,19 @@ gst_videofilter_chain (GstPad * pad, GstData * _data) videofilter->to_width, videofilter->to_height, size, videofilter->from_buf_size, videofilter->to_buf_size); - g_return_if_fail (size >= videofilter->from_buf_size); if (size > videofilter->from_buf_size) { GST_INFO ("buffer size %ld larger than expected (%d)", size, videofilter->from_buf_size); + return GST_FLOW_ERROR; } outbuf = gst_pad_alloc_buffer (videofilter->srcpad, GST_BUFFER_OFFSET_NONE, - videofilter->to_buf_size); + videofilter->to_buf_size, GST_RPAD_CAPS (videofilter->srcpad)); GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf); GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf); - g_return_if_fail (videofilter->format); + g_return_val_if_fail (videofilter->format, GST_FLOW_ERROR); GST_DEBUG ("format %s", videofilter->format->fourcc); videofilter->in_buf = buf; @@ -363,9 +347,11 @@ gst_videofilter_chain (GstPad * pad, GstData * _data) GST_DEBUG ("gst_videofilter_chain: pushing buffer of %d bytes in '%s'", GST_BUFFER_SIZE (outbuf), GST_OBJECT_NAME (videofilter)); - gst_pad_push (videofilter->srcpad, GST_DATA (outbuf)); + gst_pad_push (videofilter->srcpad, outbuf); gst_buffer_unref (buf); + + return GST_FLOW_OK; } static void @@ -422,7 +408,6 @@ void gst_videofilter_set_output_size (GstVideofilter * videofilter, int width, int height) { - int ret; GstCaps *srccaps; GstStructure *structure; @@ -434,17 +419,14 @@ gst_videofilter_set_output_size (GstVideofilter * videofilter, videofilter->to_buf_size = (videofilter->to_width * videofilter->to_height * videofilter->format->bpp) / 8; - srccaps = gst_caps_copy (gst_pad_get_negotiated_caps (videofilter->srcpad)); + //srccaps = gst_caps_copy (gst_pad_get_negotiated_caps (videofilter->srcpad)); + srccaps = gst_caps_copy (GST_PAD_CAPS (videofilter->srcpad)); structure = gst_caps_get_structure (srccaps, 0); gst_structure_set (structure, "width", G_TYPE_INT, width, "height", G_TYPE_INT, height, NULL); - ret = gst_pad_try_set_caps (videofilter->srcpad, srccaps); - - if (ret < 0) { - g_critical ("could not set output size"); - } + gst_pad_set_caps (videofilter->srcpad, srccaps); } static void diff --git a/gst/videofilter/gstvideoflip.c b/gst/videofilter/gstvideoflip.c index 81f9d767e..b6685b2f3 100644 --- a/gst/videofilter/gstvideoflip.c +++ b/gst/videofilter/gstvideoflip.c @@ -147,14 +147,14 @@ gst_videoflip_class_init (gpointer g_class, gpointer class_data) gobject_class = G_OBJECT_CLASS (g_class); videofilter_class = GST_VIDEOFILTER_CLASS (g_class); + gobject_class->set_property = gst_videoflip_set_property; + gobject_class->get_property = gst_videoflip_get_property; + g_object_class_install_property (gobject_class, ARG_METHOD, g_param_spec_enum ("method", "method", "method", GST_TYPE_VIDEOFLIP_METHOD, GST_VIDEOFLIP_METHOD_90R, G_PARAM_READWRITE)); - gobject_class->set_property = gst_videoflip_set_property; - gobject_class->get_property = gst_videoflip_get_property; - videofilter_class->setup = gst_videoflip_setup; } diff --git a/sys/oss/gstosselement.c b/sys/oss/gstosselement.c index 839366b9a..9f8ca68de 100644 --- a/sys/oss/gstosselement.c +++ b/sys/oss/gstosselement.c @@ -151,6 +151,9 @@ gst_osselement_class_init (GstOssElementClass * klass) parent_class = g_type_class_ref (GST_TYPE_ELEMENT); + gobject_class->set_property = gst_osselement_set_property; + gobject_class->get_property = gst_osselement_get_property; + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DEVICE, g_param_spec_string ("device", "Device", "OSS device (/dev/dspN usually)", "default", G_PARAM_READWRITE)); @@ -162,8 +165,6 @@ gst_osselement_class_init (GstOssElementClass * klass) g_param_spec_string ("device_name", "Device name", "Name of the device", NULL, G_PARAM_READABLE)); - gobject_class->set_property = gst_osselement_set_property; - gobject_class->get_property = gst_osselement_get_property; gobject_class->finalize = gst_osselement_finalize; gstelement_class->change_state = gst_osselement_change_state; @@ -524,18 +525,19 @@ gst_osselement_parse_caps (GstOssElement * oss, const GstCaps * caps) { gint bps, format; GstStructure *structure; + gboolean res; structure = gst_caps_get_structure (caps, 0); - gst_structure_get_int (structure, "width", &oss->width); - gst_structure_get_int (structure, "depth", &oss->depth); + res = gst_structure_get_int (structure, "width", &oss->width); + res &= gst_structure_get_int (structure, "depth", &oss->depth); - if (oss->width != oss->depth) + if (!res || oss->width != oss->depth) return FALSE; - gst_structure_get_int (structure, "law", &oss->law); - gst_structure_get_int (structure, "endianness", &oss->endianness); - gst_structure_get_boolean (structure, "signed", &oss->sign); + res = gst_structure_get_int (structure, "law", &oss->law); + res &= gst_structure_get_int (structure, "endianness", &oss->endianness); + res &= gst_structure_get_boolean (structure, "signed", &oss->sign); if (!gst_ossformat_get (oss->law, oss->endianness, oss->sign, oss->width, oss->depth, &format, &bps)) { @@ -691,14 +693,17 @@ gst_osselement_open_audio (GstOssElement * oss) /* Ok, so how do we open the device? We assume that we have (max.) one * pad, and if this is a sinkpad, we're osssink (w). else, we're osssrc (r) */ - padlist = gst_element_get_pad_list (GST_ELEMENT (oss)); + GST_LOCK (oss); + padlist = GST_ELEMENT (oss)->pads; if (padlist != NULL) { GstPad *firstpad = padlist->data; if (GST_PAD_IS_SINK (firstpad)) { mode = GST_OSSELEMENT_WRITE; } + GST_UNLOCK (oss); } else { + GST_UNLOCK (oss); goto do_mixer; } @@ -832,7 +837,7 @@ gst_osselement_close_audio (GstOssElement * oss) { gst_ossmixer_free_list (oss); if (oss->probed_caps) { - gst_caps_free (oss->probed_caps); + gst_caps_unref (oss->probed_caps); oss->probed_caps = NULL; } @@ -912,7 +917,7 @@ gst_osselement_set_property (GObject * object, case ARG_DEVICE: /* disallow changing the device while it is opened get_property("device") should return the right one */ - if (gst_element_get_state (GST_ELEMENT (oss)) == GST_STATE_NULL) { + if (oss->fd == -1) { g_free (oss->device); oss->device = g_strdup (g_value_get_string (value)); @@ -938,7 +943,7 @@ gst_osselement_set_property (GObject * object, case ARG_MIXERDEV: /* disallow changing the device while it is opened get_property("mixerdev") should return the right one */ - if (gst_element_get_state (GST_ELEMENT (oss)) == GST_STATE_NULL) { + if (oss->fd == -1) { g_free (oss->mixer_dev); oss->mixer_dev = g_strdup (g_value_get_string (value)); } diff --git a/sys/oss/gstossmixer.c b/sys/oss/gstossmixer.c index b54268fbe..eabb62e0c 100644 --- a/sys/oss/gstossmixer.c +++ b/sys/oss/gstossmixer.c @@ -88,8 +88,7 @@ fill_labels (void) { gchar *given, *wanted; } - cases[] = - { + cases[] = { /* Note: this list is simply ripped from soundcard.h. For * some people, some values might be missing (3D surround, * etc.) - feel free to add them. That's the reason why @@ -434,7 +433,7 @@ void gst_ossmixer_build_list (GstOssElement * oss) { gint i, devmask, master = -1; - const GList *pads = gst_element_get_pad_list (GST_ELEMENT (oss)); + const GList *pads; GstPadDirection dir = GST_PAD_UNKNOWN; #ifdef SOUND_MIXER_INFO @@ -451,9 +450,12 @@ gst_ossmixer_build_list (GstOssElement * oss) return; } + GST_LOCK (oss); + pads = GST_ELEMENT (oss)->pads; /* get direction */ if (pads && g_list_length ((GList *) pads) == 1) dir = GST_PAD_DIRECTION (GST_PAD (pads->data)); + GST_UNLOCK (oss); /* get masks */ if (ioctl (oss->mixer_fd, SOUND_MIXER_READ_RECMASK, &oss->recmask) < 0 || diff --git a/sys/oss/gstosssink.c b/sys/oss/gstosssink.c index e9c7438c4..0432e9b13 100644 --- a/sys/oss/gstosssink.c +++ b/sys/oss/gstosssink.c @@ -71,17 +71,16 @@ static gboolean gst_osssink_query (GstElement * element, GstQueryType type, static gboolean gst_osssink_sink_query (GstPad * pad, GstQueryType type, GstFormat * format, gint64 * value); -static GstCaps *gst_osssink_sink_fixate (GstPad * pad, const GstCaps * caps); static GstCaps *gst_osssink_getcaps (GstPad * pad); -static GstPadLinkReturn gst_osssink_sinkconnect (GstPad * pad, - const GstCaps * caps); +static gboolean gst_osssink_setcaps (GstPad * pad, GstCaps * caps); static void gst_osssink_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_osssink_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); -static void gst_osssink_chain (GstPad * pad, GstData * _data); +static GstFlowReturn gst_osssink_chain (GstPad * pad, GstBuffer * buffer); +static gboolean gst_osssink_handle_event (GstPad * pad, GstEvent * event); /* OssSink signals and args */ enum @@ -109,7 +108,7 @@ static GstStaticPadTemplate osssink_sink_factory = "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " "signed = (boolean) { TRUE, FALSE }, " "width = (int) 16, " - "depth = (int) { 8, 16 }, " + "depth = (int) 16, " "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]; " "audio/x-raw-int, " "signed = (boolean) { TRUE, FALSE }, " @@ -180,6 +179,9 @@ gst_osssink_class_init (GstOssSinkClass * klass) parent_class = g_type_class_ref (GST_TYPE_OSSELEMENT); + gobject_class->set_property = gst_osssink_set_property; + gobject_class->get_property = gst_osssink_get_property; + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MUTE, g_param_spec_boolean ("mute", "Mute", "Mute the audio", FALSE, G_PARAM_READWRITE)); @@ -205,8 +207,6 @@ gst_osssink_class_init (GstOssSinkClass * klass) G_STRUCT_OFFSET (GstOssSinkClass, handoff), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - gobject_class->set_property = gst_osssink_set_property; - gobject_class->get_property = gst_osssink_get_property; gobject_class->dispose = gst_osssink_dispose; gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_osssink_change_state); @@ -223,15 +223,16 @@ gst_osssink_init (GstOssSink * osssink) gst_pad_new_from_template (gst_static_pad_template_get (&osssink_sink_factory), "sink"); gst_element_add_pad (GST_ELEMENT (osssink), osssink->sinkpad); - gst_pad_set_link_function (osssink->sinkpad, gst_osssink_sinkconnect); gst_pad_set_getcaps_function (osssink->sinkpad, gst_osssink_getcaps); - gst_pad_set_fixate_function (osssink->sinkpad, gst_osssink_sink_fixate); + gst_pad_set_setcaps_function (osssink->sinkpad, gst_osssink_setcaps); + //gst_pad_set_fixate_function (osssink->sinkpad, gst_osssink_sink_fixate); gst_pad_set_convert_function (osssink->sinkpad, gst_osssink_convert); gst_pad_set_query_function (osssink->sinkpad, gst_osssink_sink_query); gst_pad_set_query_type_function (osssink->sinkpad, gst_osssink_get_query_types); gst_pad_set_formats_function (osssink->sinkpad, gst_osssink_get_formats); + gst_pad_set_event_function (osssink->sinkpad, gst_osssink_handle_event); gst_pad_set_chain_function (osssink->sinkpad, gst_osssink_chain); GST_DEBUG ("initializing osssink"); @@ -244,44 +245,33 @@ gst_osssink_init (GstOssSink * osssink) gst_object_set_parent (GST_OBJECT (osssink->provided_clock), GST_OBJECT (osssink)); osssink->handled = 0; - - GST_FLAG_SET (osssink, GST_ELEMENT_THREAD_SUGGESTED); - GST_FLAG_SET (osssink, GST_ELEMENT_EVENT_AWARE); } -static GstCaps * -gst_osssink_sink_fixate (GstPad * pad, const GstCaps * caps) +static gboolean +gst_osssink_setcaps (GstPad * pad, GstCaps * caps) { - GstCaps *newcaps; - GstStructure *structure; - - newcaps = - gst_caps_new_full (gst_structure_copy (gst_caps_get_structure (caps, 0)), - NULL); - structure = gst_caps_get_structure (newcaps, 0); + GstOssSink *osssink = GST_OSSSINK (GST_PAD_PARENT (pad)); - if (gst_caps_structure_fixate_field_nearest_int (structure, "rate", 44100)) { - return newcaps; - } - if (gst_caps_structure_fixate_field_nearest_int (structure, "depth", 16)) { - return newcaps; - } - if (gst_caps_structure_fixate_field_nearest_int (structure, "width", 16)) { - return newcaps; + if (!gst_osselement_parse_caps (GST_OSSELEMENT (osssink), caps)) { + GST_ELEMENT_ERROR (osssink, CORE, NEGOTIATION, (NULL), + ("received unkown format")); + gst_element_abort_preroll (GST_ELEMENT (osssink)); + return FALSE; } - if (gst_caps_structure_fixate_field_nearest_int (structure, "channels", 2)) { - return newcaps; + if (!gst_osselement_sync_parms (GST_OSSELEMENT (osssink))) { + GST_ELEMENT_ERROR (osssink, CORE, NEGOTIATION, (NULL), + ("received unkown format")); + gst_element_abort_preroll (GST_ELEMENT (osssink)); + return FALSE; } - gst_caps_free (newcaps); - - return NULL; + return TRUE; } static GstCaps * gst_osssink_getcaps (GstPad * pad) { - GstOssSink *osssink = GST_OSSSINK (gst_pad_get_parent (pad)); + GstOssSink *osssink = GST_OSSSINK (GST_PAD_PARENT (pad)); GstCaps *caps; gst_osselement_probe_caps (GST_OSSELEMENT (osssink)); @@ -295,21 +285,6 @@ gst_osssink_getcaps (GstPad * pad) return caps; } -static GstPadLinkReturn -gst_osssink_sinkconnect (GstPad * pad, const GstCaps * caps) -{ - GstOssSink *osssink = GST_OSSSINK (gst_pad_get_parent (pad)); - - if (!gst_osselement_parse_caps (GST_OSSELEMENT (osssink), caps)) - return GST_PAD_LINK_REFUSED; - - if (!gst_osselement_sync_parms (GST_OSSELEMENT (osssink))) { - return GST_PAD_LINK_REFUSED; - } - - return GST_PAD_LINK_OK; -} - static inline gint gst_osssink_get_delay (GstOssSink * osssink) { @@ -389,48 +364,71 @@ gst_osssink_set_clock (GstElement * element, GstClock * clock) osssink->clock = clock; } -static void -gst_osssink_chain (GstPad * pad, GstData * _data) +static gboolean +gst_osssink_handle_event (GstPad * pad, GstEvent * event) +{ + GstOssSink *osssink; + gboolean result = TRUE; + + osssink = GST_OSSSINK (GST_PAD_PARENT (pad)); + + GST_STREAM_LOCK (pad); + switch (GST_EVENT_TYPE (event)) { + case GST_EVENT_EOS: + ioctl (GST_OSSELEMENT (osssink)->fd, SNDCTL_DSP_SYNC, 0); + gst_audio_clock_set_active (GST_AUDIO_CLOCK (osssink->provided_clock), + FALSE); + gst_element_finish_preroll (GST_ELEMENT (osssink), + GST_STREAM_GET_LOCK (pad)); + gst_pipeline_post_message (GST_ELEMENT_MANAGER (osssink), + gst_message_new_eos (GST_OBJECT (osssink))); + break; + default: + break; + } + GST_STREAM_UNLOCK (pad); + + return result; +} + +static GstFlowReturn +gst_osssink_chain (GstPad * pad, GstBuffer * buf) { - GstBuffer *buf = GST_BUFFER (_data); GstOssSink *osssink; GstClockTimeDiff buftime, soundtime, elementtime; guchar *data; guint to_write; gint delay; + GstFlowReturn result = GST_FLOW_OK; /* this has to be an audio buffer */ - osssink = GST_OSSSINK (gst_pad_get_parent (pad)); - - if (GST_IS_EVENT (buf)) { - GstEvent *event = GST_EVENT (buf); - - switch (GST_EVENT_TYPE (event)) { - case GST_EVENT_EOS: - ioctl (GST_OSSELEMENT (osssink)->fd, SNDCTL_DSP_SYNC, 0); - gst_audio_clock_set_active (GST_AUDIO_CLOCK (osssink->provided_clock), - FALSE); - gst_pad_event_default (pad, event); - return; - default: - gst_pad_event_default (pad, event); - return; - } - g_assert_not_reached (); - } + osssink = GST_OSSSINK (GST_PAD_PARENT (pad)); if (!GST_OSSELEMENT (osssink)->bps) { gst_buffer_unref (buf); GST_ELEMENT_ERROR (osssink, CORE, NEGOTIATION, (NULL), ("format wasn't negotiated before chain function")); - return; + return GST_FLOW_NOT_NEGOTIATED; + } + + GST_STREAM_LOCK (pad); + result = + gst_element_finish_preroll (GST_ELEMENT (osssink), + GST_STREAM_GET_LOCK (pad)); + if (result != GST_FLOW_OK) { + goto done; } data = GST_BUFFER_DATA (buf); to_write = GST_BUFFER_SIZE (buf); /* sync audio with buffers timestamp. elementtime is the *current* time. * soundtime is the time if the soundcard has processed all queued data. */ - elementtime = gst_element_get_time (GST_ELEMENT (osssink)); + if (GST_ELEMENT (osssink)->clock) { + elementtime = gst_clock_get_time (GST_ELEMENT (osssink)->clock) - + GST_ELEMENT (osssink)->base_time; + } else { + elementtime = 0; + } delay = gst_osssink_get_delay (osssink); if (delay < 0) delay = 0; @@ -504,7 +502,11 @@ gst_osssink_chain (GstPad * pad, GstData * _data) gst_audio_clock_update_time ((GstAudioClock *) osssink->provided_clock, gst_osssink_get_time (osssink->provided_clock, osssink)); +done: + GST_STREAM_UNLOCK (pad); gst_buffer_unref (buf); + + return result; } static const GstFormat * @@ -526,7 +528,7 @@ gst_osssink_convert (GstPad * pad, GstFormat src_format, gint64 src_value, { GstOssSink *osssink; - osssink = GST_OSSSINK (gst_pad_get_parent (pad)); + osssink = GST_OSSSINK (GST_PAD_PARENT (pad)); return gst_osselement_convert (GST_OSSELEMENT (osssink), src_format, src_value, dest_format, dest_value); @@ -551,7 +553,7 @@ gst_osssink_sink_query (GstPad * pad, GstQueryType type, GstFormat * format, gboolean res = TRUE; GstOssSink *osssink; - osssink = GST_OSSSINK (gst_pad_get_parent (pad)); + osssink = GST_OSSSINK (GST_PAD_PARENT (pad)); switch (type) { case GST_QUERY_LATENCY: @@ -655,11 +657,15 @@ static GstElementStateReturn gst_osssink_change_state (GstElement * element) { GstOssSink *osssink; + GstElementStateReturn result = GST_STATE_SUCCESS; osssink = GST_OSSSINK (element); switch (GST_STATE_TRANSITION (element)) { + case GST_STATE_NULL_TO_READY: + break; case GST_STATE_READY_TO_PAUSED: + result = GST_STATE_ASYNC; break; case GST_STATE_PAUSED_TO_PLAYING: gst_audio_clock_set_active (GST_AUDIO_CLOCK (osssink->provided_clock), @@ -677,12 +683,14 @@ gst_osssink_change_state (GstElement * element) gst_osselement_reset (GST_OSSELEMENT (osssink)); osssink->handled = 0; break; + case GST_STATE_READY_TO_NULL: + break; default: break; } if (GST_ELEMENT_CLASS (parent_class)->change_state) - return GST_ELEMENT_CLASS (parent_class)->change_state (element); + GST_ELEMENT_CLASS (parent_class)->change_state (element); - return GST_STATE_SUCCESS; + return result; } diff --git a/sys/oss/gstosssrc.c b/sys/oss/gstosssrc.c index 60edc3908..4e066e548 100644 --- a/sys/oss/gstosssrc.c +++ b/sys/oss/gstosssrc.c @@ -92,8 +92,7 @@ static void gst_osssrc_class_init (GstOssSrcClass * klass); static void gst_osssrc_init (GstOssSrc * osssrc); static void gst_osssrc_dispose (GObject * object); -static GstPadLinkReturn gst_osssrc_srcconnect (GstPad * pad, - const GstCaps * caps); +static GstPadLinkReturn gst_osssrc_src_link (GstPad * pad, GstPad * peer); static GstCaps *gst_osssrc_getcaps (GstPad * pad); static const GstFormat *gst_osssrc_get_formats (GstPad * pad); static gboolean gst_osssrc_convert (GstPad * pad, @@ -117,7 +116,7 @@ static const GstQueryType *gst_osssrc_get_query_types (GstPad * pad); static gboolean gst_osssrc_src_query (GstPad * pad, GstQueryType type, GstFormat * format, gint64 * value); -static GstData *gst_osssrc_get (GstPad * pad); +static gboolean gst_osssrc_loop (GstPad * pad); static GstElementClass *parent_class = NULL; @@ -168,6 +167,9 @@ gst_osssrc_class_init (GstOssSrcClass * klass) parent_class = g_type_class_ref (GST_TYPE_OSSELEMENT); + gobject_class->set_property = gst_osssrc_set_property; + gobject_class->get_property = gst_osssrc_get_property; + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFFERSIZE, g_param_spec_ulong ("buffersize", "Buffer Size", "The size of the buffers with samples", 0, G_MAXULONG, 0, @@ -177,8 +179,6 @@ gst_osssrc_class_init (GstOssSrcClass * klass) "The fragment as 0xMMMMSSSS (MMMM = total fragments, 2^SSSS = fragment size)", 0, G_MAXINT, 6, G_PARAM_READWRITE)); - gobject_class->set_property = gst_osssrc_set_property; - gobject_class->get_property = gst_osssrc_get_property; gobject_class->dispose = gst_osssrc_dispose; gstelement_class->change_state = gst_osssrc_change_state; @@ -194,9 +194,9 @@ gst_osssrc_init (GstOssSrc * osssrc) osssrc->srcpad = gst_pad_new_from_template (gst_static_pad_template_get (&osssrc_src_factory), "src"); - gst_pad_set_get_function (osssrc->srcpad, gst_osssrc_get); + gst_pad_set_loop_function (osssrc->srcpad, gst_osssrc_loop); gst_pad_set_getcaps_function (osssrc->srcpad, gst_osssrc_getcaps); - gst_pad_set_link_function (osssrc->srcpad, gst_osssrc_srcconnect); + gst_pad_set_link_function (osssrc->srcpad, gst_osssrc_src_link); gst_pad_set_convert_function (osssrc->srcpad, gst_osssrc_convert); gst_pad_set_formats_function (osssrc->srcpad, gst_osssrc_get_formats); gst_pad_set_event_function (osssrc->srcpad, gst_osssrc_src_event); @@ -236,7 +236,7 @@ gst_osssrc_getcaps (GstPad * pad) GstOssSrc *src; GstCaps *caps; - src = GST_OSSSRC (gst_pad_get_parent (pad)); + src = GST_OSSSRC (GST_PAD_PARENT (pad)); gst_osselement_probe_caps (GST_OSSELEMENT (src)); @@ -250,19 +250,9 @@ gst_osssrc_getcaps (GstPad * pad) } static GstPadLinkReturn -gst_osssrc_srcconnect (GstPad * pad, const GstCaps * caps) +gst_osssrc_src_link (GstPad * pad, GstPad * peer) { - GstOssSrc *src; - - src = GST_OSSSRC (gst_pad_get_parent (pad)); - - if (!gst_osselement_parse_caps (GST_OSSELEMENT (src), caps)) - return GST_PAD_LINK_REFUSED; - - if (!gst_osselement_sync_parms (GST_OSSELEMENT (src))) - return GST_PAD_LINK_REFUSED; - - return GST_PAD_LINK_OK; + return GST_RPAD_LINKFUNC (peer) (peer, pad); } static gboolean @@ -271,9 +261,10 @@ gst_osssrc_negotiate (GstPad * pad) GstOssSrc *src; GstCaps *allowed; - src = GST_OSSSRC (gst_pad_get_parent (pad)); + src = GST_OSSSRC (GST_PAD_PARENT (pad)); - allowed = gst_pad_get_allowed_caps (pad); + //allowed = gst_pad_get_allowed_caps (pad); + allowed = NULL; if (!gst_osselement_merge_fixed_caps (GST_OSSELEMENT (src), allowed)) return FALSE; @@ -282,17 +273,15 @@ gst_osssrc_negotiate (GstPad * pad) return FALSE; /* set caps on src pad */ - if (gst_pad_try_set_caps (src->srcpad, - gst_caps_new_simple ("audio/x-raw-int", - "endianness", G_TYPE_INT, GST_OSSELEMENT (src)->endianness, - "signed", G_TYPE_BOOLEAN, GST_OSSELEMENT (src)->sign, - "width", G_TYPE_INT, GST_OSSELEMENT (src)->width, - "depth", G_TYPE_INT, GST_OSSELEMENT (src)->depth, - "rate", G_TYPE_INT, GST_OSSELEMENT (src)->rate, - "channels", G_TYPE_INT, GST_OSSELEMENT (src)->channels, - NULL)) <= 0) { - return FALSE; - } + GST_PAD_CAPS (src->srcpad) = + gst_caps_new_simple ("audio/x-raw-int", + "endianness", G_TYPE_INT, GST_OSSELEMENT (src)->endianness, + "signed", G_TYPE_BOOLEAN, GST_OSSELEMENT (src)->sign, + "width", G_TYPE_INT, GST_OSSELEMENT (src)->width, + "depth", G_TYPE_INT, GST_OSSELEMENT (src)->depth, + "rate", G_TYPE_INT, GST_OSSELEMENT (src)->rate, + "channels", G_TYPE_INT, GST_OSSELEMENT (src)->channels, NULL); + return TRUE; } @@ -332,21 +321,22 @@ gst_osssrc_set_clock (GstElement * element, GstClock * clock) osssrc->clock = clock; } -static GstData * -gst_osssrc_get (GstPad * pad) +static gboolean +gst_osssrc_loop (GstPad * pad) { GstOssSrc *src; GstBuffer *buf; glong readbytes; glong readsamples; - src = GST_OSSSRC (gst_pad_get_parent (pad)); + src = GST_OSSSRC (GST_PAD_PARENT (pad)); GST_DEBUG ("attempting to read something from the soundcard"); if (src->need_eos) { src->need_eos = FALSE; - return GST_DATA (gst_event_new (GST_EVENT_EOS)); + gst_pad_push_event (pad, gst_event_new (GST_EVENT_EOS)); + return FALSE; } buf = gst_buffer_new_and_alloc (src->buffersize); @@ -356,14 +346,14 @@ gst_osssrc_get (GstPad * pad) if (!gst_osssrc_negotiate (pad)) { gst_buffer_unref (buf); GST_ELEMENT_ERROR (src, CORE, NEGOTIATION, (NULL), (NULL)); - return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT)); + return FALSE; } } if (GST_OSSELEMENT (src)->bps == 0) { gst_buffer_unref (buf); GST_ELEMENT_ERROR (src, CORE, NEGOTIATION, (NULL), ("format wasn't negotiated before chain function")); - return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT)); + return FALSE; } readbytes = read (GST_OSSELEMENT (src)->fd, GST_BUFFER_DATA (buf), @@ -371,13 +361,13 @@ gst_osssrc_get (GstPad * pad) if (readbytes < 0) { gst_buffer_unref (buf); GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), GST_ERROR_SYSTEM); - return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT)); + return FALSE; } if (readbytes == 0) { gst_buffer_unref (buf); - gst_element_set_eos (GST_ELEMENT (src)); - return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT)); + //gst_element_set_eos (GST_ELEMENT (src)); + return FALSE; } readsamples = readbytes * GST_OSSELEMENT (src)->rate / @@ -412,7 +402,9 @@ gst_osssrc_get (GstPad * pad) GST_DEBUG ("pushed buffer from soundcard of %ld bytes, timestamp %" G_GINT64_FORMAT, readbytes, GST_BUFFER_TIMESTAMP (buf)); - return GST_DATA (buf); + gst_pad_push (pad, buf); + + return TRUE; } static void @@ -509,7 +501,7 @@ gst_osssrc_convert (GstPad * pad, GstFormat src_format, gint64 src_value, { GstOssSrc *osssrc; - osssrc = GST_OSSSRC (gst_pad_get_parent (pad)); + osssrc = GST_OSSSRC (GST_PAD_PARENT (pad)); return gst_osselement_convert (GST_OSSELEMENT (osssrc), src_format, src_value, dest_format, dest_value); @@ -533,7 +525,7 @@ gst_osssrc_src_event (GstPad * pad, GstEvent * event) GstOssSrc *osssrc; gboolean retval = FALSE; - osssrc = GST_OSSSRC (gst_pad_get_parent (pad)); + osssrc = GST_OSSSRC (GST_PAD_PARENT (pad)); switch (GST_EVENT_TYPE (event)) { case GST_EVENT_EOS: @@ -589,7 +581,7 @@ gst_osssrc_src_query (GstPad * pad, GstQueryType type, GstFormat * format, gboolean res = FALSE; GstOssSrc *osssrc; - osssrc = GST_OSSSRC (gst_pad_get_parent (pad)); + osssrc = GST_OSSSRC (GST_PAD_PARENT (pad)); switch (type) { case GST_QUERY_POSITION: |