summaryrefslogtreecommitdiff
path: root/src/input/input_v4l2.c
diff options
context:
space:
mode:
authorJulian Scheel <julian@jusst.de>2010-01-30 12:46:18 +0100
committerJulian Scheel <julian@jusst.de>2010-01-30 12:46:18 +0100
commit3c039d3b4c3bc24d26cb33c532c587c737564441 (patch)
tree902e0a9d6ae4551c6af996af3f8897d940386f0e /src/input/input_v4l2.c
parent474815e24bf5ed57813bab2c970bce13ad822e3c (diff)
parente0d73e94178127b08b922f2a0ca607fd320a9d9c (diff)
downloadxine-lib-3c039d3b4c3bc24d26cb33c532c587c737564441.tar.gz
xine-lib-3c039d3b4c3bc24d26cb33c532c587c737564441.tar.bz2
Merge with xine-lib-1.2
Diffstat (limited to 'src/input/input_v4l2.c')
-rw-r--r--src/input/input_v4l2.c53
1 files changed, 38 insertions, 15 deletions
diff --git a/src/input/input_v4l2.c b/src/input/input_v4l2.c
index 2ecb5bf0c..ef08a63ee 100644
--- a/src/input/input_v4l2.c
+++ b/src/input/input_v4l2.c
@@ -26,9 +26,9 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-
+/*
#define LOG
-
+*/
#include <xine/input_plugin.h>
#include <xine/xine_plugin.h>
#include <xine/xine_internal.h>
@@ -91,19 +91,26 @@ typedef struct {
v4l2_radio_t* radio;
} v4l2_input_plugin_t;
-static void v4l2_input_enqueue_video_buffer(v4l2_input_plugin_t *this, int idx);
+static int v4l2_input_enqueue_video_buffer(v4l2_input_plugin_t *this, int idx);
static int v4l2_input_dequeue_video_buffer(v4l2_input_plugin_t *this, buf_element_t *input);
static int v4l2_input_setup_video_streaming(v4l2_input_plugin_t *this);
static int v4l2_input_open(input_plugin_t *this_gen) {
v4l2_input_plugin_t *this = (v4l2_input_plugin_t*) this_gen;
+ int ret;
lprintf("Opening %s\n", this->mrl);
this->fd = v4l2_open(this->mrl, O_RDWR);
if (this->fd) {
/* TODO: Clean up this mess */
this->events = xine_event_new_queue(this->stream);
- v4l2_ioctl(this->fd, VIDIOC_QUERYCAP, &(this->cap));
+ ret = v4l2_ioctl(this->fd, VIDIOC_QUERYCAP, &(this->cap));
+ if (ret < 0)
+ {
+ xprintf (this->stream->xine, XINE_VERBOSITY_LOG,
+ LOG_MODULE": capability query failed: %s\n", strerror (-ret));
+ return 0;
+ }
if (this->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) {
this->video = malloc(sizeof(v4l2_video_t));
this->video->headerSent = 0;
@@ -117,16 +124,19 @@ static int v4l2_input_open(input_plugin_t *this_gen) {
return 1;
} else {
/* TODO: Fallbacks */
- lprintf("Video streaming setup failed.\n");
+ xprintf (this->stream->xine, XINE_VERBOSITY_LOG,
+ LOG_MODULE": video streaming setup failed\n");
return 0;
}
} else {
/* TODO: Radio streaming */
- lprintf("Sorry, only video is supported for now.\n");
+ xprintf (this->stream->xine, XINE_VERBOSITY_LOG,
+ LOG_MODULE": sorry, only video is supported for now\n");
return 0;
}
} else {
- lprintf("Device doesn't support streaming. Prod the author to support the other methods.\n");
+ xprintf (this->stream->xine, XINE_VERBOSITY_LOG,
+ LOG_MODULE": device doesn't support streaming - prod the author to support the other methods\n");
return 0;
}
} else {
@@ -180,7 +190,8 @@ static int v4l2_input_setup_video_streaming(v4l2_input_plugin_t *this) {
this->video->bufcount = 0;
return 0;
}
- v4l2_input_enqueue_video_buffer(this, i);
+ if (v4l2_input_enqueue_video_buffer(this, i) < 0)
+ goto fail;
}
struct v4l2_format fmt;
@@ -229,9 +240,14 @@ static buf_element_t* v4l2_input_read_block(input_plugin_t *this_gen, fifo_buffe
this->video->index = 0;
buf->type = BUF_VIDEO_YUY2;
} else {
- lprintf("Sending video frame (sent %d of %d)\n", this->video->index, this->video->buffers[this->video->inbuf.index].length);
+ lprintf("Sending video frame (sent %zd of %zd)\n", this->video->index, this->video->buffers[this->video->inbuf.index].length);
/* TODO: Add audio support */
this->video->headerSent = v4l2_input_dequeue_video_buffer(this, buf);
+ if (this->video->headerSent < 0)
+ {
+ buf->free_buffer (buf);
+ buf = NULL;
+ }
}
return buf;
}
@@ -251,12 +267,16 @@ static uint32_t v4l2_input_blocksize(input_plugin_t *this_gen) {
static int v4l2_input_dequeue_video_buffer(v4l2_input_plugin_t *this, buf_element_t *output)
{
+ int ret;
+
if (!this->video->index)
{
memset (&this->video->inbuf, 0, sizeof (this->video->inbuf));
this->video->inbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
this->video->inbuf.memory = V4L2_MEMORY_MMAP;
- v4l2_ioctl(this->fd, VIDIOC_DQBUF, &this->video->inbuf);
+ ret = v4l2_ioctl(this->fd, VIDIOC_DQBUF, &this->video->inbuf);
+ if (ret < 0)
+ return -1; /* failure */
output->decoder_flags = BUF_FLAG_FRAME_START;
}
else
@@ -269,26 +289,26 @@ static int v4l2_input_dequeue_video_buffer(v4l2_input_plugin_t *this, buf_elemen
if (output->size > output->max_size)
output->size = output->max_size;
- xine_fast_memcpy (output->content, this->video->buffers[this->video->inbuf.index].start + this->video->index, output->size);
+ xine_fast_memcpy (output->content, (char *)this->video->buffers[this->video->inbuf.index].start + this->video->index, output->size);
this->video->index += output->size;
if (this->video->index == this->video->buffers[this->video->inbuf.index].length)
{
output->decoder_flags |= BUF_FLAG_FRAME_END;
- v4l2_input_enqueue_video_buffer(this, this->video->inbuf.index);
- return 0;
+ ret = v4l2_input_enqueue_video_buffer(this, this->video->inbuf.index);
+ return -(ret < 0);
}
return 1;
}
-static void v4l2_input_enqueue_video_buffer(v4l2_input_plugin_t *this, int idx) {
+static int v4l2_input_enqueue_video_buffer(v4l2_input_plugin_t *this, int idx) {
struct v4l2_buffer buf;
memset(&buf, 0, sizeof(buf));
buf.index = idx;
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
- v4l2_ioctl(this->fd, VIDIOC_QBUF, &buf);
+ return v4l2_ioctl(this->fd, VIDIOC_QBUF, &buf);
}
static void v4l2_input_dispose(input_plugin_t *this_gen) {
@@ -398,6 +418,9 @@ static input_plugin_t *v4l2_class_get_instance(input_class_t *gen_cls, xine_stre
this->radio = NULL;
lprintf("Ready to read!\n");
+ xprintf (this->stream->xine, XINE_VERBOSITY_NONE,
+ LOG_MODULE": WARNING: this plugin is not of release quality\n");
+
return &this->input_plugin;
}