mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 09:55:36 +00:00
gst/videotestsrc/: Cleanups.
Original commit message from CVS: 2005-07-19 Andy Wingo <wingo@pobox.com> * gst/videotestsrc/: Cleanups.
This commit is contained in:
parent
02fc9a164a
commit
09c2e02b0a
11 changed files with 185 additions and 315 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2005-07-19 Andy Wingo <wingo@pobox.com>
|
||||||
|
|
||||||
|
* gst/videotestsrc/: Cleanups.
|
||||||
|
|
||||||
2005-07-19 Wim Taymans <wim@fluendo.com>
|
2005-07-19 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* ext/gnomevfs/gstgnomevfssrc.c: (gst_gnomevfssrc_create):
|
* ext/gnomevfs/gstgnomevfssrc.c: (gst_gnomevfssrc_create):
|
||||||
|
|
|
@ -14,6 +14,9 @@ a support library for audio elements
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<!-- ##### SECTION Stability_Level ##### -->
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### ENUM GstAudioFieldFlag ##### -->
|
<!-- ##### ENUM GstAudioFieldFlag ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,9 @@ interface for elements that provide color balance operations
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<!-- ##### SECTION Stability_Level ##### -->
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### STRUCT GstColorBalance ##### -->
|
<!-- ##### STRUCT GstColorBalance ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,9 @@ gconf default elements support
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<!-- ##### SECTION Stability_Level ##### -->
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### FUNCTION gst_gconf_get_string ##### -->
|
<!-- ##### FUNCTION gst_gconf_get_string ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,9 @@ gstmixer
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<!-- ##### SECTION Stability_Level ##### -->
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### STRUCT GstMixer ##### -->
|
<!-- ##### STRUCT GstMixer ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,9 @@ an implementation of an audio ringbuffer
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<!-- ##### SECTION Stability_Level ##### -->
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### STRUCT GstRingBuffer ##### -->
|
<!-- ##### STRUCT GstRingBuffer ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,9 @@ interface for elements that provide tuner operations
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<!-- ##### SECTION Stability_Level ##### -->
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### STRUCT GstTuner ##### -->
|
<!-- ##### STRUCT GstTuner ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* GStreamer
|
/* GStreamer
|
||||||
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
||||||
|
* Copyright (C) <2002> David A. Schleef <ds@schleef.org>
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Library General Public
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
@ -17,6 +18,7 @@
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -27,40 +29,32 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <liboil/liboil.h>
|
#include <liboil/liboil.h>
|
||||||
|
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY (videotestsrc_debug);
|
GST_DEBUG_CATEGORY (videotestsrc_debug);
|
||||||
#define GST_CAT_DEFAULT videotestsrc_debug
|
#define GST_CAT_DEFAULT videotestsrc_debug
|
||||||
|
|
||||||
/* elementfactory information */
|
|
||||||
static GstElementDetails videotestsrc_details =
|
static GstElementDetails videotestsrc_details =
|
||||||
GST_ELEMENT_DETAILS ("Video test source",
|
GST_ELEMENT_DETAILS ("Video test source",
|
||||||
"Source/Video",
|
"Source/Video",
|
||||||
"Creates a test video stream",
|
"Creates a test video stream",
|
||||||
"David A. Schleef <ds@schleef.org>");
|
"David A. Schleef <ds@schleef.org>");
|
||||||
|
|
||||||
/* GstVideotestsrc signals and args */
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
/* FILL ME */
|
|
||||||
LAST_SIGNAL
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
ARG_0,
|
PROP_0,
|
||||||
ARG_TYPE,
|
PROP_PATTERN,
|
||||||
ARG_SYNC,
|
PROP_TIMESTAMP_OFFSET,
|
||||||
ARG_NUM_BUFFERS,
|
|
||||||
ARG_TIMESTAMP_OFFSET,
|
|
||||||
/* FILL ME */
|
/* FILL ME */
|
||||||
};
|
};
|
||||||
|
|
||||||
static GstCaps *capslist = NULL;
|
|
||||||
|
|
||||||
static void gst_videotestsrc_base_init (gpointer g_class);
|
GST_BOILERPLATE (GstVideoTestSrc, gst_videotestsrc, GstPushSrc,
|
||||||
static void gst_videotestsrc_class_init (GstVideotestsrcClass * klass);
|
GST_TYPE_PUSH_SRC);
|
||||||
static void gst_videotestsrc_init (GstVideotestsrc * videotestsrc);
|
|
||||||
|
|
||||||
static void gst_videotestsrc_set_pattern (GstVideotestsrc * videotestsrc,
|
|
||||||
|
static void gst_videotestsrc_set_pattern (GstVideoTestSrc * videotestsrc,
|
||||||
int pattern_type);
|
int pattern_type);
|
||||||
static void gst_videotestsrc_set_property (GObject * object, guint prop_id,
|
static void gst_videotestsrc_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
|
@ -70,60 +64,13 @@ static void gst_videotestsrc_get_property (GObject * object, guint prop_id,
|
||||||
static GstCaps *gst_videotestsrc_getcaps (GstBaseSrc * bsrc);
|
static GstCaps *gst_videotestsrc_getcaps (GstBaseSrc * bsrc);
|
||||||
static gboolean gst_videotestsrc_setcaps (GstBaseSrc * bsrc, GstCaps * caps);
|
static gboolean gst_videotestsrc_setcaps (GstBaseSrc * bsrc, GstCaps * caps);
|
||||||
static gboolean gst_videotestsrc_negotiate (GstBaseSrc * bsrc);
|
static gboolean gst_videotestsrc_negotiate (GstBaseSrc * bsrc);
|
||||||
static gboolean gst_videotestsrc_start (GstBaseSrc * src);
|
|
||||||
static gboolean gst_videotestsrc_stop (GstBaseSrc * src);
|
|
||||||
static void gst_videotestsrc_get_times (GstBaseSrc * src, GstBuffer * buffer,
|
static void gst_videotestsrc_get_times (GstBaseSrc * src, GstBuffer * buffer,
|
||||||
GstClockTime * start, GstClockTime * end);
|
GstClockTime * start, GstClockTime * end);
|
||||||
|
static gboolean gst_videotestsrc_event (GstBaseSrc * bsrc, GstEvent * event);
|
||||||
|
|
||||||
static GstFlowReturn gst_videotestsrc_create (GstPushSrc * psrc,
|
static GstFlowReturn gst_videotestsrc_create (GstPushSrc * psrc,
|
||||||
GstBuffer ** buffer);
|
GstBuffer ** buffer);
|
||||||
|
|
||||||
#if 0
|
|
||||||
static const GstEventMask *gst_videotestsrc_get_event_masks (GstPad * pad);
|
|
||||||
#endif
|
|
||||||
static gboolean gst_videotestsrc_event (GstBaseSrc * bsrc, GstEvent * event);
|
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
|
||||||
|
|
||||||
static GstCaps *gst_videotestsrc_get_capslist (void);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
static GstCaps *gst_videotestsrc_get_capslist_size (int width, int height,
|
|
||||||
double rate);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static GstPadTemplate *
|
|
||||||
gst_videotestsrc_src_template_factory (void)
|
|
||||||
{
|
|
||||||
return gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
|
|
||||||
gst_videotestsrc_get_capslist ());
|
|
||||||
}
|
|
||||||
|
|
||||||
GType
|
|
||||||
gst_videotestsrc_get_type (void)
|
|
||||||
{
|
|
||||||
static GType videotestsrc_type = 0;
|
|
||||||
|
|
||||||
if (!videotestsrc_type) {
|
|
||||||
static const GTypeInfo videotestsrc_info = {
|
|
||||||
sizeof (GstVideotestsrcClass),
|
|
||||||
gst_videotestsrc_base_init,
|
|
||||||
NULL,
|
|
||||||
(GClassInitFunc) gst_videotestsrc_class_init,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
sizeof (GstVideotestsrc),
|
|
||||||
0,
|
|
||||||
(GInstanceInitFunc) gst_videotestsrc_init,
|
|
||||||
};
|
|
||||||
|
|
||||||
videotestsrc_type =
|
|
||||||
g_type_register_static (GST_TYPE_PUSH_SRC, "GstVideotestsrc",
|
|
||||||
&videotestsrc_info, 0);
|
|
||||||
}
|
|
||||||
return videotestsrc_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define GST_TYPE_VIDEOTESTSRC_PATTERN (gst_videotestsrc_pattern_get_type ())
|
#define GST_TYPE_VIDEOTESTSRC_PATTERN (gst_videotestsrc_pattern_get_type ())
|
||||||
static GType
|
static GType
|
||||||
|
@ -139,7 +86,7 @@ gst_videotestsrc_pattern_get_type (void)
|
||||||
|
|
||||||
if (!videotestsrc_pattern_type) {
|
if (!videotestsrc_pattern_type) {
|
||||||
videotestsrc_pattern_type =
|
videotestsrc_pattern_type =
|
||||||
g_enum_register_static ("GstVideotestsrcPattern", pattern_types);
|
g_enum_register_static ("GstVideoTestSrcPattern", pattern_types);
|
||||||
}
|
}
|
||||||
return videotestsrc_pattern_type;
|
return videotestsrc_pattern_type;
|
||||||
}
|
}
|
||||||
|
@ -152,89 +99,137 @@ gst_videotestsrc_base_init (gpointer g_class)
|
||||||
gst_element_class_set_details (element_class, &videotestsrc_details);
|
gst_element_class_set_details (element_class, &videotestsrc_details);
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
gst_element_class_add_pad_template (element_class,
|
||||||
gst_videotestsrc_src_template_factory ());
|
gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
|
||||||
|
gst_videotestsrc_getcaps (NULL)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_videotestsrc_class_init (GstVideotestsrcClass * klass)
|
gst_videotestsrc_class_init (GstVideoTestSrcClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
GstElementClass *gstelement_class;
|
|
||||||
GstBaseSrcClass *gstbasesrc_class;
|
GstBaseSrcClass *gstbasesrc_class;
|
||||||
GstPushSrcClass *gstpushsrc_class;
|
GstPushSrcClass *gstpushsrc_class;
|
||||||
|
|
||||||
gobject_class = (GObjectClass *) klass;
|
gobject_class = (GObjectClass *) klass;
|
||||||
gstelement_class = (GstElementClass *) klass;
|
|
||||||
gstbasesrc_class = (GstBaseSrcClass *) klass;
|
gstbasesrc_class = (GstBaseSrcClass *) klass;
|
||||||
gstpushsrc_class = (GstPushSrcClass *) klass;
|
gstpushsrc_class = (GstPushSrcClass *) klass;
|
||||||
|
|
||||||
gobject_class->set_property = gst_videotestsrc_set_property;
|
gobject_class->set_property = gst_videotestsrc_set_property;
|
||||||
gobject_class->get_property = gst_videotestsrc_get_property;
|
gobject_class->get_property = gst_videotestsrc_get_property;
|
||||||
|
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TYPE,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_PATTERN,
|
||||||
g_param_spec_enum ("pattern", "Pattern",
|
g_param_spec_enum ("pattern", "Pattern",
|
||||||
"Type of test pattern to generate", GST_TYPE_VIDEOTESTSRC_PATTERN, 1,
|
"Type of test pattern to generate", GST_TYPE_VIDEOTESTSRC_PATTERN, 1,
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC,
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
||||||
g_param_spec_boolean ("sync", "Sync", "Synchronize to clock", TRUE,
|
PROP_TIMESTAMP_OFFSET, g_param_spec_int64 ("timestamp-offset",
|
||||||
G_PARAM_READWRITE));
|
"Timestamp offset",
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_BUFFERS,
|
"An offset added to timestamps set on buffers (in ns)", G_MININT64,
|
||||||
g_param_spec_int ("num-buffers", "num-buffers",
|
G_MAXINT64, 0, G_PARAM_READWRITE));
|
||||||
"Number of buffers to output before sending EOS", -1, G_MAXINT,
|
|
||||||
0, G_PARAM_READWRITE));
|
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TIMESTAMP_OFFSET,
|
|
||||||
g_param_spec_int64 ("timestamp-offset", "Timestamp offset",
|
|
||||||
"An offset added to timestamps set on buffers (in ns)",
|
|
||||||
G_MININT64, G_MAXINT64, 0, G_PARAM_READWRITE));
|
|
||||||
|
|
||||||
parent_class = g_type_class_ref (GST_TYPE_PUSH_SRC);
|
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_INIT (videotestsrc_debug, "videotestsrc", 0,
|
|
||||||
"Video Test Source");
|
|
||||||
|
|
||||||
gstbasesrc_class->get_caps = gst_videotestsrc_getcaps;
|
gstbasesrc_class->get_caps = gst_videotestsrc_getcaps;
|
||||||
gstbasesrc_class->set_caps = gst_videotestsrc_setcaps;
|
gstbasesrc_class->set_caps = gst_videotestsrc_setcaps;
|
||||||
gstbasesrc_class->negotiate = gst_videotestsrc_negotiate;
|
gstbasesrc_class->negotiate = gst_videotestsrc_negotiate;
|
||||||
gstbasesrc_class->start = gst_videotestsrc_start;
|
|
||||||
gstbasesrc_class->stop = gst_videotestsrc_stop;
|
|
||||||
gstbasesrc_class->get_times = gst_videotestsrc_get_times;
|
gstbasesrc_class->get_times = gst_videotestsrc_get_times;
|
||||||
gstbasesrc_class->event = gst_videotestsrc_event;
|
gstbasesrc_class->event = gst_videotestsrc_event;
|
||||||
|
|
||||||
gstpushsrc_class->create = gst_videotestsrc_create;
|
gstpushsrc_class->create = gst_videotestsrc_create;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static void
|
||||||
gst_videotestsrc_negotiate (GstBaseSrc * bsrc)
|
gst_videotestsrc_init (GstVideoTestSrc * videotestsrc)
|
||||||
{
|
{
|
||||||
|
gst_videotestsrc_set_pattern (videotestsrc, GST_VIDEOTESTSRC_SMPTE);
|
||||||
|
|
||||||
|
videotestsrc->segment_start_frame = -1;
|
||||||
|
videotestsrc->segment_end_frame = -1;
|
||||||
|
videotestsrc->timestamp_offset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_videotestsrc_set_pattern (GstVideoTestSrc * videotestsrc, int pattern_type)
|
||||||
|
{
|
||||||
|
videotestsrc->pattern_type = pattern_type;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (videotestsrc, "setting pattern to %d", pattern_type);
|
||||||
|
|
||||||
|
switch (pattern_type) {
|
||||||
|
case GST_VIDEOTESTSRC_SMPTE:
|
||||||
|
videotestsrc->make_image = gst_videotestsrc_smpte;
|
||||||
|
break;
|
||||||
|
case GST_VIDEOTESTSRC_SNOW:
|
||||||
|
videotestsrc->make_image = gst_videotestsrc_snow;
|
||||||
|
break;
|
||||||
|
case GST_VIDEOTESTSRC_BLACK:
|
||||||
|
videotestsrc->make_image = gst_videotestsrc_black;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_videotestsrc_set_property (GObject * object, guint prop_id,
|
||||||
|
const GValue * value, GParamSpec * pspec)
|
||||||
|
{
|
||||||
|
GstVideoTestSrc *videotestsrc = GST_VIDEOTESTSRC (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_PATTERN:
|
||||||
|
gst_videotestsrc_set_pattern (videotestsrc, g_value_get_enum (value));
|
||||||
|
break;
|
||||||
|
case PROP_TIMESTAMP_OFFSET:
|
||||||
|
videotestsrc->timestamp_offset = g_value_get_int64 (value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_videotestsrc_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
|
GParamSpec * pspec)
|
||||||
|
{
|
||||||
|
GstVideoTestSrc *videotestsrc = GST_VIDEOTESTSRC (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_PATTERN:
|
||||||
|
g_value_set_enum (value, videotestsrc->pattern_type);
|
||||||
|
break;
|
||||||
|
case PROP_TIMESTAMP_OFFSET:
|
||||||
|
g_value_set_int64 (value, videotestsrc->timestamp_offset);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* threadsafe because this gets called as the plugin is loaded */
|
||||||
|
static GstCaps *
|
||||||
|
gst_videotestsrc_getcaps (GstBaseSrc * unused)
|
||||||
|
{
|
||||||
|
static GstCaps *capslist = NULL;
|
||||||
|
|
||||||
|
if (!capslist) {
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
GstCaps *temp;
|
|
||||||
gboolean result = FALSE;
|
|
||||||
|
|
||||||
/* get all possible caps on this link */
|
|
||||||
caps = gst_pad_get_allowed_caps (GST_BASE_SRC_PAD (bsrc));
|
|
||||||
temp = gst_caps_normalize (caps);
|
|
||||||
gst_caps_unref (caps);
|
|
||||||
caps = temp;
|
|
||||||
|
|
||||||
if (gst_caps_get_size (caps) > 0) {
|
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
|
int i;
|
||||||
|
|
||||||
/* pick the first one */
|
caps = gst_caps_new_empty ();
|
||||||
temp = gst_caps_copy_nth (caps, 0);
|
for (i = 0; i < n_fourccs; i++) {
|
||||||
gst_caps_unref (caps);
|
structure = paint_get_structure (fourcc_list + i);
|
||||||
caps = temp;
|
gst_structure_set (structure,
|
||||||
|
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
|
||||||
structure = gst_caps_get_structure (caps, 0);
|
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
|
||||||
|
"framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE, NULL);
|
||||||
gst_caps_structure_fixate_field_nearest_int (structure, "width", 320);
|
gst_caps_append_structure (caps, structure);
|
||||||
gst_caps_structure_fixate_field_nearest_int (structure, "height", 240);
|
|
||||||
gst_caps_structure_fixate_field_nearest_double (structure, "framerate",
|
|
||||||
30.0);
|
|
||||||
|
|
||||||
result = gst_pad_set_caps (GST_BASE_SRC_PAD (bsrc), caps);
|
|
||||||
gst_caps_unref (caps);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
capslist = caps;
|
||||||
|
}
|
||||||
|
|
||||||
|
return gst_caps_copy (capslist);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -265,18 +260,6 @@ gst_videotestsrc_parse_caps (const GstCaps * caps,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
static gboolean
|
|
||||||
gst_videotestsrc_src_accept_caps (GstPad * pad, const GstCaps * caps)
|
|
||||||
{
|
|
||||||
gint width, height;
|
|
||||||
gdouble rate;
|
|
||||||
struct fourcc_list_struct *fourcc;
|
|
||||||
|
|
||||||
return gst_videotestsrc_parse_caps (caps, &width, &height, &rate, &fourcc);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_videotestsrc_setcaps (GstBaseSrc * bsrc, GstCaps * caps)
|
gst_videotestsrc_setcaps (GstBaseSrc * bsrc, GstCaps * caps)
|
||||||
{
|
{
|
||||||
|
@ -284,7 +267,7 @@ gst_videotestsrc_setcaps (GstBaseSrc * bsrc, GstCaps * caps)
|
||||||
gint width, height;
|
gint width, height;
|
||||||
gdouble rate;
|
gdouble rate;
|
||||||
struct fourcc_list_struct *fourcc;
|
struct fourcc_list_struct *fourcc;
|
||||||
GstVideotestsrc *videotestsrc;
|
GstVideoTestSrc *videotestsrc;
|
||||||
|
|
||||||
videotestsrc = GST_VIDEOTESTSRC (bsrc);
|
videotestsrc = GST_VIDEOTESTSRC (bsrc);
|
||||||
|
|
||||||
|
@ -303,95 +286,52 @@ gst_videotestsrc_setcaps (GstBaseSrc * bsrc, GstCaps * caps)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstCaps *
|
static gboolean
|
||||||
gst_videotestsrc_get_capslist (void)
|
gst_videotestsrc_negotiate (GstBaseSrc * bsrc)
|
||||||
{
|
{
|
||||||
return gst_caps_copy (capslist);
|
GstCaps *caps;
|
||||||
|
GstCaps *temp;
|
||||||
|
gboolean result = FALSE;
|
||||||
|
|
||||||
|
/* get all possible caps on this link */
|
||||||
|
caps = gst_pad_get_allowed_caps (GST_BASE_SRC_PAD (bsrc));
|
||||||
|
temp = gst_caps_normalize (caps);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
caps = temp;
|
||||||
|
|
||||||
|
if (gst_caps_get_size (caps) > 0) {
|
||||||
|
GstStructure *structure;
|
||||||
|
|
||||||
|
/* pick the first one */
|
||||||
|
gst_caps_truncate (caps);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
result = gst_pad_set_caps (GST_BASE_SRC_PAD (bsrc), caps);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
generate_capslist (void)
|
gst_videotestsrc_get_times (GstBaseSrc * src, GstBuffer * buffer,
|
||||||
|
GstClockTime * start, GstClockTime * end)
|
||||||
{
|
{
|
||||||
if (!capslist) {
|
*start = GST_CLOCK_TIME_NONE;
|
||||||
GstCaps *caps;
|
*end = GST_CLOCK_TIME_NONE;
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
capslist = caps;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
static GstCaps *
|
|
||||||
gst_videotestsrc_get_capslist_size (int width, int height, double rate)
|
|
||||||
{
|
|
||||||
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", G_TYPE_INT, width,
|
|
||||||
"height", G_TYPE_INT, height, "framerate", G_TYPE_INT, rate, NULL);
|
|
||||||
gst_caps_append_structure (caps, structure);
|
|
||||||
}
|
|
||||||
|
|
||||||
return caps;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static GstCaps *
|
|
||||||
gst_videotestsrc_getcaps (GstBaseSrc * bsrc)
|
|
||||||
{
|
|
||||||
GstVideotestsrc *vts;
|
|
||||||
|
|
||||||
vts = GST_VIDEOTESTSRC (bsrc);
|
|
||||||
|
|
||||||
return gst_videotestsrc_get_capslist ();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_videotestsrc_init (GstVideotestsrc * videotestsrc)
|
|
||||||
{
|
|
||||||
gst_videotestsrc_set_pattern (videotestsrc, GST_VIDEOTESTSRC_SMPTE);
|
|
||||||
|
|
||||||
videotestsrc->num_buffers = -1;
|
|
||||||
videotestsrc->num_buffers_left = -1;
|
|
||||||
videotestsrc->segment_start_frame = -1;
|
|
||||||
videotestsrc->segment_end_frame = -1;
|
|
||||||
videotestsrc->timestamp_offset = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_videotestsrc_event (GstBaseSrc * bsrc, GstEvent * event)
|
gst_videotestsrc_event (GstBaseSrc * bsrc, GstEvent * event)
|
||||||
{
|
{
|
||||||
gboolean res = TRUE;
|
gboolean res = TRUE;
|
||||||
GstVideotestsrc *videotestsrc;
|
GstVideoTestSrc *videotestsrc;
|
||||||
gint64 new_n_frames;
|
gint64 new_n_frames;
|
||||||
|
|
||||||
videotestsrc = GST_VIDEOTESTSRC (bsrc);
|
videotestsrc = GST_VIDEOTESTSRC (bsrc);
|
||||||
|
@ -440,7 +380,7 @@ gst_videotestsrc_event (GstBaseSrc * bsrc, GstEvent * event)
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_videotestsrc_create (GstPushSrc * psrc, GstBuffer ** buffer)
|
gst_videotestsrc_create (GstPushSrc * psrc, GstBuffer ** buffer)
|
||||||
{
|
{
|
||||||
GstVideotestsrc *videotestsrc;
|
GstVideoTestSrc *videotestsrc;
|
||||||
gulong newsize;
|
gulong newsize;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
GstFlowReturn res;
|
GstFlowReturn res;
|
||||||
|
@ -490,104 +430,14 @@ no_buffer:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_videotestsrc_start (GstBaseSrc * src)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_videotestsrc_stop (GstBaseSrc * src)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_videotestsrc_get_times (GstBaseSrc * src, GstBuffer * buffer,
|
|
||||||
GstClockTime * start, GstClockTime * end)
|
|
||||||
{
|
|
||||||
*start = GST_CLOCK_TIME_NONE;
|
|
||||||
*end = GST_CLOCK_TIME_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_videotestsrc_set_pattern (GstVideotestsrc * videotestsrc, int pattern_type)
|
|
||||||
{
|
|
||||||
videotestsrc->pattern_type = pattern_type;
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (videotestsrc, "setting pattern to %d", pattern_type);
|
|
||||||
switch (pattern_type) {
|
|
||||||
case GST_VIDEOTESTSRC_SMPTE:
|
|
||||||
videotestsrc->make_image = gst_videotestsrc_smpte;
|
|
||||||
break;
|
|
||||||
case GST_VIDEOTESTSRC_SNOW:
|
|
||||||
videotestsrc->make_image = gst_videotestsrc_snow;
|
|
||||||
break;
|
|
||||||
case GST_VIDEOTESTSRC_BLACK:
|
|
||||||
videotestsrc->make_image = gst_videotestsrc_black;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_videotestsrc_set_property (GObject * object, guint prop_id,
|
|
||||||
const GValue * value, GParamSpec * pspec)
|
|
||||||
{
|
|
||||||
GstVideotestsrc *videotestsrc;
|
|
||||||
|
|
||||||
g_return_if_fail (GST_IS_VIDEOTESTSRC (object));
|
|
||||||
videotestsrc = GST_VIDEOTESTSRC (object);
|
|
||||||
|
|
||||||
switch (prop_id) {
|
|
||||||
case ARG_TYPE:
|
|
||||||
gst_videotestsrc_set_pattern (videotestsrc, g_value_get_enum (value));
|
|
||||||
break;
|
|
||||||
case ARG_NUM_BUFFERS:
|
|
||||||
videotestsrc->num_buffers = g_value_get_int (value);
|
|
||||||
break;
|
|
||||||
case ARG_TIMESTAMP_OFFSET:
|
|
||||||
videotestsrc->timestamp_offset = g_value_get_int64 (value);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_videotestsrc_get_property (GObject * object, guint prop_id, GValue * value,
|
|
||||||
GParamSpec * pspec)
|
|
||||||
{
|
|
||||||
GstVideotestsrc *videotestsrc;
|
|
||||||
|
|
||||||
g_return_if_fail (GST_IS_VIDEOTESTSRC (object));
|
|
||||||
videotestsrc = GST_VIDEOTESTSRC (object);
|
|
||||||
|
|
||||||
switch (prop_id) {
|
|
||||||
case ARG_TYPE:
|
|
||||||
g_value_set_enum (value, videotestsrc->pattern_type);
|
|
||||||
break;
|
|
||||||
case ARG_NUM_BUFFERS:
|
|
||||||
g_value_set_int (value, videotestsrc->num_buffers);
|
|
||||||
break;
|
|
||||||
case ARG_TIMESTAMP_OFFSET:
|
|
||||||
g_value_set_int64 (value, videotestsrc->timestamp_offset);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
plugin_init (GstPlugin * plugin)
|
plugin_init (GstPlugin * plugin)
|
||||||
{
|
{
|
||||||
oil_init ();
|
oil_init ();
|
||||||
|
|
||||||
generate_capslist ();
|
GST_DEBUG_CATEGORY_INIT (videotestsrc_debug, "videotestsrc", 0,
|
||||||
|
"Video Test Source");
|
||||||
|
|
||||||
return gst_element_register (plugin, "videotestsrc", GST_RANK_NONE,
|
return gst_element_register (plugin, "videotestsrc", GST_RANK_NONE,
|
||||||
GST_TYPE_VIDEOTESTSRC);
|
GST_TYPE_VIDEOTESTSRC);
|
||||||
|
|
|
@ -29,9 +29,9 @@ G_BEGIN_DECLS
|
||||||
#define GST_TYPE_VIDEOTESTSRC \
|
#define GST_TYPE_VIDEOTESTSRC \
|
||||||
(gst_videotestsrc_get_type())
|
(gst_videotestsrc_get_type())
|
||||||
#define GST_VIDEOTESTSRC(obj) \
|
#define GST_VIDEOTESTSRC(obj) \
|
||||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEOTESTSRC,GstVideotestsrc))
|
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEOTESTSRC,GstVideoTestSrc))
|
||||||
#define GST_VIDEOTESTSRC_CLASS(klass) \
|
#define GST_VIDEOTESTSRC_CLASS(klass) \
|
||||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VIDEOTESTSRC,GstVideotestsrc))
|
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VIDEOTESTSRC,GstVideoTestSrc))
|
||||||
#define GST_IS_VIDEOTESTSRC(obj) \
|
#define GST_IS_VIDEOTESTSRC(obj) \
|
||||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEOTESTSRC))
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEOTESTSRC))
|
||||||
#define GST_IS_VIDEOTESTSRC_CLASS(obj) \
|
#define GST_IS_VIDEOTESTSRC_CLASS(obj) \
|
||||||
|
@ -41,16 +41,16 @@ typedef enum {
|
||||||
GST_VIDEOTESTSRC_SMPTE,
|
GST_VIDEOTESTSRC_SMPTE,
|
||||||
GST_VIDEOTESTSRC_SNOW,
|
GST_VIDEOTESTSRC_SNOW,
|
||||||
GST_VIDEOTESTSRC_BLACK,
|
GST_VIDEOTESTSRC_BLACK,
|
||||||
} GstVideotestsrcPattern;
|
} GstVideoTestSrcPattern;
|
||||||
|
|
||||||
typedef struct _GstVideotestsrc GstVideotestsrc;
|
typedef struct _GstVideoTestSrc GstVideoTestSrc;
|
||||||
typedef struct _GstVideotestsrcClass GstVideotestsrcClass;
|
typedef struct _GstVideoTestSrcClass GstVideoTestSrcClass;
|
||||||
|
|
||||||
struct _GstVideotestsrc {
|
struct _GstVideoTestSrc {
|
||||||
GstPushSrc element;
|
GstPushSrc element;
|
||||||
|
|
||||||
/* type of output */
|
/* type of output */
|
||||||
GstVideotestsrcPattern pattern_type;
|
GstVideoTestSrcPattern pattern_type;
|
||||||
|
|
||||||
/* video state */
|
/* video state */
|
||||||
char *format_name;
|
char *format_name;
|
||||||
|
@ -64,20 +64,18 @@ struct _GstVideotestsrc {
|
||||||
gint64 timestamp_offset; /* base offset */
|
gint64 timestamp_offset; /* base offset */
|
||||||
GstClockTime running_time; /* total running time */
|
GstClockTime running_time; /* total running time */
|
||||||
gint64 n_frames; /* total frames sent */
|
gint64 n_frames; /* total frames sent */
|
||||||
GstClock *clock;
|
|
||||||
gint num_buffers, num_buffers_left;
|
|
||||||
gint64 segment_start_frame;
|
gint64 segment_start_frame;
|
||||||
gint64 segment_end_frame;
|
gint64 segment_end_frame;
|
||||||
gboolean segment;
|
gboolean segment;
|
||||||
|
|
||||||
void (*make_image) (GstVideotestsrc *v, unsigned char *dest, int w, int h);
|
void (*make_image) (GstVideoTestSrc *v, unsigned char *dest, int w, int h);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstVideotestsrcClass {
|
struct _GstVideoTestSrcClass {
|
||||||
GstPushSrcClass parent_class;
|
GstPushSrcClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gst_videotestsrc_get_type (void) G_GNUC_CONST;
|
GType gst_videotestsrc_get_type (void);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -493,9 +493,9 @@ paint_get_structure (struct fourcc_list_struct * format)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns the size in bytes for one video frame of the given dimensions
|
/* returns the size in bytes for one video frame of the given dimensions
|
||||||
* given the fourcc in GstVideotestsrc */
|
* given the fourcc in GstVideoTestSrc */
|
||||||
int
|
int
|
||||||
gst_videotestsrc_get_size (GstVideotestsrc * v, int w, int h)
|
gst_videotestsrc_get_size (GstVideoTestSrc * v, int w, int h)
|
||||||
{
|
{
|
||||||
paintinfo pi = { 0 };
|
paintinfo pi = { 0 };
|
||||||
paintinfo *p = π
|
paintinfo *p = π
|
||||||
|
@ -513,7 +513,7 @@ gst_videotestsrc_get_size (GstVideotestsrc * v, int w, int h)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_videotestsrc_smpte (GstVideotestsrc * v, unsigned char *dest, int w, int h)
|
gst_videotestsrc_smpte (GstVideoTestSrc * v, unsigned char *dest, int w, int h)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int y1, y2;
|
int y1, y2;
|
||||||
|
@ -622,7 +622,7 @@ gst_videotestsrc_smpte (GstVideotestsrc * v, unsigned char *dest, int w, int h)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_videotestsrc_snow (GstVideotestsrc * v, unsigned char *dest, int w, int h)
|
gst_videotestsrc_snow (GstVideoTestSrc * v, unsigned char *dest, int w, int h)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
|
@ -656,7 +656,7 @@ gst_videotestsrc_snow (GstVideotestsrc * v, unsigned char *dest, int w, int h)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_videotestsrc_black (GstVideotestsrc * v, unsigned char *dest, int w, int h)
|
gst_videotestsrc_black (GstVideoTestSrc * v, unsigned char *dest, int w, int h)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
paintinfo pi;
|
paintinfo pi;
|
||||||
|
|
|
@ -65,12 +65,12 @@ struct fourcc_list_struct *
|
||||||
paintinfo_find_by_structure (const GstStructure *structure);
|
paintinfo_find_by_structure (const GstStructure *structure);
|
||||||
GstStructure *
|
GstStructure *
|
||||||
paint_get_structure (struct fourcc_list_struct *format);
|
paint_get_structure (struct fourcc_list_struct *format);
|
||||||
int gst_videotestsrc_get_size (GstVideotestsrc * v, int w, int h);
|
int gst_videotestsrc_get_size (GstVideoTestSrc * v, int w, int h);
|
||||||
void gst_videotestsrc_smpte (GstVideotestsrc * v,
|
void gst_videotestsrc_smpte (GstVideoTestSrc * v,
|
||||||
unsigned char *dest, int w, int h);
|
unsigned char *dest, int w, int h);
|
||||||
void gst_videotestsrc_snow (GstVideotestsrc * v,
|
void gst_videotestsrc_snow (GstVideoTestSrc * v,
|
||||||
unsigned char *dest, int w, int h);
|
unsigned char *dest, int w, int h);
|
||||||
void gst_videotestsrc_black (GstVideotestsrc * v,
|
void gst_videotestsrc_black (GstVideoTestSrc * v,
|
||||||
unsigned char *dest, int w, int h);
|
unsigned char *dest, int w, int h);
|
||||||
|
|
||||||
extern struct fourcc_list_struct fourcc_list[];
|
extern struct fourcc_list_struct fourcc_list[];
|
||||||
|
|
Loading…
Reference in a new issue