[gst-devel] segmentation fault creating a cap
25fps 48kHz
the.nox at gmail.com
Tue Jan 2 23:36:12 CET 2007
Hi !
First of all, happy new year !
I am learning, and with this purpose I'm trying to code a very simple
application -- gst-launch-0.10 v4lsrc ! xvimagesink -- to simply play
with my webcam. It was more or less easy, but I noticed that, by
default, the image was very little (QCIF, 176x144). I managed to
isolate the issue in the webcam because the same code with a
bttv-driven TV card in another computer showed me a normal-sized TV
window.
So, the first thing I made was to test the webcam with 3rd-party apps
to verify its max. capable size. Well, tests reported that 320x240
would be the safe bet. Easier done than said ! ;) Let's modify the
previous command a bit, and check if gstreamer complaints about
anything: gst-launch-0.10 v4lsrc !
video/x-raw-yuv,width=320,height=240,format:fourcc=I420,framerate:double=25
! xvimagesink
It worked! So, i put my hands on punching some keys and modify the app
to apply those properties to the cap. That led me to the segmentation
fault I mentioned in the subject. I have attached below the code of
the app (I can trace the segfault with gdb if desired). I can override
the segmentation fault if, instead of using gst_caps_new_simple(), i
create the cap with gst_caps_new_full(). But this workaround does not
resize the image.
As I am learning, I would kindly ask you to throw me hints instead of
direct solutions, if any. My guess is that the cap I am creating is
not fixed (because using gst_caps_new_full() to create the cap doesn't
link pad and cap properly, and i get this error in stdout:
GStreamer-CRITICAL **: gst_pad_set_caps: assertion `caps == NULL ||
gst_caps_is_fixed (caps)' failed ) . But I haven't been able to locate
a way to create a fixed cap. Core Reference Manual says that "A
GstCaps is fixed when it has no properties with ranges or lists", but
maybe i'm not understanding the concept as I haven't identified a
function in GStreamer 0.10 to create it (only to check if is fixed or
not).
Thank you very much. Best regards,
____________
So, the execution of the following piece of code printed in stdout
GLib-GObject-WARNING **: can't peek value table for type `(null)'
which is not currently referenced
GLib-GObject-WARNING **: gvalue.c:96: cannot initialize GValue with
type `(null)', this type has no GTypeValueTable implementation
GLib-GObject-WARNING **: gtype.c:3337: type id `0' is invalid
GLib-GObject-WARNING **: can't peek value table for type `<invalid>'
which is not currently referenced
Segmentation fault
And the code is as follows:
============================
main.c
#include "include/camotion.h"
#include <stdio.h>
#include <gst/gst.h>
#include <glib.h>
int
main (int argc, char *argv[])
{
GstElement *pipeline = NULL, *webCam = NULL, *videoSink = NULL;
GMainLoop *loop;
GstBus *bus;
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
g_print ("gst-launch-0.10 v4lsrc !
video/x-raw-yuv,width=320,height=240,format:fourcc=I420,framerate:double=25
! xvimagesink\n");
if (!pipeline)
pipeline = gst_pipeline_new ("pipeline");
if (!webCam)
webCam = gst_element_factory_make ("v4lsrc", "webCam");
if (!videoSink)
videoSink = gst_element_factory_make ("xvimagesink", "videoSink");
bus = gst_pipeline_get_bus (GST_PIPELINE(pipeline));
gst_bus_add_watch (bus, bus_call, NULL);
gst_object_unref (bus);
gst_element_set_state (pipeline, GST_STATE_PAUSED);
gst_bin_add_many (GST_BIN(pipeline), webCam, videoSink, NULL);
/* link */
if (!link_with_filter (webCam, videoSink))
{
g_warning ("Failed to link elements!");
}
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print ("Running\n");
g_main_loop_run (loop);
/* Clean up nicely */
g_print ("Returned, stopping playback\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Deleting pipeline\n");
/* Unreferencing the BIN destroys its contained elements */
gst_object_unref (GST_OBJECT (pipeline));
gst_object_unref (GST_OBJECT (loop));
return 0;
}
==========================
include/camotion.h
#include <stdio.h>
#include <stdlib.h>
#include <gst/gst.h>
#include <glib.h>
static gboolean
bus_call (GstBus *bus, GstMessage *msg, gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_EOS:
g_print ("End-of-stream\n");
g_main_loop_quit (loop);
break;
case GST_MESSAGE_ERROR: {
gchar *debug;
GError *err;
gst_message_parse_error (msg, &err, &debug);
g_free (debug);
g_print ("Error: %s\n", err->message);
g_error_free (err);
g_main_loop_quit (loop);
break;
}
default:
break;
}
return TRUE;
}
static gboolean
link_with_filter(GstElement *src_wc, GstElement *sink_xv){
GstCaps *caps;
GstPad *src_pad, *sink_pad;
src_pad = gst_element_get_pad (src_wc, "src");
sink_pad = gst_element_get_pad (sink_xv, "sink");
/* Creating filter for the elements */
caps = gst_caps_new_simple ("video/x-raw-yuv",
"width", G_TYPE_INT, 320,
"height", G_TYPE_INT, 240,
"format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
"framerate", G_TYPE_DOUBLE,25,
NULL);
gst_pad_set_caps (sink_pad, caps);
/* Link the pads */
gst_pad_link (src_pad, sink_pad);
return TRUE;
}
More information about the gstreamer-devel
mailing list