-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig.c
198 lines (183 loc) · 5.34 KB
/
config.c
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
//////////////////////////////////////////////////////////////////////////////
/// ///
/// This file is part of the VDR mpv plugin and licensed under AGPLv3 ///
/// ///
/// See the README file for copyright information ///
/// ///
//////////////////////////////////////////////////////////////////////////////
#include <stdlib.h>
#include <unistd.h>
#include <sstream>
#include <vdr/tools.h>
#include "config.h"
cMpvPluginConfig::cMpvPluginConfig()
{
HideMainMenuEntry = 0;
UseDeinterlace = 1;
UsePassthrough = 1;
UseDtsHdPassthrough = 1;
StereoDownmix = 0;
PlaylistOnNextKey = 0;
PlaylistIfNoChapters = 1;
ShowMediaTitle = 0;
ShowSubtitles = 0;
ExitAtEnd = 1;
ShowAfterStop = 0;
SavePos = 0;
SoftVol = 0;
BrowserRoot = "/";
RefreshRate = 0;
VideoOut = "vdpau";
HwDec = "vdpau";
GpuCtx = "auto";
AudioOut = "alsa:device=default";
DiscDevice = "/dev/dvd";
Languages = "deu,de,ger,eng,en";
PlayListExtString = "m3u,ini,pls,txt,playlist";
MainMenuEntry = "MPV";
NoScripts = 0;
X11Display = ":0.0";
Geometry = "";
Windowed = 0;
ShowOptions = 0;
DRMdev = "";
}
vector<string> cMpvPluginConfig::ExplodeString(string Input)
{
vector<string> Result;
std::stringstream Data(Input);
string Item;
while(std::getline(Data, Item, ','))
{
if (Item != "")
Result.push_back(Item);
}
return Result;
}
int cMpvPluginConfig::ProcessArgs(int argc, char *const argv[])
{
char *s;
for (;;)
{
switch (getopt(argc, argv, "a:v:h:c:d:b:l:x:rm:swg:e:"))
{
case 'a': // audio out
AudioOut = optarg;
continue;
case 'v': // video out
VideoOut = optarg;
continue;
case 'h': // hwdec-codecs
HwDec = optarg;
continue;
case 'c': // gpu-context
GpuCtx = optarg;
continue;
case 'd': // dvd-device
DiscDevice = optarg;
continue;
case 'b': // browser root
BrowserRoot = optarg;
continue;
case 'l': // languages
Languages = optarg;
continue;
case 'x': // playlist extensions
PlayListExtString = optarg;
continue;
case 'r': // refresh rate
RefreshRate = 1;
continue;
case 'm':
MainMenuEntry = optarg;
continue;
case 's':
NoScripts = 1;
continue;
case 'w':
Windowed = 1;
continue;
case 'g':
Geometry = optarg;
continue;
case 'e':
DRMdev = optarg;
continue;
case EOF:
break;
case ':':
esyslog("[mpv]: missing argument for option '%c'\n", optopt);
return 0;
default:
esyslog("[mpv]: unknown option '%c'\n", optopt);
return 0;
}
break;
}
while (optind < argc)
{
esyslog("[mpv]: unhandled argument '%s'\n", argv[optind++]);
}
if ((s = getenv("DISPLAY")))
{
X11Display = s;
}
else if (strcmp(GpuCtx.c_str(),"drm") && strcmp(VideoOut.c_str(),"drm"))
setenv("DISPLAY", X11Display.c_str(), 1);
//convert the playlist extension string to a vector
PlaylistExtensions = ExplodeString(PlayListExtString);
return 1;
}
const char *cMpvPluginConfig::CommandLineHelp(void)
{
return
" -a audio\tmpv --ao (Default: alsa:device=default)\n"
" -v video\tmpv --vo (Default: vdpau)\n"
" -h hwdec\tmpv --hwdec-codecs (Default: vdpau)\n"
" -c gpuctx\tmpv --gpu-context (Default: auto)\n"
" -d device\tmpv optical disc device (Default: /dev/dvd)\n"
" -l languages\tlanguages for audio and subtitles (Default: deu,de,ger,eng,en)\n"
" -b /dir\tbrowser root directory\n"
" -x extensions\tfiles with this extensions are handled as playlists\n"
"\t\t(Default: m3u,ini,pls,txt,playlist)\n"
#ifdef USE_XRANDR
" -r\t\tswitch modeline to refresh rate of played file\n"
#endif
" -m text\ttext displayed in VDR main menu (Default: MPV)\n"
" -s\t\tdon't load mpv LUA scripts\n"
" -w windowed mode with X11\n"
" -g geometry\t X11 geometry [W[xH]][+-x+-y][/WS] or x:y\n"
;
}
bool cMpvPluginConfig::SetupParse(const char *name, const char *value)
{
if (!strcasecmp(name, "HideMainMenuEntry"))
HideMainMenuEntry = atoi(value);
else if (!strcasecmp(name, "UseDeinterlace"))
UseDeinterlace = atoi(value);
else if (!strcasecmp(name, "UsePassthrough"))
UsePassthrough = atoi(value);
else if (!strcasecmp(name, "StereoDownmix"))
StereoDownmix = atoi(value);
else if (!strcasecmp(name, "UseDtsHdPassthrough"))
UseDtsHdPassthrough = atoi(value);
else if (!strcasecmp(name, "PlaylistOnNextKey"))
PlaylistOnNextKey = atoi(value);
else if (!strcasecmp(name, "PlaylistIfNoChapters"))
PlaylistIfNoChapters = atoi(value);
else if (!strcasecmp(name, "ShowMediaTitle"))
ShowMediaTitle = atoi(value);
else if (!strcasecmp(name, "ShowSubtitles"))
ShowSubtitles = atoi(value);
else if (!strcasecmp(name, "ExitAtEnd"))
ExitAtEnd = atoi(value);
else if (!strcasecmp(name, "ShowAfterStop"))
ShowAfterStop = atoi(value);
else if (!strcasecmp(name, "SavePos"))
SavePos = atoi(value);
else if (!strcasecmp(name, "SoftVol"))
SoftVol = atoi(value);
else
return false;
return true;
}