1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
|
/*
* config.c: User settings
*
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
* $Id: config.c,v 1.2 2006-07-02 17:03:26 phintuka Exp $
*
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <getopt.h>
#include <vdr/config.h>
#include "config.h"
#define DEFAULT_DEINTERLACE_OPTS "method=Linear,cheap_mode=1,pulldown=0,use_progressive_frame_flag=1"
const char *config_t::s_bufferSize[] =
{"custom","tiny","small","medium","large","huge",NULL};
const int config_t::i_pesBufferSize[] =
{0,50,250,500,1000,2000,500};
const char *config_t::s_aspects[] =
{"automatic", "default", "4:3", "16:9", "Pan&Scan", "CenterCutOut", 0};
const char *config_t::s_deinterlaceMethods[] =
{"none", "bob", "weave", "greedy", "onefield", "onefield_xv",
"linearblend", "tvtime", 0};
const char *config_t::s_deinterlaceMethodNames[] =
{"off", "Bob", "Weave", "Greedy", "One Field", "One Field XV",
"Linear Blend", "TvTime", NULL};
const char *config_t::s_decoderPriority[] =
{"low", "normal", "high", 0};
const char *config_t::s_fieldOrder[] =
{"normal", "inverted", NULL};
const char *config_t::s_audioDriverNames[] =
{"automatic","Alsa","OSS","no audio","Arts","ESound",NULL};
const char *config_t::s_audioDrivers[] =
{"auto","alsa","oss","none","arts","esound",NULL};
const char *config_t::s_videoDriverNamesX11[] =
{"automatic","XShm","Xv","XvMC","XvMC+VLD","no video",NULL};
const char *config_t::s_videoDriversX11[] =
{"auto","X11","xv","xvmc","xxmc","none",NULL};
const char *config_t::s_videoDriverNamesFB[] =
{"automatic","Framebuffer","DirectFB","No Video",NULL};
const char *config_t::s_videoDriversFB[] =
{"auto","fb","DirectFB","none",NULL};
const char *config_t::s_frontendNames[] =
{"X11 (sxfe)", "Framebuffer (fbfe)", "Off", NULL};
const char *config_t::s_frontends[] =
{"sxfe", "fbfe", "", NULL};
const char *config_t::s_frontend_files[] =
{"lib" PLUGIN_NAME_I18N "-sxfe.so." XINELIBOUTPUT_VERSION,
"lib" PLUGIN_NAME_I18N "-fbfe.so." XINELIBOUTPUT_VERSION,
// example: xineliboutput-sxfe.so.0.4.0
"",
NULL};
const char *config_t::s_audioEqNames[] =
{"30 Hz", "60 Hz", "125 Hz", "250 Hz", "500 Hz",
"1 kHz", "2 kHz", "4 kHz", "8 kHz", "16 kHz", NULL};
const char *config_t::s_audioVisualizationNames[] =
{"Off", "Goom", "Oscilloscope", "FFT Scope", "FFT Graph", NULL};
const char *config_t::s_audioVisualizations[] =
{"none", "goom", "oscope", "fftscope", "fftgraph", NULL};
static char *strcatrealloc(char *dest, const char *src)
{
if (!src || !*src)
return dest;
int l = (dest ? strlen(dest) : 0) + strlen(src) + 1;
if(dest) {
dest = (char *)realloc(dest, l);
strcat(dest, src);
} else {
dest = (char*)malloc(l);
strcpy(dest, src);
}
return dest;
}
config_t::config_t() {
memset(this, 0, sizeof(config_t));
strcpy(local_frontend, s_frontends[FRONTEND_X11]);
strcpy(video_driver , s_videoDriversX11[X11_DRIVER_XV]);
strcpy(video_port , "127.0.0.1:0.0");
strcpy(modeline , "");
strcpy(audio_driver , s_audioDrivers[AUDIO_DRIVER_ALSA]);
strcpy(audio_port , "default");
post_plugins = NULL;
audio_delay = 0;
audio_compression = 0;
memset(audio_equalizer,0,sizeof(audio_equalizer));
strcpy(audio_visualization, "goom");
//strcpy(audio_vis_goom_opts, "fps:25,width:720,height:576");
headphone = 0;
audio_upmix = 0;
audio_surround = 0;
inactivity_timer = 0;
decoder_priority = DECODER_PRIORITY_NORMAL;
pes_buffers = i_pesBufferSize[PES_BUFFERS_SMALL_250];
strcpy(deinterlace_method, s_deinterlaceMethods[DEINTERLACE_NONE]);
strcpy(deinterlace_opts, DEFAULT_DEINTERLACE_OPTS);
display_aspect = 0; /* auto */
hide_main_menu = 0;
prescale_osd = 1;
prescale_osd_downscale = 0;
unscaled_osd = 0;
unscaled_osd_opaque = 0;
unscaled_osd_lowresvideo = 1;
alpha_correction = 0;
alpha_correction_abs = 0;
fullscreen = 0;
modeswitch = 1;
width = 720;
height = 576;
scale_video = 0;
field_order = 0;
autocrop = 0;
remote_mode = 0;
listen_port = LISTEN_PORT;
use_remote_keyboard = 1;
remote_usetcp = 1;
remote_useudp = 1;
remote_usertp = 1;
remote_usepipe = 1;
remote_usebcast = 1;
strcpy(remote_rtp_addr, "224.0.1.9");
remote_rtp_port = LISTEN_PORT;
remote_rtp_ttl = 1;
remote_rtp_always_on = 0;
use_x_keyboard = 1;
hue = -1;
saturation = -1;
contrast = -1;
brightness = -1;
strcpy(browse_files_dir, "/video");
strcpy(browse_images_dir, "/video");
main_menu_mode = ShowMenu;
force_primary_device = 0;
m_ProcessedArgs = NULL;
};
bool config_t::ProcessArg(const char *Name, const char *Value)
{
char *s = m_ProcessedArgs;
m_ProcessedArgs = NULL;
if(SetupParse(Name, Value)) {
m_ProcessedArgs = s ? s : strcpy(new char[4096], " ");
strcat(strcat(m_ProcessedArgs, Name), " ");
return true;
}
m_ProcessedArgs = s;
return false;
}
char *m_ProcessedArgs;
bool config_t::ProcessArgs(int argc, char *argv[])
{
static struct option long_options[] = {
{ "display", required_argument, NULL, 'd' },
{ "fullscreen", no_argument, NULL, 'f' },
{ "xkeyboard", no_argument, NULL, 'k' },
//{ "noxkeyboard",no_argument, NULL, 'K' },
{ "local", required_argument, NULL, 'l' },
{ "nolocal", no_argument, NULL, 'L' },
{ "modeline", required_argument, NULL, 'm' },
{ "remote", required_argument, NULL, 'r' },
{ "noremote", no_argument, NULL, 'R' },
{ "window", no_argument, NULL, 'w' },
{ "video", required_argument, NULL, 'V' },
{ "audio", required_argument, NULL, 'A' },
{ "post", required_argument, NULL, 'P' },
{ "primary", no_argument, NULL, 'p' },
{ "exit-on-close",no_argument, NULL, 'c' },
{ NULL }
};
int c;
while ((c = getopt_long(argc, argv, "d:fkKl:Lm:r:RW", long_options, NULL)) != -1) {
switch (c) {
case 'd': ProcessArg("Video.Port", optarg);
break;
case 'f': ProcessArg("Fullscreen", "1");
break;
case 'k': ProcessArg("X11.UseKeyboard", "1");
break;
//case 'K': ProcessArg("X11.UseKeyboard", "0");
//break;
case 'l': ProcessArg("Frontend", optarg);
break;
case 'L': ProcessArg("Frontend", "none");
break;
case 'm': ProcessArg("Modeline", optarg);
break;
case 'r': ProcessArg("Remote.ListenPort", optarg);
ProcessArg("RemoteMode", "1");
break;
case 'R': ProcessArg("RemoteMode", "0");
break;
case 'w': ProcessArg("Fullscreen", "0");
break;
case 'V': ProcessArg("Video.Driver", optarg);
break;
case 'A': ProcessArg("Audio.Driver", optarg);
break;
case 'P': if(post_plugins)
post_plugins = strcatrealloc(post_plugins, ";");
post_plugins = strcatrealloc(post_plugins, optarg);
break;
case 'p': ProcessArg("ForcePrimaryDevice", "1");
break;
case 'c': exit_on_close = 1;
break;
default: return false;
}
}
return true;
}
bool config_t::SetupParse(const char *Name, const char *Value)
{
char *pt;
if(m_ProcessedArgs && NULL != (pt=strstr(m_ProcessedArgs+1, Name)) &&
*(pt-1) == ' ' && *(pt+strlen(Name)) == ' ')
return true;
if (!strcasecmp(Name, "Frontend")) strcpy(local_frontend, Value);
else if (!strcasecmp(Name, "Modeline")) strcpy(modeline, Value);
else if (!strcasecmp(Name, "VideoModeSwitching")) modeswitch = atoi(Value);
else if (!strcasecmp(Name, "Fullscreen")) fullscreen = atoi(Value);
else if (!strcasecmp(Name, "DisplayAspect")) display_aspect = strstra(Value, s_aspects, 0);
else if (!strcasecmp(Name, "ForcePrimaryDevice")) force_primary_device = atoi(Value);
else if (!strcasecmp(Name, "X11.WindowWidth")) width = atoi(Value);
else if (!strcasecmp(Name, "X11.WindowHeight")) height = atoi(Value);
else if (!strcasecmp(Name, "X11.UseKeyboard")) use_x_keyboard = atoi(Value);
else if (!strcasecmp(Name, "Audio.Driver")) strcpy(audio_driver, Value);
else if (!strcasecmp(Name, "Audio.Port")) strcpy(audio_port, Value);
else if (!strcasecmp(Name, "Audio.Delay")) audio_delay = atoi(Value);
else if (!strcasecmp(Name, "Audio.Compression")) audio_compression = atoi(Value);
else if (!strcasecmp(Name, "Audio.Visualization")) strcpy(audio_visualization, Value);
else if (!strcasecmp(Name, "Audio.Surround")) audio_surround = atoi(Value);
else if (!strcasecmp(Name, "Audio.Upmix")) audio_upmix = atoi(Value);
else if (!strcasecmp(Name, "Audio.Headphone")) headphone = atoi(Value);
else if (!strcasecmp(Name, "OSD.HideMainMenu")) hide_main_menu = atoi(Value);
else if (!strcasecmp(Name, "OSD.Prescale")) prescale_osd = atoi(Value);
else if (!strcasecmp(Name, "OSD.Downscale")) prescale_osd_downscale = atoi(Value);
else if (!strcasecmp(Name, "OSD.UnscaledAlways")) unscaled_osd = atoi(Value);
else if (!strcasecmp(Name, "OSD.UnscaledOpaque")) unscaled_osd_opaque = atoi(Value);
else if (!strcasecmp(Name, "OSD.UnscaledLowRes")) unscaled_osd_lowresvideo = atoi(Value);
else if (!strcasecmp(Name, "OSD.AlphaCorrection")) alpha_correction = atoi(Value);
else if (!strcasecmp(Name, "OSD.AlphaCorrectionAbs")) alpha_correction_abs = atoi(Value);
else if (!strcasecmp(Name, "RemoteMode")) remote_mode = atoi(Value);
else if (!strcasecmp(Name, "Remote.ListenPort")) listen_port = atoi(Value);
else if (!strcasecmp(Name, "Remote.Keyboard")) use_remote_keyboard = atoi(Value);
else if (!strcasecmp(Name, "Remote.UseTcp")) remote_usetcp = atoi(Value);
else if (!strcasecmp(Name, "Remote.UseUdp")) remote_useudp = atoi(Value);
else if (!strcasecmp(Name, "Remote.UseRtp")) remote_usertp = atoi(Value);
else if (!strcasecmp(Name, "Remote.UsePipe")) remote_usepipe= atoi(Value);
else if (!strcasecmp(Name, "Remote.UseBroadcast")) remote_usebcast = atoi(Value);
else if (!strcasecmp(Name, "Remote.Rtp.Address")) strncpy(remote_rtp_addr, Value, 20);
else if (!strcasecmp(Name, "Remote.Rtp.Port")) remote_rtp_port = atoi(Value);
else if (!strcasecmp(Name, "Remote.Rtp.TTL")) remote_rtp_ttl = atoi(Value);
else if (!strcasecmp(Name, "Remote.Rtp.AlwaysOn")) remote_rtp_always_on = atoi(Value);
else if (!strcasecmp(Name, "Decoder.InactivityTimer")) inactivity_timer=atoi(Value);
else if (!strcasecmp(Name, "Decoder.Priority")) decoder_priority=strstra(Value,s_decoderPriority,1);
else if (!strcasecmp(Name, "Decoder.PesBuffers")) pes_buffers=atoi(Value);
else if (!strcasecmp(Name, "Video.Driver")) strcpy(video_driver, Value);
else if (!strcasecmp(Name, "Video.Port")) strcpy(video_port, Value);
else if (!strcasecmp(Name, "Video.Scale")) scale_video = atoi(Value);
else if (!strcasecmp(Name, "Video.DeinterlaceOptions")) strcpy(deinterlace_opts, Value);
else if (!strcasecmp(Name, "Video.Deinterlace")) strcpy(deinterlace_method, Value);
else if (!strcasecmp(Name, "Video.FieldOrder")) field_order=atoi(Value)?1:0;
else if (!strcasecmp(Name, "Video.AutoCrop")) autocrop = atoi(Value);
else if (!strcasecmp(Name, "Video.HUE")) hue = atoi(Value);
else if (!strcasecmp(Name, "Video.Saturation")) saturation = atoi(Value);
else if (!strcasecmp(Name, "Video.Contrast")) contrast = atoi(Value);
else if (!strcasecmp(Name, "Video.Brightness")) brightness = atoi(Value);
else if (!strcasecmp(Name, "BrowseFilesDir")) strcpy(browse_files_dir, Value);
else if (!strcasecmp(Name, "BrowseImagesDir")) strcpy(browse_images_dir, Value);
else if (!strcasecmp(Name, "Audio.Equalizer"))
sscanf(Value,"%d %d %d %d %d %d %d %d %d %d",
audio_equalizer ,audio_equalizer+1,
audio_equalizer+2,audio_equalizer+3,
audio_equalizer+4,audio_equalizer+5,
audio_equalizer+6,audio_equalizer+7,
audio_equalizer+8,audio_equalizer+9);
else return false;
return true;
}
/* Global instance */
config_t xc;
|