summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Salt <linux@youmustbejoking.demon.co.uk>2010-01-29 19:34:22 +0000
committerDarren Salt <linux@youmustbejoking.demon.co.uk>2010-01-29 19:34:22 +0000
commitd7eebbd54d3883246d6ff8ba906846b57a1bfd92 (patch)
tree16276c2141705c637527695e6770fcbbd08cdd6a
parenta588599bd24399e45f82fcb19b6a28fb6537771f (diff)
parent81e86315a6966e172f4988f8925f830e01072c53 (diff)
downloadxine-lib-d7eebbd54d3883246d6ff8ba906846b57a1bfd92.tar.gz
xine-lib-d7eebbd54d3883246d6ff8ba906846b57a1bfd92.tar.bz2
Merge from 1.1.
-rw-r--r--m4/input.m47
-rw-r--r--src/input/Makefile.am4
-rw-r--r--src/input/input_v4l2.c53
3 files changed, 45 insertions, 19 deletions
diff --git a/m4/input.m4 b/m4/input.m4
index 2f5ceeec9..04c480720 100644
--- a/m4/input.m4
+++ b/m4/input.m4
@@ -90,8 +90,11 @@ AC_DEFUN([XINE_INPUT_PLUGINS], [
AC_MSG_ERROR([Video4Linux support requested, but prerequisite headers not found.])
fi
XINE_ARG_ENABLE([libv4l], [Enable libv4l support])
- if test "x$enable_libv4l" != "xno"; then
- AC_CHECK_HEADERS([libv4l2.h], [have_libv4l=yes], [have_libv4l=no])
+ if test "x$enable_libv4l" != "xno"; then
+ PKG_CHECK_MODULES([V4L2], [libv4l2],
+ [have_libv4l=yes
+ AC_DEFINE([HAVE_LIBV4L2_H], [1], [Define this if you have libv4l installed])],
+ [have_libv4l=no])
if test "x$hard_enable_libv4l" = "xyes" && test "x$have_libv4l" = "xno"; then
AC_MSG_ERROR([libv4l requested, but libv4l not found])
fi
diff --git a/src/input/Makefile.am b/src/input/Makefile.am
index c740351d6..608b7e68f 100644
--- a/src/input/Makefile.am
+++ b/src/input/Makefile.am
@@ -126,8 +126,8 @@ xineplug_inp_v4l_la_LIBADD = $(XINE_LIB) $(ALSA_LIBS) $(LTLIBINTL)
xineplug_inp_v4l_la_CFLAGS = $(AM_CFLAGS) $(ALSA_CFLAGS)
xineplug_inp_v4l2_la_SOURCES = input_v4l2.c
-xineplug_inp_v4l2_la_LIBADD = $(XINE_LIB) $(ALSA_LIBS)
-xineplug_inp_v4l2_la_CFLAGS = $(VISIBILITY_FLAG) $(AM_CFLAGS)
+xineplug_inp_v4l2_la_LIBADD = $(XINE_LIB) $(ALSA_LIBS) $(LTLIBINTL) $(V4L2_LIBS)
+xineplug_inp_v4l2_la_CFLAGS = $(AM_CFLAGS) $(ALSA_CFLAGS) $(V4L2_CFLAGS)
xineplug_inp_v4l2_la_LDFLAGS = -avoid-version -module
xineplug_inp_gnome_vfs_la_SOURCES = input_gnome_vfs.c net_buf_ctrl.c
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;
}