annotate libvo/vo_caca.c @ 14471:6cdd5669e930

Here is an updated draft with the bits discussed previously merged: - short startcode removed - QT/Microsoft codec_specific_data removed, reverted to a neutral format - meta packet removed, merged in the info packet. - stream class simplified, added metadata stream patch by (Luca Barbato <lu_zero gentoo org>)
author michael
date Wed, 12 Jan 2005 11:54:30 +0000
parents c1aff21286dd
children 05aa13cdf92f
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"
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
29
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
30 #include <caca.h>
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
31
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
32 static vo_info_t info = {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
33 "libcaca",
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
34 "caca",
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
35 "Pigeon <pigeon@pigeond.net>",
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
36 ""
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
37 };
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
38
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
39 LIBVO_EXTERN (caca)
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 /* caca stuff */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
42 static struct caca_bitmap *cbitmap = NULL;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
43
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
44 /* image infos */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
45 static int image_format;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
46 static int image_width;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
47 static int image_height;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
48
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
49 static int screen_w, screen_h;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
50
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
51 /* We want 24bpp always for now */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
52 static unsigned int bpp = 24;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
53 static unsigned int depth = 3;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
54 static unsigned int rmask = 0xff0000;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
55 static unsigned int gmask = 0x00ff00;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
56 static unsigned int bmask = 0x0000ff;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
57 static unsigned int amask = 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
58
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
59 #define MESSAGE_SIZE 512
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
60 #define MESSAGE_DURATION 5
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
61
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
62 static time_t stoposd = 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
63 static int showosdmessage = 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
64 static char osdmessagetext[MESSAGE_SIZE];
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
65 static char posbar[MESSAGE_SIZE];
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
66
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
67 static int osdx = 0, osdy = 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
68 static int posbary = 2;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
69
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
70 static void osdmessage(int duration, char *fmt, ...)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
71 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
72 /*
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
73 * for outputting a centered string at the bottom
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
74 * of our window for a while
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 va_list ar;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
77 char m[MESSAGE_SIZE];
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
78
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
79 va_start(ar, fmt);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
80 vsprintf(m, fmt, ar);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
81 va_end(ar);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
82 strcpy(osdmessagetext, m);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
83
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
84 showosdmessage = 1;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
85 stoposd = time(NULL) + duration;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
86 osdx = (screen_w - strlen (osdmessagetext)) / 2;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
87 posbar[0] = '\0';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
88 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
89
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
90 static void osdpercent(int duration, int min, int max, int val, char *desc, char *unit)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
91 {
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 * prints a bar for setting values
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
94 */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
95 float step;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
96 int where, i;
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 step = (float)screen_w / (float)(max - min);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
99 where = (val - min) * step;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
100 osdmessage (duration, "%s: %i%s", desc, val, unit);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
101 posbar[0] = '|';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
102 posbar[screen_w - 1] = '|';
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 for (i = 0; i < screen_w; i++)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
105 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
106 if (i == where)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
107 posbar[i] = '#';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
108 else
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
109 posbar[i] = '-';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
110 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
111
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
112 if (where != 0)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
113 posbar[0] = '|';
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 (where != (screen_w - 1))
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
116 posbar[screen_w - 1] = '|';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
117
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
118 posbar[screen_w] = '\0';
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 static int resize ()
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
122 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
123 screen_w = caca_get_width();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
124 screen_h = caca_get_height();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
125
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
126 if (cbitmap)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
127 caca_free_bitmap(cbitmap);
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 cbitmap = caca_create_bitmap(bpp, image_width, image_height,
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
130 depth * image_width, rmask, gmask, bmask,
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
131 amask);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
132
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
133 if (!cbitmap)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
134 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
135
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
136 return 0;
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
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
139 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
140 uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format)
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 image_height = height;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
143 image_width = width;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
144 image_format = format;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
145
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
146 showosdmessage = 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
147 posbar[0] = '\0';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
148
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
149 return resize ();
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
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
152 static uint32_t draw_frame(uint8_t *src[])
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
153 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
154 caca_draw_bitmap(0, 0, screen_w, screen_h, cbitmap, src[0]);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
155 return 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
156 }
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 static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y)
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 return 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
161 }
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 static void flip_page(void)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
164 {
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 if (showosdmessage)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
167 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
168 if (time(NULL) >= stoposd)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
169 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
170 showosdmessage = 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
171 if (posbar)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
172 posbar[0] = '\0';
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
173 } else {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
174 caca_putstr(osdx, osdy, osdmessagetext);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
175
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
176 if (posbar)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
177 caca_putstr(0, posbary, posbar);
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 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
180
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
181 caca_refresh();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
182 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
183
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
184 static void check_events (void)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
185 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
186 unsigned int cev;
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 if ((cev = caca_get_event(CACA_EVENT_ANY)))
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 if (cev & CACA_EVENT_RESIZE)
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 caca_refresh();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
193 resize();
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
194 } else if (cev & CACA_EVENT_KEY_RELEASE)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
195 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
196 int key = (cev & 0x00ffffff);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
197 enum caca_feature cf;
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 switch (key) {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
200 case 'd':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
201 case 'D':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
202 /* Toggle dithering method */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
203 cf = 1 + caca_get_feature(CACA_DITHERING);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
204 if (cf > CACA_DITHERING_MAX)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
205 cf = CACA_DITHERING_MIN;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
206 caca_set_feature(cf);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
207 osdmessage(MESSAGE_DURATION, "Using %s", caca_get_feature_name(cf));
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
208 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
209
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
210 case 'a':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
211 case 'A':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
212 /* Toggle antialiasing method */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
213 cf = 1 + caca_get_feature(CACA_ANTIALIASING);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
214 if (cf > CACA_ANTIALIASING_MAX)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
215 cf = CACA_ANTIALIASING_MIN;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
216 caca_set_feature(cf);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
217 osdmessage(MESSAGE_DURATION, "Using %s", caca_get_feature_name(cf));
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
218 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
219
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
220 case 'b':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
221 case 'B':
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
222 /* Toggle background method */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
223 cf = 1 + caca_get_feature(CACA_BACKGROUND);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
224 if (cf > CACA_BACKGROUND_MAX)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
225 cf = CACA_BACKGROUND_MIN;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
226 caca_set_feature(cf);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
227 osdmessage(MESSAGE_DURATION, "Using %s", caca_get_feature_name(cf));
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
228 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
229
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
230 case CACA_KEY_UP:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
231 mplayer_put_key(KEY_UP);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
232 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
233 case CACA_KEY_DOWN:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
234 mplayer_put_key(KEY_DOWN);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
235 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
236 case CACA_KEY_LEFT:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
237 mplayer_put_key(KEY_LEFT);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
238 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
239 case CACA_KEY_RIGHT:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
240 mplayer_put_key(KEY_RIGHT);
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_ESCAPE:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
243 mplayer_put_key(KEY_ESC);
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_PAGEUP:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
246 mplayer_put_key(KEY_PAGE_UP);
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_PAGEDOWN:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
249 mplayer_put_key(KEY_PAGE_DOWN);
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_RETURN:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
252 mplayer_put_key(KEY_ENTER);
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_HOME:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
255 mplayer_put_key(KEY_HOME);
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_END:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
258 mplayer_put_key(KEY_END);
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 default:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
261 if (key <= 255)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
262 mplayer_put_key (key);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
263 break;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
264 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
265 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
266 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
267 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
268
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
269 static void uninit(void)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
270 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
271 caca_free_bitmap(cbitmap);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
272 cbitmap = NULL;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
273 caca_end();
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 static void draw_osd(void)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
278 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
279 #ifdef USE_OSD
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
280 if (vo_osd_progbar_type != -1)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
281 osdpercent(MESSAGE_DURATION, 0, 255,
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
282 vo_osd_progbar_value, __sub_osd_names[vo_osd_progbar_type],
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 #endif
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
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
287 static uint32_t preinit(const char *arg)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
288 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
289 if (arg)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
290 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
291 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
292 return ENOSYS;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
293 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
294
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
295 if (caca_init())
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
296 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
297 mp_msg(MSGT_VO, MSGL_ERR, "vo_caca: failed to initialize\n");
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
298 return ENOSYS;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
299 }
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 caca_set_window_title("MPlayer");
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
302
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
303 /* Default libcaca features */
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
304 caca_set_feature(CACA_ANTIALIASING_PREFILTER);
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
305 caca_set_feature(CACA_DITHERING_RANDOM);
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 return 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
308 }
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 static uint32_t query_format(uint32_t format)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
311 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
312 if (format == IMGFMT_BGR24)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
313 return
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
314 #ifdef USE_OSD
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
315 VFCAP_OSD |
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
316 #endif
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
317 VFCAP_CSP_SUPPORTED;
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 return 0;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
320 }
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 static uint32_t control(uint32_t request, void *data, ...)
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 switch(request)
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
325 {
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
326 case VOCTRL_QUERY_FORMAT:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
327 return query_format(*((uint32_t *)data));
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
328 default:
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
329 return VO_NOTIMPL;
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
330 }
c1aff21286dd libcaca video output driver by Howell Tam
alex
parents:
diff changeset
331 }