File: v4l2.h

package info (click to toggle)
vlc 2.0.3-5+deb7u2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 155,976 kB
  • ctags: 54,884
  • sloc: ansic: 350,796; cpp: 80,439; objc: 28,824; sh: 13,349; makefile: 2,096; xml: 1,536; asm: 815; python: 240; perl: 110; sed: 16
file content (135 lines) | stat: -rw-r--r-- 3,899 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*****************************************************************************
 * v4l2.h : Video4Linux2 input module for vlc
 *****************************************************************************
 * Copyright (C) 2002-2011 the VideoLAN team
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#include <vlc_common.h>

#if defined(HAVE_LINUX_VIDEODEV2_H)
#   include <linux/videodev2.h>
#elif defined(HAVE_SYS_VIDEOIO_H)
#   include <sys/videoio.h>
#else
#   error "No Video4Linux2 headers found."
#endif

/* Hacks to compile with old headers */
#ifndef V4L2_CTRL_FLAG_VOLATILE /* 3.2 */
# warning Please update Video4Linux2 headers!
# define V4L2_CTRL_FLAG_VOLATILE 0x0080
#endif
#ifdef __linux__
# include <linux/version.h>
# if LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
#  define V4L2_CTRL_TYPE_BITMASK 8
# endif
#endif
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
/* FreeBSD 10 and earlier does not have V4L2_CTRL_TYPE_BITMASK */
# define V4L2_CTRL_TYPE_BITMASK 8
#endif
#ifndef V4L2_CID_ILLUMINATORS_1 /* 2.6.37 */
# define V4L2_CID_ILLUMINATORS_1 (V4L2_CID_BASE+38)
# define V4L2_CID_ILLUMINATORS_2 (V4L2_CID_BASE+37)
#endif
#ifndef V4L2_CID_CHROMA_GAIN /* 2.6.35 */
# define V4L2_CID_CHROMA_GAIN (V4L2_CID_BASE+36)
# define V4L2_COLORFX_VIVID 9
# define V4L2_COLORFX_SKIN_WHITEN 8
# define V4L2_COLORFX_GRASS_GREEN 7
# define V4L2_COLORFX_SKY_BLUE 6
# define V4L2_COLORFX_SKETCH 5
# define V4L2_COLORFX_EMBOSS 4
# define V4L2_COLORFX_NEGATIVE 3
#endif
#ifndef V4L2_CID_ROTATE /* 2.6.33 */
# define V4L2_CID_BG_COLOR (V4L2_CID_BASE+35)
# define V4L2_CID_ROTATE (V4L2_CID_BASE+34)
#endif

#ifdef HAVE_LIBV4L2
#   include <libv4l2.h>
#else
#   define v4l2_close close
#   define v4l2_dup dup
#   define v4l2_ioctl ioctl
#   define v4l2_read read
#   define v4l2_mmap mmap
#   define v4l2_munmap munmap
#endif

#define CFG_PREFIX "v4l2-"

/* TODO: remove this, use callbacks */
typedef enum {
    IO_METHOD_READ=1,
    IO_METHOD_MMAP,
    IO_METHOD_USERPTR,
} io_method;

typedef struct vlc_v4l2_ctrl vlc_v4l2_ctrl_t;

/* TODO: move this to access.c and demux.c (separately) */
struct demux_sys_t
{
    int  i_fd;

    /* Video */
    io_method io;

    struct buffer_t *p_buffers;
    unsigned int i_nbuffers;
#define blocksize i_nbuffers /* HACK HACK */

    int i_fourcc;
    uint32_t i_block_flags;

    es_out_id_t *p_es;

    vlc_v4l2_ctrl_t *controls;

#ifdef HAVE_LIBV4L2
    bool b_libv4l2;
#endif
};

struct buffer_t
{
    void *  start;
    size_t  length;
};

/* video.c */
void ParseMRL(vlc_object_t *, const char *);
int OpenVideo(vlc_object_t *, demux_sys_t *, bool);
block_t* GrabVideo(vlc_object_t *, demux_sys_t *);

/* demux.c */
int DemuxOpen(vlc_object_t *);
void DemuxClose(vlc_object_t *);
float GetAbsoluteMaxFrameRate(vlc_object_t *, int fd, uint32_t fmt);
void GetMaxDimensions(vlc_object_t *, int fd, uint32_t fmt, float fps_min,
                      uint32_t *pwidth, uint32_t *pheight);

/* access.c */
int AccessOpen(vlc_object_t *);
void AccessClose(vlc_object_t *);

/* controls.c */
vlc_v4l2_ctrl_t *ControlsInit(vlc_object_t *, int fd);
void ControlsDeinit(vlc_object_t *, vlc_v4l2_ctrl_t *);