annotate libvo/vo_bl.c @ 13498:5e21336ee2a0

THE "vf=eq2=1.0:-0.8" fix Sync with 1.754: better default parameter,added counterpart option, better names for few options, 3-pass support and improved documentation. ( Eng patch by Loren Merritt )
author gpoirier
date Tue, 28 Sep 2004 08:17:45 +0000
parents 076e87baf7c0
children e047e70a9767
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
1 /*
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
2 * vo_bl.c - playback using the Blinkenlights UPD protocol (and to files)
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
3 *
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
4 * UDP socket handling copied from bsender.c part of blib-0.6:
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
5 * http://sven.gimp.org/blinkenlights/
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
6 * Copyright (c) 2001-2001 The Blinkenlights Crew:
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
7 * Sven Neumann <sven@gimp.org>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
8 * Michael Natterer <mitch@gimp.org>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
9 * Daniel Mack <daniel@yoobay.net>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
10 * (these portions are licensed under GNU GPL v2 or "(at your option)
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
11 * any later version")
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
12 *
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
13 * Other stuff: Copyright (C) Rik Snel 2002, License GNU GPL v2
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
14 *
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
15 * patch from Stefan Schuermans <1stein@schuermans.info>:
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
16 * - correction of "maxval" in Blinkenlights UDP protcol
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
17 * - new scheme for new HDL
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
18 * - new scheme for grayscale in arbitrary size
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
19 */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
20
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
21 #include <stdio.h>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
22 #include <stdlib.h>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
23 #include <string.h>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
24 #include <unistd.h>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
25 #include <fcntl.h>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
26 #include <errno.h>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
27 #include <sys/stat.h>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
28 #include <sys/types.h>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
29 #include <sys/time.h>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
30 #include <sys/mman.h>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
31 #include <sys/ioctl.h>
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
32
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
33 #include "config.h"
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
34
10281
54bcbf28698a Networking support under MinGW.
diego
parents: 10206
diff changeset
35 #ifndef HAVE_WINSOCK2
54bcbf28698a Networking support under MinGW.
diego
parents: 10206
diff changeset
36 #define closesocket close
54bcbf28698a Networking support under MinGW.
diego
parents: 10206
diff changeset
37 #include <netdb.h>
54bcbf28698a Networking support under MinGW.
diego
parents: 10206
diff changeset
38 #include <sys/socket.h>
54bcbf28698a Networking support under MinGW.
diego
parents: 10206
diff changeset
39 #include <netinet/in.h>
54bcbf28698a Networking support under MinGW.
diego
parents: 10206
diff changeset
40 #else
54bcbf28698a Networking support under MinGW.
diego
parents: 10206
diff changeset
41 #include <winsock2.h>
54bcbf28698a Networking support under MinGW.
diego
parents: 10206
diff changeset
42 #endif
54bcbf28698a Networking support under MinGW.
diego
parents: 10206
diff changeset
43
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
44 #include "video_out.h"
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
45 #include "video_out_internal.h"
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
46 #include "../mp_msg.h"
10594
57bdcdb061d7 Removed the historic cfgparser and switched full to the new config parser (altought some macros still remain for compatibility). As a side effect 90% of the warning messages are gone from the core. Things should be cleaner now and less confusing for newbies.
alex
parents: 10281
diff changeset
47 #include "../m_option.h"
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
48 #include "fastmemcpy.h"
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
49
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7326
diff changeset
50 static vo_info_t info =
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
51 {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
52 "Blinkenlights driver: http://www.blinkenlights.de",
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
53 "bl",
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
54 "Rik Snel <snel@phys.uu.nl>",
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
55 ""
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
56 };
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
57
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7326
diff changeset
58 LIBVO_EXTERN (bl)
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7326
diff changeset
59
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
60 /* General variables */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
61
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
62 static unsigned char *image = NULL;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
63 static unsigned char *tmp = NULL;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
64 static int framenum, yoff, stride;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
65 static char *bl_subdevice = NULL;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
66 static int prevpts = -1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
67
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
68 typedef struct {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
69 char *name; /* filename */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
70 FILE *fp;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
71 } bl_file_t;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
72
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
73 typedef struct {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
74 char *name; /* hostname */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
75 int port;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
76 int fd; /* file descriptor */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
77 } bl_host_t;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
78
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
79 typedef struct {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
80 char *name;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
81 int img_format;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
82
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
83 int channels;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
84 int width;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
85 int height;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
86 int bpc; /* bits per component: bpc = 3, channels = 3 => bpp = 24*/
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
87
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
88 /* file output functions */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
89 int (*init_file)(bl_file_t *file);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
90 void (*write_frame)(bl_file_t *file, unsigned char *i, int duration);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
91 void (*close_file)(bl_file_t *file);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
92
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
93 /* network output functions */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
94 int (*init_connection)(bl_host_t *host);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
95 void (*send_frame)(bl_host_t *host);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
96 void (*close_connection)(bl_host_t *host);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
97 } bl_properties_t;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
98
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
99 static bl_properties_t *bl = NULL;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
100
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
101 /* arbitrary limit because I am too lazy to do proper memory management */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
102 #define BL_MAX_FILES 16
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
103 #define BL_MAX_HOSTS 16
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
104 static bl_file_t bl_files[BL_MAX_FILES];
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
105 static bl_host_t bl_hosts[BL_MAX_HOSTS];
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
106 static int no_bl_files = 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
107 static int no_bl_hosts = 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
108
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
109 typedef struct {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
110 uint32_t magic;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
111 uint16_t height;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
112 uint16_t width;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
113 uint16_t channels;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
114 uint16_t maxval;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
115 unsigned char data[0];
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
116 } bl_packet_t;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
117
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
118 static bl_packet_t *bl_packet = NULL;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
119 static int bl_size;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
120
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
121 /* bml output functions */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
122 static int bml_init(bl_file_t *f) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
123 f->fp = fopen(f->name, "w");
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
124 if (!f->fp) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
125 mp_msg(MSGT_VO, MSGL_ERR, "bl: error opening %s\n", f->name);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
126 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
127 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
128 fprintf(f->fp,
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
129 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
130 "<blm width=\"%d\" height=\"%d\" bits=\"%d\" channels=\"%d\">\n"
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
131 " <header>\n"
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
132 " <title>Movie autogenerated by MPlayer</title>\n"
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
133 " <url>http://www.mplayerhq.hu</url>\n"
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
134 " </header>\n", bl->width, bl->height, bl->bpc, bl->channels);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
135 return 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
136 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
137
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
138 static void bml_write_frame(bl_file_t *f, unsigned char *i, int duration) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
139 int j, k;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
140 fprintf(f->fp, " <frame duration=\"%d\">\n", duration);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
141 for (j = 0; j < bl->height; j++) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
142 fprintf(f->fp, " <row>");
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
143 for (k = 0; k < bl->width; k++)
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
144 fprintf(f->fp, "%02x", *(i + j * bl->width + k));
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
145 fprintf(f->fp, "</row>\n");
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
146 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
147 fprintf(f->fp, " </frame>\n");
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
148 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
149
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
150 static void bml_close(bl_file_t *f) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
151 fprintf(f->fp, "</blm>\n");
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
152 fclose(f->fp);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
153 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
154
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
155 /* Blinkenlights UDP protocol */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
156 static int udp_init(bl_host_t *h) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
157 struct sockaddr_in addr;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
158 struct hostent *dest;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
159
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
160 dest = gethostbyname(h->name);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
161 if (!dest) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
162 mp_msg(MSGT_VO, MSGL_ERR,
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
163 "unable to resolve host %s\n", h->name);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
164 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
165 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
166
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
167 h->fd = -1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
168 addr.sin_family = AF_INET;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
169 addr.sin_port = htons(h->port);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
170
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
171 memcpy(&addr.sin_addr.s_addr, dest->h_addr_list[0], dest->h_length);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
172
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
173 h->fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
174 if (h->fd < 0) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
175 mp_msg(MSGT_VO, MSGL_ERR,
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
176 "couldn't create socket for %s\n", h->name);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
177 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
178 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
179 if (connect(h->fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
180 mp_msg(MSGT_VO, MSGL_ERR, "couldn't connect socket for %s\n",
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
181 h->name);
10281
54bcbf28698a Networking support under MinGW.
diego
parents: 10206
diff changeset
182 closesocket(h->fd);
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
183 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
184 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
185 return 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
186 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
187
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
188 static void udp_send(bl_host_t *h) {
10206
35e306346e59 Using recv/send instead read/write for proper MinGW support (it's a 4.2BSD standard). Patch by FloDt <flodt8@yahoo.de>
alex
parents: 8171
diff changeset
189 if (send(h->fd, bl_packet, bl_size, 0) != bl_size)
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
190 mp_msg(MSGT_VO, MSGL_ERR, "unable to send to %s\n", h->name);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
191 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
192
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
193 static void udp_close(bl_host_t *h) {
10281
54bcbf28698a Networking support under MinGW.
diego
parents: 10206
diff changeset
194 closesocket(h->fd);
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
195 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
196
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
197 #define NO_BLS 3
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
198
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
199 static bl_properties_t bls[NO_BLS] = {
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
200 { "hdl", IMGFMT_YV12, 1, 18, 8, 8,
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
201 &bml_init, &bml_write_frame, &bml_close,
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
202 &udp_init, &udp_send, &udp_close },
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
203 { "arcade", IMGFMT_YV12, 1, 26, 20, 8,
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
204 &bml_init, &bml_write_frame, &bml_close,
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
205 &udp_init, &udp_send, &udp_close },
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
206 { "grayscale", IMGFMT_YV12, 1, -1, -1, 8, /* use width and height of movie */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
207 &bml_init, &bml_write_frame, &bml_close,
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
208 &udp_init, &udp_send, &udp_close } };
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
209
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
210 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
211 uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format)
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
212 {
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
213 void * ptr;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
214
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
215 /* adapt size of Blinkenlights UDP stream to size of movie */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
216 if (bl->width < 0 || bl->height < 0) {
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
217 if (bl->width < 0) /* use width of movie */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
218 bl->width = width;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
219 if (bl->height < 0) /* use height of movie */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
220 bl->height = height;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
221 /* check for maximum size of UDP packet */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
222 if (12 + bl->width*bl->height*bl->channels > 65507) {
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
223 mp_msg(MSGT_VO, MSGL_ERR, "bl: %dx%d-%d does not fit into an UDP packet\n",
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
224 bl->width, bl->height, bl->channels);
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
225 return 1;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
226 }
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
227 /* resize frame and tmp buffers */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
228 bl_size = 12 + bl->width*bl->height*bl->channels;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
229 ptr = realloc(bl_packet, 12 + bl->width*bl->height*3); /* space for header and image data */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
230 if (ptr)
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
231 bl_packet = (bl_packet_t*)ptr;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
232 else {
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
233 mp_msg(MSGT_VO, MSGL_ERR, "bl: out of memory error\n");
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
234 return 1;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
235 }
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
236 image = ((unsigned char*)bl_packet + 12); /* pointer to image data */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
237 ptr = realloc(tmp, bl->width*bl->height*3); /* space for image data only */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
238 if (ptr)
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
239 tmp = (unsigned char*)ptr;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
240 else {
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
241 mp_msg(MSGT_VO, MSGL_ERR, "bl: out of memory error\n");
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
242 return 1;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
243 }
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
244 }
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
245
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
246 framenum = 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
247 if (format != IMGFMT_YV12) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
248 mp_msg(MSGT_VO, MSGL_ERR, "vo_bl called with wrong format");
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
249 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
250 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
251 if (width > bl->width) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
252 mp_msg(MSGT_VO, MSGL_ERR, "bl: width of movie too large %d > %d\n", width, bl->width);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
253 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
254 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
255 if (height > bl->height) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
256 mp_msg(MSGT_VO, MSGL_ERR, "bl: height of movie too large %d > %d\n", height, bl->height);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
257 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
258 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
259 if (!image) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
260 mp_msg(MSGT_VO, MSGL_ERR, "bl: image should be initialized, internal error\n");
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
261 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
262 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
263 memset(image, 0, bl->width*bl->height*3); /* blank the image */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
264 mp_msg(MSGT_VO, MSGL_V, "vo_config bl called\n");
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
265 return 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
266 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
267
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
268 static void draw_osd(void) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
269 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
270
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
271 static void flip_page (void) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
272 int i;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
273
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
274 if (prevpts >= 0) for (i = 0; i < no_bl_files; i++)
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
275 bl->write_frame(&bl_files[i], tmp, (vo_pts - prevpts)/90);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
276 memcpy(tmp, image, bl->width*bl->height*bl->channels);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
277 prevpts = vo_pts;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
278
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
279 for (i = 0; i < no_bl_hosts; i++) bl->send_frame(&bl_hosts[i]);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
280
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
281
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
282 framenum++;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
283 return;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
284 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
285
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
286 static uint32_t draw_frame(uint8_t * src[]) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
287 return 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
288 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
289
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
290 static uint32_t query_format(uint32_t format) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
291 if (format == bl->img_format)
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
292 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
293 return 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
294 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
295
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
296 static void uninit(void) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
297 int i;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
298 mp_msg(MSGT_VO, MSGL_V, "bl: uninit called\n");
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
299 free(bl_packet);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
300 bl_packet = NULL;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
301 free(bl_subdevice);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
302 bl_subdevice = NULL;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
303 for (i = 0; i < no_bl_files; i++) bl->close_file(&bl_files[i]);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
304 for (i = 0; i < no_bl_hosts; i++) bl->close_connection(&bl_hosts[i]);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
305 no_bl_files = 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
306 no_bl_hosts = 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
307 bl = NULL;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
308 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
309
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
310 static void check_events(void) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
311 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
312
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
313 static uint32_t draw_slice(uint8_t *srcimg[], int stride[],
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
314 int wf, int hf, int xf, int yf) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
315 int i, j, w, h, x, y;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
316 uint8_t *dst;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
317 uint8_t *src=srcimg[0];
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
318 uint8_t *src1=srcimg[1];
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
319 uint8_t *src2=srcimg[2];
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
320 w = wf; h = hf; x = xf; y = yf;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
321 dst=image; /* + zr->off_y + zr->image_width*(y/zr->vdec)+x;*/
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
322 // copy Y:
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
323 for (i = 0; i < h; i++) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
324 memcpy(dst,src,w);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
325 dst+=bl->width;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
326 src+=stride[0];
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
327
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
328 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
329 return 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
330 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
331
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
332 static uint32_t preinit(const char *arg) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
333 char *p, *q;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
334 int end = 0, i;
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
335 char txt[256];
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
336 if (!arg || strlen(arg) == 0) {
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
337 mp_msg(MSGT_VO, MSGL_ERR, "bl: subdevice must be given, example: -vo bl:arcade:host=localhost:2323\n");
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
338 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
339 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
340
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
341 bl_subdevice = malloc(strlen(arg) + 1);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
342 if (!bl_subdevice) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
343 mp_msg(MSGT_VO, MSGL_ERR, "bl: out of memory error\n");
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
344 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
345 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
346 p = bl_subdevice;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
347 strcpy(p, arg);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
348 mp_msg(MSGT_VO, MSGL_V, "bl: preinit called with %s\n", arg);
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
349 for (i = 0; i < NO_BLS; i++) {
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
350 if (!strncmp(p, bls[i].name, strlen(bls[i].name)))
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
351 break;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
352 }
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
353 if (i >= NO_BLS) {
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
354 txt[0] = 0;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
355 for (i = 0; i < NO_BLS; i++)
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
356 if (strlen( txt ) + 4 + strlen( bls[i].name ) + 1 < sizeof(txt))
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
357 sprintf( txt + strlen( txt ), "%s%s",
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
358 txt[0] == 0 ? "" : i == NO_BLS - 1 ? " or " : ", ", bls[i].name );
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
359 mp_msg(MSGT_VO, MSGL_ERR, "bl: subdevice must start with %s\nbl: i.e. -vo bl:arcade:host=localhost:2323\n", txt);
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
360 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
361 }
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
362 bl = &bls[i];
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
363 p += strlen(bls[i].name);
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
364 if (*p == '\0') {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
365 no_bl_hosts = 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
366 bl_hosts[0].name = "localhost";
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
367 bl_hosts[0].port = 2323;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
368 mp_msg(MSGT_VO, MSGL_V, "bl: no hosts/files specified, using localhost:2323\n");
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
369 end = 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
370 } else if (*p != ':') {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
371 mp_msg(MSGT_VO, MSGL_ERR, "bl: syntax error in subdevice\n");
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
372 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
373 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
374 p++;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
375
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
376 while (!end) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
377 q = p + 5;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
378 if (!strncmp(p, "file=", 5)) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
379 if (no_bl_files == BL_MAX_FILES) {
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
380 mp_msg(MSGT_VO, MSGL_ERR, "bl: maximum number of files reached (%d)\n", BL_MAX_FILES);
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
381 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
382 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
383 p += 5;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
384 while (*q != ',' && *q != '\0') q++;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
385 if (*q == '\0') end = 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
386 *q = '\0';
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
387 bl_files[no_bl_files].name = p;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
388 mp_msg(MSGT_VO, MSGL_V, "blfile[%d]: %s\n",
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
389 no_bl_files, p);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
390 no_bl_files++;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
391 } else if (!strncmp(p, "host=", 5)) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
392 if (no_bl_hosts == BL_MAX_HOSTS) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
393 mp_msg(MSGT_VO, MSGL_ERR, "bl: maximum number of hosts reached (%d)\n", BL_MAX_HOSTS);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
394 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
395 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
396 p += 5;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
397 while (*q != ',' && *q != '\0' && *q != ':') q++;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
398 if (*q == ':') {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
399 *q++ = '\0';
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
400 bl_hosts[no_bl_hosts].name = p;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
401 bl_hosts[no_bl_hosts].port = atoi(q);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
402 while (*q != ',' && *q != '\0') q++;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
403 if (*q == '\0') end = 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
404 } else {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
405 /* use default port */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
406 if (*q == '\0') end = 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
407 *q = '\0';
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
408 bl_hosts[no_bl_hosts].name = p;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
409 bl_hosts[no_bl_hosts].port = 2323;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
410 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
411 mp_msg(MSGT_VO, MSGL_V,
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
412 "blhost[%d]: %s:%d\n",
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
413 no_bl_hosts, p,
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
414 bl_hosts[no_bl_hosts].port);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
415 no_bl_hosts++;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
416 } else {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
417 mp_msg(MSGT_VO, MSGL_ERR, "bl: syntax error in entry %d in subdevice %s, should be a comma seperated\nlist of host=name:port and file=foo.bml\n", no_bl_hosts, no_bl_files, arg);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
418 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
419 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
420 p = ++q;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
421 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
422
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
423 if (bl->width >= 0 && bl->height >= 0) { /* size already known */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
424 bl_size = 12 + bl->width*bl->height*bl->channels;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
425 bl_packet = malloc(12 + bl->width*bl->height*3); /* space for header and image data */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
426 image = ((unsigned char*)bl_packet + 12); /* pointer to image data */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
427 tmp = malloc(bl->width*bl->height*3); /* space for image data only */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
428 }
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
429 else { /* size unknown yet */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
430 bl_size = 12;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
431 bl_packet = malloc(12 + 3); /* space for header and a pixel */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
432 image = ((unsigned char*)bl_packet + 12); /* pointer to image data */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
433 tmp = malloc(3); /* space for a pixel only */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
434 }
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
435
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
436 if (!bl_packet || !tmp) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
437 mp_msg(MSGT_VO, MSGL_ERR, "bl: out of memory error\n");
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
438 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
439 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
440 bl_packet->magic = htonl(0x23542666);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
441 bl_packet->width = htons(bl->width);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
442 bl_packet->height = htons(bl->height);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
443 bl_packet->channels = htons(bl->channels);
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
444 bl_packet->maxval = htons((1 << bl->bpc) - 1);
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
445
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
446 /* open all files */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
447 for (i = 0; i < no_bl_files; i++)
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
448 if (bl->init_file(&bl_files[i])) return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
449
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
450 /* open all sockets */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
451 for (i = 0; i < no_bl_hosts; i++)
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
452 if (bl->init_connection(&bl_hosts[i])) return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
453
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
454
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
455 return 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
456 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
457
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
458 static uint32_t control(uint32_t request, void *data, ...) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
459 switch (request) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
460 case VOCTRL_QUERY_FORMAT:
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
461 return query_format(*((uint32_t*)data));
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
462 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
463 return VO_NOTIMPL;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
464 }