annotate libvo/vo_bl.c @ 15834:1d2234930e70

mentioning xorg
author alex
date Mon, 27 Jun 2005 20:23:11 +0000
parents 05aa13cdf92f
children 7a33ae1f8e6d
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"
13787
e047e70a9767 Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents: 13000
diff changeset
46 #include "mp_msg.h"
e047e70a9767 Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents: 13000
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;
15158
d570dfbf9ef6 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 13787
diff changeset
71 int header_written; /* if header was written already */
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
72 } bl_file_t;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
73
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
74 typedef struct {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
75 char *name; /* hostname */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
76 int port;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
77 int fd; /* file descriptor */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
78 } bl_host_t;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
79
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
80 typedef struct {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
81 char *name;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
82 int img_format;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
83
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
84 int channels;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
85 int width;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
86 int height;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
87 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
88
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
89 /* file output functions */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
90 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
91 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
92 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
93
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
94 /* network output functions */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
95 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
96 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
97 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
98 } bl_properties_t;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
99
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
100 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
101
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
102 /* 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
103 #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
104 #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
105 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
106 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
107 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
108 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
109
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
110 typedef struct {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
111 uint32_t magic;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
112 uint16_t height;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
113 uint16_t width;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
114 uint16_t channels;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
115 uint16_t maxval;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
116 unsigned char data[0];
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
117 } bl_packet_t;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
118
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
119 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
120 static int bl_size;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
121
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
122 /* bml output functions */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
123 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
124 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
125 if (!f->fp) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
126 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
127 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
128 }
15158
d570dfbf9ef6 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 13787
diff changeset
129 f->header_written = 0;
d570dfbf9ef6 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 13787
diff changeset
130 return 0;
d570dfbf9ef6 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 13787
diff changeset
131 }
d570dfbf9ef6 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 13787
diff changeset
132
d570dfbf9ef6 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 13787
diff changeset
133 static void bml_write_frame(bl_file_t *f, unsigned char *i, int duration) {
d570dfbf9ef6 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 13787
diff changeset
134 int j, k;
d570dfbf9ef6 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 13787
diff changeset
135 if( ! f->header_written )
d570dfbf9ef6 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 13787
diff changeset
136 {
d570dfbf9ef6 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 13787
diff changeset
137 fprintf(f->fp,
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
138 "<?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
139 "<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
140 " <header>\n"
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
141 " <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
142 " <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
143 " </header>\n", bl->width, bl->height, bl->bpc, bl->channels);
15158
d570dfbf9ef6 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 13787
diff changeset
144 f->header_written = 1;
d570dfbf9ef6 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 13787
diff changeset
145 }
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
146 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
147 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
148 fprintf(f->fp, " <row>");
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
149 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
150 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
151 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
152 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
153 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
154 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
155
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
156 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
157 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
158 fclose(f->fp);
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
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
161 /* Blinkenlights UDP protocol */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
162 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
163 struct sockaddr_in addr;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
164 struct hostent *dest;
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 dest = gethostbyname(h->name);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
167 if (!dest) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
168 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
169 "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
170 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
171 }
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 = -1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
174 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
175 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
176
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
177 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
178
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
179 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
180 if (h->fd < 0) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
181 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
182 "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
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 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
186 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
187 h->name);
10281
54bcbf28698a Networking support under MinGW.
diego
parents: 10206
diff changeset
188 closesocket(h->fd);
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
189 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
190 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
191 return 0;
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
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
194 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
195 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
196 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
197 }
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 void udp_close(bl_host_t *h) {
10281
54bcbf28698a Networking support under MinGW.
diego
parents: 10206
diff changeset
200 closesocket(h->fd);
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
201 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
202
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
203 #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
204
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
205 static bl_properties_t bls[NO_BLS] = {
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
206 { "hdl", IMGFMT_YV12, 1, 18, 8, 8,
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
207 &bml_init, &bml_write_frame, &bml_close,
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
208 &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
209 { "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
210 &bml_init, &bml_write_frame, &bml_close,
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
211 &udp_init, &udp_send, &udp_close },
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
212 { "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
213 &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
214 &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
215
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
216 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
15212
05aa13cdf92f replace VO and VF numeric flags with #defined identifiers
henry
parents: 15158
diff changeset
217 uint32_t d_height, uint32_t flags, char *title, uint32_t format)
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
218 {
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
219 void * ptr;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
220
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
221 /* adapt size of Blinkenlights UDP stream to size of movie */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
222 if (bl->width < 0 || bl->height < 0) {
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
223 if (bl->width < 0) /* use width of movie */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
224 bl->width = width;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
225 if (bl->height < 0) /* use height of movie */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
226 bl->height = height;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
227 /* check for maximum size of UDP packet */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
228 if (12 + bl->width*bl->height*bl->channels > 65507) {
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
229 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
230 bl->width, bl->height, bl->channels);
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
231 return 1;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
232 }
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
233 /* resize frame and tmp buffers */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
234 bl_size = 12 + bl->width*bl->height*bl->channels;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
235 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
236 if (ptr)
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
237 bl_packet = (bl_packet_t*)ptr;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
238 else {
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
239 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
240 return 1;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
241 }
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
242 image = ((unsigned char*)bl_packet + 12); /* pointer to image data */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
243 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
244 if (ptr)
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
245 tmp = (unsigned char*)ptr;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
246 else {
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
247 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
248 return 1;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
249 }
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
250 }
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
251
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
252 framenum = 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
253 if (format != IMGFMT_YV12) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
254 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
255 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
256 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
257 if (width > bl->width) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
258 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
259 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
260 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
261 if (height > bl->height) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
262 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
263 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
264 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
265 if (!image) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
266 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
267 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
268 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
269 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
270 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
271 return 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
272 }
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 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
275 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
276
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
277 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
278 int i;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
279
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
280 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
281 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
282 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
283 prevpts = vo_pts;
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 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
286
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
287
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
288 framenum++;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
289 return;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
290 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
291
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
292 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
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 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
297 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
298 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
299 return 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
300 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
301
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
302 static void uninit(void) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
303 int i;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
304 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
305 free(bl_packet);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
306 bl_packet = NULL;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
307 free(bl_subdevice);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
308 bl_subdevice = NULL;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
309 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
310 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
311 no_bl_files = 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
312 no_bl_hosts = 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
313 bl = NULL;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
314 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
315
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
316 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
317 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
318
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
319 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
320 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
321 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
322 uint8_t *dst;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
323 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
324 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
325 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
326 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
327 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
328 // copy Y:
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
329 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
330 memcpy(dst,src,w);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
331 dst+=bl->width;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
332 src+=stride[0];
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
333
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
334 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
335 return 0;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
336 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
337
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
338 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
339 char *p, *q;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
340 int end = 0, i;
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
341 char txt[256];
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
342 if (!arg || strlen(arg) == 0) {
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
343 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
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
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
347 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
348 if (!bl_subdevice) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
349 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
350 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
351 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
352 p = bl_subdevice;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
353 strcpy(p, arg);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
354 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
355 for (i = 0; i < NO_BLS; i++) {
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
356 if (!strncmp(p, bls[i].name, strlen(bls[i].name)))
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
357 break;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
358 }
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
359 if (i >= NO_BLS) {
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
360 txt[0] = 0;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
361 for (i = 0; i < NO_BLS; i++)
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
362 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
363 sprintf( txt + strlen( txt ), "%s%s",
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
364 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
365 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
366 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
367 }
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
368 bl = &bls[i];
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
369 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
370 if (*p == '\0') {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
371 no_bl_hosts = 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
372 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
373 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
374 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
375 end = 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
376 } else if (*p != ':') {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
377 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
378 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
379 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
380 p++;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
381
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
382 while (!end) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
383 q = p + 5;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
384 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
385 if (no_bl_files == BL_MAX_FILES) {
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
386 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
387 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
388 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
389 p += 5;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
390 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
391 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
392 *q = '\0';
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
393 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
394 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
395 no_bl_files, p);
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
396 no_bl_files++;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
397 } 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
398 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
399 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
400 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
401 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
402 p += 5;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
403 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
404 if (*q == ':') {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
405 *q++ = '\0';
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
406 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
407 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
408 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
409 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
410 } else {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
411 /* use default port */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
412 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
413 *q = '\0';
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].name = p;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
415 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
416 }
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_V,
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
418 "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
419 no_bl_hosts, p,
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
420 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
421 no_bl_hosts++;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
422 } else {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
423 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
424 return 1;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
425 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
426 p = ++q;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
427 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
428
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
429 if (bl->width >= 0 && bl->height >= 0) { /* size already known */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
430 bl_size = 12 + bl->width*bl->height*bl->channels;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
431 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
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(bl->width*bl->height*3); /* space for image data only */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
434 }
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
435 else { /* size unknown yet */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
436 bl_size = 12;
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
437 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
438 image = ((unsigned char*)bl_packet + 12); /* pointer to image data */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
439 tmp = malloc(3); /* space for a pixel only */
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
440 }
7326
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
441
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
442 if (!bl_packet || !tmp) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
443 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
444 return 1;
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 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
447 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
448 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
449 bl_packet->channels = htons(bl->channels);
13000
076e87baf7c0 --Patch by Stefan '1stein' Schuermans <1stein@schuermans.info>:
rik
parents: 10594
diff changeset
450 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
451
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
452 /* open all files */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
453 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
454 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
455
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
456 /* open all sockets */
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
457 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
458 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
459
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
460
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
461 return 0;
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
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
464 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
465 switch (request) {
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
466 case VOCTRL_QUERY_FORMAT:
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
467 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
468 }
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
469 return VO_NOTIMPL;
ec3e58120e2a extensible blinkenlights driver, can currently be used for the Arcade http://www.blinkenlights.de/arcade
rik
parents:
diff changeset
470 }