diff options
Diffstat (limited to 'config.c')
-rw-r--r-- | config.c | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/config.c b/config.c new file mode 100644 index 0000000..9fdc834 --- /dev/null +++ b/config.c @@ -0,0 +1,149 @@ +////////////////////////////////////////////////////////////////////////////// +/// /// +/// 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; + UsePassthrough = 1; + UseDtsHdPassthrough = 1; + StereoDownmix = 0; + PlaylistOnNextKey = 0; + PlaylistIfNoChapters = 1; + ShowMediaTitle = 0; + + BrowserRoot = "/"; + RefreshRate = 0; + VideoOut = "vdpau"; + HwDec = "vdpau"; + AudioOut = "alsa:device=default"; + DiscDevice = "/dev/dvd"; + Languages = "deu,de,ger,eng,en"; + PlayListExtString = "m3u,ini,pls,txt,playlist"; + + X11Display = ":0.0"; +} + +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; + if ((s = getenv("DISPLAY"))) + { + X11Display = s; + } + else + setenv("DISPLAY", X11Display.c_str(), 1); + + for (;;) + { + switch (getopt(argc, argv, "a:v:h:d:b:l:x:r")) + { + case 'a': // audio out + AudioOut = optarg; + continue; + case 'v': // video out + VideoOut = optarg; + continue; + case 'h': // hwdec-codecs + HwDec = 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 EOF: + break; + case ':': + esyslog("[mpv]: missing argument for option '%c'\n", optopt); + return 0; + default: + esyslog("[mpv]: unkown option '%c'\n", optopt); + return 0; + } + break; + } + while (optind < argc) + { + esyslog("[mpv]: unhandled argument '%s'\n", argv[optind++]); + } + + //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" + " -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 + ; +} + +bool cMpvPluginConfig::SetupParse(const char *name, const char *value) +{ + if (!strcasecmp(name, "HideMainMenuEntry")) + HideMainMenuEntry = 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 + return false; + return true; +} + |