2002-07-26 22:18:57 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2004-07-27 21:51:32 +00:00
|
|
|
#include "gstvideotestsrc.h"
|
|
|
|
#include "videotestsrc.h"
|
2002-07-26 22:18:57 +00:00
|
|
|
|
2002-07-28 13:40:53 +00:00
|
|
|
#include <string.h>
|
2002-07-26 22:18:57 +00:00
|
|
|
#include <stdlib.h>
|
Convert a few inner loops to use liboil. This is currently optional, and is only enabled if liboil is present (duh!).
Original commit message from CVS:
Convert a few inner loops to use liboil. This is currently
optional, and is only enabled if liboil is present (duh!).
* configure.ac: Check for liboil-0.1
* gst/intfloat/Makefile.am:
* gst/intfloat/gstint2float.c: (conv_f32_s16), (scalarmult_f32),
(gst_int2float_chain_gint16):
* gst/videofilter/Makefile.am:
* gst/videofilter/gstvideobalance.c: (gst_videobalance_class_init),
(tablelookup_u8), (gst_videobalance_planar411):
* gst/videotestsrc/Makefile.am:
* gst/videotestsrc/gstvideotestsrc.c: (plugin_init):
* gst/videotestsrc/videotestsrc.c: (splat_u8), (paint_hline_YUY2),
(paint_hline_IYU2), (paint_hline_str4), (paint_hline_str3),
(paint_hline_RGB565), (paint_hline_xRGB1555):
2004-02-12 07:37:50 +00:00
|
|
|
#include <liboil/liboil.h>
|
2002-07-26 22:18:57 +00:00
|
|
|
|
2004-07-22 15:55:33 +00:00
|
|
|
GST_DEBUG_CATEGORY (videotestsrc_debug);
|
|
|
|
#define GST_CAT_DEFAULT videotestsrc_debug
|
2002-07-26 22:18:57 +00:00
|
|
|
|
|
|
|
/* elementfactory information */
|
2004-03-14 22:34:34 +00:00
|
|
|
static GstElementDetails videotestsrc_details =
|
|
|
|
GST_ELEMENT_DETAILS ("Video test source",
|
|
|
|
"Source/Video",
|
|
|
|
"Creates a test video stream",
|
|
|
|
"David A. Schleef <ds@schleef.org>");
|
2002-07-26 22:18:57 +00:00
|
|
|
|
|
|
|
/* GstVideotestsrc signals and args */
|
2002-10-04 06:49:51 +00:00
|
|
|
enum
|
|
|
|
{
|
2002-07-26 22:18:57 +00:00
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2002-10-04 06:49:51 +00:00
|
|
|
enum
|
|
|
|
{
|
2002-07-26 22:18:57 +00:00
|
|
|
ARG_0,
|
2003-04-23 07:38:32 +00:00
|
|
|
ARG_TYPE,
|
2003-05-18 23:20:24 +00:00
|
|
|
ARG_SYNC,
|
2004-05-21 22:39:30 +00:00
|
|
|
ARG_NUM_BUFFERS
|
|
|
|
/* FILL ME */
|
2002-07-26 22:18:57 +00:00
|
|
|
};
|
|
|
|
|
2004-08-04 11:08:13 +00:00
|
|
|
static GstCaps *capslist = NULL;
|
|
|
|
|
2003-11-02 20:48:33 +00:00
|
|
|
static void gst_videotestsrc_base_init (gpointer g_class);
|
2002-10-04 06:49:51 +00:00
|
|
|
static void gst_videotestsrc_class_init (GstVideotestsrcClass * klass);
|
|
|
|
static void gst_videotestsrc_init (GstVideotestsrc * videotestsrc);
|
2004-03-14 22:34:34 +00:00
|
|
|
static GstElementStateReturn gst_videotestsrc_change_state (GstElement *
|
|
|
|
element);
|
|
|
|
static void gst_videotestsrc_set_clock (GstElement * element, GstClock * clock);
|
2002-07-26 22:18:57 +00:00
|
|
|
|
2004-07-22 15:55:33 +00:00
|
|
|
static void gst_videotestsrc_set_pattern (GstVideotestsrc * videotestsrc,
|
2004-03-14 22:34:34 +00:00
|
|
|
int pattern_type);
|
2002-10-04 06:49:51 +00:00
|
|
|
static void gst_videotestsrc_set_property (GObject * object, guint prop_id,
|
2004-03-14 22:34:34 +00:00
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_videotestsrc_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
2002-07-26 22:18:57 +00:00
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
static void gst_videotestsrc_loop (GstPad * pad);
|
2002-07-26 22:18:57 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
static const GstQueryType *gst_videotestsrc_get_query_types (GstPad * pad);
|
2005-05-09 10:56:13 +00:00
|
|
|
static gboolean gst_videotestsrc_src_query (GstPad * pad, GstQuery * query);
|
|
|
|
|
|
|
|
#if 0
|
2004-06-18 22:32:44 +00:00
|
|
|
static const GstEventMask *gst_videotestsrc_get_event_masks (GstPad * pad);
|
2005-05-09 10:56:13 +00:00
|
|
|
#endif
|
2004-06-18 22:32:44 +00:00
|
|
|
static gboolean gst_videotestsrc_handle_src_event (GstPad * pad,
|
|
|
|
GstEvent * event);
|
2003-12-14 21:25:32 +00:00
|
|
|
|
2002-07-26 22:18:57 +00:00
|
|
|
static GstElementClass *parent_class = NULL;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
static GstCaps *gst_videotestsrc_get_capslist (void);
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
#if 0
|
2004-03-14 22:34:34 +00:00
|
|
|
static GstCaps *gst_videotestsrc_get_capslist_size (int width, int height,
|
|
|
|
double rate);
|
2003-12-22 01:47:09 +00:00
|
|
|
#endif
|
2003-04-16 07:52:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
static GstPadTemplate *
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videotestsrc_src_template_factory (void)
|
2003-04-16 07:52:54 +00:00
|
|
|
{
|
2003-12-22 01:47:09 +00:00
|
|
|
return gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videotestsrc_get_capslist ());
|
2003-04-16 07:52:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GType
|
2002-07-26 22:18:57 +00:00
|
|
|
gst_videotestsrc_get_type (void)
|
|
|
|
{
|
|
|
|
static GType videotestsrc_type = 0;
|
|
|
|
|
|
|
|
if (!videotestsrc_type) {
|
|
|
|
static const GTypeInfo videotestsrc_info = {
|
2003-11-02 20:48:33 +00:00
|
|
|
sizeof (GstVideotestsrcClass),
|
|
|
|
gst_videotestsrc_base_init,
|
2002-07-26 22:18:57 +00:00
|
|
|
NULL,
|
2002-10-04 06:49:51 +00:00
|
|
|
(GClassInitFunc) gst_videotestsrc_class_init,
|
2002-07-26 22:18:57 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2002-10-04 06:49:51 +00:00
|
|
|
sizeof (GstVideotestsrc),
|
2002-07-26 22:18:57 +00:00
|
|
|
0,
|
2002-10-04 06:49:51 +00:00
|
|
|
(GInstanceInitFunc) gst_videotestsrc_init,
|
2002-07-26 22:18:57 +00:00
|
|
|
};
|
2002-10-04 06:49:51 +00:00
|
|
|
|
|
|
|
videotestsrc_type =
|
2004-03-15 19:32:28 +00:00
|
|
|
g_type_register_static (GST_TYPE_ELEMENT, "GstVideotestsrc",
|
|
|
|
&videotestsrc_info, 0);
|
2002-07-26 22:18:57 +00:00
|
|
|
}
|
|
|
|
return videotestsrc_type;
|
|
|
|
}
|
|
|
|
|
2003-04-23 07:38:32 +00:00
|
|
|
#define GST_TYPE_VIDEOTESTSRC_PATTERN (gst_videotestsrc_pattern_get_type ())
|
|
|
|
static GType
|
|
|
|
gst_videotestsrc_pattern_get_type (void)
|
|
|
|
{
|
|
|
|
static GType videotestsrc_pattern_type = 0;
|
|
|
|
static GEnumValue pattern_types[] = {
|
2004-03-14 22:34:34 +00:00
|
|
|
{GST_VIDEOTESTSRC_SMPTE, "smpte", "SMPTE 100% color bars"},
|
|
|
|
{GST_VIDEOTESTSRC_SNOW, "snow", "Random (television snow)"},
|
2004-08-02 15:35:13 +00:00
|
|
|
{GST_VIDEOTESTSRC_BLACK, "black", "100% Black"},
|
2004-03-14 22:34:34 +00:00
|
|
|
{0, NULL, NULL},
|
2003-04-23 07:38:32 +00:00
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!videotestsrc_pattern_type) {
|
|
|
|
videotestsrc_pattern_type =
|
2004-03-15 19:32:28 +00:00
|
|
|
g_enum_register_static ("GstVideotestsrcPattern", pattern_types);
|
2003-04-23 07:38:32 +00:00
|
|
|
}
|
|
|
|
return videotestsrc_pattern_type;
|
|
|
|
}
|
|
|
|
|
2003-11-02 20:48:33 +00:00
|
|
|
static void
|
|
|
|
gst_videotestsrc_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
|
|
|
|
|
|
gst_element_class_set_details (element_class, &videotestsrc_details);
|
|
|
|
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videotestsrc_src_template_factory ());
|
2003-11-02 20:48:33 +00:00
|
|
|
}
|
2002-07-26 22:18:57 +00:00
|
|
|
static void
|
2002-10-04 06:49:51 +00:00
|
|
|
gst_videotestsrc_class_init (GstVideotestsrcClass * klass)
|
2002-07-26 22:18:57 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
2002-10-04 06:49:51 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2002-07-26 22:18:57 +00:00
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
gobject_class->set_property = gst_videotestsrc_set_property;
|
|
|
|
gobject_class->get_property = gst_videotestsrc_get_property;
|
|
|
|
|
2003-04-23 07:38:32 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TYPE,
|
2004-03-14 22:34:34 +00:00
|
|
|
g_param_spec_enum ("pattern", "Pattern",
|
2004-03-15 19:32:28 +00:00
|
|
|
"Type of test pattern to generate", GST_TYPE_VIDEOTESTSRC_PATTERN, 1,
|
|
|
|
G_PARAM_READWRITE));
|
2003-05-18 23:20:24 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC,
|
2004-03-14 22:34:34 +00:00
|
|
|
g_param_spec_boolean ("sync", "Sync", "Synchronize to clock", TRUE,
|
2004-03-15 19:32:28 +00:00
|
|
|
G_PARAM_READWRITE));
|
2004-04-27 09:42:45 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_BUFFERS,
|
|
|
|
g_param_spec_int ("num-buffers", "num-buffers",
|
|
|
|
"Number of buffers to output before sending EOS", -1, G_MAXINT,
|
|
|
|
0, G_PARAM_READWRITE));
|
2002-07-26 22:18:57 +00:00
|
|
|
|
2002-10-04 06:49:51 +00:00
|
|
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
2002-07-26 22:18:57 +00:00
|
|
|
|
2002-07-30 07:38:01 +00:00
|
|
|
gstelement_class->change_state = gst_videotestsrc_change_state;
|
2004-03-14 22:34:34 +00:00
|
|
|
gstelement_class->set_clock = gst_videotestsrc_set_clock;
|
2004-07-22 15:55:33 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (videotestsrc_debug, "videotestsrc", 0,
|
|
|
|
"Video Test Source");
|
2003-05-01 06:24:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videotestsrc_set_clock (GstElement * element, GstClock * clock)
|
2003-05-01 06:24:34 +00:00
|
|
|
{
|
|
|
|
GstVideotestsrc *v;
|
|
|
|
|
|
|
|
v = GST_VIDEOTESTSRC (element);
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_object_replace ((GstObject **) & v->clock, (GstObject *) clock);
|
2002-07-26 22:18:57 +00:00
|
|
|
}
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
static GstCaps *
|
2005-03-31 09:43:49 +00:00
|
|
|
gst_videotestsrc_src_negotiate (GstPad * pad)
|
2003-12-22 01:47:09 +00:00
|
|
|
{
|
2005-03-31 09:43:49 +00:00
|
|
|
GstCaps *caps;
|
|
|
|
GstCaps *temp;
|
2003-12-22 01:47:09 +00:00
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
/* get all possible caps on this link */
|
|
|
|
caps = gst_pad_get_allowed_caps (pad);
|
|
|
|
temp = gst_caps_normalize (caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
caps = temp;
|
2003-12-22 01:47:09 +00:00
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
if (gst_caps_get_size (caps) > 0) {
|
|
|
|
GstStructure *structure;
|
2003-12-22 01:47:09 +00:00
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
/* pick the first one */
|
|
|
|
temp = gst_caps_copy_nth (caps, 0);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
caps = temp;
|
2003-12-22 01:47:09 +00:00
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
|
|
|
|
|
|
|
gst_caps_structure_fixate_field_nearest_int (structure, "width", 320);
|
|
|
|
gst_caps_structure_fixate_field_nearest_int (structure, "height", 240);
|
|
|
|
gst_caps_structure_fixate_field_nearest_double (structure, "framerate",
|
|
|
|
30.0);
|
2003-12-22 01:47:09 +00:00
|
|
|
}
|
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
return caps;
|
2003-12-22 01:47:09 +00:00
|
|
|
}
|
|
|
|
|
2003-01-10 13:38:32 +00:00
|
|
|
static GstPadLinkReturn
|
2005-03-31 09:43:49 +00:00
|
|
|
gst_videotestsrc_src_link (GstPad * pad, GstPad * peer)
|
|
|
|
{
|
|
|
|
return GST_PAD_LINK_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_videotestsrc_parse_caps (const GstCaps * caps,
|
|
|
|
gint * width, gint * height, gdouble * rate,
|
|
|
|
struct fourcc_list_struct **fourcc)
|
2002-07-26 22:18:57 +00:00
|
|
|
{
|
2003-12-22 01:47:09 +00:00
|
|
|
const GstStructure *structure;
|
|
|
|
GstPadLinkReturn ret;
|
2002-07-26 22:18:57 +00:00
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
GST_DEBUG ("parsing caps");
|
|
|
|
|
|
|
|
if (gst_caps_get_size (caps) < 1)
|
|
|
|
return FALSE;
|
2002-07-26 22:18:57 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
2003-06-10 16:22:41 +00:00
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
*fourcc = paintinfo_find_by_structure (structure);
|
|
|
|
if (!*fourcc) {
|
2004-07-22 15:55:33 +00:00
|
|
|
g_critical ("videotestsrc format not found");
|
2005-03-31 09:43:49 +00:00
|
|
|
return FALSE;
|
2002-07-26 22:18:57 +00:00
|
|
|
}
|
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
ret = gst_structure_get_int (structure, "width", width);
|
|
|
|
ret &= gst_structure_get_int (structure, "height", height);
|
|
|
|
ret &= gst_structure_get_double (structure, "framerate", rate);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2003-04-16 07:52:54 +00:00
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
#if 0
|
|
|
|
static gboolean
|
|
|
|
gst_videotestsrc_src_accept_caps (GstPad * pad, const GstCaps * caps)
|
|
|
|
{
|
|
|
|
gint width, height;
|
|
|
|
gdouble rate;
|
|
|
|
struct fourcc_list_struct *fourcc;
|
2002-07-26 22:18:57 +00:00
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
return gst_videotestsrc_parse_caps (caps, &width, &height, &rate, &fourcc);
|
|
|
|
}
|
|
|
|
#endif
|
2002-10-04 06:49:51 +00:00
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
static gboolean
|
|
|
|
gst_videotestsrc_setcaps (GstPad * pad, GstCaps * caps)
|
|
|
|
{
|
|
|
|
gboolean res;
|
|
|
|
gint width, height;
|
|
|
|
gdouble rate;
|
|
|
|
struct fourcc_list_struct *fourcc;
|
|
|
|
GstVideotestsrc *videotestsrc;
|
2002-07-26 22:18:57 +00:00
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
videotestsrc = GST_VIDEOTESTSRC (GST_PAD_PARENT (pad));
|
|
|
|
|
|
|
|
res = gst_videotestsrc_parse_caps (caps, &width, &height, &rate, &fourcc);
|
|
|
|
if (res) {
|
|
|
|
/* looks ok here */
|
|
|
|
videotestsrc->fourcc = fourcc;
|
|
|
|
videotestsrc->width = width;
|
|
|
|
videotestsrc->height = height;
|
|
|
|
videotestsrc->rate = rate;
|
|
|
|
videotestsrc->bpp = videotestsrc->fourcc->bitspp;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (videotestsrc, "size %dx%d, %f fps", videotestsrc->width,
|
|
|
|
videotestsrc->height, videotestsrc->rate);
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
2002-07-26 22:18:57 +00:00
|
|
|
}
|
|
|
|
|
2003-09-11 19:25:40 +00:00
|
|
|
static void
|
|
|
|
gst_videotestsrc_src_unlink (GstPad * pad)
|
|
|
|
{
|
|
|
|
GstVideotestsrc *videotestsrc;
|
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
videotestsrc = GST_VIDEOTESTSRC (GST_PAD_PARENT (pad));
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_videotestsrc_activate (GstPad * pad, GstActivateMode mode)
|
|
|
|
{
|
|
|
|
gboolean result = FALSE;
|
|
|
|
GstVideotestsrc *videotestsrc;
|
|
|
|
|
|
|
|
videotestsrc = GST_VIDEOTESTSRC (GST_OBJECT_PARENT (pad));
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case GST_ACTIVATE_PULL:
|
|
|
|
break;
|
|
|
|
case GST_ACTIVATE_PUSH:
|
|
|
|
/* if we have a scheduler we can start the task */
|
|
|
|
if (GST_ELEMENT_SCHEDULER (videotestsrc)) {
|
|
|
|
GST_STREAM_LOCK (pad);
|
|
|
|
GST_RPAD_TASK (pad) =
|
|
|
|
gst_scheduler_create_task (GST_ELEMENT_SCHEDULER (videotestsrc),
|
|
|
|
(GstTaskFunction) gst_videotestsrc_loop, pad);
|
|
|
|
|
|
|
|
gst_task_start (GST_RPAD_TASK (pad));
|
|
|
|
GST_STREAM_UNLOCK (pad);
|
|
|
|
result = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_ACTIVATE_NONE:
|
|
|
|
/* step 1, unblock clock sync (if any) */
|
|
|
|
|
|
|
|
/* step 2, make sure streaming finishes */
|
|
|
|
GST_STREAM_LOCK (pad);
|
|
|
|
/* step 3, stop the task */
|
|
|
|
gst_task_stop (GST_RPAD_TASK (pad));
|
|
|
|
gst_object_unref (GST_OBJECT (GST_RPAD_TASK (pad)));
|
|
|
|
GST_STREAM_UNLOCK (pad);
|
|
|
|
|
|
|
|
result = TRUE;
|
|
|
|
break;
|
gst/: Don't ignore _push() return values.
Original commit message from CVS:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_chain),
(gst_audio_convert_caps_remove_format_info),
(gst_audio_convert_setcaps), (gst_audio_convert_fixate),
(gst_audio_convert_change_state), (gst_audio_convert_channels):
* gst/videotestsrc/gstvideotestsrc.c:
(gst_videotestsrc_src_negotiate), (gst_videotestsrc_src_link),
(gst_videotestsrc_parse_caps), (gst_videotestsrc_src_accept_caps),
(gst_videotestsrc_setcaps), (gst_videotestsrc_activate),
(gst_videotestsrc_init), (gst_videotestsrc_loop):
Don't ignore _push() return values.
Make sure no processing is done when shutting down.
Videotestsrc pad activation fix.
2005-05-05 09:49:08 +00:00
|
|
|
default:
|
|
|
|
result = FALSE;
|
|
|
|
break;
|
2005-03-31 09:43:49 +00:00
|
|
|
}
|
|
|
|
return result;
|
2003-09-11 19:25:40 +00:00
|
|
|
}
|
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
|
2002-07-30 07:38:01 +00:00
|
|
|
static GstElementStateReturn
|
2002-10-04 06:49:51 +00:00
|
|
|
gst_videotestsrc_change_state (GstElement * element)
|
2002-07-30 07:38:01 +00:00
|
|
|
{
|
2003-09-11 19:25:40 +00:00
|
|
|
GstVideotestsrc *videotestsrc;
|
2005-03-31 09:43:49 +00:00
|
|
|
GstElementStateReturn result;
|
2002-10-04 06:49:51 +00:00
|
|
|
|
2003-09-11 19:25:40 +00:00
|
|
|
videotestsrc = GST_VIDEOTESTSRC (element);
|
2002-07-30 07:38:01 +00:00
|
|
|
|
2002-10-04 06:49:51 +00:00
|
|
|
switch (GST_STATE_TRANSITION (element)) {
|
2003-09-11 19:25:40 +00:00
|
|
|
case GST_STATE_NULL_TO_READY:
|
|
|
|
break;
|
|
|
|
case GST_STATE_READY_TO_PAUSED:
|
2004-04-27 09:42:45 +00:00
|
|
|
videotestsrc->num_buffers_left = videotestsrc->num_buffers;
|
2003-09-11 19:25:40 +00:00
|
|
|
break;
|
2002-10-04 06:49:51 +00:00
|
|
|
case GST_STATE_PAUSED_TO_PLAYING:
|
|
|
|
break;
|
2005-03-31 09:43:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
result = parent_class->change_state (element);
|
|
|
|
|
|
|
|
switch (GST_STATE_TRANSITION (element)) {
|
2002-10-04 06:49:51 +00:00
|
|
|
case GST_STATE_PLAYING_TO_PAUSED:
|
2003-09-11 19:25:40 +00:00
|
|
|
break;
|
|
|
|
case GST_STATE_PAUSED_TO_READY:
|
|
|
|
videotestsrc->timestamp_offset = 0;
|
2004-08-05 17:51:07 +00:00
|
|
|
videotestsrc->running_time = 0;
|
2003-09-11 19:25:40 +00:00
|
|
|
videotestsrc->n_frames = 0;
|
2002-10-04 06:49:51 +00:00
|
|
|
break;
|
2003-06-11 22:39:37 +00:00
|
|
|
case GST_STATE_READY_TO_NULL:
|
|
|
|
break;
|
2002-10-04 06:49:51 +00:00
|
|
|
}
|
2002-07-30 07:38:01 +00:00
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
return result;
|
2002-10-04 06:49:51 +00:00
|
|
|
}
|
2002-07-30 07:38:01 +00:00
|
|
|
|
2002-10-04 06:49:51 +00:00
|
|
|
static GstCaps *
|
|
|
|
gst_videotestsrc_get_capslist (void)
|
|
|
|
{
|
2004-08-04 11:08:13 +00:00
|
|
|
return gst_caps_copy (capslist);
|
|
|
|
}
|
2002-10-04 06:49:51 +00:00
|
|
|
|
2004-08-04 11:08:13 +00:00
|
|
|
static void
|
|
|
|
generate_capslist (void)
|
|
|
|
{
|
|
|
|
if (!capslist) {
|
|
|
|
GstCaps *caps;
|
|
|
|
GstStructure *structure;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
caps = gst_caps_new_empty ();
|
|
|
|
for (i = 0; i < n_fourccs; i++) {
|
|
|
|
structure = paint_get_structure (fourcc_list + i);
|
|
|
|
gst_structure_set (structure,
|
|
|
|
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
|
|
|
|
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
|
|
|
|
"framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE, NULL);
|
|
|
|
gst_caps_append_structure (caps, structure);
|
|
|
|
}
|
2003-07-14 08:36:03 +00:00
|
|
|
|
2004-08-04 11:08:13 +00:00
|
|
|
capslist = caps;
|
|
|
|
}
|
2003-07-14 08:36:03 +00:00
|
|
|
}
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
#if 0
|
2003-07-14 08:36:03 +00:00
|
|
|
static GstCaps *
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_videotestsrc_get_capslist_size (int width, int height, double rate)
|
2003-07-14 08:36:03 +00:00
|
|
|
{
|
|
|
|
GstCaps *caps;
|
2003-12-22 01:47:09 +00:00
|
|
|
GstStructure *structure;
|
|
|
|
int i;
|
2003-07-14 08:36:03 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
caps = gst_caps_new_empty ();
|
|
|
|
for (i = 0; i < n_fourccs; i++) {
|
2003-12-22 01:47:09 +00:00
|
|
|
structure = paint_get_structure (fourcc_list + i);
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_structure_set (structure,
|
2004-03-15 19:32:28 +00:00
|
|
|
"width", G_TYPE_INT, width,
|
|
|
|
"height", G_TYPE_INT, height, "framerate", G_TYPE_INT, rate, NULL);
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_caps_append_structure (caps, structure);
|
|
|
|
}
|
2003-07-14 08:36:03 +00:00
|
|
|
|
|
|
|
return caps;
|
2002-07-30 07:38:01 +00:00
|
|
|
}
|
2003-12-22 01:47:09 +00:00
|
|
|
#endif
|
2002-07-30 07:38:01 +00:00
|
|
|
|
2002-10-04 06:49:51 +00:00
|
|
|
static GstCaps *
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_videotestsrc_getcaps (GstPad * pad)
|
2002-07-26 22:18:57 +00:00
|
|
|
{
|
2002-10-04 06:49:51 +00:00
|
|
|
GstVideotestsrc *vts;
|
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
vts = GST_VIDEOTESTSRC (GST_PAD_PARENT (pad));
|
2002-10-04 06:49:51 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
return gst_videotestsrc_get_capslist ();
|
2002-10-04 06:49:51 +00:00
|
|
|
}
|
2002-07-26 22:18:57 +00:00
|
|
|
|
2002-10-04 06:49:51 +00:00
|
|
|
static void
|
|
|
|
gst_videotestsrc_init (GstVideotestsrc * videotestsrc)
|
|
|
|
{
|
2004-03-14 22:34:34 +00:00
|
|
|
videotestsrc->srcpad =
|
|
|
|
gst_pad_new_from_template (gst_videotestsrc_src_template_factory (),
|
|
|
|
"src");
|
2002-10-04 06:49:51 +00:00
|
|
|
gst_pad_set_getcaps_function (videotestsrc->srcpad, gst_videotestsrc_getcaps);
|
2005-03-31 09:43:49 +00:00
|
|
|
gst_pad_set_setcaps_function (videotestsrc->srcpad, gst_videotestsrc_setcaps);
|
2002-10-04 06:49:51 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (videotestsrc), videotestsrc->srcpad);
|
2005-03-31 09:43:49 +00:00
|
|
|
gst_pad_set_activate_function (videotestsrc->srcpad,
|
|
|
|
gst_videotestsrc_activate);
|
|
|
|
gst_pad_set_loop_function (videotestsrc->srcpad, gst_videotestsrc_loop);
|
2003-09-11 19:25:40 +00:00
|
|
|
gst_pad_set_link_function (videotestsrc->srcpad, gst_videotestsrc_src_link);
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_pad_set_unlink_function (videotestsrc->srcpad,
|
|
|
|
gst_videotestsrc_src_unlink);
|
2003-12-14 21:25:32 +00:00
|
|
|
gst_pad_set_query_function (videotestsrc->srcpad, gst_videotestsrc_src_query);
|
|
|
|
gst_pad_set_query_type_function (videotestsrc->srcpad,
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videotestsrc_get_query_types);
|
2004-06-18 22:32:44 +00:00
|
|
|
gst_pad_set_event_function (videotestsrc->srcpad,
|
|
|
|
gst_videotestsrc_handle_src_event);
|
|
|
|
|
2002-07-26 22:18:57 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videotestsrc_set_pattern (videotestsrc, GST_VIDEOTESTSRC_SMPTE);
|
2003-07-14 08:36:03 +00:00
|
|
|
|
2004-04-27 09:42:45 +00:00
|
|
|
videotestsrc->num_buffers = -1;
|
|
|
|
videotestsrc->num_buffers_left = -1;
|
2003-07-14 08:36:03 +00:00
|
|
|
videotestsrc->sync = TRUE;
|
2004-06-18 22:32:44 +00:00
|
|
|
videotestsrc->need_discont = FALSE;
|
|
|
|
videotestsrc->loop = FALSE;
|
|
|
|
videotestsrc->segment_start_frame = -1;
|
|
|
|
videotestsrc->segment_end_frame = -1;
|
|
|
|
videotestsrc->timestamp_offset = 0;
|
2003-06-11 22:39:37 +00:00
|
|
|
}
|
2003-05-18 23:20:24 +00:00
|
|
|
|
2002-07-26 22:18:57 +00:00
|
|
|
|
2003-12-14 21:25:32 +00:00
|
|
|
static const GstQueryType *
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videotestsrc_get_query_types (GstPad * pad)
|
2003-12-14 21:25:32 +00:00
|
|
|
{
|
|
|
|
static const GstQueryType query_types[] = {
|
|
|
|
GST_QUERY_POSITION,
|
|
|
|
0,
|
|
|
|
};
|
|
|
|
|
|
|
|
return query_types;
|
2004-03-14 22:34:34 +00:00
|
|
|
}
|
2003-12-14 21:25:32 +00:00
|
|
|
|
|
|
|
static gboolean
|
2005-05-09 10:56:13 +00:00
|
|
|
gst_videotestsrc_src_query (GstPad * pad, GstQuery * query)
|
2003-12-14 21:25:32 +00:00
|
|
|
{
|
|
|
|
gboolean res = FALSE;
|
2005-03-31 09:43:49 +00:00
|
|
|
GstVideotestsrc *videotestsrc = GST_VIDEOTESTSRC (GST_PAD_PARENT (pad));
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2005-05-09 10:56:13 +00:00
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
2003-12-14 21:25:32 +00:00
|
|
|
case GST_QUERY_POSITION:
|
2005-05-09 10:56:13 +00:00
|
|
|
{
|
|
|
|
GstFormat format;
|
|
|
|
gint64 current;
|
|
|
|
|
|
|
|
gst_query_parse_position (query, &format, NULL, NULL);
|
|
|
|
|
|
|
|
switch (format) {
|
2004-03-15 19:32:28 +00:00
|
|
|
case GST_FORMAT_TIME:
|
2005-05-09 10:56:13 +00:00
|
|
|
current = videotestsrc->running_time;
|
2004-03-15 19:32:28 +00:00
|
|
|
res = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_FORMAT_DEFAULT: /* frames */
|
2005-05-09 10:56:13 +00:00
|
|
|
current = videotestsrc->n_frames;
|
2004-03-15 19:32:28 +00:00
|
|
|
res = TRUE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2003-12-14 21:25:32 +00:00
|
|
|
}
|
2005-05-09 10:56:13 +00:00
|
|
|
if (res) {
|
|
|
|
gst_query_set_position (query, format, current, -1);
|
|
|
|
}
|
2003-12-14 21:25:32 +00:00
|
|
|
break;
|
2005-05-09 10:56:13 +00:00
|
|
|
}
|
2003-12-14 21:25:32 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2005-05-09 10:56:13 +00:00
|
|
|
#if 0
|
2004-06-18 22:32:44 +00:00
|
|
|
static const GstEventMask *
|
|
|
|
gst_videotestsrc_get_event_masks (GstPad * pad)
|
|
|
|
{
|
|
|
|
static const GstEventMask src_event_masks[] = {
|
|
|
|
{GST_EVENT_SEEK, GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH},
|
|
|
|
{0,}
|
|
|
|
};
|
|
|
|
|
|
|
|
return src_event_masks;
|
|
|
|
}
|
2005-05-09 10:56:13 +00:00
|
|
|
#endif
|
2004-06-18 22:32:44 +00:00
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_videotestsrc_handle_src_event (GstPad * pad, GstEvent * event)
|
|
|
|
{
|
|
|
|
gboolean res = TRUE;
|
|
|
|
GstVideotestsrc *videotestsrc;
|
|
|
|
gint64 new_n_frames;
|
|
|
|
|
|
|
|
g_return_val_if_fail (pad != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
|
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
videotestsrc = GST_VIDEOTESTSRC (GST_PAD_PARENT (pad));
|
2004-06-18 22:32:44 +00:00
|
|
|
new_n_frames = videotestsrc->n_frames;
|
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_SEEK:
|
|
|
|
{
|
|
|
|
switch (GST_EVENT_SEEK_FORMAT (event)) {
|
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
new_n_frames =
|
|
|
|
GST_EVENT_SEEK_OFFSET (event) * (double) videotestsrc->rate /
|
|
|
|
GST_SECOND;
|
|
|
|
videotestsrc->segment_start_frame = new_n_frames;
|
|
|
|
videotestsrc->segment_end_frame =
|
|
|
|
GST_EVENT_SEEK_ENDOFFSET (event) * (double) videotestsrc->rate /
|
|
|
|
GST_SECOND;
|
|
|
|
videotestsrc->loop =
|
|
|
|
GST_EVENT_SEEK_TYPE (event) & GST_SEEK_FLAG_SEGMENT_LOOP;
|
|
|
|
break;
|
|
|
|
case GST_FORMAT_DEFAULT:
|
|
|
|
new_n_frames = GST_EVENT_SEEK_OFFSET (event);
|
|
|
|
videotestsrc->segment_start_frame = new_n_frames;
|
|
|
|
videotestsrc->segment_end_frame = GST_EVENT_SEEK_ENDOFFSET (event);
|
|
|
|
videotestsrc->loop =
|
|
|
|
GST_EVENT_SEEK_TYPE (event) & GST_SEEK_FLAG_SEGMENT_LOOP;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (videotestsrc->n_frames != new_n_frames) {
|
|
|
|
videotestsrc->n_frames = new_n_frames;
|
|
|
|
videotestsrc->need_discont = TRUE;
|
|
|
|
}
|
2005-03-31 09:43:49 +00:00
|
|
|
gst_event_unref (event);
|
2004-06-18 22:32:44 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
2003-12-14 21:25:32 +00:00
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
static void
|
|
|
|
gst_videotestsrc_loop (GstPad * pad)
|
2002-07-26 22:18:57 +00:00
|
|
|
{
|
|
|
|
GstVideotestsrc *videotestsrc;
|
|
|
|
gulong newsize;
|
2005-03-31 09:43:49 +00:00
|
|
|
GstBuffer *outbuf;
|
2002-07-26 22:18:57 +00:00
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
videotestsrc = GST_VIDEOTESTSRC (GST_PAD_PARENT (pad));
|
2004-07-22 15:55:33 +00:00
|
|
|
GST_LOG_OBJECT (videotestsrc, "get");
|
2002-07-26 22:18:57 +00:00
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
/* no format on this pad, find a format */
|
|
|
|
if (GST_PAD_CAPS (pad) == NULL) {
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
caps = gst_videotestsrc_src_negotiate (pad);
|
|
|
|
if (!gst_pad_set_caps (videotestsrc->srcpad, caps)) {
|
|
|
|
GST_ELEMENT_ERROR (videotestsrc, CORE, NEGOTIATION, (NULL),
|
|
|
|
("format could not be negotiated"));
|
|
|
|
gst_pad_push_event (pad, gst_event_new (GST_EVENT_EOS));
|
|
|
|
goto need_pause;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
if (videotestsrc->fourcc == NULL) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (videotestsrc, CORE, NEGOTIATION, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("format wasn't negotiated before get function"));
|
2005-03-31 09:43:49 +00:00
|
|
|
gst_pad_push_event (pad, gst_event_new (GST_EVENT_EOS));
|
|
|
|
goto need_pause;
|
2003-12-14 21:25:32 +00:00
|
|
|
}
|
2003-07-14 08:36:03 +00:00
|
|
|
|
2004-06-18 22:32:44 +00:00
|
|
|
if (videotestsrc->need_discont) {
|
|
|
|
GstClockTime ts = videotestsrc->timestamp_offset +
|
|
|
|
(videotestsrc->n_frames * GST_SECOND) / (double) videotestsrc->rate;
|
|
|
|
|
|
|
|
videotestsrc->need_discont = FALSE;
|
2005-03-31 09:43:49 +00:00
|
|
|
gst_pad_push_event (pad, gst_event_new_discontinuous (FALSE,
|
|
|
|
GST_FORMAT_TIME, ts, NULL));
|
2004-06-18 22:32:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((videotestsrc->segment_end_frame != -1) &&
|
|
|
|
(videotestsrc->n_frames > videotestsrc->segment_end_frame)) {
|
|
|
|
if (videotestsrc->loop) {
|
2005-03-31 09:43:49 +00:00
|
|
|
//gst_pad_push_event (pad, gst_event_new (GST_EVENT_SEGMENT_DONE));
|
2004-06-18 22:32:44 +00:00
|
|
|
} else {
|
2005-03-31 09:43:49 +00:00
|
|
|
gst_pad_push_event (pad, gst_event_new (GST_EVENT_EOS));
|
|
|
|
goto need_pause;
|
2004-06-18 22:32:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (videotestsrc->num_buffers_left == 0) {
|
2005-03-31 09:43:49 +00:00
|
|
|
gst_pad_push_event (pad, gst_event_new (GST_EVENT_EOS));
|
|
|
|
goto need_pause;
|
2004-06-18 22:32:44 +00:00
|
|
|
} else {
|
|
|
|
if (videotestsrc->num_buffers_left > 0)
|
|
|
|
videotestsrc->num_buffers_left--;
|
|
|
|
}
|
|
|
|
|
2004-01-09 01:53:31 +00:00
|
|
|
newsize = gst_videotestsrc_get_size (videotestsrc, videotestsrc->width,
|
|
|
|
videotestsrc->height);
|
2005-03-31 09:43:49 +00:00
|
|
|
g_return_if_fail (newsize > 0);
|
2002-07-26 22:18:57 +00:00
|
|
|
|
2004-07-22 15:55:33 +00:00
|
|
|
GST_LOG_OBJECT (videotestsrc, "creating buffer of %ld bytes for %dx%d image",
|
|
|
|
newsize, videotestsrc->width, videotestsrc->height);
|
2002-07-26 22:18:57 +00:00
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
outbuf =
|
|
|
|
gst_pad_alloc_buffer (pad, GST_BUFFER_OFFSET_NONE, newsize,
|
|
|
|
GST_RPAD_CAPS (pad));
|
|
|
|
|
|
|
|
if (GST_BUFFER_CAPS (outbuf) != GST_PAD_CAPS (pad)) {
|
|
|
|
if (!gst_pad_set_caps (pad, GST_BUFFER_CAPS (outbuf))) {
|
|
|
|
GST_ELEMENT_ERROR (videotestsrc, CORE, NEGOTIATION, (NULL),
|
|
|
|
("format wasn't accepted"));
|
|
|
|
gst_pad_push_event (pad, gst_event_new (GST_EVENT_EOS));
|
|
|
|
goto need_pause;
|
|
|
|
}
|
|
|
|
}
|
2002-07-30 01:25:26 +00:00
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
videotestsrc->make_image (videotestsrc, (void *) GST_BUFFER_DATA (outbuf),
|
2004-03-14 22:34:34 +00:00
|
|
|
videotestsrc->width, videotestsrc->height);
|
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = videotestsrc->timestamp_offset +
|
2004-08-05 17:51:07 +00:00
|
|
|
videotestsrc->running_time;
|
2005-03-31 09:43:49 +00:00
|
|
|
GST_BUFFER_DURATION (outbuf) = GST_SECOND / (double) videotestsrc->rate;
|
2004-03-14 22:34:34 +00:00
|
|
|
if (videotestsrc->sync) {
|
2004-01-14 00:53:52 +00:00
|
|
|
/* FIXME this is not correct if we do QoS */
|
|
|
|
if (videotestsrc->clock) {
|
2005-03-31 09:43:49 +00:00
|
|
|
//gst_element_wait (GST_ELEMENT (videotestsrc), GST_BUFFER_TIMESTAMP (outbuf));
|
2004-01-14 00:53:52 +00:00
|
|
|
}
|
2003-05-01 06:24:34 +00:00
|
|
|
}
|
2004-08-05 17:51:07 +00:00
|
|
|
videotestsrc->n_frames++;
|
2005-03-31 09:43:49 +00:00
|
|
|
videotestsrc->running_time += GST_BUFFER_DURATION (outbuf);
|
|
|
|
|
gst/: Don't ignore _push() return values.
Original commit message from CVS:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_chain),
(gst_audio_convert_caps_remove_format_info),
(gst_audio_convert_setcaps), (gst_audio_convert_fixate),
(gst_audio_convert_change_state), (gst_audio_convert_channels):
* gst/videotestsrc/gstvideotestsrc.c:
(gst_videotestsrc_src_negotiate), (gst_videotestsrc_src_link),
(gst_videotestsrc_parse_caps), (gst_videotestsrc_src_accept_caps),
(gst_videotestsrc_setcaps), (gst_videotestsrc_activate),
(gst_videotestsrc_init), (gst_videotestsrc_loop):
Don't ignore _push() return values.
Make sure no processing is done when shutting down.
Videotestsrc pad activation fix.
2005-05-05 09:49:08 +00:00
|
|
|
if (gst_pad_push (pad, outbuf) != GST_FLOW_OK)
|
|
|
|
goto need_pause;
|
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
need_pause:
|
|
|
|
{
|
|
|
|
gst_task_pause (GST_RPAD_TASK (pad));
|
|
|
|
}
|
2002-07-26 22:18:57 +00:00
|
|
|
}
|
|
|
|
|
2003-04-23 07:38:32 +00:00
|
|
|
static void
|
2004-07-22 15:55:33 +00:00
|
|
|
gst_videotestsrc_set_pattern (GstVideotestsrc * videotestsrc, int pattern_type)
|
2003-04-23 07:38:32 +00:00
|
|
|
{
|
2004-07-22 15:55:33 +00:00
|
|
|
videotestsrc->type = pattern_type;
|
2003-04-23 07:38:32 +00:00
|
|
|
|
2004-07-22 15:55:33 +00:00
|
|
|
GST_DEBUG_OBJECT (videotestsrc, "setting pattern to %d", pattern_type);
|
2004-03-14 22:34:34 +00:00
|
|
|
switch (pattern_type) {
|
2003-04-23 07:38:32 +00:00
|
|
|
case GST_VIDEOTESTSRC_SMPTE:
|
2004-07-22 15:55:33 +00:00
|
|
|
videotestsrc->make_image = gst_videotestsrc_smpte;
|
2003-04-23 07:38:32 +00:00
|
|
|
break;
|
|
|
|
case GST_VIDEOTESTSRC_SNOW:
|
2004-07-22 15:55:33 +00:00
|
|
|
videotestsrc->make_image = gst_videotestsrc_snow;
|
2003-04-23 07:38:32 +00:00
|
|
|
break;
|
|
|
|
case GST_VIDEOTESTSRC_BLACK:
|
2004-07-22 15:55:33 +00:00
|
|
|
videotestsrc->make_image = gst_videotestsrc_black;
|
2003-04-23 07:38:32 +00:00
|
|
|
break;
|
|
|
|
default:
|
2004-03-14 22:34:34 +00:00
|
|
|
g_assert_not_reached ();
|
2003-04-23 07:38:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-26 22:18:57 +00:00
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videotestsrc_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
2002-07-26 22:18:57 +00:00
|
|
|
{
|
2004-07-22 15:55:33 +00:00
|
|
|
GstVideotestsrc *videotestsrc;
|
2002-07-26 22:18:57 +00:00
|
|
|
|
|
|
|
/* it's not null if we got it, but it might not be ours */
|
2002-10-04 06:49:51 +00:00
|
|
|
g_return_if_fail (GST_IS_VIDEOTESTSRC (object));
|
2004-07-22 15:55:33 +00:00
|
|
|
videotestsrc = GST_VIDEOTESTSRC (object);
|
2002-07-26 22:18:57 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2003-04-23 07:38:32 +00:00
|
|
|
case ARG_TYPE:
|
2004-07-22 15:55:33 +00:00
|
|
|
gst_videotestsrc_set_pattern (videotestsrc, g_value_get_enum (value));
|
2003-04-23 07:38:32 +00:00
|
|
|
break;
|
2003-05-18 23:20:24 +00:00
|
|
|
case ARG_SYNC:
|
2004-07-22 15:55:33 +00:00
|
|
|
videotestsrc->sync = g_value_get_boolean (value);
|
2003-05-18 23:20:24 +00:00
|
|
|
break;
|
2004-04-27 09:42:45 +00:00
|
|
|
case ARG_NUM_BUFFERS:
|
2004-07-22 15:55:33 +00:00
|
|
|
videotestsrc->num_buffers = g_value_get_int (value);
|
2004-04-27 09:42:45 +00:00
|
|
|
break;
|
2002-07-26 22:18:57 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videotestsrc_get_property (GObject * object, guint prop_id, GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2002-07-26 22:18:57 +00:00
|
|
|
{
|
2004-07-22 15:55:33 +00:00
|
|
|
GstVideotestsrc *videotestsrc;
|
2002-07-26 22:18:57 +00:00
|
|
|
|
|
|
|
/* it's not null if we got it, but it might not be ours */
|
2002-10-04 06:49:51 +00:00
|
|
|
g_return_if_fail (GST_IS_VIDEOTESTSRC (object));
|
2004-07-22 15:55:33 +00:00
|
|
|
videotestsrc = GST_VIDEOTESTSRC (object);
|
2002-07-26 22:18:57 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2003-04-23 07:38:32 +00:00
|
|
|
case ARG_TYPE:
|
2004-07-22 15:55:33 +00:00
|
|
|
g_value_set_enum (value, videotestsrc->type);
|
2003-04-23 07:38:32 +00:00
|
|
|
break;
|
2003-05-18 23:20:24 +00:00
|
|
|
case ARG_SYNC:
|
2004-07-22 15:55:33 +00:00
|
|
|
g_value_set_boolean (value, videotestsrc->sync);
|
2003-05-18 23:20:24 +00:00
|
|
|
break;
|
2004-04-27 09:42:45 +00:00
|
|
|
case ARG_NUM_BUFFERS:
|
2004-07-22 15:55:33 +00:00
|
|
|
g_value_set_int (value, videotestsrc->num_buffers);
|
2004-04-27 09:42:45 +00:00
|
|
|
break;
|
2002-07-26 22:18:57 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2003-11-02 20:48:33 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2002-07-26 22:18:57 +00:00
|
|
|
{
|
2004-03-14 22:34:34 +00:00
|
|
|
oil_init ();
|
Convert a few inner loops to use liboil. This is currently optional, and is only enabled if liboil is present (duh!).
Original commit message from CVS:
Convert a few inner loops to use liboil. This is currently
optional, and is only enabled if liboil is present (duh!).
* configure.ac: Check for liboil-0.1
* gst/intfloat/Makefile.am:
* gst/intfloat/gstint2float.c: (conv_f32_s16), (scalarmult_f32),
(gst_int2float_chain_gint16):
* gst/videofilter/Makefile.am:
* gst/videofilter/gstvideobalance.c: (gst_videobalance_class_init),
(tablelookup_u8), (gst_videobalance_planar411):
* gst/videotestsrc/Makefile.am:
* gst/videotestsrc/gstvideotestsrc.c: (plugin_init):
* gst/videotestsrc/videotestsrc.c: (splat_u8), (paint_hline_YUY2),
(paint_hline_IYU2), (paint_hline_str4), (paint_hline_str3),
(paint_hline_RGB565), (paint_hline_xRGB1555):
2004-02-12 07:37:50 +00:00
|
|
|
|
2004-08-04 11:08:13 +00:00
|
|
|
generate_capslist ();
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
return gst_element_register (plugin, "videotestsrc", GST_RANK_NONE,
|
|
|
|
GST_TYPE_VIDEOTESTSRC);
|
2002-07-26 22:18:57 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"videotestsrc",
|
|
|
|
"Creates a test video stream",
|
|
|
|
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
|