summaryrefslogtreecommitdiff
path: root/src/mpvoptions.cpp
diff options
context:
space:
mode:
authorMateusz Łukasik <mati75@linuxmint.pl>2017-02-03 08:16:09 +0100
committerMateusz Łukasik <mati75@linuxmint.pl>2017-02-03 08:16:09 +0100
commitbcae744b1bae2f5015cb3efdd0d2226150cd79e5 (patch)
tree872701745b36fbfbeb16dd1d59d485bc1e494dbd /src/mpvoptions.cpp
parent634cd2063f449c5d38046de88a395af77e2c9ea5 (diff)
New upstream version 17.2.0~ds0
Diffstat (limited to 'src/mpvoptions.cpp')
-rw-r--r--src/mpvoptions.cpp106
1 files changed, 89 insertions, 17 deletions
diff --git a/src/mpvoptions.cpp b/src/mpvoptions.cpp
index c3427f3..51d57cc 100644
--- a/src/mpvoptions.cpp
+++ b/src/mpvoptions.cpp
@@ -1,5 +1,5 @@
/* smplayer, GUI front-end for mplayer.
- Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net>
+ Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@
#include <QDir>
#include <QDebug>
#include "inforeader.h"
+#include "deviceinfo.h"
void MPVProcess::addArgument(const QString & /*a*/) {
}
@@ -60,10 +61,11 @@ void MPVProcess::setMedia(const QString & media, bool is_playlist) {
"METADATA_TRACK=${metadata/by-key/track:}\n"
"METADATA_COPYRIGHT=${metadata/by-key/copyright:}\n"
- "INFO_MEDIA_TITLE=${=media-title:}\n";
+ "INFO_MEDIA_TITLE=${=media-title:}\n"
+ "INFO_STREAM_PATH=${stream-path}\n";
#ifdef CUSTOM_STATUS
- arg << "--term-status-msg=STATUS: ${=time-pos} / ${=duration:${=length:0}} P: ${=pause} B: ${=paused-for-cache} I: ${=core-idle}";
+ arg << "--term-status-msg=STATUS: ${=time-pos} / ${=duration:${=length:0}} P: ${=pause} B: ${=paused-for-cache} I: ${=core-idle} VB: ${=video-bitrate:0} AB: ${=audio-bitrate:0}";
#endif
if (is_playlist) {
@@ -107,10 +109,18 @@ void MPVProcess::disableInput() {
}
bool MPVProcess::isOptionAvailable(const QString & option) {
- InfoReader * ir = InfoReader::obj(executable());
- ir->getInfo();
- //qDebug() << "MPVProcess::isOptionAvailable: option_list:" << ir->optionList();
- return ir->optionList().contains(option);
+ static QStringList option_list;
+ static QString mpv_bin;
+
+ if (option_list.isEmpty() || mpv_bin != executable()) {
+ InfoReader * ir = InfoReader::obj(executable());
+ ir->getInfo();
+ option_list = ir->optionList();
+ mpv_bin = executable();
+ //qDebug() << "MPVProcess::isOptionAvailable: option_list:" << option_list;
+ }
+
+ return option_list.contains(option);
}
void MPVProcess::addVFIfAvailable(const QString & vf, const QString & value) {
@@ -250,6 +260,12 @@ void MPVProcess::setOption(const QString & option_name, const QVariant & value)
arg << line_spacing + "=" + value.toString();
}
else
+ if (option_name == "ass-force-style") {
+ QString ass_force_style = "--ass-force-style";
+ if (isOptionAvailable("--sub-ass-force-style")) ass_force_style = "--sub-ass-force-style";
+ arg << ass_force_style + "=" + value.toString();
+ }
+ else
if (option_name == "stop-xscreensaver") {
bool stop_ss = value.toBool();
if (stop_ss) arg << "--stop-screensaver"; else arg << "--no-stop-screensaver";
@@ -323,16 +339,65 @@ void MPVProcess::setOption(const QString & option_name, const QVariant & value)
if (b) arg << "--" + option_name; else arg << "--no-" + option_name;
}
else
+ if (option_name == "vo") {
+ QString vo = value.toString();
+ if (vo.endsWith(",")) vo.chop(1);
+ #ifndef Q_OS_WIN
+ if (isOptionAvailable("--xv-adaptor")) {
+ QRegExp rx("xv:adaptor=(\\d+)");
+ if (rx.indexIn(vo) > -1) {
+ QString adaptor = rx.cap(1);
+ vo = "xv";
+ arg << "--xv-adaptor=" + adaptor;
+ }
+ }
+ #endif
+ arg << "--vo=" + vo + ",";
+ }
+ else
if (option_name == "ao") {
- QString o = value.toString();
- if (o.startsWith("alsa:device=")) {
- if (o.endsWith(",")) o.chop(1); // Remove last character
- QString device = o.mid(12);
- //qDebug() << "MPVProcess::setOption: alsa device:" << device;
- device = device.replace("=", ":").replace(".", ",");
- o = "alsa:device=[" + device + "]";
+ QString ao = value.toString();
+
+ QStringList l;
+ if (ao.contains(":")) l = DeviceInfo::extractDevice(ao);
+ if (l.count() > 0) ao = l[0];
+
+ if (isOptionAvailable("--audio-device")) {
+ if (l.count() == 3) {
+ #ifndef Q_OS_WIN
+ if (l[0] == "pulse") {
+ arg << "--audio-device=pulse/" + l[2];
+ }
+ #if USE_MPV_ALSA_DEVICES
+ else
+ if (l[0] == "alsa") {
+ arg << "--audio-device=alsa/" + l[1];
+ }
+ #endif
+ #else
+ if (l[0] == "dsound") {
+ arg << "--audio-device=dsound/" + l[1];
+ }
+ else
+ if (l[0] == "wasapi") {
+ arg << "--audio-device=wasapi/" + l[1];
+ }
+ #endif
+ }
+ } else {
+ #ifndef Q_OS_WIN
+ if (l.count() > 1) {
+ if (l[0] == "alsa") {
+ ao = "alsa:device=[hw:" + l[1] + "]";
+ }
+ else
+ if (l[0] == "pulse") {
+ ao = "pulse::" + l[1];
+ }
+ }
+ #endif
}
- arg << "--ao=" + o;
+ arg << "--ao=" + ao + ",";
}
else
if (option_name == "vc") {
@@ -386,10 +451,9 @@ void MPVProcess::setOption(const QString & option_name, const QVariant & value)
}
else
if (option_name == "wid" ||
- option_name == "vo" ||
option_name == "aid" || option_name == "vid" ||
option_name == "volume" ||
- option_name == "ass-styles" || option_name == "ass-force-style" ||
+ option_name == "ass-styles" ||
option_name == "embeddedfonts" ||
option_name == "osd-scale" ||
option_name == "speed" ||
@@ -404,6 +468,7 @@ void MPVProcess::setOption(const QString & option_name, const QVariant & value)
option_name == "dvd-device" || option_name == "cdrom-device" ||
option_name == "demuxer" ||
option_name == "frames" ||
+ option_name == "user-agent" || option_name == "referrer" ||
option_name == "ab-loop-a" || option_name == "ab-loop-b")
{
QString s = "--" + option_name;
@@ -439,6 +504,13 @@ void MPVProcess::addUserOption(const QString & option) {
}
}
+void MPVProcess::setSubEncoding(const QString & codepage, const QString & enca_lang) {
+ Q_UNUSED(enca_lang)
+ if (!codepage.isEmpty()) {
+ arg << "--sub-codepage=" + codepage;
+ }
+}
+
void MPVProcess::addVF(const QString & filter_name, const QVariant & value) {
QString option = value.toString();