annotate libvo/vo_v4l2.c @ 36372:c95bdc49af2e

ad_ffmpeg: fix commit fixing sample rate changes to actually work.
author reimar
date Wed, 16 Oct 2013 17:20:31 +0000
parents efc3594f1f07
children 5d3f93051de9
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"
30650
6fc02905e992 Add header for v4l2_write() instead of forward declaring it.
diego
parents: 30122
diff changeset
45 #include "vo_v4l2.h"
23905
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
46
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
47 #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
48 #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
49
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
50 int v4l2_fd = -1;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
51 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
52
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
53 /* suboptions */
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
54 static int output = -1;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
55 static char *device = NULL;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
56
28828
56eee6ffba9b Make data related to suboption parsing const in libvo
reimar
parents: 26739
diff changeset
57 static const opt_t subopts[] = {
30122
1772a5171ac7 Fix function declarations to avoid casting function pointers.
reimar
parents: 29263
diff changeset
58 {"output", OPT_ARG_INT, &output, int_non_neg},
23905
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
59 {"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
60 {NULL}
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
61 };
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
62
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
63 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
64 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
65 "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
66 "v4l2",
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
67 "Benjamin Zores",
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
68 ""
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
69 };
25220
c9e9ac2008c2 Mark the vo_functions_t definitions as const where possible.
reimar
parents: 25216
diff changeset
70 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
71
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
72 int
33319
efc3594f1f07 Fix function to match what send_mpeg_pes_packet expects,
reimar
parents: 33305
diff changeset
73 v4l2_write (const unsigned char *data, int len)
23905
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
74 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
75 if (v4l2_fd < 0)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
76 return 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
77
23905
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
78 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
79 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
80
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
81 /* video out functions */
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
82
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
83 static int
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
84 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
85 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
86 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
87 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
88 return 0;
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
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
91 static int
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
92 preinit (const char *arg)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
93 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
94 struct v4l2_output vout;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
95 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
96 int err;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
97
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
98 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
99 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
100 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
101 "\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
102 "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
103 "\nOptions:\n"
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
104 " device=/dev/videoX\n"
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
105 " 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
106 " output=<0-...>\n"
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
107 " 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
108 "\n" );
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
109 return -1;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
110 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
111
23905
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
112 if (!device)
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
113 device = strdup (DEFAULT_MPEG_DECODER);
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
114
23905
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
115 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
116 if (v4l2_fd < 0)
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
117 {
23905
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
118 free (device);
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
119 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
120 return -1;
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
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
123 /* check for device hardware MPEG decoding capability */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
124 ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG;
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
125 ctrls.count = 0;
23905
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
126 ctrls.controls = NULL;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
127
23905
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
128 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
129 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
130 free (device);
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
131 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
132 return -1;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
133 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
134
23905
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
135 /* list available outputs */
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
136 vout.index = 0;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
137 err = 1;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
138 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
139 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
140 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
141 err = 0;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
142 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
143 vout.index++;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
144 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
145 if (err)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
146 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
147 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
148 free (device);
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
149 return -1;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
150 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
151 else
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
152 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
153
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
154 /* set user specified output */
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
155 if (output != -1)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
156 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
157 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
158 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
159 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
160 "%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
161 free (device);
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
162 return -1;
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
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
166 /* display device name */
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
167 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
168 free (device);
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
169
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
170 /* display current video output */
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
171 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
172 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
173 vout.index = output;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
174 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
175 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
176 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
177 "%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
178 return -1;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
179 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
180 else
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
181 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
182 "%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
183 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
184 else
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
185 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
186 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
187 "%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
188 return -1;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
189 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
190
23905
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
191 return 0;
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
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
194 static void
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
195 draw_osd (void)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
196 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
197 /* do nothing */
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
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
200 static int
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
201 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
202 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
203 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
204 return 0;
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
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
207 static void
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
208 flip_page (void)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
209 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
210 if (v4l2_fd < 0)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
211 return;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
212
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
213 if (!pes)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
214 return;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
215
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
216 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
217 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
218 v4l2_write);
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
219
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
220 /* 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
221 pes = NULL;
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
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
224 static int
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
225 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
226 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
227 return 0;
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
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
230 static void
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
231 uninit (void)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
232 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
233 if (v4l2_fd < 0)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
234 return;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
235
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
236 /* close device */
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
237 close (v4l2_fd);
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
238 v4l2_fd = -1;
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
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
241 static void
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
242 check_events (void)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
243 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
244 /* do nothing */
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
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
247 static int
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
248 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
249 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
250 if (format != IMGFMT_MPEGPES)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
251 return 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
252
23905
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
253 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
254 }
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
255
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
256 static int
33305
ddb45e9443ec Remove the variable arguments from the libvo control() functions.
iive
parents: 30650
diff changeset
257 control (uint32_t request, void *data)
23905
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
258 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
259 switch (request)
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
260 {
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
261 case VOCTRL_QUERY_FORMAT:
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
262 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
263 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
264
23905
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
265 return VO_NOTIMPL;
fb63124c7920 v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
diff changeset
266 }