1 |
commit: b598cbac8677e292b34b62104620e072fe9acf43 |
2 |
Author: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Dec 25 19:54:21 2020 +0000 |
4 |
Commit: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Dec 25 19:54:35 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b598cbac |
7 |
|
8 |
media-video/subtitlecomposer: Fix build with >=media-video/mpv-0.33 |
9 |
|
10 |
Reported-by: Julien Papasian <julien.papasian <AT> gmail.com> |
11 |
Closes: https://bugs.gentoo.org/760006 |
12 |
Package-Manager: Portage-3.0.12, Repoman-3.0.2 |
13 |
Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org> |
14 |
|
15 |
.../files/subtitlecomposer-0.7.0-mpv-0.33.patch | 260 +++++++++++++++++++++ |
16 |
.../subtitlecomposer/subtitlecomposer-0.7.0.ebuild | 1 + |
17 |
2 files changed, 261 insertions(+) |
18 |
|
19 |
diff --git a/media-video/subtitlecomposer/files/subtitlecomposer-0.7.0-mpv-0.33.patch b/media-video/subtitlecomposer/files/subtitlecomposer-0.7.0-mpv-0.33.patch |
20 |
new file mode 100644 |
21 |
index 00000000000..a97ab22543b |
22 |
--- /dev/null |
23 |
+++ b/media-video/subtitlecomposer/files/subtitlecomposer-0.7.0-mpv-0.33.patch |
24 |
@@ -0,0 +1,260 @@ |
25 |
+From d09a3cbc60da86f57d06477dea1a57962a11ffb2 Mon Sep 17 00:00:00 2001 |
26 |
+From: Mladen Milinkovic <maxrd2@××××××××××.net> |
27 |
+Date: Mon, 8 Jul 2019 20:19:03 +0200 |
28 |
+Subject: [PATCH] MPV player config options aren't hardcoded anymore. |
29 |
+ |
30 |
+--- |
31 |
+ src/videoplayerplugins/mpv/mpvbackend.cpp | 37 ++++++- |
32 |
+ src/videoplayerplugins/mpv/mpvbackend.h | 8 +- |
33 |
+ .../mpv/mpvconfigwidget.cpp | 102 ++++++++++++++++-- |
34 |
+ src/videoplayerplugins/mpv/mpvconfigwidget.h | 8 ++ |
35 |
+ 4 files changed, 139 insertions(+), 16 deletions(-) |
36 |
+ |
37 |
+diff --git a/src/videoplayerplugins/mpv/mpvbackend.cpp b/src/videoplayerplugins/mpv/mpvbackend.cpp |
38 |
+index d85a56c..9fdcd95 100644 |
39 |
+--- a/src/videoplayerplugins/mpv/mpvbackend.cpp |
40 |
++++ b/src/videoplayerplugins/mpv/mpvbackend.cpp |
41 |
+@@ -33,8 +33,6 @@ |
42 |
+ #include <KMessageBox> |
43 |
+ |
44 |
+ using namespace SubtitleComposer; |
45 |
+-using namespace mpv; |
46 |
+-using namespace mpv::qt; |
47 |
+ |
48 |
+ MPVBackend::MPVBackend() |
49 |
+ : PlayerBackend(), |
50 |
+@@ -218,6 +216,37 @@ MPVBackend::mpvEventHandle(mpv_event *event) |
51 |
+ } |
52 |
+ } |
53 |
+ |
54 |
++static QVariant |
55 |
++node_to_variant(const mpv_node *node) |
56 |
++{ |
57 |
++ switch(node->format) { |
58 |
++ case MPV_FORMAT_STRING: |
59 |
++ return QVariant(QString::fromUtf8(node->u.string)); |
60 |
++ case MPV_FORMAT_FLAG: |
61 |
++ return QVariant(static_cast<bool>(node->u.flag)); |
62 |
++ case MPV_FORMAT_INT64: |
63 |
++ return QVariant(static_cast<qlonglong>(node->u.int64)); |
64 |
++ case MPV_FORMAT_DOUBLE: |
65 |
++ return QVariant(node->u.double_); |
66 |
++ case MPV_FORMAT_NODE_ARRAY: { |
67 |
++ mpv_node_list *list = node->u.list; |
68 |
++ QVariantList qlist; |
69 |
++ for(int n = 0; n < list->num; n++) |
70 |
++ qlist.append(node_to_variant(&list->values[n])); |
71 |
++ return QVariant(qlist); |
72 |
++ } |
73 |
++ case MPV_FORMAT_NODE_MAP: { |
74 |
++ mpv_node_list *list = node->u.list; |
75 |
++ QVariantMap qmap; |
76 |
++ for(int n = 0; n < list->num; n++) |
77 |
++ qmap.insert(QString::fromUtf8(list->keys[n]), node_to_variant(&list->values[n])); |
78 |
++ return QVariant(qmap); |
79 |
++ } |
80 |
++ default: // MPV_FORMAT_NONE, unknown values (e.g. future extensions) |
81 |
++ return QVariant(); |
82 |
++ } |
83 |
++} |
84 |
++ |
85 |
+ void |
86 |
+ MPVBackend::updateTextData(const mpv_event_property *prop) |
87 |
+ { |
88 |
+@@ -230,7 +259,7 @@ MPVBackend::updateTextData(const mpv_event_property *prop) |
89 |
+ if(val.format != MPV_FORMAT_NODE_MAP) |
90 |
+ continue; |
91 |
+ |
92 |
+- const QMap<QString, QVariant> &map = mpv::qt::node_to_variant(&val).toMap(); |
93 |
++ const QMap<QString, QVariant> &map = node_to_variant(&val).toMap(); |
94 |
+ |
95 |
+ if(map[QStringLiteral("type")].toString() != QStringLiteral("sub") |
96 |
+ || map[QStringLiteral("external")].toBool() == true) |
97 |
+@@ -269,7 +298,7 @@ MPVBackend::updateAudioData(const mpv_event_property *prop) |
98 |
+ if(val.format != MPV_FORMAT_NODE_MAP) |
99 |
+ continue; |
100 |
+ |
101 |
+- const QMap<QString, QVariant> &map = mpv::qt::node_to_variant(&val).toMap(); |
102 |
++ const QMap<QString, QVariant> &map = node_to_variant(&val).toMap(); |
103 |
+ |
104 |
+ if(map[QStringLiteral("type")].toString() != QStringLiteral("audio")) |
105 |
+ continue; |
106 |
+diff --git a/src/videoplayerplugins/mpv/mpvbackend.h b/src/videoplayerplugins/mpv/mpvbackend.h |
107 |
+index d0edf2e..5e19fa1 100644 |
108 |
+--- a/src/videoplayerplugins/mpv/mpvbackend.h |
109 |
++++ b/src/videoplayerplugins/mpv/mpvbackend.h |
110 |
+@@ -23,7 +23,7 @@ |
111 |
+ |
112 |
+ #include "videoplayer/playerbackend.h" |
113 |
+ |
114 |
+-#include <mpv/qthelper.hpp> |
115 |
++#include <mpv/client.h> |
116 |
+ |
117 |
+ #include <QWidget> |
118 |
+ #include <QString> |
119 |
+@@ -76,14 +76,10 @@ signals: |
120 |
+ protected slots: |
121 |
+ void onMPVEvents(); |
122 |
+ |
123 |
+-protected: |
124 |
+- void setupProcessArgs(const QString &filePath); |
125 |
+- |
126 |
++private: |
127 |
+ void mpvEventHandle(mpv_event *event); |
128 |
+- |
129 |
+ static void wakeup(void *ctx); |
130 |
+ |
131 |
+-private: |
132 |
+ void updateTextData(const mpv_event_property *prop); |
133 |
+ void updateAudioData(const mpv_event_property *prop); |
134 |
+ void updateVideoData(); |
135 |
+diff --git a/src/videoplayerplugins/mpv/mpvconfigwidget.cpp b/src/videoplayerplugins/mpv/mpvconfigwidget.cpp |
136 |
+index 78458f8..6958141 100644 |
137 |
+--- a/src/videoplayerplugins/mpv/mpvconfigwidget.cpp |
138 |
++++ b/src/videoplayerplugins/mpv/mpvconfigwidget.cpp |
139 |
+@@ -20,6 +20,11 @@ |
140 |
+ |
141 |
+ #include "mpvconfigwidget.h" |
142 |
+ |
143 |
++#include <locale> |
144 |
++#include <mpv/client.h> |
145 |
++ |
146 |
++#include "scconfig.h" |
147 |
++ |
148 |
+ using namespace SubtitleComposer; |
149 |
+ |
150 |
+ MPVConfigWidget::MPVConfigWidget(QWidget *parent) |
151 |
+@@ -27,14 +32,99 @@ MPVConfigWidget::MPVConfigWidget(QWidget *parent) |
152 |
+ { |
153 |
+ setupUi(this); |
154 |
+ |
155 |
+- kcfg_mpvVideoOutput->addItems(QString("vdpau vaapi opengl opengl-hq sdl xv wayland x11 null").split(' ')); |
156 |
+- kcfg_mpvVideoOutput->setProperty("kcfg_property", QByteArray("currentText")); |
157 |
++ // FIXME: libmpv requires LC_NUMERIC category to be set to "C".. is there some nicer way to do this? |
158 |
++ std::setlocale(LC_NUMERIC, "C"); |
159 |
++ m_mpv = mpv_create(); |
160 |
++ mpv_request_log_messages(m_mpv, "info"); |
161 |
++ if(mpv_initialize(m_mpv) >= 0) { |
162 |
++ getHelpResponse(); // make sure there are no log messages |
163 |
++ static QStringList bad = { |
164 |
++ QStringLiteral("libmpv"), |
165 |
++ QStringLiteral("null"), |
166 |
++ QStringLiteral("image"), |
167 |
++ QStringLiteral("tct"), |
168 |
++ QStringLiteral("caca"), |
169 |
++ QStringLiteral("pcm"), |
170 |
++ }; |
171 |
++ |
172 |
++ mpv_set_property_string(m_mpv, "vo", "help"); |
173 |
++ for(QString row : getHelpResponse()) { |
174 |
++ int pos = row.indexOf(QChar(' ')); |
175 |
++ if(pos == -1) |
176 |
++ continue; |
177 |
++ const QString name = row.left(pos); |
178 |
++ if(bad.contains(name)) |
179 |
++ continue; |
180 |
++ row.insert(pos, "\t-"); |
181 |
++ if(SCConfig::mpvVideoOutput() == name) |
182 |
++ kcfg_mpvVideoOutput->setCurrentIndex(kcfg_mpvHwDecode->count()); |
183 |
++ kcfg_mpvVideoOutput->addItem(row, name); |
184 |
++ } |
185 |
++ kcfg_mpvVideoOutput->setProperty("kcfg_property", QByteArray("currentData")); |
186 |
++ |
187 |
++ mpv_set_property_string(m_mpv, "hwdec", "help"); |
188 |
++ kcfg_mpvHwDecode->addItem(QStringLiteral("auto\t- Choose best HW decoder"), QStringLiteral("auto")); |
189 |
++ for(QString row : getHelpResponse()) { |
190 |
++ int pos = row.indexOf(QChar(' ')); |
191 |
++ if(pos == -1) |
192 |
++ continue; |
193 |
++ const QString name = row.left(pos); |
194 |
++ const QString lastName = kcfg_mpvHwDecode->itemData(kcfg_mpvHwDecode->count() - 1).toString(); |
195 |
++ if(lastName == name || bad.contains(name)) |
196 |
++ continue; |
197 |
++ if(SCConfig::mpvHwDecode() == name) |
198 |
++ kcfg_mpvHwDecode->setCurrentIndex(kcfg_mpvHwDecode->count()); |
199 |
++ kcfg_mpvHwDecode->addItem(name, name); |
200 |
++ } |
201 |
++ kcfg_mpvHwDecode->setProperty("kcfg_property", QByteArray("currentData")); |
202 |
++ |
203 |
++ mpv_set_property_string(m_mpv, "ao", "help"); |
204 |
++ for(QString row : getHelpResponse()) { |
205 |
++ int pos = row.indexOf(QChar(' ')); |
206 |
++ if(pos == -1) |
207 |
++ continue; |
208 |
++ const QString name = row.left(pos); |
209 |
++ if(bad.contains(name)) |
210 |
++ continue; |
211 |
++ row.insert(pos, "\t-"); |
212 |
++ if(SCConfig::mpvAudioOutput() == name) |
213 |
++ kcfg_mpvAudioOutput->setCurrentIndex(kcfg_mpvHwDecode->count()); |
214 |
++ kcfg_mpvAudioOutput->addItem(row, name); |
215 |
++ } |
216 |
++ kcfg_mpvAudioOutput->setProperty("kcfg_property", QByteArray("currentData")); |
217 |
+ |
218 |
+- kcfg_mpvHwDecode->addItems(QString("auto vdpau vaapi vaapi-copy").split(' ')); |
219 |
+- kcfg_mpvHwDecode->setProperty("kcfg_property", QByteArray("currentText")); |
220 |
++ mpv_detach_destroy(m_mpv); |
221 |
++ } else { |
222 |
++ kcfg_mpvVideoOutput->addItems(QString("vdpau vaapi opengl opengl-hq sdl xv wayland x11 null").split(' ')); |
223 |
++ kcfg_mpvVideoOutput->setProperty("kcfg_property", QByteArray("currentText")); |
224 |
+ |
225 |
+- kcfg_mpvAudioOutput->addItems(QString("pulse alsa oss portaudio jack null").split(' ')); |
226 |
+- kcfg_mpvAudioOutput->setProperty("kcfg_property", QByteArray("currentText")); |
227 |
++ kcfg_mpvHwDecode->addItems(QString("auto vdpau vaapi vaapi-copy").split(' ')); |
228 |
++ kcfg_mpvHwDecode->setProperty("kcfg_property", QByteArray("currentText")); |
229 |
++ |
230 |
++ kcfg_mpvAudioOutput->addItems(QString("pulse alsa oss portaudio jack null").split(' ')); |
231 |
++ kcfg_mpvAudioOutput->setProperty("kcfg_property", QByteArray("currentText")); |
232 |
++ } |
233 |
++} |
234 |
++ |
235 |
++const QStringList |
236 |
++MPVConfigWidget::getHelpResponse() |
237 |
++{ |
238 |
++ QStringList res; |
239 |
++ while(m_mpv) { |
240 |
++ mpv_event *event = mpv_wait_event(m_mpv, .1); |
241 |
++ if(event->event_id == MPV_EVENT_LOG_MESSAGE) { |
242 |
++ mpv_event_log_message *msg = reinterpret_cast<mpv_event_log_message *>(event->data); |
243 |
++ if(msg->log_level == MPV_LOG_LEVEL_INFO && strcmp(msg->prefix, "cplayer") == 0) { |
244 |
++ QString row = QString::fromUtf8(msg->text).simplified(); |
245 |
++ if(row.endsWith(QChar(':'))) |
246 |
++ continue; |
247 |
++ res << row; |
248 |
++ } |
249 |
++ } else if(event->event_id == MPV_EVENT_NONE) { |
250 |
++ break; |
251 |
++ } |
252 |
++ } |
253 |
++ return res; |
254 |
+ } |
255 |
+ |
256 |
+ MPVConfigWidget::~MPVConfigWidget() |
257 |
+diff --git a/src/videoplayerplugins/mpv/mpvconfigwidget.h b/src/videoplayerplugins/mpv/mpvconfigwidget.h |
258 |
+index f4105d7..775b507 100644 |
259 |
+--- a/src/videoplayerplugins/mpv/mpvconfigwidget.h |
260 |
++++ b/src/videoplayerplugins/mpv/mpvconfigwidget.h |
261 |
+@@ -23,6 +23,8 @@ |
262 |
+ |
263 |
+ #include "ui_mpvconfigwidget.h" |
264 |
+ |
265 |
++#include <mpv/client.h> |
266 |
++ |
267 |
+ namespace SubtitleComposer { |
268 |
+ class MPVConfigWidget : public QWidget, private Ui::MPVConfigWidget |
269 |
+ { |
270 |
+@@ -31,6 +33,12 @@ class MPVConfigWidget : public QWidget, private Ui::MPVConfigWidget |
271 |
+ public: |
272 |
+ explicit MPVConfigWidget(QWidget *parent = 0); |
273 |
+ virtual ~MPVConfigWidget(); |
274 |
++ |
275 |
++private: |
276 |
++ const QStringList getHelpResponse(); |
277 |
++ |
278 |
++private: |
279 |
++ mpv_handle *m_mpv; |
280 |
+ }; |
281 |
+ } |
282 |
+ |
283 |
+-- |
284 |
+2.29.2 |
285 |
|
286 |
diff --git a/media-video/subtitlecomposer/subtitlecomposer-0.7.0.ebuild b/media-video/subtitlecomposer/subtitlecomposer-0.7.0.ebuild |
287 |
index d5fe989dd52..6dbfebafa05 100644 |
288 |
--- a/media-video/subtitlecomposer/subtitlecomposer-0.7.0.ebuild |
289 |
+++ b/media-video/subtitlecomposer/subtitlecomposer-0.7.0.ebuild |
290 |
@@ -57,6 +57,7 @@ RDEPEND="${DEPEND}" |
291 |
PATCHES=( |
292 |
"${FILESDIR}/${P}-tests-optional.patch" |
293 |
"${FILESDIR}/${P}-valid-desktop-file.patch" # bug 745429 |
294 |
+ "${FILESDIR}/${P}-mpv-0.33.patch" # bug 760006 |
295 |
) |
296 |
|
297 |
S="${WORKDIR}/SubtitleComposer-${PV}" |