[gst-devel] GStreamer-CRITICAL **: gst_clock_get_time: assertion 'GST_IS_CLOCK(clock)' failed
junghak kim
spk9012 at gmail.com
Mon Sep 25 05:19:18 CEST 2006
I'm trygin to make a simple plug-in to test pipeline with webcam using
v4lsrc.
But, It emits the error message below iteratively.
(gst-launch-0.10:21050): GStreamer-CRITICAL **: gst_clock_get_time:
assertion 'GST_IS_CLOCK(clock)' failed
I followed the basic build process for new plugin.
$ make-element new-plugin-name
$ make
$ make install
Please find my attached source codes and reply.
Thanks alot..
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20060925/c0d49b5d/attachment.htm>
-------------- next part --------------
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gst/gst.h>
#include "gstcamcorderbin.h"
GST_DEBUG_CATEGORY_STATIC (gst_camcorder_bin_debug);
#define GST_CAT_DEFAULT gst_camcorder_bin_debug
#define VOLUME_MAX_DOUBLE 4.0
#ifndef GST_HAVE_GLIB_2_8
#define _gst_gvalue_set_gstobject(gvalue,obj) \
if (obj != NULL) { \
gst_object_ref (obj); \
g_value_set_object (gvalue, obj); \
g_object_unref (obj); \
} else { \
g_value_set_object (gvalue, NULL); \
}
#else
#define _gst_gvalue_set_gstobject(gvalue,obj) \
g_value_set_object (gvalue, obj);
#endif
/* Filter signals and args */
enum
{
/* FILL ME */
LAST_SIGNAL
};
enum
{
ARG_0,
ARG_VIDEO_SRC,
};
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("ANY")
);
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("ANY")
);
GST_BOILERPLATE (GstCamcorderBin, gst_camcorder_bin, GstElement,
GST_TYPE_PIPELINE);
static void gst_camcorder_bin_dispose (GObject * object);
static void gst_camcorder_bin_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_camcorder_bin_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static GstStateChangeReturn gst_camcorder_bin_change_state (GstElement * element,
GstStateChange transition);
static GstFlowReturn gst_camcorder_bin_chain (GstPad * pad, GstBuffer * buf);
static gboolean gen_video_elements(GstCamcorderBin* camcorder_bin);
static void
gst_camcorder_bin_base_init (gpointer gclass)
{
static GstElementDetails element_details = {
"camcorder Bin",
"Generic/Bin/camcorder",
"A/V Recording from devices and streams",
"Junghak Kim <kjh5 at samsung.com>"
};
GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&src_factory));
gst_element_class_set_details (element_class, &element_details);
}
/* initialize the plugin's class */
static void
gst_camcorder_bin_class_init(GstCamcorderBinClass* klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gobject_class->set_property = gst_camcorder_bin_set_property;
gobject_class->get_property = gst_camcorder_bin_get_property;
g_object_class_install_property (gobject_class, ARG_VIDEO_SRC,
g_param_spec_object ("video-src", "Video Source",
"the video input element to use (NULL = default sink)",
GST_TYPE_ELEMENT, G_PARAM_READWRITE));
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_camcorder_bin_dispose);
gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_camcorder_bin_change_state);
}
static void
gst_camcorder_bin_init (GstCamcorderBin* camcorder_bin,
GstCamcorderBinClass* gclass)
{
//GstElementClass *klass = GST_ELEMENT_GET_CLASS (camcorder_bin);
camcorder_bin->v_enc_bin = NULL;
camcorder_bin->video_src = NULL;
camcorder_bin->video_sink = NULL;
gen_video_elements(camcorder_bin);
}
static void
gst_camcorder_bin_clean_elements(GstCamcorderBin* camcorder_bin)
{
if (camcorder_bin->v_enc_bin)
gst_object_unref(camcorder_bin->v_enc_bin);
if (camcorder_bin->video_sink)
gst_object_unref(camcorder_bin->video_sink);
}
static void
gst_camcorder_bin_dispose (GObject * object)
{
GstCamcorderBin *camcorder_bin;
camcorder_bin = GST_CAMCORDER_BIN(object);
gst_camcorder_bin_clean_elements(camcorder_bin);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
gst_camcorder_bin_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstCamcorderBin *camcorder_bin = NULL;
g_return_if_fail (GST_IS_CAMCORDER_BIN (object));
camcorder_bin = GST_CAMCORDER_BIN (object);
switch (prop_id) {
case ARG_VIDEO_SRC:
if (camcorder_bin->video_src != NULL)
{
gst_object_unref (camcorder_bin->video_src);
}
camcorder_bin->video_src = g_value_get_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_camcorder_bin_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstCamcorderBin *camcorder_bin = NULL;
g_return_if_fail (GST_IS_CAMCORDER_BIN (object));
camcorder_bin = GST_CAMCORDER_BIN (object);
switch (prop_id) {
case ARG_VIDEO_SRC:
_gst_gvalue_set_gstobject (value, camcorder_bin->video_src);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static gboolean
gen_video_elements(GstCamcorderBin* camcorder_bin)
{
if (camcorder_bin->v_enc_bin == NULL)
{
camcorder_bin->v_enc_bin = gst_bin_new ("v_enc_bin");
if (camcorder_bin->v_enc_bin == NULL)
g_printf("%s(%d): Failed to make a bin element for video encoding.\n", __FILE__, __LINE__);
}
camcorder_bin->video_src = gst_element_factory_make ("v4lsrc", "videosrc");
if (camcorder_bin->video_src == NULL)
g_printf("%s(%d): Both v4lsrc and videotestsrc elements are missing.\n", __FILE__, __LINE__);
g_object_set(G_OBJECT(camcorder_bin->video_src), "device", "/dev/video0", NULL);
g_object_set(G_OBJECT(camcorder_bin->video_src), "num-buffers", 250, NULL);
gst_element_set_state (camcorder_bin->video_src, GST_STATE_NULL);
camcorder_bin->video_sink = gst_element_factory_make("sdlvideosink", "video_sink");
if (camcorder_bin->video_sink == NULL);
g_printf("%s(%d): Failed to make a sdlvideosink element.\n", __FILE__, __LINE__);
gst_element_set_state (camcorder_bin->video_sink, GST_STATE_NULL);
return TRUE;
}
static gboolean
link_video_elements(GstCamcorderBin* camcorder_bin)
{
GstPad *pad;
GstCaps* caps;
caps = gst_caps_new_simple("video/x-raw-yuv",
"format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
"width", G_TYPE_INT, 176,
"height", G_TYPE_INT, 144,
NULL);
gst_bin_add_many(GST_BIN(camcorder_bin->v_enc_bin),
camcorder_bin->video_src,
camcorder_bin->video_sink,
NULL);
if (!gst_element_link_filtered(camcorder_bin->video_src, camcorder_bin->video_sink, caps))
g_printf("%s(%d): Failed in gst_element_link_filtered.\n", __FILE__, __LINE__);
if (caps != NULL)
gst_caps_unref(caps);
return TRUE;
}
gboolean
gst_camcorder_bin_link(GstCamcorderBin* camcorder_bin)
{
if (link_video_elements(camcorder_bin) == NULL)
g_printf("%s(%d): Failed to create a v_enc_bin.\n", __FILE__, __LINE__);
gst_element_set_state (camcorder_bin->v_enc_bin, GST_STATE_READY);
return TRUE;
}
static GstStateChangeReturn
gst_camcorder_bin_change_state (GstElement * element, GstStateChange transition)
{
GstStateChangeReturn ret;
GstCamcorderBin *camcorder_bin;
camcorder_bin = GST_CAMCORDER_BIN (element);
switch (transition)
{
case GST_STATE_CHANGE_NULL_TO_READY:
gst_camcorder_bin_link(camcorder_bin);
break;
case GST_STATE_CHANGE_READY_TO_NULL:
if (camcorder_bin->v_enc_bin != NULL)
{
gst_camcorder_bin_clean_elements(camcorder_bin);
gst_element_set_state(camcorder_bin->v_enc_bin, GST_STATE_NULL);
}
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
break;
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
gst_element_set_state (camcorder_bin->v_enc_bin, GST_STATE_PLAYING);
break;
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
gst_element_set_state (camcorder_bin->v_enc_bin, GST_STATE_PAUSED);
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
if (camcorder_bin->v_enc_bin)
gst_camcorder_bin_clean_elements(camcorder_bin);
break;
default:
break;
}
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
if (ret == GST_STATE_CHANGE_FAILURE)
return ret;
switch (transition) {
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
break;
default:
break;
}
return ret;
}
static gboolean
plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (gst_camcorder_bin_debug, "camcorderbin",
0, "camcorder bin");
return gst_element_register (plugin, "camcorderbin",
GST_RANK_NONE, GST_TYPE_CAMCORDER_BIN);
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"camcorderbin",
"camcorder bin",
plugin_init, VERSION, "LGPL", "GStreamer", "http://gstreamer.net/")
-------------- next part --------------
#ifndef __GST_CAMCORDER_BIN_H__
#define __GST_CAMCORDER_BIN_H__
#include <gst/gst.h>
G_BEGIN_DECLS
/* #defines don't like whitespacey bits */
#define GST_TYPE_CAMCORDER_BIN \
(gst_camcorder_bin_get_type())
#define GST_CAMCORDER_BIN(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CAMCORDER_BIN,GstCamcorderBin))
#define GST_CAMCORDER_BIN_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CAMCORDER_BIN,GstCamcorderBinClass))
#define GST_IS_CAMCORDER_BIN(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CAMCORDER_BIN))
#define GST_IS_CAMCORDER_BIN_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CAMCORDER_BIN))
typedef struct _GstCamcorderBin GstCamcorderBin;
typedef struct _GstCamcorderBinClass GstCamcorderBinClass;
struct _GstCamcorderBin
{
GstPipeline pipeline;
GstElement *v_enc_bin;
GstElement *video_src, *video_sink;
};
struct _GstCamcorderBinClass
{
GstPipelineClass parent_class;
};
GType gst_camcorder_bin_get_type (void);
G_END_DECLS
#endif /* __GST_CAMCORDER_BIN_H__ */
More information about the gstreamer-devel
mailing list