* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#undef __STRICT_ANSI__ //workaround due to broken kernel headers
#include "config.h"
-#include "avformat.h"
+#include "libavformat/avformat.h"
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
-#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
-#endif
#include <sys/time.h>
#include <asm/types.h>
#include <linux/videodev2.h>
#include <time.h>
+#include <strings.h>
static const int desired_video_buffers = 256;
}
}
- return -1;
+ return PIX_FMT_NONE;
}
static int mmap_init(AVFormatContext *ctx)
int res, frame_rate, frame_rate_base;
uint32_t desired_format, capabilities;
- if (ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0) {
- av_log(s1, AV_LOG_ERROR, "Missing/Wrong width, height or framerate\n");
-
+ if (ap->width <= 0 || ap->height <= 0) {
+ av_log(s1, AV_LOG_ERROR, "Wrong size (%dx%d)\n", ap->width, ap->height);
+ return -1;
+ }
+ if (ap->time_base.den <= 0) {
+ av_log(s1, AV_LOG_ERROR, "Wrong time base (%d)\n", ap->time_base.den);
return -1;
}
frame_rate_base = ap->time_base.num;
if((unsigned)width > 32767 || (unsigned)height > 32767) {
- av_log(s1, AV_LOG_ERROR, "Wrong size %dx%d\n", width, height);
+ av_log(s1, AV_LOG_ERROR, "Wrong size (%dx%d)\n", width, height);
return -1;
}
capabilities = 0;
s->fd = device_open(s1, &capabilities);
if (s->fd < 0) {
- av_free(st);
-
return AVERROR(EIO);
}
av_log(s1, AV_LOG_INFO, "[%d]Capabilities: %x\n", s->fd, capabilities);
if (desired_format == 0) {
av_log(s1, AV_LOG_ERROR, "Cannot find a proper format.\n");
close(s->fd);
- av_free(st);
return AVERROR(EIO);
}
}
if (res < 0) {
close(s->fd);
- av_free(st);
return AVERROR(EIO);
}
AVInputFormat v4l2_demuxer = {
"video4linux2",
- "video grab",
+ NULL_IF_CONFIG_SMALL("video grab"),
sizeof(struct video_data),
NULL,
v4l2_read_header,