{
switch (prop_id) {
case PROP_DEVICE:
- if (v4l2object->videodev)
- g_free (v4l2object->videodev);
+ g_free (v4l2object->videodev);
v4l2object->videodev = g_value_dup_string (value);
break;
case PROP_STD:
norm =
GST_TUNER_NORM (gst_tuner_get_norm (GST_TUNER (v4l2object->element)));
if (norm) {
- if (v4l2object->std) {
- g_free (v4l2object->std);
- }
+ g_free (v4l2object->std);
v4l2object->std = g_strdup (norm->label);
gst_tuner_norm_changed (tuner, norm);
g_object_notify (G_OBJECT (v4l2object->element), "std");
channel =
GST_TUNER_CHANNEL (gst_tuner_get_channel (GST_TUNER (v4l2object->
element)));
- if (v4l2object->input) {
- g_free (v4l2object->input);
- }
+ g_free (v4l2object->input);
v4l2object->input = g_strdup (channel->label);
gst_tuner_channel_changed (tuner, channel);
g_object_notify (G_OBJECT (v4l2object->element), "input");
read_error:
{
GST_ELEMENT_ERROR (v4l2src, RESOURCE, SYNC,
- (_("error read()ing %d bytes on device %s"),
+ (_("Error read()ing %d bytes on device %s."),
buffersize, v4l2src->v4l2object->videodev), GST_ERROR_SYSTEM);
gst_buffer_unref (*buf);
return GST_FLOW_ERROR;
short_read:
{
GST_ELEMENT_ERROR (v4l2src, RESOURCE, SYNC, (NULL),
- ("error read()ing a buffer on device %s: got only %d bytes instead of expected %d",
+ ("Error read()ing a buffer on device %s: got only %d bytes instead of expected %d.",
v4l2src->v4l2object->videodev, amount, buffersize));
gst_buffer_unref (*buf);
return GST_FLOW_ERROR;
no_framerate:
{
GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS,
- (_("could not get frame rate for %s, try to set use-undef-fps "
- "property to true"), v4l2src->v4l2object->videodev), (NULL));
+ (_("Could not get frame rate for %s, try to set use-undef-fps "
+ "property to true."), v4l2src->v4l2object->videodev), (NULL));
return GST_FLOW_ERROR;
}
}
}
if (fstat (v4l2object->video_fd, &s) < 0) {
GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, NOT_FOUND,
- (_("Cannot identify device '%s'"), v4l2object->videodev),
+ (_("Cannot identify device '%s'."), v4l2object->videodev),
GST_ERROR_SYSTEM);
XCloseDisplay (dpy);
return;
cap_failed:
{
GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS,
- (_("Error getting capabilities for device '%s':"
- " It isn't a v4l2 driver. Check if it is a v4l1 driver"),
+ (_("Error getting capabilities for device '%s': "
+ "It isn't a v4l2 driver. Check if it is a v4l1 driver."),
v4l2object->videodev), GST_ERROR_SYSTEM);
return FALSE;
}
break; /* end of enumeration */
else {
GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS,
- ("Failed to get %d in input enumeration for %s",
+ (_("Failed to get %d in input enumeration for %s."),
n, v4l2object->videodev), GST_ERROR_SYSTEM);
return FALSE;
}
vtun.index = input.tuner;
if (ioctl (v4l2object->video_fd, VIDIOC_G_TUNER, &vtun) < 0) {
GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS,
- ("Failed to get tuner %d settings on %s",
+ (_("Failed to get tuner %d settings on %s."),
input.tuner, v4l2object->videodev), GST_ERROR_SYSTEM);
g_object_unref (G_OBJECT (channel));
return FALSE;
break; /* end of enumeration */
else {
GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS,
- ("Failed to get %d in norm enumeration for %s",
+ (_("Failed to get %d in norm enumeration for %s."),
n, v4l2object->videodev), GST_ERROR_SYSTEM);
return FALSE;
}
break;
} else {
GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS,
- ("Failed to get %d in control enumeration for %s",
+ (_("Failed to get %d in control enumeration for %s."),
n, v4l2object->videodev), GST_ERROR_SYSTEM);
return FALSE;
}
break; /* end of enumeration */
else {
GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS,
- ("Failed to get %d in menu enumeration for %s",
+ (_("Failed to get %d in menu enumeration for %s"),
n, v4l2object->videodev), GST_ERROR_SYSTEM);
return FALSE;
}
stat_failed:
{
GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, NOT_FOUND,
- (_("Cannot identify device '%s'"), v4l2object->videodev),
+ (_("Cannot identify device '%s'."), v4l2object->videodev),
GST_ERROR_SYSTEM);
goto error;
}
no_device:
{
GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, NOT_FOUND,
- (_("This isn't a device '%s'"), v4l2object->videodev),
+ (_("This isn't a device '%s'."), v4l2object->videodev),
GST_ERROR_SYSTEM);
goto error;
}
std_failed:
{
GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
- (_("Failed to set norm 0x%llx for device %s: %s"),
+ (_("Failed to set norm 0x%llx for device %s: %s."),
norm, v4l2object->videodev), GST_ERROR_SYSTEM);
return FALSE;
}
freq_failed:
{
GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
- (_("Failed to get current tuner frequency for device %s"),
+ (_("Failed to get current tuner frequency for device %s."),
v4l2object->videodev), GST_ERROR_SYSTEM);
return FALSE;
}
freq_failed:
{
GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
- (_("Failed to set current tuner frequency for device %s to %lu"),
+ (_("Failed to set current tuner frequency for device %s to %lu."),
v4l2object->videodev, frequency), GST_ERROR_SYSTEM);
return FALSE;
}
tuner_failed:
{
GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
- (_("Failed to get signal strength for device %s"),
+ (_("Failed to get signal strength for device %s."),
v4l2object->videodev), GST_ERROR_SYSTEM);
return FALSE;
}
ctrl_failed:
{
GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
- (_("Failed to get value for control %d on device %s"),
+ (_("Failed to get value for control %d on device %s."),
attribute_num, v4l2object->videodev), GST_ERROR_SYSTEM);
return FALSE;
}
ctrl_failed:
{
GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
- (_("Failed to set value %d for control %d on device %s"),
+ (_("Failed to set value %d for control %d on device %s."),
value, attribute_num, v4l2object->videodev), GST_ERROR_SYSTEM);
return FALSE;
}
input_failed:
{
GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
- (_("Failed to get current input on device %s"),
+ (_("Failed to get current input on device %s."),
v4l2object->videodev), GST_ERROR_SYSTEM);
return FALSE;
}
input_failed:
{
GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
- (_("Failed to set input %d on device %s"),
+ (_("Failed to set input %d on device %s."),
input, v4l2object->videodev), GST_ERROR_SYSTEM);
return FALSE;
}
failed:
{
GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS,
- (_("failed to get number %d in pixelformat enumeration for %s: %s"),
+ (_("Failed to get number %d in pixelformat enumeration for %s."),
n, v4l2src->v4l2object->videodev), GST_ERROR_SYSTEM);
g_free (format);
return FALSE;
break;
default:
GST_ELEMENT_WARNING (v4l2src, RESOURCE, FAILED,
- (_("Grabbing frame got interrupted on %s. No expected reason"),
+ (_("Grabbing frame got interrupted on %s. No expected reason."),
v4l2src->v4l2object->videodev), GST_ERROR_SYSTEM);
break;
}
einval:
{
GST_ELEMENT_ERROR (v4l2src, RESOURCE, FAILED,
- (_("Failed trying to get frames from device %s"),
+ (_("Failed trying to get frames from device %s."),
v4l2src->v4l2object->videodev),
(_("The buffer type is not supported, or the index is out of bounds,"
" or no buffers have been allocated yet, or the userptr"
nomem:
{
GST_ELEMENT_ERROR (v4l2src, RESOURCE, FAILED,
- (_("Failed trying to get frames from device %s. Not enough memory"),
+ (_("Failed trying to get frames from device %s. Not enough memory."),
v4l2src->v4l2object->videodev),
- (_("insufficient memory to enqueue a user pointer buffer. device %s"),
+ (_("insufficient memory to enqueue a user pointer buffer. device %s."),
v4l2src->v4l2object->videodev));
return -1;
}
too_many_trials:
{
GST_ELEMENT_ERROR (v4l2src, RESOURCE, FAILED,
- (_("Failed trying to get frames from device %s"),
+ (_("Failed trying to get frames from device %s."),
v4l2src->v4l2object->videodev),
- (_("Failed after 100 tries. device %s"),
+ (_("Failed after 100 tries. device %s."),
v4l2src->v4l2object->videodev));
return -1;
}
fmt_failed:
{
GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS,
- (_("failed to get pixelformat for device %s"),
+ (_("Failed to get pixelformat for device %s."),
v4l2src->v4l2object->videodev), GST_ERROR_SYSTEM);
return FALSE;
}
fmt_failed:
{
GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS,
- (_("failed to set pixelformat to %s @ %dx%d for device %s: %s"),
+ (_("Failed to set pixelformat to %s @ %dx%d for device %s: %s."),
fmt->description, *width, *height, v4l2src->v4l2object->videodev),
GST_ERROR_SYSTEM);
return FALSE;
pixfmt_failed:
{
GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS,
- (_("failed to set pixelformat to %s @ %dx%d for device %s: %s"),
+ (_("Failed to set pixelformat to %s @ %dx%d for device %s: %s."),
fmt->description, *width, *height, v4l2src->v4l2object->videodev),
GST_ERROR_SYSTEM);
return FALSE;
}
fail:
{
+ /* ERROR was posted */
return FALSE;
}
}
broken_driver:
{
GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ,
- (_("the driver of device '%s' is broken."),
+ (_("The driver of device '%s' is broken."),
v4l2src->v4l2object->videodev),
("no supported read capability from %s",
v4l2src->v4l2object->videodev));
querybuf_failed:
{
GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ,
- (_("Could not get buffer properties of buffer %d"), n),
+ (_("Could not get buffer properties of buffer %d."), n),
GST_ERROR_SYSTEM);
gst_v4l2src_capture_deinit (v4l2src);
return FALSE;
mmap_failed:
{
GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ,
- (_("Could not mmap video buffer %d: %s"), n), GST_ERROR_SYSTEM);
+ (_("Could not mmap video buffer %d."), n), GST_ERROR_SYSTEM);
gst_v4l2src_capture_deinit (v4l2src);
buffer->start = 0;
return FALSE;
streamon_failed:
{
GST_ELEMENT_ERROR (v4l2src, RESOURCE, OPEN_READ,
- (_("Error starting streaming capture from device %s"),
+ (_("Error starting streaming capture from device %s."),
v4l2src->v4l2object->videodev), GST_ERROR_SYSTEM);
return FALSE;
}
streamoff_failed:
{
GST_ELEMENT_ERROR (v4l2src, RESOURCE, CLOSE,
- (_("Error stopping streaming capture from device %s: %s"),
+ (_("Error stopping streaming capture from device %s."),
v4l2src->v4l2object->videodev), GST_ERROR_SYSTEM);
return FALSE;
}
GstV4l2Buffer * srcbuf)
{
GstBuffer *buf;
+ GstClockTime timestamp, duration;
+ GstClock *clock;
if (data == NULL) {
buf = gst_buffer_new_and_alloc (size);
}
GST_BUFFER_SIZE (buf) = size;
- GST_BUFFER_TIMESTAMP (buf) =
- gst_clock_get_time (GST_ELEMENT (v4l2src)->clock);
- GST_BUFFER_TIMESTAMP (buf) -= GST_ELEMENT (v4l2src)->base_time;
- GST_BUFFER_OFFSET (buf) = v4l2src->offset++;
-
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_READONLY);
+
+ /* timestamps, LOCK to get clock and base time. */
+ GST_OBJECT_LOCK (v4l2src);
+ if ((clock = GST_ELEMENT_CLOCK (v4l2src))) {
+ /* we have a clock, get base time and ref clock */
+ timestamp = GST_ELEMENT (v4l2src)->base_time;
+ gst_object_ref (clock);
+ } else {
+ /* no clock, can't set timestamps */
+ timestamp = GST_CLOCK_TIME_NONE;
+ }
+ GST_OBJECT_UNLOCK (v4l2src);
+
+ if (clock) {
+ /* the time now is the time of the clock minus the base time */
+ timestamp = gst_clock_get_time (clock) - timestamp;
+ gst_object_unref (clock);
+ }
+
if (v4l2src->fps_n > 0) {
- GST_BUFFER_DURATION (buf) =
+ duration =
gst_util_uint64_scale_int (GST_SECOND, v4l2src->fps_d, v4l2src->fps_n);
} else {
- GST_BUFFER_DURATION (buf) = GST_CLOCK_TIME_NONE;
+ duration = GST_CLOCK_TIME_NONE;
}
+ GST_BUFFER_TIMESTAMP (buf) = timestamp;
+ GST_BUFFER_DURATION (buf) = duration;
+
+ /* offsets */
+ GST_BUFFER_OFFSET (buf) = v4l2src->offset++;
+ GST_BUFFER_OFFSET_END (buf) = v4l2src->offset;
/* the negotiate() method already set caps on the source pad */
gst_buffer_set_caps (buf, GST_PAD_CAPS (GST_BASE_SRC_PAD (v4l2src)));
+/* GStreamer
+ *
+ * Copyright (C) 2006 Edgard Lima <edgard dot lima at indt dot org dot br>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
case GST_MESSAGE_ERROR:{
GError *err;
gchar *debug;
+ gchar *str;
gst_message_parse_error (message, &err, &debug);
- g_print ("%s error: %s\n",
- gst_element_get_name (message->src), err->message);
+ str = gst_element_get_name (message->src);
+ g_print ("%s error: %s\n", str, err->message);
+ g_free (str);
g_print ("Debug: %s\n", debug);
g_error_free (err);
gchar input[128] = { '\0' };
gulong frequency = 0;
gboolean undeffps = FALSE;
-
+ GstBus *bus;
/* see for input option */
}
}
-
/* Print any remaining command line arguments (not options). */
if (optind < argc) {
printf ("Use -h to see help message.\n" "non-option ARGV-elements: ");
putchar ('\n');
}
-
-
/* init */
gst_init (&argc, &argv);
}
/* you would normally check that the elements were created properly */
- gst_bus_add_watch (gst_pipeline_get_bus (GST_PIPELINE (pipeline)),
- my_bus_callback, NULL);
+ bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
+ gst_bus_add_watch (bus, my_bus_callback, NULL);
/* put together a pipeline */
gst_bin_add_many (GST_BIN (pipeline), source, sink, NULL);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
+ gst_object_unref (bus);
gst_object_unref (pipeline);
gst_deinit ();