From 9c1e52ad11a587a24d75728281226e6d2436496a Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Mon, 9 Sep 2002 07:12:29 +0000 Subject: [PATCH] This patch: 1) would provide v4l2 plugins, if only the CVS server wouldn't bork on all commits :-(. This patch will c... Original commit message from CVS: This patch: 1) would provide v4l2 plugins, if only the CVS server wouldn't bork on all commits :-(. This patch will come later on in a separate commit when SF fixes her repository. 2) it fixes capsnego for all the video4linux1 plugins 3) it rewrites the debugging of all v4l1 plugins, which now make use of the standard gstreamer debugging features (gst-mask=...). This should make debugging video4linux1/gstreamer problems much easier then it used to be. VS: ---------------------------------------------------------------------- --- common | 2 +- sys/v4l/gstv4lmjpegsink.c | 23 ++++++---- sys/v4l/gstv4lmjpegsrc.c | 99 +++++++++++++++++++++++++------------------- sys/v4l/gstv4lmjpegsrc.h | 4 +- sys/v4l/gstv4lsrc.c | 93 +++++++++-------------------------------- sys/v4l/gstv4lsrc.h | 4 +- sys/v4l/v4l_calls.c | 82 +++++++++--------------------------- sys/v4l/v4l_calls.h | 2 +- sys/v4l/v4lmjpegsink_calls.c | 75 +++++++++------------------------ sys/v4l/v4lmjpegsrc_calls.c | 75 +++++++++------------------------ sys/v4l/v4lsrc_calls.c | 86 +++++++++++--------------------------- 11 files changed, 183 insertions(+), 362 deletions(-) diff --git a/common b/common index 355c616..2f6d9cf 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 355c616d5f6779ea194f8b61704229c6fb04ae7b +Subproject commit 2f6d9cfdaaa83ab454d263d6eba88046debadc2d diff --git a/sys/v4l/gstv4lmjpegsink.c b/sys/v4l/gstv4lmjpegsink.c index a91b168..b71645b 100644 --- a/sys/v4l/gstv4lmjpegsink.c +++ b/sys/v4l/gstv4lmjpegsink.c @@ -188,6 +188,12 @@ gst_v4lmjpegsink_sinkconnect (GstPad *pad, if (!GST_CAPS_IS_FIXED (vscapslist) || !GST_V4L_IS_OPEN(GST_V4LELEMENT(v4lmjpegsink))) return GST_PAD_CONNECT_DELAYED; + /* in case the buffers are active (which means that we already + * did capsnego before and didn't clean up), clean up anyways */ + if (GST_V4L_IS_ACTIVE(GST_V4LELEMENT(v4lmjpegsink))) + if (!gst_v4lmjpegsink_playback_deinit(v4lmjpegsink)) + return GST_PAD_CONNECT_REFUSED; + for (caps = vscapslist; caps != NULL; caps = vscapslist = vscapslist->next) { gst_caps_get_int (caps, "width", &v4lmjpegsink->width); @@ -199,6 +205,13 @@ gst_v4lmjpegsink_sinkconnect (GstPad *pad, GST_V4LELEMENT(v4lmjpegsink)->norm, 0)) /* TODO: interlacing */ continue; + /* set buffer info */ + if (!gst_v4lmjpegsink_set_buffer(v4lmjpegsink, + v4lmjpegsink->numbufs, v4lmjpegsink->bufsize)) + continue; + if (!gst_v4lmjpegsink_playback_init(v4lmjpegsink)) + continue; + g_signal_emit (G_OBJECT (v4lmjpegsink), gst_v4lmjpegsink_signals[SIGNAL_HAVE_SIZE], 0, v4lmjpegsink->width, v4lmjpegsink->height); @@ -243,7 +256,7 @@ gst_v4lmjpegsink_chain (GstPad *pad, gst_element_clock_wait(GST_ELEMENT(v4lmjpegsink), v4lmjpegsink->clock, GST_BUFFER_TIMESTAMP(buf), NULL); } - + /* check size */ if (GST_BUFFER_SIZE(buf) > v4lmjpegsink->breq.size) { @@ -342,12 +355,8 @@ gst_v4lmjpegsink_change_state (GstElement *element) /* set up change state */ switch (GST_STATE_TRANSITION(element)) { case GST_STATE_READY_TO_PAUSED: - /* set buffer info */ - if (!gst_v4lmjpegsink_set_buffer(v4lmjpegsink, - v4lmjpegsink->numbufs, v4lmjpegsink->bufsize)) - return GST_STATE_FAILURE; - if (!gst_v4lmjpegsink_playback_init(v4lmjpegsink)) - return GST_STATE_FAILURE; + /* we used to do buffer setup here, but that's now done + * right after capsnego */ break; case GST_STATE_PAUSED_TO_PLAYING: /* start */ diff --git a/sys/v4l/gstv4lmjpegsrc.c b/sys/v4l/gstv4lmjpegsrc.c index f935282..6322727 100644 --- a/sys/v4l/gstv4lmjpegsrc.c +++ b/sys/v4l/gstv4lmjpegsrc.c @@ -206,8 +206,6 @@ gst_v4lmjpegsrc_init (GstV4lMjpegSrc *v4lmjpegsrc) v4lmjpegsrc->numbufs = 64; v4lmjpegsrc->bufsize = 256; - - v4lmjpegsrc->capslist = capslist; } @@ -219,7 +217,55 @@ gst_v4lmjpegsrc_srcconnect (GstPad *pad, v4lmjpegsrc = GST_V4LMJPEGSRC (gst_pad_get_parent (pad)); - /* we will try_set_caps() with the actual size (wxh) when we know it */ + /* in case the buffers are active (which means that we already + * did capsnego before and didn't clean up), clean up anyways */ + if (GST_V4L_IS_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc))) + if (!gst_v4lmjpegsrc_capture_deinit(v4lmjpegsrc)) + return GST_PAD_CONNECT_REFUSED; + + /* Note: basically, we don't give a damn about the opposite caps here. + * that might seem odd, but it isn't. we know that the opposite caps is + * either NULL or has mime type video/jpeg, and in both cases, we'll set + * our own mime type back and it'll work. Other properties are to be set + * by the src, not by the opposite caps */ + + /* set buffer info */ + if (!gst_v4lmjpegsrc_set_buffer(v4lmjpegsrc, v4lmjpegsrc->numbufs, v4lmjpegsrc->bufsize)) + return GST_PAD_CONNECT_REFUSED; + + /* set capture parameters and mmap the buffers */ + if (!v4lmjpegsrc->frame_width && !v4lmjpegsrc->frame_height && + v4lmjpegsrc->x_offset < 0 && v4lmjpegsrc->y_offset < 0 && + v4lmjpegsrc->horizontal_decimation == v4lmjpegsrc->vertical_decimation) + { + if (!gst_v4lmjpegsrc_set_capture(v4lmjpegsrc, + v4lmjpegsrc->horizontal_decimation, v4lmjpegsrc->quality)) + return GST_PAD_CONNECT_REFUSED; + } + else + { + if (!gst_v4lmjpegsrc_set_capture_m(v4lmjpegsrc, + v4lmjpegsrc->x_offset, v4lmjpegsrc->y_offset, + v4lmjpegsrc->frame_width, v4lmjpegsrc->frame_height, + v4lmjpegsrc->horizontal_decimation, v4lmjpegsrc->vertical_decimation, + v4lmjpegsrc->quality)) + return GST_PAD_CONNECT_REFUSED; + } + /* we now have an actual width/height - *set it* */ + caps = gst_caps_new("v4lmjpegsrc_caps", + "video/jpeg", + gst_props_new( + "width", GST_PROPS_INT(v4lmjpegsrc->end_width), + "height", GST_PROPS_INT(v4lmjpegsrc->end_height), + NULL ) ); + if (!gst_pad_try_set_caps(v4lmjpegsrc->srcpad, caps)) + { + gst_element_error(GST_ELEMENT(v4lmjpegsrc), + "Failed to set new caps"); + return GST_PAD_CONNECT_REFUSED; + } + if (!gst_v4lmjpegsrc_capture_init(v4lmjpegsrc)) + return GST_PAD_CONNECT_REFUSED; return GST_PAD_CONNECT_OK; } @@ -248,8 +294,11 @@ gst_v4lmjpegsrc_get (GstPad *pad) if (!gst_v4lmjpegsrc_grab_frame(v4lmjpegsrc, &num, &(GST_BUFFER_SIZE(buf)))) return NULL; GST_BUFFER_DATA(buf) = gst_v4lmjpegsrc_get_buffer(v4lmjpegsrc, num); - GST_BUFFER_TIMESTAMP (buf) = v4lmjpegsrc->bsync.timestamp.tv_sec * 1000000000 + - v4lmjpegsrc->bsync.timestamp.tv_usec * 1000; + if (!v4lmjpegsrc->first_timestamp) + v4lmjpegsrc->first_timestamp = v4lmjpegsrc->bsync.timestamp.tv_sec * 1000000 + + v4lmjpegsrc->bsync.timestamp.tv_usec; + GST_BUFFER_TIMESTAMP(buf) = v4lmjpegsrc->bsync.timestamp.tv_sec * 1000000 + + v4lmjpegsrc->bsync.timestamp.tv_usec - v4lmjpegsrc->first_timestamp; return buf; } @@ -358,7 +407,6 @@ gst_v4lmjpegsrc_change_state (GstElement *element) { GstV4lMjpegSrc *v4lmjpegsrc; GstElementStateReturn parent_value; - GstCaps *caps; g_return_val_if_fail(GST_IS_V4LMJPEGSRC(element), GST_STATE_FAILURE); @@ -366,42 +414,9 @@ gst_v4lmjpegsrc_change_state (GstElement *element) switch (GST_STATE_TRANSITION(element)) { case GST_STATE_READY_TO_PAUSED: - /* set buffer info */ - if (!gst_v4lmjpegsrc_set_buffer(v4lmjpegsrc, v4lmjpegsrc->numbufs, v4lmjpegsrc->bufsize)) - return GST_STATE_FAILURE; - /* set capture parameters and mmap the buffers */ - if (!v4lmjpegsrc->frame_width && !v4lmjpegsrc->frame_height && - v4lmjpegsrc->x_offset < 0 && v4lmjpegsrc->y_offset < 0 && - v4lmjpegsrc->horizontal_decimation == v4lmjpegsrc->vertical_decimation) - { - if (!gst_v4lmjpegsrc_set_capture(v4lmjpegsrc, - v4lmjpegsrc->horizontal_decimation, v4lmjpegsrc->quality)) - return GST_STATE_FAILURE; - } - else - { - if (!gst_v4lmjpegsrc_set_capture_m(v4lmjpegsrc, - v4lmjpegsrc->x_offset, v4lmjpegsrc->y_offset, - v4lmjpegsrc->frame_width, v4lmjpegsrc->frame_height, - v4lmjpegsrc->horizontal_decimation, v4lmjpegsrc->vertical_decimation, - v4lmjpegsrc->quality)) - return GST_STATE_FAILURE; - } - /* we now have an actual width/height - *set it* */ - caps = gst_caps_new("v4lmjpegsrc_caps", - "video/jpeg", - gst_props_new( - "width", GST_PROPS_INT(v4lmjpegsrc->end_width), - "height", GST_PROPS_INT(v4lmjpegsrc->end_height), - NULL ) ); - if (!gst_pad_try_set_caps(v4lmjpegsrc->srcpad, caps)) - { - gst_element_error(GST_ELEMENT(v4lmjpegsrc), - "Failed to set new caps"); - return GST_STATE_FAILURE; - } - if (!gst_v4lmjpegsrc_capture_init(v4lmjpegsrc)) - return GST_STATE_FAILURE; + /* actual buffer set-up used to be done here - but I moved + * it to capsnego itself */ + v4lmjpegsrc->first_timestamp = 0; break; case GST_STATE_PAUSED_TO_PLAYING: /* queue all buffer, start streaming capture */ diff --git a/sys/v4l/gstv4lmjpegsrc.h b/sys/v4l/gstv4lmjpegsrc.h index 641fd60..fd154bf 100644 --- a/sys/v4l/gstv4lmjpegsrc.h +++ b/sys/v4l/gstv4lmjpegsrc.h @@ -55,8 +55,8 @@ struct _GstV4lMjpegSrc { struct mjpeg_sync bsync; struct mjpeg_requestbuffers breq; - /* list of available caps */ - GstCaps *capslist; + /* first timestamp */ + guint64 first_timestamp; /* caching values */ gint x_offset; diff --git a/sys/v4l/gstv4lsrc.c b/sys/v4l/gstv4lsrc.c index d3fde6f..2af0c74 100644 --- a/sys/v4l/gstv4lsrc.c +++ b/sys/v4l/gstv4lsrc.c @@ -172,9 +172,7 @@ gst_v4lsrc_init (GstV4lSrc *v4lsrc) v4lsrc->palette = 0; /* means 'any' - user can specify a specific palette */ v4lsrc->width = 160; v4lsrc->height = 120; - v4lsrc->buffer_size = v4lsrc->width * v4lsrc->height * 1.5; - - v4lsrc->capslist = capslist; + v4lsrc->buffer_size = 0; } @@ -188,6 +186,12 @@ gst_v4lsrc_srcconnect (GstPad *pad, v4lsrc = GST_V4LSRC (gst_pad_get_parent (pad)); + /* in case the buffers are active (which means that we already + * did capsnego before and didn't clean up), clean up anyways */ + if (GST_V4L_IS_ACTIVE(GST_V4LELEMENT(v4lsrc))) + if (!gst_v4lsrc_capture_deinit(v4lsrc)) + return GST_PAD_CONNECT_REFUSED; + palette = v4lsrc->palette; /* TODO: caps = gst_caps_normalize(capslist); */ @@ -348,8 +352,11 @@ gst_v4lsrc_srcconnect (GstPad *pad, if (!gst_pad_try_set_caps(v4lsrc->srcpad, newcaps)) continue; - else - return GST_PAD_CONNECT_OK; + + if (!gst_v4lsrc_capture_init(v4lsrc)) + return GST_PAD_CONNECT_REFUSED; + + return GST_PAD_CONNECT_OK; } /* still nothing - no good caps */ @@ -382,10 +389,11 @@ gst_v4lsrc_get (GstPad *pad) GST_BUFFER_DATA(buf) = gst_v4lsrc_get_buffer(v4lsrc, num); GST_BUFFER_SIZE(buf) = v4lsrc->buffer_size; - g_print ("%lu %lu\n", v4lsrc->timestamp_soft_sync[num].tv_sec, v4lsrc->timestamp_soft_sync[num].tv_usec); - - GST_BUFFER_TIMESTAMP (buf) = v4lsrc->timestamp_soft_sync[num].tv_sec * 1000000 + - v4lsrc->timestamp_soft_sync[num].tv_usec; + if (!v4lsrc->first_timestamp) + v4lsrc->first_timestamp = v4lsrc->timestamp_soft_sync[num].tv_sec * 1000000 + + v4lsrc->timestamp_soft_sync[num].tv_usec; + GST_BUFFER_TIMESTAMP(buf) = v4lsrc->timestamp_soft_sync[num].tv_sec * 1000000 + + v4lsrc->timestamp_soft_sync[num].tv_usec - v4lsrc->first_timestamp; return buf; } @@ -473,9 +481,6 @@ gst_v4lsrc_change_state (GstElement *element) { GstV4lSrc *v4lsrc; gint transition = GST_STATE_TRANSITION (element); - guint32 fourcc; - gint depth=0, bpp=0; - GstCaps *caps; g_return_val_if_fail(GST_IS_V4LSRC(element), GST_STATE_FAILURE); @@ -485,67 +490,9 @@ gst_v4lsrc_change_state (GstElement *element) case GST_STATE_NULL_TO_READY: break; case GST_STATE_READY_TO_PAUSED: - /* extremely ugly hack for a weird behaviour in the capsnego system - try capsnego again */ - switch (v4lsrc->mmap.format) - { - case VIDEO_PALETTE_RGB555: - fourcc = GST_MAKE_FOURCC('R','G','B',' '); - bpp = 16; - depth = 15; - break; - case VIDEO_PALETTE_RGB565: - fourcc = GST_MAKE_FOURCC('R','G','B',' '); - bpp = 16; - depth = 16; - break; - case VIDEO_PALETTE_RGB24: - fourcc = GST_MAKE_FOURCC('R','G','B',' '); - bpp = 24; - depth = 24; - break; - case VIDEO_PALETTE_RGB32: - fourcc = GST_MAKE_FOURCC('R','G','B',' '); - bpp = 32; - depth = 32; - break; - case VIDEO_PALETTE_YUV411: - fourcc = GST_MAKE_FOURCC('Y','4','1','P'); - break; - case VIDEO_PALETTE_YUV422: - fourcc = GST_MAKE_FOURCC('Y','U','Y','2'); - break; - case VIDEO_PALETTE_YUV420P: - fourcc = GST_MAKE_FOURCC('I','4','2','0'); - break; - case VIDEO_PALETTE_UYVY: - fourcc = GST_MAKE_FOURCC('U','Y','V','Y'); - break; - default: - return GST_STATE_FAILURE; - } - if (bpp && depth) - caps = gst_caps_new("v4lsrc_caps", - "video/raw", - gst_props_new( - "format", GST_PROPS_FOURCC(fourcc), - "width", GST_PROPS_INT(v4lsrc->width), - "height", GST_PROPS_INT(v4lsrc->height), - "bpp", GST_PROPS_INT(bpp), - "depth", GST_PROPS_INT(depth), - NULL ) ); - else - caps = gst_caps_new("v4lsrc_caps", - "video/raw", - gst_props_new( - "format", GST_PROPS_FOURCC(fourcc), - "width", GST_PROPS_INT(v4lsrc->width), - "height", GST_PROPS_INT(v4lsrc->height), - NULL ) ); - if (!gst_pad_try_set_caps(v4lsrc->srcpad, caps)) - return GST_STATE_FAILURE; - - if (!gst_v4lsrc_capture_init(v4lsrc)) - return GST_STATE_FAILURE; + v4lsrc->first_timestamp = 0; + /* buffer setup used to be done here, but I moved it to + * capsnego */ break; case GST_STATE_PAUSED_TO_PLAYING: /* queue all buffer, start streaming capture */ diff --git a/sys/v4l/gstv4lsrc.h b/sys/v4l/gstv4lsrc.h index 6dcc083..cbe8f99 100644 --- a/sys/v4l/gstv4lsrc.h +++ b/sys/v4l/gstv4lsrc.h @@ -68,8 +68,8 @@ struct _GstV4lSrc { pthread_mutex_t mutex_queued_frames; pthread_cond_t cond_queued_frames; - /* list of available caps */ - GstCaps *capslist; + /* first timestamp */ + guint64 first_timestamp; /* caching values */ gint width; diff --git a/sys/v4l/v4l_calls.c b/sys/v4l/v4l_calls.c index 713f1f8..43431dd 100644 --- a/sys/v4l/v4l_calls.c +++ b/sys/v4l/v4l_calls.c @@ -17,8 +17,6 @@ * Boston, MA 02111-1307, USA. */ -/*#define DEBUG */ - #include #include #include @@ -28,6 +26,11 @@ #include #include "v4l_calls.h" +#define DEBUG(format, args...) \ + GST_DEBUG_ELEMENT(GST_CAT_PLUGIN_INFO, \ + GST_ELEMENT(v4lelement), \ + "V4L: " format "\n", ##args) + char *picture_name[] = { "Hue", "Brightness", "Contrast", "Saturation", NULL }; @@ -44,10 +47,7 @@ char *norm_name[] = { "PAL", "NTSC", "SECAM", NULL }; static gboolean gst_v4l_get_capabilities (GstV4lElement *v4lelement) { -#ifdef DEBUG - fprintf(stderr, "V4L: gst_v4l_get_capabilities()\n"); -#endif - + DEBUG("getting capabilities"); GST_V4L_CHECK_OPEN(v4lelement); if (ioctl(v4lelement->video_fd, VIDIOCGCAP, &(v4lelement->vcap)) < 0) @@ -71,10 +71,7 @@ gst_v4l_get_capabilities (GstV4lElement *v4lelement) gboolean gst_v4l_open (GstV4lElement *v4lelement) { -#ifdef DEBUG - fprintf(stderr, "V4L: gst_v4l_open()\n"); -#endif - + DEBUG("opening device %s", v4lelement->videodev); GST_V4L_CHECK_NOT_OPEN(v4lelement); GST_V4L_CHECK_NOT_ACTIVE(v4lelement); @@ -130,10 +127,7 @@ gst_v4l_open (GstV4lElement *v4lelement) gboolean gst_v4l_close (GstV4lElement *v4lelement) { -#ifdef DEBUG - fprintf(stderr, "V4L: gst_v4l_close()\n"); -#endif - + DEBUG("closing device"); GST_V4L_CHECK_OPEN(v4lelement); GST_V4L_CHECK_NOT_ACTIVE(v4lelement); @@ -152,10 +146,7 @@ gst_v4l_close (GstV4lElement *v4lelement) gint gst_v4l_get_num_chans (GstV4lElement *v4lelement) { -#ifdef DEBUG - fprintf(stderr, "V4L: gst_v4l_get_num_chans()\n"); -#endif - + DEBUG("getting number of channels"); GST_V4L_CHECK_OPEN(v4lelement); return v4lelement->vcap.channels; @@ -174,9 +165,7 @@ gst_v4l_get_chan_names (GstV4lElement *v4lelement) GList *list = NULL; gint i; -#ifdef DEBUG - fprintf(stderr, "V4L: gst_v4l_get_chan_names()\n"); -#endif + DEBUG("getting channel names"); if (!GST_V4L_IS_OPEN(v4lelement)) return NULL; @@ -205,10 +194,7 @@ gst_v4l_get_chan_norm (GstV4lElement *v4lelement, gint *channel, gint *norm) { -#ifdef DEBUG - fprintf(stderr, "V4L: gst_v4l_get_chan_norm()\n"); -#endif - + DEBUG("getting current channel and norm"); GST_V4L_CHECK_OPEN(v4lelement); if (channel) @@ -232,11 +218,8 @@ gst_v4l_set_chan_norm (GstV4lElement *v4lelement, gint channel, gint norm) { -#ifdef DEBUG - fprintf(stderr, "V4L: gst_v4l_set_chan_norm(), channel = %d, norm = %d (%s)\n", + DEBUG("setting channel = %d, norm = %d (%s)", channel, norm, norm_name[norm]); -#endif - GST_V4L_CHECK_OPEN(v4lelement); GST_V4L_CHECK_NOT_ACTIVE(v4lelement); @@ -271,10 +254,7 @@ gst_v4l_set_chan_norm (GstV4lElement *v4lelement, gboolean gst_v4l_has_tuner (GstV4lElement *v4lelement) { -#ifdef DEBUG - fprintf(stderr, "V4L: gst_v4l_has_tuner()\n"); -#endif - + DEBUG("checking whether device has a tuner"); GST_V4L_CHECK_OPEN(v4lelement); return (v4lelement->vcap.type & VID_TYPE_TUNER && @@ -292,10 +272,7 @@ gboolean gst_v4l_get_frequency (GstV4lElement *v4lelement, gulong *frequency) { -#ifdef DEBUG - fprintf(stderr, "V4L: gst_v4l_get_frequency()\n"); -#endif - + DEBUG("getting tuner frequency"); GST_V4L_CHECK_OPEN(v4lelement); if (!gst_v4l_has_tuner(v4lelement)) @@ -323,11 +300,7 @@ gboolean gst_v4l_set_frequency (GstV4lElement *v4lelement, gulong frequency) { -#ifdef DEBUG - fprintf(stderr, "gst_v4l_set_frequency(), frequency = %ul\n", - frequency); -#endif - + DEBUG("setting tuner frequency to %lu", frequency); GST_V4L_CHECK_OPEN(v4lelement); GST_V4L_CHECK_NOT_ACTIVE(v4lelement); @@ -359,11 +332,8 @@ gst_v4l_get_picture (GstV4lElement *v4lelement, { struct video_picture vpic; -#ifdef DEBUG - fprintf(stderr, "V4L: gst_v4l_get_picture(), type = %d (%s)\n", + DEBUG("getting picture property type %d (%s)", type, picture_name[type]); -#endif - GST_V4L_CHECK_OPEN(v4lelement); if (ioctl(v4lelement->video_fd, VIDIOCGPICT, &vpic) < 0) @@ -412,11 +382,8 @@ gst_v4l_set_picture (GstV4lElement *v4lelement, { struct video_picture vpic; -#ifdef DEBUG - fprintf(stderr, "V4L: gst_v4l_set_picture(), type = %d (%s), value = %d\n", + DEBUG("setting picture type %d (%s) to value %d", type, picture_name[type], value); -#endif - GST_V4L_CHECK_OPEN(v4lelement); if (ioctl(v4lelement->video_fd, VIDIOCGPICT, &vpic) < 0) @@ -468,10 +435,7 @@ gst_v4l_set_picture (GstV4lElement *v4lelement, gboolean gst_v4l_has_audio (GstV4lElement *v4lelement) { -#ifdef DEBUG - fprintf(stderr, "V4L: gst_v4l_has_audio()\n"); -#endif - + DEBUG("checking whether device has audio"); GST_V4L_CHECK_OPEN(v4lelement); return (v4lelement->vcap.audios > 0 && @@ -492,11 +456,8 @@ gst_v4l_get_audio (GstV4lElement *v4lelement, { struct video_audio vau; -#ifdef DEBUG - fprintf(stderr, "V4L: v4l_gst_get_audio(), type = %d (%s)\n", + DEBUG("getting audio parameter type %d (%s)", type, audio_name[type]); -#endif - GST_V4L_CHECK_OPEN(v4lelement); if (!gst_v4l_has_audio(v4lelement)) @@ -545,11 +506,8 @@ gst_v4l_set_audio (GstV4lElement *v4lelement, { struct video_audio vau; -#ifdef DEBUG - fprintf(stderr, "V4L: v4l_gst_set_audio(), type = %d (%s), value = %d\n", + DEBUG("setting audio parameter type %d (%s) to value %d", type, audio_name[type], value); -#endif - GST_V4L_CHECK_OPEN(v4lelement); if (!gst_v4l_has_audio(v4lelement)) diff --git a/sys/v4l/v4l_calls.h b/sys/v4l/v4l_calls.h index f554eaf..892b0e0 100644 --- a/sys/v4l/v4l_calls.h +++ b/sys/v4l/v4l_calls.h @@ -61,7 +61,7 @@ extern "C" { if (!(v4lelement->vcap.type & VID_TYPE_OVERLAY)) \ { \ gst_element_error(GST_ELEMENT(v4lelement), \ - "Device doesn';t do overlay"); \ + "Device doesn't do overlay"); \ return FALSE; \ } diff --git a/sys/v4l/v4lmjpegsink_calls.c b/sys/v4l/v4lmjpegsink_calls.c index eea1214..280f8fd 100644 --- a/sys/v4l/v4lmjpegsink_calls.c +++ b/sys/v4l/v4lmjpegsink_calls.c @@ -17,8 +17,6 @@ * Boston, MA 02111-1307, USA. */ -/*#define DEBUG */ - #include #include #include @@ -34,6 +32,11 @@ #define MAP_FAILED ( (caddr_t) -1 ) #endif +#define DEBUG(format, args...) \ + GST_DEBUG_ELEMENT(GST_CAT_PLUGIN_INFO, \ + GST_ELEMENT(v4lmjpegsink), \ + "V4LMJPEGSINK: " format "\n", ##args) + /****************************************************** * gst_v4lmjpegsink_sync_thread() @@ -46,9 +49,7 @@ gst_v4lmjpegsink_sync_thread (void *arg) GstV4lMjpegSink *v4lmjpegsink = GST_V4LMJPEGSINK(arg); gint frame = 0; /* frame that we're currently syncing on */ -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSINK: gst_v4lmjpegsink_sync_thread()\n"); -#endif + DEBUG("starting sync thread"); /* Allow easy shutting down by other processes... */ pthread_setcancelstate( PTHREAD_CANCEL_ENABLE, NULL ); @@ -69,6 +70,7 @@ gst_v4lmjpegsink_sync_thread (void *arg) } pthread_mutex_unlock(&(v4lmjpegsink->mutex_queued_frames)); + DEBUG("thread-syncing on next frame"); if (ioctl(GST_V4LELEMENT(v4lmjpegsink)->video_fd, MJPIOC_SYNC, &(v4lmjpegsink->bsync)) < 0) { @@ -100,9 +102,7 @@ gst_v4lmjpegsink_sync_thread (void *arg) } end: -#ifdef DEBUG - fprintf(stderr, "Sync thread got signalled to exit\n"); -#endif + DEBUG("Sync thread got signalled to exit"); pthread_exit(NULL); } @@ -117,10 +117,7 @@ static gboolean gst_v4lmjpegsink_queue_frame (GstV4lMjpegSink *v4lmjpegsink, gint num) { -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSINK: gst_v4lmjpegsink_queue_frame(), num = %d\n", - num); -#endif + DEBUG("queueing frame %d", num); /* queue on this frame */ if (ioctl(GST_V4LELEMENT(v4lmjpegsink)->video_fd, MJPIOC_QBUF_PLAY, &num) < 0) @@ -150,10 +147,7 @@ static gboolean gst_v4lmjpegsink_sync_frame (GstV4lMjpegSink *v4lmjpegsink, gint *num) { -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSINK: gst_v4lmjpegsink_sync_frame(), num = %d\n", - num); -#endif + DEBUG("syncing on next frame"); /* calculate next frame */ v4lmjpegsink->current_frame = (v4lmjpegsink->current_frame+1)%v4lmjpegsink->breq.count; @@ -188,11 +182,8 @@ gst_v4lmjpegsink_set_buffer (GstV4lMjpegSink *v4lmjpegsink, gint numbufs, gint bufsize) { -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSINK: gst_v4lmjpegsink_set_buffer(), numbufs = %d, bufsize = %d KB\n", + DEBUG("setting buffer info to numbufs = %d, bufsize = %d KB", numbufs, bufsize); -#endif - GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsink)); GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lmjpegsink)); @@ -221,12 +212,8 @@ gst_v4lmjpegsink_set_playback (GstV4lMjpegSink *v4lmjpegsink, gint mw, mh; struct mjpeg_params bparm; -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSINK: gst_v4lmjpegsink_set_playback(), " - "size = %dx%d, X/Y-offsets = %d/%d, norm = %d, interlacing = %d\n", + DEBUG("setting size = %dx%d, X/Y-offsets = %d/%d, norm = %d, interlacing = %d\n", width, height, x_offset, y_offset, norm, interlacing); -#endif - GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsink)); /*GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lmjpegsink)); */ @@ -348,10 +335,7 @@ gst_v4lmjpegsink_playback_init (GstV4lMjpegSink *v4lmjpegsink) { gint n; -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSINK: gst_v4lmjpegsink_playback_init()\n"); -#endif - + DEBUG("initting playback subsystem"); GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsink)); GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lmjpegsink)); @@ -370,7 +354,7 @@ gst_v4lmjpegsink_playback_init (GstV4lMjpegSink *v4lmjpegsink) /* Map the buffers */ GST_V4LELEMENT(v4lmjpegsink)->buffer = mmap(0, v4lmjpegsink->breq.count * v4lmjpegsink->breq.size, - PROT_READ, MAP_SHARED, GST_V4LELEMENT(v4lmjpegsink)->video_fd, 0); + PROT_READ|PROT_WRITE, MAP_SHARED, GST_V4LELEMENT(v4lmjpegsink)->video_fd, 0); if (GST_V4LELEMENT(v4lmjpegsink)->buffer == MAP_FAILED) { gst_element_error(GST_ELEMENT(v4lmjpegsink), @@ -418,10 +402,7 @@ gst_v4lmjpegsink_playback_start (GstV4lMjpegSink *v4lmjpegsink) { gint n; -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSINK: gst_v4lmjpegsink_playback_start()\n"); -#endif - + DEBUG("starting playback"); GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsink)); GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lmjpegsink)); @@ -455,10 +436,7 @@ guint8 * gst_v4lmjpegsink_get_buffer (GstV4lMjpegSink *v4lmjpegsink, gint num) { -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSINK: gst_v4lmjpegsink_get_buffer(), num = %d\n", - num); -#endif + DEBUG("gst_v4lmjpegsink_get_buffer(), num = %d", num); if (!GST_V4L_IS_ACTIVE(GST_V4LELEMENT(v4lmjpegsink)) || !GST_V4L_IS_OPEN(GST_V4LELEMENT(v4lmjpegsink))) @@ -481,10 +459,7 @@ gboolean gst_v4lmjpegsink_play_frame (GstV4lMjpegSink *v4lmjpegsink, gint num) { -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSINK: gst_v4lmjpegsink_play_frame()\n"); -#endif - + DEBUG("playing frame %d", num); GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsink)); GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lmjpegsink)); @@ -505,11 +480,7 @@ gboolean gst_v4lmjpegsink_wait_frame (GstV4lMjpegSink *v4lmjpegsink, gint *num) { -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSINK: gst_v4lmjpegsink_wait_frame(), num = %d\n", - num); -#endif - + DEBUG("waiting for next frame to be finished playing"); GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsink)); GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lmjpegsink)); @@ -531,10 +502,7 @@ gst_v4lmjpegsink_playback_stop (GstV4lMjpegSink *v4lmjpegsink) { gint num; -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSINK: gst_v4lmjpegsink_playback_stop()\n"); -#endif - + DEBUG("stopping playback"); GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsink)); GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lmjpegsink)); @@ -561,10 +529,7 @@ gst_v4lmjpegsink_playback_stop (GstV4lMjpegSink *v4lmjpegsink) gboolean gst_v4lmjpegsink_playback_deinit (GstV4lMjpegSink *v4lmjpegsink) { -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSINK: gst_v4lmjpegsink_playback_deinit()\n"); -#endif - + DEBUG("quitting playback subsystem"); GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsink)); GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lmjpegsink)); diff --git a/sys/v4l/v4lmjpegsrc_calls.c b/sys/v4l/v4lmjpegsrc_calls.c index 28af416..ffe4b75 100644 --- a/sys/v4l/v4lmjpegsrc_calls.c +++ b/sys/v4l/v4lmjpegsrc_calls.c @@ -17,8 +17,6 @@ * Boston, MA 02111-1307, USA. */ -/*#define DEBUG */ - #include #include #include @@ -33,6 +31,12 @@ #define MAP_FAILED ( (caddr_t) -1 ) #endif +#define DEBUG(format, args...) \ + GST_DEBUG_ELEMENT(GST_CAT_PLUGIN_INFO, \ + GST_ELEMENT(v4lmjpegsrc), \ + "V4LMJPEGSRC: " format "\n", ##args) + + char *input_name[] = { "Composite", "S-Video", "TV-Tuner", "Autodetect" }; @@ -46,10 +50,7 @@ static gboolean gst_v4lmjpegsrc_queue_frame (GstV4lMjpegSrc *v4lmjpegsrc, gint num) { -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSRC: gst_v4lmjpegsrc_queue_frame(), num = %d\n", - num); -#endif + DEBUG("queueing frame %d", num); if (ioctl(GST_V4LELEMENT(v4lmjpegsrc)->video_fd, MJPIOC_QBUF_CAPT, &num) < 0) { @@ -73,10 +74,7 @@ static gboolean gst_v4lmjpegsrc_sync_next_frame (GstV4lMjpegSrc *v4lmjpegsrc, gint *num) { -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSRC: gst_v4lmjpegsrc_sync_frame(), num = %d\n", - num); -#endif + DEBUG("syncing on next frame"); if (ioctl(GST_V4LELEMENT(v4lmjpegsrc)->video_fd, MJPIOC_SYNC, &(v4lmjpegsrc->bsync)) < 0) { @@ -106,10 +104,8 @@ gst_v4lmjpegsrc_set_input_norm (GstV4lMjpegSrc *v4lmjpegsrc, { struct mjpeg_status bstat; -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSRC: gst_v4lmjpegsrc_set_input_norm(), input = %d (%s), norm = %d (%s)\n", + DEBUG("setting input = %d (%s), norm = %d (%s)", input, input_name[input], norm, norm_name[norm]); -#endif GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsrc)); GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc)); @@ -198,11 +194,8 @@ gst_v4lmjpegsrc_set_buffer (GstV4lMjpegSrc *v4lmjpegsrc, gint numbufs, gint bufsize) { -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSRC: gst_v4lmjpegsrc_set_buffer(), numbufs = %d, bufsize = %d KB\n", + DEBUG("setting buffer info to numbufs = %d, bufsize = %d KB", numbufs, bufsize); -#endif - GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsrc)); GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc)); @@ -227,11 +220,8 @@ gst_v4lmjpegsrc_set_capture (GstV4lMjpegSrc *v4lmjpegsrc, int norm, input, mw; struct mjpeg_params bparm; -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSRC: gst_v4lmjpegsrc_set_capture(), decimation = %d, quality = %d\n", + DEBUG("setting decimation = %d, quality = %d", decimation, quality); -#endif - GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsrc)); GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc)); @@ -297,12 +287,9 @@ gboolean gst_v4lmjpegsrc_set_capture_m (GstV4lMjpegSrc *v4lmjpegsrc, gint maxwidth; struct mjpeg_params bparm; -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSRC: gst_v4lmjpegsrc_set_capture_m(), x_offset = %d, y_offset = %d, " + DEBUG("setting x_offset = %d, y_offset = %d, " "width = %d, height = %d, h_decimation = %d, v_decimation = %d, quality = %d\n", x_offset, y_offset, width, height, h_decimation, v_decimation, quality); -#endif - GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsrc)); GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc)); @@ -419,10 +406,7 @@ gboolean gst_v4lmjpegsrc_set_capture_m (GstV4lMjpegSrc *v4lmjpegsrc, gboolean gst_v4lmjpegsrc_capture_init (GstV4lMjpegSrc *v4lmjpegsrc) { -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSRC: gst_v4lmjpegsrc_capture_init()\n"); -#endif - + DEBUG("initting capture subsystem"); GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsrc)); GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc)); @@ -441,7 +425,7 @@ gst_v4lmjpegsrc_capture_init (GstV4lMjpegSrc *v4lmjpegsrc) /* Map the buffers */ GST_V4LELEMENT(v4lmjpegsrc)->buffer = mmap(0, v4lmjpegsrc->breq.count * v4lmjpegsrc->breq.size, - PROT_READ, MAP_SHARED, GST_V4LELEMENT(v4lmjpegsrc)->video_fd, 0); + PROT_READ|PROT_WRITE, MAP_SHARED, GST_V4LELEMENT(v4lmjpegsrc)->video_fd, 0); if (GST_V4LELEMENT(v4lmjpegsrc)->buffer == MAP_FAILED) { gst_element_error(GST_ELEMENT(v4lmjpegsrc), @@ -466,10 +450,7 @@ gst_v4lmjpegsrc_capture_start (GstV4lMjpegSrc *v4lmjpegsrc) { int n; -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSRC: gst_v4lmjpegsrc_capture_start()\n"); -#endif - + DEBUG("starting capture"); GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsrc)); GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc)); @@ -493,10 +474,7 @@ gst_v4lmjpegsrc_grab_frame (GstV4lMjpegSrc *v4lmjpegsrc, gint *num, gint *size) { -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSRC: gst_v4lmjpegsrc_grab_frame()\n"); -#endif - + DEBUG("grabbing frame"); GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsrc)); GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc)); @@ -520,10 +498,7 @@ guint8 * gst_v4lmjpegsrc_get_buffer (GstV4lMjpegSrc *v4lmjpegsrc, gint num) { -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSRC: gst_v4lmjpegsrc_get_buffer(), num = %d\n", - num); -#endif + DEBUG("gst_v4lmjpegsrc_get_buffer(), num = %d", num); if (!GST_V4L_IS_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc)) || !GST_V4L_IS_OPEN(GST_V4LELEMENT(v4lmjpegsrc))) @@ -546,11 +521,7 @@ gboolean gst_v4lmjpegsrc_requeue_frame (GstV4lMjpegSrc *v4lmjpegsrc, gint num) { -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSRC: gst_v4lmjpegsrc_requeue_frame(), num = %d\n", - num); -#endif - + DEBUG("requeueing frame %d", num); GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsrc)); GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc)); @@ -570,10 +541,7 @@ gst_v4lmjpegsrc_requeue_frame (GstV4lMjpegSrc *v4lmjpegsrc, gboolean gst_v4lmjpegsrc_capture_stop (GstV4lMjpegSrc *v4lmjpegsrc) { -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSRC: gst_v4lmjpegsrc_capture_stop()\n"); -#endif - + DEBUG("stopping capture"); GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsrc)); GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc)); @@ -594,10 +562,7 @@ gst_v4lmjpegsrc_capture_stop (GstV4lMjpegSrc *v4lmjpegsrc) gboolean gst_v4lmjpegsrc_capture_deinit (GstV4lMjpegSrc *v4lmjpegsrc) { -#ifdef DEBUG - fprintf(stderr, "V4LMJPEGSRC: gst_v4lmjpegsrc_capture_deinit()\n"); -#endif - + DEBUG("quitting capture subsystem"); GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsrc)); GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc)); diff --git a/sys/v4l/v4lsrc_calls.c b/sys/v4l/v4lsrc_calls.c index 0dc30d0..ca6c131 100644 --- a/sys/v4l/v4lsrc_calls.c +++ b/sys/v4l/v4lsrc_calls.c @@ -17,8 +17,6 @@ * Boston, MA 02111-1307, USA. */ -/*#define DEBUG */ - #include #include #include @@ -38,6 +36,10 @@ #define MAP_FAILED ( (caddr_t) -1 ) #endif +#define DEBUG(format, args...) \ + GST_DEBUG_ELEMENT(GST_CAT_PLUGIN_INFO, \ + GST_ELEMENT(v4lsrc), \ + "V4LSRC: " format "\n", ##args) /* palette names */ char *palette_name[] = { @@ -71,10 +73,7 @@ static gboolean gst_v4lsrc_queue_frame (GstV4lSrc *v4lsrc, gint num) { -#ifdef DEBUG - fprintf(stderr, "V4LSRC: gst_v4lsrc_queue_frame(), num = %d\n", - num); -#endif + DEBUG("queueing frame %d", num); v4lsrc->mmap.frame = num; @@ -115,9 +114,7 @@ gst_v4lsrc_soft_sync_thread (void *arg) GstV4lSrc *v4lsrc = GST_V4LSRC(arg); gint frame = 0; -#ifdef DEBUG - fprintf(stderr, "gst_v4lsrc_soft_sync_thread()\n"); -#endif + DEBUG("starting software sync thread"); /* Allow easy shutting down by other processes... */ pthread_setcancelstate( PTHREAD_CANCEL_ENABLE, NULL ); @@ -131,10 +128,10 @@ gst_v4lsrc_soft_sync_thread (void *arg) { if (v4lsrc->frame_queued[frame] < 0) break; -#ifdef DEBUG - fprintf(stderr, "Waiting for new frames to be queued (%d < %d)\n", + + DEBUG("Waiting for new frames to be queued (%d < %d)", v4lsrc->num_queued_frames, MIN_BUFFERS_QUEUED); -#endif + pthread_cond_wait(&(v4lsrc->cond_queued_frames), &(v4lsrc->mutex_queued_frames)); } @@ -142,16 +139,12 @@ gst_v4lsrc_soft_sync_thread (void *arg) if (!v4lsrc->num_queued_frames) { -#ifdef DEBUG - fprintf(stderr, "Got signal to exit...\n"); -#endif + DEBUG("Got signal to exit..."); goto end; } /* sync on the frame */ -#ifdef DEBUG - fprintf(stderr, "Sync\'ing on frame %d\n", frame); -#endif + DEBUG("Sync\'ing on frame %d", frame); retry: if (ioctl(GST_V4LELEMENT(v4lsrc)->video_fd, VIDIOCSYNC, &frame) < 0) { @@ -185,9 +178,7 @@ retry: } end: -#ifdef DEBUG - fprintf(stderr, "Software sync thread got signalled to exit\n"); -#endif + DEBUG("Software sync thread got signalled to exit"); pthread_exit(NULL); } @@ -202,20 +193,15 @@ static gboolean gst_v4lsrc_sync_next_frame (GstV4lSrc *v4lsrc, gint *num) { -#ifdef DEBUG - fprintf(stderr, "V4LSRC: gst_v4lsrc_sync_frame()\n"); -#endif - *num = v4lsrc->sync_frame = (v4lsrc->sync_frame + 1)%v4lsrc->mbuf.frames; + DEBUG("syncing on next frame (%d)", *num); + /* "software sync()" on the frame */ pthread_mutex_lock(&(v4lsrc->mutex_soft_sync)); if (v4lsrc->isready_soft_sync[*num] == 0) { -#ifdef DEBUG - fprintf(stderr, "Waiting for frame %d to be synced on\n", - *num); -#endif + DEBUG("Waiting for frame %d to be synced on", *num); pthread_cond_wait(&(v4lsrc->cond_soft_sync[*num]), &(v4lsrc->mutex_soft_sync)); } @@ -241,13 +227,11 @@ gst_v4lsrc_set_capture (GstV4lSrc *v4lsrc, gint height, gint palette) { -#ifdef DBUG - fprintf(stderr, "V4LSRC: gst_v4lsrc_set_capture(), width = %d, height = %d, palette = %d\n", + DEBUG("capture properties set to width = %d, height = %d, palette = %d", width, height, palette); -#endif /*GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lsrc));*/ - GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lsrc)); + /*GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lsrc));*/ v4lsrc->mmap.width = width; v4lsrc->mmap.height = height; @@ -268,10 +252,7 @@ gst_v4lsrc_capture_init (GstV4lSrc *v4lsrc) { int n; -#ifdef DEBUG - fprintf(stderr, "V4LSRC: gst_v4lsrc_capture_init()\n"); -#endif - + DEBUG("initting capture subsystem"); GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lsrc)); GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lsrc)); @@ -371,10 +352,7 @@ gst_v4lsrc_capture_start (GstV4lSrc *v4lsrc) { int n; -#ifdef DEBUG - fprintf(stderr, "V4LSRC: gst_v4lsrc_capture_start()\n"); -#endif - + DEBUG("starting capture"); GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lsrc)); GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lsrc)); @@ -410,10 +388,7 @@ gst_v4lsrc_capture_start (GstV4lSrc *v4lsrc) gboolean gst_v4lsrc_grab_frame (GstV4lSrc *v4lsrc, gint *num) { -#ifdef DEBUG - fprintf(stderr, "V4LSRC: gst_v4lsrc_grab_frame()\n"); -#endif - + DEBUG("grabbing frame"); GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lsrc)); GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lsrc)); @@ -434,10 +409,7 @@ gst_v4lsrc_grab_frame (GstV4lSrc *v4lsrc, gint *num) guint8 * gst_v4lsrc_get_buffer (GstV4lSrc *v4lsrc, gint num) { -#ifdef DEBUG - fprintf(stderr, "V4LSRC: gst_v4lsrc_get_buffer(), num = %d\n", - num); -#endif + DEBUG("gst_v4lsrc_get_buffer(), num = %d", num); if (!GST_V4L_IS_ACTIVE(GST_V4LELEMENT(v4lsrc)) || !GST_V4L_IS_OPEN(GST_V4LELEMENT(v4lsrc))) @@ -459,11 +431,7 @@ gst_v4lsrc_get_buffer (GstV4lSrc *v4lsrc, gint num) gboolean gst_v4lsrc_requeue_frame (GstV4lSrc *v4lsrc, gint num) { -#ifdef DEBUG - fprintf(stderr, "V4LSRC: gst_v4lsrc_requeue_buffer(), num = %d\n", - num); -#endif - + DEBUG("requeueing frame %d", num); GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lsrc)); GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lsrc)); @@ -486,10 +454,7 @@ gst_v4lsrc_capture_stop (GstV4lSrc *v4lsrc) { int n; -#ifdef DEBUG - fprintf(stderr, "V4LSRC: gst_v4lsrc_capture_stop()\n"); -#endif - + DEBUG("stopping capture"); GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lsrc)); GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lsrc)); @@ -512,10 +477,7 @@ gst_v4lsrc_capture_stop (GstV4lSrc *v4lsrc) gboolean gst_v4lsrc_capture_deinit (GstV4lSrc *v4lsrc) { -#ifdef DEBUG - fprintf(stderr, "V4LSRC: gst_v4lsrc_capture_deinit()\n"); -#endif - + DEBUG("quitting capture subsystem"); GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lsrc)); GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lsrc)); -- 2.7.4