diff options
author | Ronald S. Bultje <rbultje@ronald.bitfreak.net> | 2003-05-21 06:33:18 +0000 |
---|---|---|
committer | Ronald S. Bultje <rbultje@ronald.bitfreak.net> | 2003-05-21 06:33:18 +0000 |
commit | 6588850d7426b792046254d5ddf050c47172e932 (patch) | |
tree | be06b509f6e905de522c5d36dd4b831ef6c98d4b /sys/v4l2/gstv4l2src.c | |
parent | 7777638d99477dd6c3548fd958ea83c52fda1b12 (diff) | |
download | gst-plugins-bad-6588850d7426b792046254d5ddf050c47172e932.tar.gz gst-plugins-bad-6588850d7426b792046254d5ddf050c47172e932.tar.bz2 gst-plugins-bad-6588850d7426b792046254d5ddf050c47172e932.zip |
Some final fixes for the v4lsrc elements. remove software sync thread (use GST_ELEMENT_THREAD_SUGGESTED instead) make...
Original commit message from CVS:
Some final fixes for the v4lsrc elements.
* remove software sync thread (use GST_ELEMENT_THREAD_SUGGESTED instead)
* make all src elements threadsafe
* fix num_buffer argument setting in v4l2src (VIDIOC_S_PARM)
* re-add bufsize (RO) for v4lmjpegsrc
* fix the A/V sync calculation in all elements (spvf=GST_SECOND/fps, not GST_SECOND*fps)
* probably some more crap....
With all this, it actually works quite well. The TODO files describes the
next steps in order to make a full-featured video recorder based on these
elements and GStreamer (bottom). Making a simple recorder should be fairly
easy now, btw.
Diffstat (limited to 'sys/v4l2/gstv4l2src.c')
-rw-r--r-- | sys/v4l2/gstv4l2src.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/sys/v4l2/gstv4l2src.c b/sys/v4l2/gstv4l2src.c index 92ca2092..a2219606 100644 --- a/sys/v4l2/gstv4l2src.c +++ b/sys/v4l2/gstv4l2src.c @@ -195,6 +195,8 @@ gst_v4l2src_class_init (GstV4l2SrcClass *klass) static void gst_v4l2src_init (GstV4l2Src *v4l2src) { + GST_FLAG_SET(GST_ELEMENT(v4l2src), GST_ELEMENT_THREAD_SUGGESTED); + v4l2src->srcpad = gst_pad_new_from_template(src_template, "src"); gst_element_add_pad(GST_ELEMENT(v4l2src), v4l2src->srcpad); @@ -257,14 +259,14 @@ gst_v4l2src_get_fps (GstV4l2Src *v4l2src) /* if that failed ... */ if (!GST_V4L2_IS_OPEN(GST_V4L2ELEMENT(v4l2src))) - return FALSE; + return 0.; if (!gst_v4l2_get_norm(GST_V4L2ELEMENT(v4l2src), &norm)) - return FALSE; + return 0.; std = ((struct v4l2_standard *) g_list_nth_data(GST_V4L2ELEMENT(v4l2src)->norms, norm)); - fps = std->frameperiod.numerator / std->frameperiod.denominator; - + fps = (1. * std->frameperiod.denominator) / std->frameperiod.numerator; + return fps; } @@ -643,7 +645,7 @@ gst_v4l2src_srcconnect (GstPad *pad, gst_caps_get_int(caps, "width", &w); } else { int max; - gst_caps_get_int_range(caps, "width", &w, &max); + gst_caps_get_int_range(caps, "width", &max, &w); } } if (gst_caps_has_property(caps, "height")) { @@ -651,7 +653,7 @@ gst_v4l2src_srcconnect (GstPad *pad, gst_caps_get_int(caps, "height", &h); } else { int max; - gst_caps_get_int_range(caps, "height", &h, &max); + gst_caps_get_int_range(caps, "height", &max, &h); } } @@ -790,14 +792,14 @@ gst_v4l2src_get (GstPad *pad) * timeframe. This means that if time - begin_time = X sec, * we want to have written X*fps frames. If we've written * more - drop, if we've written less - dup... */ - if (v4l2src->handled * fps * GST_SECOND - time > - 1.5 * fps * GST_SECOND) { + if (v4l2src->handled * (GST_SECOND/fps) - time > + 1.5 * (GST_SECOND/fps)) { /* yo dude, we've got too many frames here! Drop! DROP! */ v4l2src->need_writes--; /* -= (v4l2src->handled - (time / fps)); */ g_signal_emit(G_OBJECT(v4l2src), gst_v4l2src_signals[SIGNAL_FRAME_DROP], 0); - } else if (v4l2src->handled * fps * GST_SECOND - time < - -1.5 * fps * GST_SECOND) { + } else if (v4l2src->handled * (GST_SECOND/fps) - time < + -1.5 * (GST_SECOND/fps)) { /* this means we're lagging far behind */ v4l2src->need_writes++; /* += ((time / fps) - v4l2src->handled); */ g_signal_emit(G_OBJECT(v4l2src), @@ -820,7 +822,7 @@ gst_v4l2src_get (GstPad *pad) v4l2src->use_num_times[num] = 1; } - GST_BUFFER_DATA(buf) = GST_V4L2ELEMENT(v4l2src)->buffer[num]; + GST_BUFFER_DATA(buf) = gst_v4l2src_get_buffer(v4l2src, num); GST_BUFFER_SIZE(buf) = v4l2src->bufsettings.bytesused; if (v4l2src->use_fixed_fps) GST_BUFFER_TIMESTAMP(buf) = v4l2src->handled * GST_SECOND / fps; @@ -831,6 +833,7 @@ gst_v4l2src_get (GstPad *pad) v4l2src->handled++; g_signal_emit(G_OBJECT(v4l2src), gst_v4l2src_signals[SIGNAL_FRAME_CAPTURE], 0); + return buf; } @@ -1001,7 +1004,7 @@ gst_v4l2src_buffer_free (GstBufferPool *pool, return; /* we've already cleaned up ourselves */ for (n=0;n<v4l2src->breq.count;n++) - if (GST_BUFFER_DATA(buf) == GST_V4L2ELEMENT(v4l2src)->buffer[n]) { + if (GST_BUFFER_DATA(buf) == gst_v4l2src_get_buffer(v4l2src, n)) { v4l2src->use_num_times[n]--; if (v4l2src->use_num_times[n] <= 0) { gst_v4l2src_requeue_frame(v4l2src, n); |