Revision: 274
http://artoolkit.svn.sourceforge.net/artoolkit/?rev=274&view=rev
Author: retrakker
Date: 2007-11-19 01:29:38 -0800 (Mon, 19 Nov 2007)
Log Message:
-----------
Attempt to fix GStreamer capture with newest GStreamer > 0.10.11
Modified Paths:
--------------
trunk/artoolkit/lib/SRC/VideoGStreamer/video.c
Modified: trunk/artoolkit/lib/SRC/VideoGStreamer/video.c
===================================================================
--- trunk/artoolkit/lib/SRC/VideoGStreamer/video.c 2007-11-06 20:33:30 UTC (rev 273)
+++ trunk/artoolkit/lib/SRC/VideoGStreamer/video.c 2007-11-19 09:29:38 UTC (rev 274)
@@ -23,29 +23,30 @@
struct _AR2VideoParamT {
+
+ /* size of the image */
+ int width, height;
+ /* the actual video buffer */
+ ARUint8 *videoBuffer;
+
/* GStreamer pipeline */
GstElement *pipeline;
/* GStreamer identity needed for probing */
GstElement *probe;
-
- /* size of the image */
- int width, height;
- /* the actual video buffer */
- ARUint8 *videoBuffer;
-
};
-static AR2VideoParamT *gVid = 0;
+static AR2VideoParamT *gVid = NULL;
static gboolean
cb_have_data (GstPad *pad,
GstBuffer *buffer,
gpointer u_data)
{
+
const GstCaps *caps;
GstStructure *str;
@@ -53,10 +54,12 @@
gdouble rate;
AR2VideoParamT *vid = (AR2VideoParamT*)u_data;
+
+ if (vid == NULL) return FALSE;
/* only do initialy for the buffer */
- if (vid->videoBuffer == 0)
+ if (vid->videoBuffer == NULL && buffer)
{
/*
@@ -70,23 +73,22 @@
gst_structure_get_int(str,"width",&width);
gst_structure_get_int(str,"height",&height);
gst_structure_get_double(str,"framerate",&rate);
-
- g_print("libARvideo: GStreamer negotiated %dx%d\n",width,height);
vid->width = width;
vid->height = height;
+
+ g_print("libARvideo: GStreamer negotiated %dx%d (size: %d / expected: %d)\n",width,height,buffer->size, (vid->width * vid->height * AR_PIX_SIZE_DEFAULT) );
/* allocate the buffer */
- vid->videoBuffer = malloc(buffer->size);
+
+ arMalloc(vid->videoBuffer, ARUint8, (vid->width * vid->height * AR_PIX_SIZE_DEFAULT) );
- return TRUE;
-
}
- else
+
+ if (vid->videoBuffer)
{
- /* copy the video buffer */
- memcpy(vid->videoBuffer, buffer->data, buffer->size);
- }
+ memcpy(vid->videoBuffer, buffer->data, buffer->size);
+ }
return TRUE;
}
@@ -213,7 +215,7 @@
arMalloc( vid, AR2VideoParamT, 1 );
/* initialise buffer */
- vid->videoBuffer = 0;
+ vid->videoBuffer = NULL;
/* report the current version and features */
g_print ("libARvideo: %s\n", gst_version_string());
@@ -253,11 +255,12 @@
/* install the probe callback for capturing */
+
gst_pad_add_buffer_probe (pad, G_CALLBACK (cb_have_data), vid);
+
+ /* gst_object_unref(pad);*/
-
-
#if 0
/* request ready state */
gst_element_set_state (vid->pipeline, GST_STATE_READY);
@@ -288,10 +291,15 @@
}
/* now preroll for V4L v2 interfaces */
- if ((strstr(config, "v4l2src") != 0) ||
+ if (
+ (strstr(config, "v4l2src") != 0) ||
(strstr(config, "dv1394src") != 0) ||
- (strstr(config, "rtspsrc") != 0) )
+ (strstr(config, "rtspsrc") != 0) /* ||
+ (strstr(config, "videotestsrc") != 0) */)
{
+
+ g_print ("libARvdeo: need special prerolling for GStreamer\n");
+
/* set playing state of the pipeline */
gst_element_set_state (vid->pipeline, GST_STATE_PLAYING);
@@ -388,3 +396,4 @@
*y = vid->height; // height of your static image
}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|