Lines 88-94
gst_v4l2_buffer_finalize (GstV4l2Buffer
Link Here
|
88 |
pool->num_live_buffers--; |
88 |
pool->num_live_buffers--; |
89 |
|
89 |
|
90 |
if (pool->running) { |
90 |
if (pool->running) { |
91 |
if (ioctl (pool->video_fd, VIDIOC_QBUF, &buffer->vbuffer) < 0) { |
91 |
if (v4l2_ioctl (pool->video_fd, VIDIOC_QBUF, &buffer->vbuffer) < 0) { |
92 |
GST_WARNING ("could not requeue buffer %p %d", buffer, index); |
92 |
GST_WARNING ("could not requeue buffer %p %d", buffer, index); |
93 |
} else { |
93 |
} else { |
94 |
/* FIXME: check that the caps didn't change */ |
94 |
/* FIXME: check that the caps didn't change */ |
Lines 106-112
gst_v4l2_buffer_finalize (GstV4l2Buffer
Link Here
|
106 |
if (!resuscitated) { |
106 |
if (!resuscitated) { |
107 |
GST_LOG ("buffer %p not recovered, unmapping", buffer); |
107 |
GST_LOG ("buffer %p not recovered, unmapping", buffer); |
108 |
gst_mini_object_unref (GST_MINI_OBJECT (pool)); |
108 |
gst_mini_object_unref (GST_MINI_OBJECT (pool)); |
109 |
munmap ((void *) GST_BUFFER_DATA (buffer), buffer->vbuffer.length); |
109 |
v4l2_munmap ((void *) GST_BUFFER_DATA (buffer), buffer->vbuffer.length); |
110 |
|
110 |
|
111 |
GST_MINI_OBJECT_CLASS (v4l2buffer_parent_class)->finalize (GST_MINI_OBJECT |
111 |
GST_MINI_OBJECT_CLASS (v4l2buffer_parent_class)->finalize (GST_MINI_OBJECT |
112 |
(buffer)); |
112 |
(buffer)); |
Lines 165-171
gst_v4l2_buffer_new (GstV4l2BufferPool *
Link Here
|
165 |
ret->vbuffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
165 |
ret->vbuffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
166 |
ret->vbuffer.memory = V4L2_MEMORY_MMAP; |
166 |
ret->vbuffer.memory = V4L2_MEMORY_MMAP; |
167 |
|
167 |
|
168 |
if (ioctl (pool->video_fd, VIDIOC_QUERYBUF, &ret->vbuffer) < 0) |
168 |
if (v4l2_ioctl (pool->video_fd, VIDIOC_QUERYBUF, &ret->vbuffer) < 0) |
169 |
goto querybuf_failed; |
169 |
goto querybuf_failed; |
170 |
|
170 |
|
171 |
GST_LOG (" index: %u", ret->vbuffer.index); |
171 |
GST_LOG (" index: %u", ret->vbuffer.index); |
Lines 179-185
gst_v4l2_buffer_new (GstV4l2BufferPool *
Link Here
|
179 |
GST_LOG (" length: %u", ret->vbuffer.length); |
179 |
GST_LOG (" length: %u", ret->vbuffer.length); |
180 |
GST_LOG (" input: %u", ret->vbuffer.input); |
180 |
GST_LOG (" input: %u", ret->vbuffer.input); |
181 |
|
181 |
|
182 |
data = (guint8 *) mmap (0, ret->vbuffer.length, |
182 |
data = (guint8 *) v4l2_mmap (0, ret->vbuffer.length, |
183 |
PROT_READ | PROT_WRITE, MAP_SHARED, pool->video_fd, |
183 |
PROT_READ | PROT_WRITE, MAP_SHARED, pool->video_fd, |
184 |
ret->vbuffer.m.offset); |
184 |
ret->vbuffer.m.offset); |
185 |
|
185 |
|
Lines 229-235
gst_v4l2_buffer_pool_finalize (GstV4l2Bu
Link Here
|
229 |
pool->lock = NULL; |
229 |
pool->lock = NULL; |
230 |
|
230 |
|
231 |
if (pool->video_fd >= 0) |
231 |
if (pool->video_fd >= 0) |
232 |
close (pool->video_fd); |
232 |
v4l2_close (pool->video_fd); |
233 |
|
233 |
|
234 |
if (pool->buffers) { |
234 |
if (pool->buffers) { |
235 |
g_free (pool->buffers); |
235 |
g_free (pool->buffers); |
Lines 292-298
gst_v4l2_buffer_pool_new (GstV4l2Src * v
Link Here
|
292 |
|
292 |
|
293 |
pool = (GstV4l2BufferPool *) gst_mini_object_new (GST_TYPE_V4L2_BUFFER_POOL); |
293 |
pool = (GstV4l2BufferPool *) gst_mini_object_new (GST_TYPE_V4L2_BUFFER_POOL); |
294 |
|
294 |
|
295 |
pool->video_fd = dup (fd); |
295 |
pool->video_fd = v4l2_dup (fd); |
296 |
if (pool->video_fd < 0) |
296 |
if (pool->video_fd < 0) |
297 |
goto dup_failed; |
297 |
goto dup_failed; |
298 |
|
298 |
|
Lines 344-350
gst_v4l2_buffer_pool_activate (GstV4l2Bu
Link Here
|
344 |
|
344 |
|
345 |
GST_LOG ("enqueue pool buffer %d", n); |
345 |
GST_LOG ("enqueue pool buffer %d", n); |
346 |
|
346 |
|
347 |
if (ioctl (pool->video_fd, VIDIOC_QBUF, buf) < 0) |
347 |
if (v4l2_ioctl (pool->video_fd, VIDIOC_QBUF, buf) < 0) |
348 |
goto queue_failed; |
348 |
goto queue_failed; |
349 |
} |
349 |
} |
350 |
pool->running = TRUE; |
350 |
pool->running = TRUE; |
Lines 519-525
gst_v4l2src_fill_format_list (GstV4l2Src
Link Here
|
519 |
format->index = n; |
519 |
format->index = n; |
520 |
format->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
520 |
format->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
521 |
|
521 |
|
522 |
if (ioctl (v4l2src->v4l2object->video_fd, VIDIOC_ENUM_FMT, format) < 0) { |
522 |
if (v4l2_ioctl (v4l2src->v4l2object->video_fd, VIDIOC_ENUM_FMT, format) < 0) { |
523 |
if (errno == EINVAL) { |
523 |
if (errno == EINVAL) { |
524 |
g_free (format); |
524 |
g_free (format); |
525 |
break; /* end of enumeration */ |
525 |
break; /* end of enumeration */ |
Lines 595-601
gst_v4l2src_probe_caps_for_format_and_si
Link Here
|
595 |
|
595 |
|
596 |
/* keep in mind that v4l2 gives us frame intervals (durations); we invert the |
596 |
/* keep in mind that v4l2 gives us frame intervals (durations); we invert the |
597 |
* fraction to get framerate */ |
597 |
* fraction to get framerate */ |
598 |
if (ioctl (fd, VIDIOC_ENUM_FRAMEINTERVALS, &ival) < 0) |
598 |
if (v4l2_ioctl (fd, VIDIOC_ENUM_FRAMEINTERVALS, &ival) < 0) |
599 |
goto enum_frameintervals_failed; |
599 |
goto enum_frameintervals_failed; |
600 |
|
600 |
|
601 |
if (ival.type == V4L2_FRMIVAL_TYPE_DISCRETE) { |
601 |
if (ival.type == V4L2_FRMIVAL_TYPE_DISCRETE) { |
Lines 621-627
gst_v4l2src_probe_caps_for_format_and_si
Link Here
|
621 |
gst_value_list_append_value (&rates, &rate); |
621 |
gst_value_list_append_value (&rates, &rate); |
622 |
|
622 |
|
623 |
ival.index++; |
623 |
ival.index++; |
624 |
} while (ioctl (fd, VIDIOC_ENUM_FRAMEINTERVALS, &ival) >= 0); |
624 |
} while (v4l2_ioctl (fd, VIDIOC_ENUM_FRAMEINTERVALS, &ival) >= 0); |
625 |
} else if (ival.type == V4L2_FRMIVAL_TYPE_STEPWISE) { |
625 |
} else if (ival.type == V4L2_FRMIVAL_TYPE_STEPWISE) { |
626 |
GValue min = { 0, }; |
626 |
GValue min = { 0, }; |
627 |
GValue step = { 0, }; |
627 |
GValue step = { 0, }; |
Lines 782-788
gst_v4l2src_probe_caps_for_format (GstV4
Link Here
|
782 |
|
782 |
|
783 |
GST_DEBUG_OBJECT (v4l2src, "Enumerating frame sizes"); |
783 |
GST_DEBUG_OBJECT (v4l2src, "Enumerating frame sizes"); |
784 |
|
784 |
|
785 |
if (ioctl (fd, VIDIOC_ENUM_FRAMESIZES, &size) < 0) |
785 |
if (v4l2_ioctl (fd, VIDIOC_ENUM_FRAMESIZES, &size) < 0) |
786 |
goto enum_framesizes_failed; |
786 |
goto enum_framesizes_failed; |
787 |
|
787 |
|
788 |
if (size.type == V4L2_FRMSIZE_TYPE_DISCRETE) { |
788 |
if (size.type == V4L2_FRMSIZE_TYPE_DISCRETE) { |
Lines 802-808
gst_v4l2src_probe_caps_for_format (GstV4
Link Here
|
802 |
results = g_list_prepend (results, tmp); |
802 |
results = g_list_prepend (results, tmp); |
803 |
|
803 |
|
804 |
size.index++; |
804 |
size.index++; |
805 |
} while (ioctl (fd, VIDIOC_ENUM_FRAMESIZES, &size) >= 0); |
805 |
} while (v4l2_ioctl (fd, VIDIOC_ENUM_FRAMESIZES, &size) >= 0); |
806 |
GST_DEBUG_OBJECT (v4l2src, "done iterating discrete frame sizes"); |
806 |
GST_DEBUG_OBJECT (v4l2src, "done iterating discrete frame sizes"); |
807 |
} else if (size.type == V4L2_FRMSIZE_TYPE_STEPWISE) { |
807 |
} else if (size.type == V4L2_FRMSIZE_TYPE_STEPWISE) { |
808 |
GST_DEBUG_OBJECT (v4l2src, "we have stepwise frame sizes:"); |
808 |
GST_DEBUG_OBJECT (v4l2src, "we have stepwise frame sizes:"); |
Lines 972-978
gst_v4l2src_grab_frame (GstV4l2Src * v4l
Link Here
|
972 |
buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
972 |
buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
973 |
buffer.memory = V4L2_MEMORY_MMAP; |
973 |
buffer.memory = V4L2_MEMORY_MMAP; |
974 |
|
974 |
|
975 |
while (ioctl (v4l2src->v4l2object->video_fd, VIDIOC_DQBUF, &buffer) < 0) { |
975 |
while (v4l2_ioctl (v4l2src->v4l2object->video_fd, VIDIOC_DQBUF, &buffer) < 0) { |
976 |
|
976 |
|
977 |
GST_WARNING_OBJECT (v4l2src, |
977 |
GST_WARNING_OBJECT (v4l2src, |
978 |
"problem grabbing frame %d (ix=%d), trials=%d, pool-ct=%d, buf.flags=%d", |
978 |
"problem grabbing frame %d (ix=%d), trials=%d, pool-ct=%d, buf.flags=%d", |
Lines 1190-1196
gst_v4l2src_set_capture (GstV4l2Src * v4
Link Here
|
1190 |
memset (&format, 0x00, sizeof (struct v4l2_format)); |
1190 |
memset (&format, 0x00, sizeof (struct v4l2_format)); |
1191 |
format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
1191 |
format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
1192 |
|
1192 |
|
1193 |
if (ioctl (fd, VIDIOC_G_FMT, &format) < 0) |
1193 |
if (v4l2_ioctl (fd, VIDIOC_G_FMT, &format) < 0) |
1194 |
goto get_fmt_failed; |
1194 |
goto get_fmt_failed; |
1195 |
|
1195 |
|
1196 |
format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
1196 |
format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
Lines 1202-1208
gst_v4l2src_set_capture (GstV4l2Src * v4
Link Here
|
1202 |
* combined, there are other modes for requesting fields individually) */ |
1202 |
* combined, there are other modes for requesting fields individually) */ |
1203 |
format.fmt.pix.field = V4L2_FIELD_INTERLACED; |
1203 |
format.fmt.pix.field = V4L2_FIELD_INTERLACED; |
1204 |
|
1204 |
|
1205 |
if (ioctl (fd, VIDIOC_S_FMT, &format) < 0) { |
1205 |
if (v4l2_ioctl (fd, VIDIOC_S_FMT, &format) < 0) { |
1206 |
if (errno != EINVAL) |
1206 |
if (errno != EINVAL) |
1207 |
goto set_fmt_failed; |
1207 |
goto set_fmt_failed; |
1208 |
|
1208 |
|
Lines 1211-1217
gst_v4l2src_set_capture (GstV4l2Src * v4
Link Here
|
1211 |
format.fmt.pix.height = height; |
1211 |
format.fmt.pix.height = height; |
1212 |
format.fmt.pix.pixelformat = pixelformat; |
1212 |
format.fmt.pix.pixelformat = pixelformat; |
1213 |
format.fmt.pix.field = V4L2_FIELD_NONE; |
1213 |
format.fmt.pix.field = V4L2_FIELD_NONE; |
1214 |
if (ioctl (fd, VIDIOC_S_FMT, &format) < 0) |
1214 |
if (v4l2_ioctl (fd, VIDIOC_S_FMT, &format) < 0) |
1215 |
goto set_fmt_failed; |
1215 |
goto set_fmt_failed; |
1216 |
} |
1216 |
} |
1217 |
|
1217 |
|
Lines 1226-1232
gst_v4l2src_set_capture (GstV4l2Src * v4
Link Here
|
1226 |
|
1226 |
|
1227 |
memset (&stream, 0x00, sizeof (struct v4l2_streamparm)); |
1227 |
memset (&stream, 0x00, sizeof (struct v4l2_streamparm)); |
1228 |
stream.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
1228 |
stream.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
1229 |
if (ioctl (fd, VIDIOC_G_PARM, &stream) < 0) { |
1229 |
if (v4l2_ioctl (fd, VIDIOC_G_PARM, &stream) < 0) { |
1230 |
GST_ELEMENT_WARNING (v4l2src, RESOURCE, SETTINGS, |
1230 |
GST_ELEMENT_WARNING (v4l2src, RESOURCE, SETTINGS, |
1231 |
(_("Could not get parameters on device '%s'"), |
1231 |
(_("Could not get parameters on device '%s'"), |
1232 |
v4l2src->v4l2object->videodev), GST_ERROR_SYSTEM); |
1232 |
v4l2src->v4l2object->videodev), GST_ERROR_SYSTEM); |
Lines 1256-1262
gst_v4l2src_set_capture (GstV4l2Src * v4
Link Here
|
1256 |
stream.parm.capture.timeperframe.denominator = fps_n; |
1256 |
stream.parm.capture.timeperframe.denominator = fps_n; |
1257 |
|
1257 |
|
1258 |
/* some cheap USB cam's won't accept any change */ |
1258 |
/* some cheap USB cam's won't accept any change */ |
1259 |
if (ioctl (fd, VIDIOC_S_PARM, &stream) < 0) { |
1259 |
if (v4l2_ioctl (fd, VIDIOC_S_PARM, &stream) < 0) { |
1260 |
GST_ELEMENT_WARNING (v4l2src, RESOURCE, SETTINGS, |
1260 |
GST_ELEMENT_WARNING (v4l2src, RESOURCE, SETTINGS, |
1261 |
(_("Video input device did not accept new frame rate setting.")), |
1261 |
(_("Video input device did not accept new frame rate setting.")), |
1262 |
GST_ERROR_SYSTEM); |
1262 |
GST_ERROR_SYSTEM); |
Lines 1338-1344
gst_v4l2src_capture_init (GstV4l2Src * v
Link Here
|
1338 |
breq.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
1338 |
breq.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
1339 |
breq.memory = V4L2_MEMORY_MMAP; |
1339 |
breq.memory = V4L2_MEMORY_MMAP; |
1340 |
|
1340 |
|
1341 |
if (ioctl (fd, VIDIOC_REQBUFS, &breq) < 0) |
1341 |
if (v4l2_ioctl (fd, VIDIOC_REQBUFS, &breq) < 0) |
1342 |
goto reqbufs_failed; |
1342 |
goto reqbufs_failed; |
1343 |
|
1343 |
|
1344 |
GST_LOG_OBJECT (v4l2src, " count: %u", breq.count); |
1344 |
GST_LOG_OBJECT (v4l2src, " count: %u", breq.count); |
Lines 1433-1439
gst_v4l2src_capture_start (GstV4l2Src *
Link Here
|
1433 |
if (!gst_v4l2_buffer_pool_activate (v4l2src->pool, v4l2src)) |
1433 |
if (!gst_v4l2_buffer_pool_activate (v4l2src->pool, v4l2src)) |
1434 |
goto pool_activate_failed; |
1434 |
goto pool_activate_failed; |
1435 |
|
1435 |
|
1436 |
if (ioctl (fd, VIDIOC_STREAMON, &type) < 0) |
1436 |
if (v4l2_ioctl (fd, VIDIOC_STREAMON, &type) < 0) |
1437 |
goto streamon_failed; |
1437 |
goto streamon_failed; |
1438 |
} |
1438 |
} |
1439 |
|
1439 |
|
Lines 1478-1484
gst_v4l2src_capture_stop (GstV4l2Src * v
Link Here
|
1478 |
if (v4l2src->use_mmap) { |
1478 |
if (v4l2src->use_mmap) { |
1479 |
/* we actually need to sync on all queued buffers but not |
1479 |
/* we actually need to sync on all queued buffers but not |
1480 |
* on the non-queued ones */ |
1480 |
* on the non-queued ones */ |
1481 |
if (ioctl (v4l2src->v4l2object->video_fd, VIDIOC_STREAMOFF, &type) < 0) |
1481 |
if (v4l2_ioctl (v4l2src->v4l2object->video_fd, VIDIOC_STREAMOFF, &type) < 0) |
1482 |
goto streamoff_failed; |
1482 |
goto streamoff_failed; |
1483 |
} |
1483 |
} |
1484 |
|
1484 |
|
Lines 1554-1567
gst_v4l2src_get_nearest_size (GstV4l2Src
Link Here
|
1554 |
fmt.fmt.pix.pixelformat = pixelformat; |
1554 |
fmt.fmt.pix.pixelformat = pixelformat; |
1555 |
fmt.fmt.pix.field = V4L2_FIELD_INTERLACED; |
1555 |
fmt.fmt.pix.field = V4L2_FIELD_INTERLACED; |
1556 |
|
1556 |
|
1557 |
r = ioctl (fd, VIDIOC_TRY_FMT, &fmt); |
1557 |
r = v4l2_ioctl (fd, VIDIOC_TRY_FMT, &fmt); |
1558 |
if (r < 0 && errno == EINVAL) { |
1558 |
if (r < 0 && errno == EINVAL) { |
1559 |
/* try again with progressive video */ |
1559 |
/* try again with progressive video */ |
1560 |
fmt.fmt.pix.width = *width; |
1560 |
fmt.fmt.pix.width = *width; |
1561 |
fmt.fmt.pix.height = *height; |
1561 |
fmt.fmt.pix.height = *height; |
1562 |
fmt.fmt.pix.pixelformat = pixelformat; |
1562 |
fmt.fmt.pix.pixelformat = pixelformat; |
1563 |
fmt.fmt.pix.field = V4L2_FIELD_NONE; |
1563 |
fmt.fmt.pix.field = V4L2_FIELD_NONE; |
1564 |
r = ioctl (fd, VIDIOC_TRY_FMT, &fmt); |
1564 |
r = v4l2_ioctl (fd, VIDIOC_TRY_FMT, &fmt); |
1565 |
} |
1565 |
} |
1566 |
|
1566 |
|
1567 |
if (r < 0) { |
1567 |
if (r < 0) { |
Lines 1581-1594
gst_v4l2src_get_nearest_size (GstV4l2Src
Link Here
|
1581 |
fmt.fmt.pix.width = *width; |
1581 |
fmt.fmt.pix.width = *width; |
1582 |
fmt.fmt.pix.height = *height; |
1582 |
fmt.fmt.pix.height = *height; |
1583 |
|
1583 |
|
1584 |
r = ioctl (fd, VIDIOC_S_FMT, &fmt); |
1584 |
r = v4l2_ioctl (fd, VIDIOC_S_FMT, &fmt); |
1585 |
if (r < 0 && errno == EINVAL) { |
1585 |
if (r < 0 && errno == EINVAL) { |
1586 |
/* try again with progressive video */ |
1586 |
/* try again with progressive video */ |
1587 |
fmt.fmt.pix.width = *width; |
1587 |
fmt.fmt.pix.width = *width; |
1588 |
fmt.fmt.pix.height = *height; |
1588 |
fmt.fmt.pix.height = *height; |
1589 |
fmt.fmt.pix.pixelformat = pixelformat; |
1589 |
fmt.fmt.pix.pixelformat = pixelformat; |
1590 |
fmt.fmt.pix.field = V4L2_FIELD_NONE; |
1590 |
fmt.fmt.pix.field = V4L2_FIELD_NONE; |
1591 |
r = ioctl (fd, VIDIOC_S_FMT, &fmt); |
1591 |
r = v4l2_ioctl (fd, VIDIOC_S_FMT, &fmt); |
1592 |
} |
1592 |
} |
1593 |
|
1593 |
|
1594 |
if (r < 0) |
1594 |
if (r < 0) |