author | unc0rr |
Sun, 02 Dec 2018 00:19:17 +0100 | |
changeset 14359 | 5e28098fb593 |
parent 13286 | 1fbf2ac1f13e |
child 14630 | 957db6db1a49 |
permissions | -rw-r--r-- |
7897 | 1 |
/* |
2 |
* Hedgewars, a free turn based strategy game |
|
11046 | 3 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
7897 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
9998
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
7897 | 17 |
*/ |
18 |
||
19 |
#include "LibavInteraction.h" |
|
20 |
||
11852 | 21 |
#ifdef VIDEOREC |
7897 | 22 |
extern "C" |
23 |
{ |
|
11298
9fcdf0969d53
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
24 |
#include "libavcodec/avcodec.h" |
7897 | 25 |
#include "libavformat/avformat.h" |
11298
9fcdf0969d53
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
26 |
#include "libavutil/avutil.h" |
7897 | 27 |
} |
28 |
||
29 |
#include <QVector> |
|
30 |
#include <QList> |
|
31 |
#include <QComboBox> |
|
32 |
||
33 |
#include "HWApplication.h" |
|
34 |
||
11298
9fcdf0969d53
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
35 |
// compatibility section |
11356
ac423fd2b9a3
libavinteraction: Adjust version guard for av_codec_is_encoder()
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11299
diff
changeset
|
36 |
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 8, 0) |
ac423fd2b9a3
libavinteraction: Adjust version guard for av_codec_is_encoder()
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11299
diff
changeset
|
37 |
#define av_codec_is_encoder(x) x->encode |
ac423fd2b9a3
libavinteraction: Adjust version guard for av_codec_is_encoder()
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11299
diff
changeset
|
38 |
#endif |
ac423fd2b9a3
libavinteraction: Adjust version guard for av_codec_is_encoder()
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11299
diff
changeset
|
39 |
|
11298
9fcdf0969d53
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
40 |
#if LIBAVCODEC_VERSION_MAJOR < 55 |
9fcdf0969d53
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
41 |
#define AVCodecID CodecID |
9fcdf0969d53
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
42 |
#endif |
9fcdf0969d53
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
43 |
|
9fcdf0969d53
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
44 |
#if LIBAVFORMAT_VERSION_MAJOR < 54 |
9fcdf0969d53
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
45 |
#define avformat_find_stream_info(x, y) av_find_stream_info(x) |
9fcdf0969d53
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
46 |
#define avformat_close_input(x) av_close_input_file(*(x)) |
9fcdf0969d53
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
47 |
#endif |
9fcdf0969d53
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
48 |
|
9fcdf0969d53
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
49 |
#if LIBAVUTIL_VERSION_MAJOR < 54 |
9fcdf0969d53
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
50 |
#define AVPixelFormat PixelFormat |
9fcdf0969d53
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
51 |
#define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P |
9429
7a97a554ac80
libavinteraction: fix typo and and compiling with modern libav
koda
parents:
9107
diff
changeset
|
52 |
#endif |
7a97a554ac80
libavinteraction: fix typo and and compiling with modern libav
koda
parents:
9107
diff
changeset
|
53 |
|
7897 | 54 |
struct Codec |
55 |
{ |
|
11298
9fcdf0969d53
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
56 |
AVCodecID id; |
7897 | 57 |
bool isAudio; |
58 |
QString shortName; // used for identification |
|
59 |
QString longName; // used for displaying to user |
|
60 |
bool isRecomended; |
|
61 |
}; |
|
62 |
||
63 |
struct Format |
|
64 |
{ |
|
65 |
QString shortName; |
|
66 |
QString longName; |
|
67 |
bool isRecomended; |
|
68 |
QString extension; |
|
69 |
QVector<Codec*> codecs; |
|
70 |
}; |
|
71 |
||
72 |
QList<Codec> codecs; |
|
73 |
QMap<QString,Format> formats; |
|
74 |
||
75 |
// test if given format supports given codec |
|
11298
9fcdf0969d53
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
76 |
bool FormatQueryCodec(AVOutputFormat *ofmt, enum AVCodecID codec_id) |
7897 | 77 |
{ |
78 |
#if LIBAVFORMAT_VERSION_MAJOR >= 54 |
|
79 |
return avformat_query_codec(ofmt, codec_id, FF_COMPLIANCE_NORMAL) == 1; |
|
80 |
#else |
|
81 |
if (ofmt->codec_tag) |
|
82 |
return !!av_codec_get_tag(ofmt->codec_tag, codec_id); |
|
83 |
return codec_id == ofmt->video_codec || codec_id == ofmt->audio_codec; |
|
84 |
#endif |
|
85 |
} |
|
86 |
||
87 |
LibavInteraction::LibavInteraction() : QObject() |
|
88 |
{ |
|
89 |
// initialize libav and register all codecs and formats |
|
90 |
av_register_all(); |
|
91 |
||
92 |
// get list of all codecs |
|
93 |
AVCodec* pCodec = NULL; |
|
8065 | 94 |
while ((pCodec = av_codec_next(pCodec))) |
7897 | 95 |
{ |
96 |
if (!av_codec_is_encoder(pCodec)) |
|
97 |
continue; |
|
98 |
||
99 |
if (pCodec->type != AVMEDIA_TYPE_VIDEO && pCodec->type != AVMEDIA_TYPE_AUDIO) |
|
100 |
continue; |
|
101 |
||
102 |
// this encoders seems to be buggy |
|
103 |
if (strcmp(pCodec->name, "rv10") == 0 || strcmp(pCodec->name, "rv20") == 0) |
|
104 |
continue; |
|
105 |
||
106 |
// doesn't support stereo sound |
|
107 |
if (strcmp(pCodec->name, "real_144") == 0) |
|
108 |
continue; |
|
109 |
||
110 |
if (!pCodec->long_name || strlen(pCodec->long_name) == 0) |
|
111 |
continue; |
|
112 |
||
113 |
if (pCodec->type == AVMEDIA_TYPE_VIDEO) |
|
114 |
{ |
|
115 |
if (pCodec->supported_framerates != NULL) |
|
116 |
continue; |
|
117 |
||
118 |
// check if codec supports yuv 4:2:0 format |
|
119 |
if (!pCodec->pix_fmts) |
|
120 |
continue; |
|
121 |
bool yuv420Supported = false; |
|
11299
64ad779be7bf
Specify the enum type for Pixel and Sample formats
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11298
diff
changeset
|
122 |
for (const enum AVPixelFormat* pfmt = pCodec->pix_fmts; *pfmt != -1; pfmt++) |
11298
9fcdf0969d53
Update libav API, keeping forward and backward compatibility
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11046
diff
changeset
|
123 |
if (*pfmt == AV_PIX_FMT_YUV420P) |
7897 | 124 |
{ |
125 |
yuv420Supported = true; |
|
126 |
break; |
|
127 |
} |
|
128 |
if (!yuv420Supported) |
|
129 |
continue; |
|
130 |
} |
|
131 |
if (pCodec->type == AVMEDIA_TYPE_AUDIO) |
|
132 |
{ |
|
133 |
// check if codec supports signed 16-bit format |
|
134 |
if (!pCodec->sample_fmts) |
|
135 |
continue; |
|
136 |
bool s16Supported = false; |
|
11299
64ad779be7bf
Specify the enum type for Pixel and Sample formats
Vittorio Giovara <vittorio.giovara@gmail.com>
parents:
11298
diff
changeset
|
137 |
for (const enum AVSampleFormat* pfmt = pCodec->sample_fmts; *pfmt != -1; pfmt++) |
7897 | 138 |
if (*pfmt == AV_SAMPLE_FMT_S16) |
139 |
{ |
|
140 |
s16Supported = true; |
|
141 |
break; |
|
142 |
} |
|
143 |
if (!s16Supported) |
|
144 |
continue; |
|
145 |
} |
|
146 |
// add codec to list of codecs |
|
147 |
codecs.push_back(Codec()); |
|
148 |
Codec & codec = codecs.back(); |
|
149 |
codec.id = pCodec->id; |
|
150 |
codec.isAudio = pCodec->type == AVMEDIA_TYPE_AUDIO; |
|
151 |
codec.shortName = pCodec->name; |
|
152 |
codec.longName = pCodec->long_name; |
|
153 |
||
154 |
codec.isRecomended = false; |
|
155 |
if (strcmp(pCodec->name, "libx264") == 0) |
|
156 |
{ |
|
157 |
codec.longName = "H.264/MPEG-4 Part 10 AVC (x264)"; |
|
158 |
codec.isRecomended = true; |
|
159 |
} |
|
160 |
else if (strcmp(pCodec->name, "libxvid") == 0) |
|
161 |
{ |
|
162 |
codec.longName = "MPEG-4 Part 2 (Xvid)"; |
|
163 |
codec.isRecomended = true; |
|
164 |
} |
|
165 |
else if (strcmp(pCodec->name, "libmp3lame") == 0) |
|
166 |
{ |
|
167 |
codec.longName = "MP3 (MPEG audio layer 3) (LAME)"; |
|
168 |
codec.isRecomended = true; |
|
169 |
} |
|
170 |
else |
|
171 |
codec.longName = pCodec->long_name; |
|
172 |
||
173 |
if (strcmp(pCodec->name, "mpeg4") == 0 || strcmp(pCodec->name, "ac3_fixed") == 0) |
|
174 |
codec.isRecomended = true; |
|
175 |
||
176 |
// FIXME: remove next line |
|
177 |
//codec.longName += QString(" (%1)").arg(codec.shortName); |
|
178 |
} |
|
179 |
||
180 |
// get list of all formats |
|
181 |
AVOutputFormat* pFormat = NULL; |
|
8065 | 182 |
while ((pFormat = av_oformat_next(pFormat))) |
7897 | 183 |
{ |
184 |
if (!pFormat->extensions) |
|
185 |
continue; |
|
186 |
||
187 |
// skip some strange formats to not confuse users |
|
188 |
if (strstr(pFormat->long_name, "raw")) |
|
189 |
continue; |
|
190 |
||
191 |
Format format; |
|
192 |
bool hasVideoCodec = false; |
|
193 |
for (QList<Codec>::iterator codec = codecs.begin(); codec != codecs.end(); ++codec) |
|
194 |
{ |
|
195 |
if (!FormatQueryCodec(pFormat, codec->id)) |
|
196 |
continue; |
|
197 |
format.codecs.push_back(&*codec); |
|
198 |
if (!codec->isAudio) |
|
199 |
hasVideoCodec = true; |
|
200 |
} |
|
201 |
if (!hasVideoCodec) |
|
202 |
continue; |
|
203 |
||
204 |
QString ext(pFormat->extensions); |
|
205 |
ext.truncate(strcspn(pFormat->extensions, ",")); |
|
206 |
format.extension = ext; |
|
207 |
format.shortName = pFormat->name; |
|
208 |
format.longName = QString("%1 (*.%2)").arg(pFormat->long_name).arg(ext); |
|
209 |
||
210 |
// FIXME: remove next line |
|
211 |
//format.longName += QString(" (%1)").arg(format.shortName); |
|
212 |
||
213 |
format.isRecomended = strcmp(pFormat->name, "mp4") == 0 || strcmp(pFormat->name, "avi") == 0; |
|
214 |
||
215 |
formats[pFormat->name] = format; |
|
216 |
} |
|
217 |
} |
|
218 |
||
219 |
void LibavInteraction::fillFormats(QComboBox * pFormats) |
|
220 |
{ |
|
221 |
// first insert recomended formats |
|
222 |
foreach(const Format & format, formats) |
|
223 |
if (format.isRecomended) |
|
224 |
pFormats->addItem(format.longName, format.shortName); |
|
225 |
||
226 |
// remember where to place separator between recomended and other formats |
|
227 |
int sep = pFormats->count(); |
|
228 |
||
229 |
// insert remaining formats |
|
230 |
foreach(const Format & format, formats) |
|
231 |
if (!format.isRecomended) |
|
232 |
pFormats->addItem(format.longName, format.shortName); |
|
233 |
||
234 |
// insert separator if necessary |
|
235 |
if (sep != 0 && sep != pFormats->count()) |
|
236 |
pFormats->insertSeparator(sep); |
|
237 |
} |
|
238 |
||
239 |
void LibavInteraction::fillCodecs(const QString & fmt, QComboBox * pVCodecs, QComboBox * pACodecs) |
|
240 |
{ |
|
241 |
Format & format = formats[fmt]; |
|
242 |
||
243 |
// first insert recomended codecs |
|
244 |
foreach(Codec * codec, format.codecs) |
|
245 |
{ |
|
246 |
if (codec->isRecomended) |
|
247 |
{ |
|
248 |
if (codec->isAudio) |
|
249 |
pACodecs->addItem(codec->longName, codec->shortName); |
|
250 |
else |
|
251 |
pVCodecs->addItem(codec->longName, codec->shortName); |
|
252 |
} |
|
253 |
} |
|
254 |
||
255 |
// remember where to place separators between recomended and other codecs |
|
256 |
int vsep = pVCodecs->count(); |
|
257 |
int asep = pACodecs->count(); |
|
258 |
||
259 |
// insert remaining codecs |
|
260 |
foreach(Codec * codec, format.codecs) |
|
261 |
{ |
|
262 |
if (!codec->isRecomended) |
|
263 |
{ |
|
264 |
if (codec->isAudio) |
|
265 |
pACodecs->addItem(codec->longName, codec->shortName); |
|
266 |
else |
|
267 |
pVCodecs->addItem(codec->longName, codec->shortName); |
|
268 |
} |
|
269 |
} |
|
270 |
||
271 |
// insert separators if necessary |
|
272 |
if (vsep != 0 && vsep != pVCodecs->count()) |
|
273 |
pVCodecs->insertSeparator(vsep); |
|
274 |
if (asep != 0 && asep != pACodecs->count()) |
|
275 |
pACodecs->insertSeparator(asep); |
|
276 |
} |
|
277 |
||
278 |
QString LibavInteraction::getExtension(const QString & format) |
|
279 |
{ |
|
280 |
return formats[format].extension; |
|
281 |
} |
|
282 |
||
283 |
// get information abaout file (duration, resolution etc) in multiline string |
|
284 |
QString LibavInteraction::getFileInfo(const QString & filepath) |
|
285 |
{ |
|
286 |
AVFormatContext* pContext = NULL; |
|
287 |
QByteArray utf8path = filepath.toUtf8(); |
|
288 |
if (avformat_open_input(&pContext, utf8path.data(), NULL, NULL) < 0) |
|
289 |
return ""; |
|
290 |
if (avformat_find_stream_info(pContext, NULL) < 0) |
|
291 |
return ""; |
|
292 |
||
293 |
int s = float(pContext->duration)/AV_TIME_BASE; |
|
12239
8db93a3a29dc
Use standard units and abbreviations in frontend
Wuzzy <almikes@aol.com>
parents:
11852
diff
changeset
|
294 |
//: Duration in minutes and seconds (SI units) |
8db93a3a29dc
Use standard units and abbreviations in frontend
Wuzzy <almikes@aol.com>
parents:
11852
diff
changeset
|
295 |
QString desc = tr("Duration: %1min %2s").arg(s/60).arg(s%60) + "\n"; |
7897 | 296 |
for (int i = 0; i < (int)pContext->nb_streams; i++) |
297 |
{ |
|
298 |
AVStream* pStream = pContext->streams[i]; |
|
299 |
if (!pStream) |
|
300 |
continue; |
|
301 |
AVCodecContext* pCodec = pContext->streams[i]->codec; |
|
302 |
if (!pCodec) |
|
303 |
continue; |
|
304 |
||
13286
1fbf2ac1f13e
Videos frontend page: Locale-aware text formatting
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
305 |
|
1fbf2ac1f13e
Videos frontend page: Locale-aware text formatting
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
306 |
AVCodec* pDecoder = avcodec_find_decoder(pCodec->codec_id); |
1fbf2ac1f13e
Videos frontend page: Locale-aware text formatting
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
307 |
QString decoderName = pDecoder ? pDecoder->name : tr("unknown"); |
7897 | 308 |
if (pCodec->codec_type == AVMEDIA_TYPE_VIDEO) |
309 |
{ |
|
310 |
if (pStream->avg_frame_rate.den) |
|
311 |
{ |
|
312 |
float fps = float(pStream->avg_frame_rate.num)/pStream->avg_frame_rate.den; |
|
13286
1fbf2ac1f13e
Videos frontend page: Locale-aware text formatting
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
313 |
//: Video metadata. %1 = video width, %2 = video height, %3 = frames per second = %4 = decoder name |
1fbf2ac1f13e
Videos frontend page: Locale-aware text formatting
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
314 |
desc += QString(tr("Video: %1x%2, %3 FPS, %4")).arg(pCodec->width).arg(pCodec->height).arg(QLocale().toString(fps, 'f', 2)).arg(decoderName); |
1fbf2ac1f13e
Videos frontend page: Locale-aware text formatting
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
315 |
} |
1fbf2ac1f13e
Videos frontend page: Locale-aware text formatting
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
316 |
else |
1fbf2ac1f13e
Videos frontend page: Locale-aware text formatting
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
317 |
{ |
1fbf2ac1f13e
Videos frontend page: Locale-aware text formatting
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
318 |
//: Video metadata. %1 = video width, %2 = video height, %3 = decoder name |
1fbf2ac1f13e
Videos frontend page: Locale-aware text formatting
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
319 |
desc += QString(tr("Video: %1x%2, %3")).arg(pCodec->width).arg(pCodec->height).arg(decoderName); |
7897 | 320 |
} |
321 |
} |
|
322 |
else if (pCodec->codec_type == AVMEDIA_TYPE_AUDIO) |
|
13286
1fbf2ac1f13e
Videos frontend page: Locale-aware text formatting
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
323 |
{ |
7897 | 324 |
desc += tr("Audio: "); |
13286
1fbf2ac1f13e
Videos frontend page: Locale-aware text formatting
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
325 |
desc += decoderName; |
1fbf2ac1f13e
Videos frontend page: Locale-aware text formatting
Wuzzy <Wuzzy2@mail.ru>
parents:
13226
diff
changeset
|
326 |
} |
7897 | 327 |
else |
328 |
continue; |
|
329 |
desc += "\n"; |
|
330 |
} |
|
331 |
AVDictionaryEntry* pComment = av_dict_get(pContext->metadata, "comment", NULL, 0); |
|
332 |
if (pComment) |
|
13226
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
333 |
{ |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
334 |
// Video comment. We expect a simple key value storage in a particular format |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
335 |
// and parse it here so the key names can be localized. |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
336 |
desc += QString("\n"); |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
337 |
QStringList strings = QString(pComment->value).split('\n'); |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
338 |
QString sPlayer, sTheme, sMap, sRecord; |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
339 |
for(int i=0; i < strings.count(); i++) |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
340 |
{ |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
341 |
QString s = strings.at(i); |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
342 |
// Original key names are in English, like: |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
343 |
// Key: Value |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
344 |
if (s.startsWith("Player: ")) |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
345 |
sPlayer = QString(s.mid(8)); |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
346 |
else if (s.startsWith("Theme: ")) |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
347 |
sTheme = QString(s.mid(7)); |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
348 |
else if (s.startsWith("Map: ")) |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
349 |
sMap = QString(s.mid(5)); |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
350 |
else if (s.startsWith("Record: ")) |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
351 |
sRecord = QString(s.mid(8)); |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
352 |
} |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
353 |
if(!sPlayer.isNull()) |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
354 |
desc += QString(tr("Player: %1")).arg(sPlayer) + "\n"; |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
355 |
if(!sTheme.isNull()) |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
356 |
desc += QString(tr("Theme: %1")).arg(sTheme) + "\n"; |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
357 |
if(!sMap.isNull()) |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
358 |
desc += QString(tr("Map: %1")).arg(sMap) + "\n"; |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
359 |
if(!sRecord.isNull()) |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
360 |
//: As in ‘recording’ |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
361 |
desc += QString(tr("Record: %1")).arg(sRecord); |
4028d7f85233
Make video metadata strings translatable in frontend
Wuzzy <Wuzzy2@mail.ru>
parents:
12239
diff
changeset
|
362 |
} |
7897 | 363 |
avformat_close_input(&pContext); |
364 |
return desc; |
|
365 |
} |
|
366 |
||
367 |
#else |
|
368 |
LibavInteraction::LibavInteraction() : QObject() |
|
369 |
{ |
|
370 |
||
371 |
} |
|
372 |
||
373 |
void LibavInteraction::fillFormats(QComboBox * pFormats) |
|
374 |
{ |
|
375 |
Q_UNUSED(pFormats); |
|
376 |
} |
|
377 |
||
378 |
void LibavInteraction::fillCodecs(const QString & format, QComboBox * pVCodecs, QComboBox * pACodecs) |
|
379 |
{ |
|
380 |
Q_UNUSED(format); |
|
381 |
Q_UNUSED(pVCodecs); |
|
382 |
Q_UNUSED(pACodecs); |
|
383 |
} |
|
384 |
||
385 |
QString LibavInteraction::getExtension(const QString & format) |
|
386 |
{ |
|
387 |
Q_UNUSED(format); |
|
388 |
||
389 |
return QString(); |
|
390 |
} |
|
391 |
||
392 |
QString LibavInteraction::getFileInfo(const QString & filepath) |
|
393 |
{ |
|
394 |
Q_UNUSED(filepath); |
|
395 |
||
396 |
return QString(); |
|
397 |
} |
|
398 |
#endif |
|
399 |
||
400 |
LibavInteraction & LibavInteraction::instance() |
|
401 |
{ |
|
402 |
static LibavInteraction instance; |
|
403 |
return instance; |
|
404 |
} |