annotate libvo/vo_caca.c @ 22962:f9a5e58f9f40

Revert previous broken removal of partial dependency list.
author diego
date Thu, 12 Apr 2007 14:42:48 +0000
parents 98eaf29b5dee
children 144162149176
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
1 /*
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
2 * MPlayer
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
3 *
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
4 * Video driver for libcaca
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
5 *
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
6 * by Pigeon <pigeon@pigeond.net>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
7 *
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
8 * Some functions/codes/ideas are from x11 and aalib vo
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
9 *
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
10 * TODO: support those draw_alpha stuff?
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
11 *
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
12 */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
13
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
14 #include <stdio.h>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
15 #include <stdlib.h>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
16 #include <sys/stat.h>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
17 #include <unistd.h>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
18 #include <string.h>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
19 #include <time.h>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
20 #include <errno.h>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
21
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
22 #include "config.h"
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
23 #include "video_out.h"
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
24 #include "video_out_internal.h"
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
25 #include "sub.h"
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
26
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
27 #include "osdep/keycodes.h"
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
28 #include "mp_msg.h"
22823
98eaf29b5dee Code cleanup: don't include a .c file in mplayer.c and fix a few
rathann
parents: 21161
diff changeset
29 #include "mp_fifo.h"
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
30
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
31 #include <caca.h>
19979
0dc175cbeed8 vo_caca: use the pre-1.x compatibility layer so recent
corey
parents: 19053
diff changeset
32 #ifdef CACA_API_VERSION_1
0dc175cbeed8 vo_caca: use the pre-1.x compatibility layer so recent
corey
parents: 19053
diff changeset
33 /* Include the pre-1.x compatibility header.
0dc175cbeed8 vo_caca: use the pre-1.x compatibility layer so recent
corey
parents: 19053
diff changeset
34 * Once libcaca 1.x is widespread, vo_caca should be fully
0dc175cbeed8 vo_caca: use the pre-1.x compatibility layer so recent
corey
parents: 19053
diff changeset
35 * converted to the new API. A patch exists:
0dc175cbeed8 vo_caca: use the pre-1.x compatibility layer so recent
corey
parents: 19053
diff changeset
36 * http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2006-July/044674.html
0dc175cbeed8 vo_caca: use the pre-1.x compatibility layer so recent
corey
parents: 19053
diff changeset
37 */
0dc175cbeed8 vo_caca: use the pre-1.x compatibility layer so recent
corey
parents: 19053
diff changeset
38 #include <caca0.h>
0dc175cbeed8 vo_caca: use the pre-1.x compatibility layer so recent
corey
parents: 19053
diff changeset
39 #endif
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
40
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
41 static vo_info_t info = {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
42 "libcaca",
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
43 "caca",
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
44 "Pigeon <pigeon@pigeond.net>",
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
45 ""
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
46 };
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
47
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
48 LIBVO_EXTERN (caca)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
49
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
50 /* caca stuff */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
51 static struct caca_bitmap *cbitmap = NULL;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
52
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
53 /* image infos */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
54 static int image_format;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
55 static int image_width;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
56 static int image_height;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
57
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
58 static int screen_w, screen_h;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
59
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
60 /* We want 24bpp always for now */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
61 static unsigned int bpp = 24;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
62 static unsigned int depth = 3;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
63 static unsigned int rmask = 0xff0000;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
64 static unsigned int gmask = 0x00ff00;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
65 static unsigned int bmask = 0x0000ff;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
66 static unsigned int amask = 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
67
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
68 #define MESSAGE_SIZE 512
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
69 #define MESSAGE_DURATION 5
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
70
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
71 static time_t stoposd = 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
72 static int showosdmessage = 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
73 static char osdmessagetext[MESSAGE_SIZE];
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
74 static char posbar[MESSAGE_SIZE];
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
75
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
76 static int osdx = 0, osdy = 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
77 static int posbary = 2;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
78
19053
75327b24e06f marks several string parameters as const, as they are not modified inside the function, Patch by Stefan Huehner, stefan AT huehner-org
reynaldo
parents: 16171
diff changeset
79 static void osdmessage(int duration, const char *fmt, ...)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
80 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
81 /*
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
82 * for outputting a centered string at the bottom
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
83 * of our window for a while
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
84 */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
85 va_list ar;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
86 char m[MESSAGE_SIZE];
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
87
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
88 va_start(ar, fmt);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
89 vsprintf(m, fmt, ar);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
90 va_end(ar);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
91 strcpy(osdmessagetext, m);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
92
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
93 showosdmessage = 1;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
94 stoposd = time(NULL) + duration;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
95 osdx = (screen_w - strlen (osdmessagetext)) / 2;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
96 posbar[0] = '\0';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
97 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
98
19053
75327b24e06f marks several string parameters as const, as they are not modified inside the function, Patch by Stefan Huehner, stefan AT huehner-org
reynaldo
parents: 16171
diff changeset
99 static void osdpercent(int duration, int min, int max, int val, const char *desc, const char *unit)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
100 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
101 /*
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
102 * prints a bar for setting values
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
103 */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
104 float step;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
105 int where, i;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
106
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
107 step = (float)screen_w / (float)(max - min);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
108 where = (val - min) * step;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
109 osdmessage (duration, "%s: %i%s", desc, val, unit);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
110 posbar[0] = '|';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
111 posbar[screen_w - 1] = '|';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
112
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
113 for (i = 0; i < screen_w; i++)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
114 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
115 if (i == where)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
116 posbar[i] = '#';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
117 else
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
118 posbar[i] = '-';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
119 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
120
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
121 if (where != 0)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
122 posbar[0] = '|';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
123
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
124 if (where != (screen_w - 1))
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
125 posbar[screen_w - 1] = '|';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
126
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
127 posbar[screen_w] = '\0';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
128 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
130 static int resize ()
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
131 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
132 screen_w = caca_get_width();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
133 screen_h = caca_get_height();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
134
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
135 if (cbitmap)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
136 caca_free_bitmap(cbitmap);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
137
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
138 cbitmap = caca_create_bitmap(bpp, image_width, image_height,
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
139 depth * image_width, rmask, gmask, bmask,
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
140 amask);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
141
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
142 if (!cbitmap)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
143 mp_msg(MSGT_VO, MSGL_FATAL, "vo_caca: caca_create_bitmap failed!\n");
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
144
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
145 return 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
146 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
147
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
148 static int config(uint32_t width, uint32_t height, uint32_t d_width,
15212
05aa13cdf92f replace VO and VF numeric flags with #defined identifiers
henry
parents: 12129
diff changeset
149 uint32_t d_height, uint32_t flags, char *title, uint32_t format)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
150 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
151 image_height = height;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
152 image_width = width;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
153 image_format = format;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
154
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
155 showosdmessage = 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
156 posbar[0] = '\0';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
157
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
158 return resize ();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
159 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
160
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
161 static int draw_frame(uint8_t *src[])
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
162 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
163 caca_draw_bitmap(0, 0, screen_w, screen_h, cbitmap, src[0]);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
164 return 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
165 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
166
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
167 static int draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
168 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
169 return 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
170 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
171
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
172 static void flip_page(void)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
173 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
174
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
175 if (showosdmessage)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
176 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
177 if (time(NULL) >= stoposd)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
178 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
179 showosdmessage = 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
180 if (posbar)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
181 posbar[0] = '\0';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
182 } else {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
183 caca_putstr(osdx, osdy, osdmessagetext);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
184
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
185 if (posbar)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
186 caca_putstr(0, posbary, posbar);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
187 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
188 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
189
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
190 caca_refresh();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
191 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
192
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
193 static void check_events (void)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
194 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
195 unsigned int cev;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
196
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
197 if ((cev = caca_get_event(CACA_EVENT_ANY)))
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
198 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
199 if (cev & CACA_EVENT_RESIZE)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
200 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
201 caca_refresh();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
202 resize();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
203 } else if (cev & CACA_EVENT_KEY_RELEASE)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
204 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
205 int key = (cev & 0x00ffffff);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
206 enum caca_feature cf;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
207
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
208 switch (key) {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
209 case 'd':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
210 case 'D':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
211 /* Toggle dithering method */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
212 cf = 1 + caca_get_feature(CACA_DITHERING);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
213 if (cf > CACA_DITHERING_MAX)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
214 cf = CACA_DITHERING_MIN;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
215 caca_set_feature(cf);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
216 osdmessage(MESSAGE_DURATION, "Using %s", caca_get_feature_name(cf));
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
217 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
218
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
219 case 'a':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
220 case 'A':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
221 /* Toggle antialiasing method */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
222 cf = 1 + caca_get_feature(CACA_ANTIALIASING);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
223 if (cf > CACA_ANTIALIASING_MAX)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
224 cf = CACA_ANTIALIASING_MIN;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
225 caca_set_feature(cf);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
226 osdmessage(MESSAGE_DURATION, "Using %s", caca_get_feature_name(cf));
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
227 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
228
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
229 case 'b':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
230 case 'B':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
231 /* Toggle background method */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
232 cf = 1 + caca_get_feature(CACA_BACKGROUND);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
233 if (cf > CACA_BACKGROUND_MAX)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
234 cf = CACA_BACKGROUND_MIN;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
235 caca_set_feature(cf);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
236 osdmessage(MESSAGE_DURATION, "Using %s", caca_get_feature_name(cf));
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
237 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
238
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
239 case CACA_KEY_UP:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
240 mplayer_put_key(KEY_UP);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
241 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
242 case CACA_KEY_DOWN:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
243 mplayer_put_key(KEY_DOWN);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
244 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
245 case CACA_KEY_LEFT:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
246 mplayer_put_key(KEY_LEFT);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
247 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
248 case CACA_KEY_RIGHT:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
249 mplayer_put_key(KEY_RIGHT);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
250 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
251 case CACA_KEY_ESCAPE:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
252 mplayer_put_key(KEY_ESC);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
253 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
254 case CACA_KEY_PAGEUP:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
255 mplayer_put_key(KEY_PAGE_UP);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
256 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
257 case CACA_KEY_PAGEDOWN:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
258 mplayer_put_key(KEY_PAGE_DOWN);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
259 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
260 case CACA_KEY_RETURN:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
261 mplayer_put_key(KEY_ENTER);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
262 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
263 case CACA_KEY_HOME:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
264 mplayer_put_key(KEY_HOME);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
265 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
266 case CACA_KEY_END:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
267 mplayer_put_key(KEY_END);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
268 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
269 default:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
270 if (key <= 255)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
271 mplayer_put_key (key);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
272 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
273 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
274 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
275 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
276 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
277
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
278 static void uninit(void)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
279 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
280 caca_free_bitmap(cbitmap);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
281 cbitmap = NULL;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
282 caca_end();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
283 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
284
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
285
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
286 static void draw_osd(void)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
287 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
288 if (vo_osd_progbar_type != -1)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
289 osdpercent(MESSAGE_DURATION, 0, 255,
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
290 vo_osd_progbar_value, __sub_osd_names[vo_osd_progbar_type],
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
291 "");
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
292 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
293
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
294 static int preinit(const char *arg)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
295 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
296 if (arg)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
297 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
298 mp_msg(MSGT_VO, MSGL_ERR, "vo_caca: Unknown subdevice: %s\n", arg);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
299 return ENOSYS;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
300 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
301
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
302 if (caca_init())
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
303 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
304 mp_msg(MSGT_VO, MSGL_ERR, "vo_caca: failed to initialize\n");
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
305 return ENOSYS;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
306 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
307
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
308 caca_set_window_title("MPlayer");
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
309
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
310 /* Default libcaca features */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
311 caca_set_feature(CACA_ANTIALIASING_PREFILTER);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
312 caca_set_feature(CACA_DITHERING_RANDOM);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
313
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
314 return 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
315 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
316
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
317 static int query_format(uint32_t format)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
318 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
319 if (format == IMGFMT_BGR24)
21161
ad7747bce52d Make compilation depending on USE_OSD unconditional.
uau
parents: 19979
diff changeset
320 return VFCAP_OSD | VFCAP_CSP_SUPPORTED;
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
321
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
322 return 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
323 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
324
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
325 static int control(uint32_t request, void *data, ...)
12129
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
326 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
327 switch(request)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
328 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
329 case VOCTRL_QUERY_FORMAT:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
330 return query_format(*((uint32_t *)data));
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
331 default:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
332 return VO_NOTIMPL;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
333 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
334 }