annotate libvo/vo_v4l2.c @ 29057:a71ce6c36d8e

sync with en/mplayer.1 r29059
author jrash
date Sun, 29 Mar 2009 12:28:46 +0000
parents 56eee6ffba9b
children 0f1b5b68af32
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23905
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
1 /*
26739
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
2 * video output for V4L2 hardware MPEG decoders
23905
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
3 *
26739
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
4 * Copyright (C) 2007 Benjamin Zores
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
5 *
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
6 * This file is part of MPlayer.
23905
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
7 *
26739
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
8 * MPlayer is free software; you can redistribute it and/or modify
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
9 * it under the terms of the GNU General Public License as published by
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
11 * (at your option) any later version.
23905
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
12 *
26739
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
13 * MPlayer is distributed in the hope that it will be useful,
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
16 * GNU General Public License for more details.
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
17 *
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
18 * You should have received a copy of the GNU General Public License along
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
19 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23905
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
21 */
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
22
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
23 #include "config.h"
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
24
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
25 #include <stdio.h>
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
26 #include <stdlib.h>
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
27 #include <string.h>
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
28 #include <errno.h>
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
29 #include <sys/types.h>
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
30 #include <sys/stat.h>
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
31 #include <sys/ioctl.h>
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
32 #include <fcntl.h>
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
33 #include <unistd.h>
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
34 #include <stdlib.h>
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
35 #include <inttypes.h>
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
36 #include <linux/types.h>
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
37 #include <linux/videodev2.h>
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
38 #include <linux/ioctl.h>
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
39
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
40 #include "mp_msg.h"
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
41 #include "subopt-helper.h"
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
42 #include "video_out.h"
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
43 #include "video_out_internal.h"
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
44 #include "libmpdemux/mpeg_packetizer.h"
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
45
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
46 #define DEFAULT_MPEG_DECODER "/dev/video16"
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
47 #define V4L2_VO_HDR "VO: [v4l2]"
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
48
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
49 int v4l2_fd = -1;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
50 static vo_mpegpes_t *pes;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
51
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
52 /* suboptions */
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
53 static int output = -1;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
54 static char *device = NULL;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
55
28828
56eee6ffba9b Make data related to suboption parsing const in libvo
reimar
parents: 26739
diff changeset
56 static const opt_t subopts[] = {
23905
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
57 {"output", OPT_ARG_INT, &output, (opt_test_f)int_non_neg},
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
58 {"device", OPT_ARG_MSTRZ, &device, NULL},
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
59 {NULL}
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
60 };
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
61
25216
3aee342be929 Make vo info structs const
reimar
parents: 23905
diff changeset
62 static const vo_info_t info =
23905
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
63 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
64 "V4L2 MPEG Video Decoder Output",
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
65 "v4l2",
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
66 "Benjamin Zores",
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
67 ""
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
68 };
25220
c9e9ac2008c2 Mark the vo_functions_t definitions as const where possible.
reimar
parents: 25216
diff changeset
69 const LIBVO_EXTERN (v4l2)
23905
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
70
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
71 int
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
72 v4l2_write (unsigned char *data, int len)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
73 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
74 if (v4l2_fd < 0)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
75 return 0;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
76
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
77 return write (v4l2_fd, data, len);
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
78 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
79
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
80 /* video out functions */
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
81
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
82 static int
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
83 config (uint32_t width, uint32_t height,
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
84 uint32_t d_width, uint32_t d_height,
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
85 uint32_t fullscreen, char *title, uint32_t format)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
86 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
87 return 0;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
88 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
89
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
90 static int
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
91 preinit (const char *arg)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
92 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
93 struct v4l2_output vout;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
94 struct v4l2_ext_controls ctrls;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
95 int err;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
96
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
97 if (subopt_parse (arg, subopts) != 0)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
98 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
99 mp_msg (MSGT_VO, MSGL_FATAL,
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
100 "\n-vo v4l2 command line help:\n"
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
101 "Example: mplayer -vo v4l2:device=/dev/video16:output=2\n"
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
102 "\nOptions:\n"
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
103 " device=/dev/videoX\n"
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
104 " Name of the MPEG decoder device file.\n"
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
105 " output=<0-...>\n"
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
106 " V4L2 id of the TV output.\n"
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
107 "\n" );
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
108 return -1;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
109 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
110
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
111 if (!device)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
112 device = strdup (DEFAULT_MPEG_DECODER);
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
113
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
114 v4l2_fd = open (device, O_RDWR);
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
115 if (v4l2_fd < 0)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
116 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
117 free (device);
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
118 mp_msg (MSGT_VO, MSGL_FATAL, "%s %s\n", V4L2_VO_HDR, strerror (errno));
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
119 return -1;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
120 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
121
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
122 /* check for device hardware MPEG decoding capability */
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
123 ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
124 ctrls.count = 0;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
125 ctrls.controls = NULL;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
126
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
127 if (ioctl (v4l2_fd, VIDIOC_G_EXT_CTRLS, &ctrls) < 0)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
128 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
129 free (device);
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
130 mp_msg (MSGT_OPEN, MSGL_FATAL, "%s %s\n", V4L2_VO_HDR, strerror (errno));
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
131 return -1;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
132 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
133
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
134 /* list available outputs */
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
135 vout.index = 0;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
136 err = 1;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
137 mp_msg (MSGT_VO, MSGL_INFO, "%s Available video outputs: ", V4L2_VO_HDR);
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
138 while (ioctl (v4l2_fd, VIDIOC_ENUMOUTPUT, &vout) >= 0)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
139 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
140 err = 0;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
141 mp_msg (MSGT_VO, MSGL_INFO, "'#%d, %s' ", vout.index, vout.name);
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
142 vout.index++;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
143 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
144 if (err)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
145 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
146 mp_msg (MSGT_VO, MSGL_INFO, "none\n");
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
147 free (device);
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
148 return -1;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
149 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
150 else
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
151 mp_msg (MSGT_VO, MSGL_INFO, "\n");
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
152
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
153 /* set user specified output */
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
154 if (output != -1)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
155 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
156 if (ioctl (v4l2_fd, VIDIOC_S_OUTPUT, &output) < 0)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
157 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
158 mp_msg (MSGT_VO, MSGL_ERR,
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
159 "%s can't set output (%s)\n", V4L2_VO_HDR, strerror (errno));
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
160 free (device);
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
161 return -1;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
162 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
163 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
164
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
165 /* display device name */
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
166 mp_msg (MSGT_VO, MSGL_INFO, "%s using %s\n", V4L2_VO_HDR, device);
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
167 free (device);
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
168
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
169 /* display current video output */
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
170 if (ioctl (v4l2_fd, VIDIOC_G_OUTPUT, &output) == 0)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
171 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
172 vout.index = output;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
173 if (ioctl (v4l2_fd, VIDIOC_ENUMOUTPUT, &vout) < 0)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
174 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
175 mp_msg (MSGT_VO, MSGL_ERR,
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
176 "%s can't get output (%s).\n", V4L2_VO_HDR, strerror (errno));
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
177 return -1;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
178 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
179 else
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
180 mp_msg (MSGT_VO, MSGL_INFO,
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
181 "%s video output: %s\n", V4L2_VO_HDR, vout.name);
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
182 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
183 else
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
184 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
185 mp_msg (MSGT_VO, MSGL_ERR,
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
186 "%s can't get output (%s).\n", V4L2_VO_HDR, strerror (errno));
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
187 return -1;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
188 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
189
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
190 return 0;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
191 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
192
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
193 static void
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
194 draw_osd (void)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
195 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
196 /* do nothing */
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
197 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
198
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
199 static int
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
200 draw_frame (uint8_t * src[])
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
201 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
202 pes = (vo_mpegpes_t *) src[0];
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
203 return 0;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
204 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
205
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
206 static void
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
207 flip_page (void)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
208 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
209 if (v4l2_fd < 0)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
210 return;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
211
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
212 if (!pes)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
213 return;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
214
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
215 send_mpeg_pes_packet (pes->data, pes->size, pes->id,
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
216 pes->timestamp ? pes->timestamp : vo_pts, 2,
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
217 v4l2_write);
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
218
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
219 /* ensure flip_page() won't be called twice */
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
220 pes = NULL;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
221 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
222
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
223 static int
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
224 draw_slice (uint8_t *image[], int stride[], int w, int h, int x, int y)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
225 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
226 return 0;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
227 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
228
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
229 static void
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
230 uninit (void)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
231 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
232 if (v4l2_fd < 0)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
233 return;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
234
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
235 /* close device */
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
236 close (v4l2_fd);
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
237 v4l2_fd = -1;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
238 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
239
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
240 static void
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
241 check_events (void)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
242 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
243 /* do nothing */
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
244 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
245
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
246 static int
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
247 query_format (uint32_t format)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
248 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
249 if (format != IMGFMT_MPEGPES)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
250 return 0;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
251
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
252 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_TIMER;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
253 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
254
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
255 static int
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
256 control (uint32_t request, void *data, ...)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
257 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
258 switch (request)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
259 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
260 case VOCTRL_QUERY_FORMAT:
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
261 return query_format (*((uint32_t*) data));
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
262 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
263
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
264 return VO_NOTIMPL;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
265 }