~ubuntu-branches/ubuntu/wily/smplayer/wily

« back to all changes in this revision

Viewing changes to src/corelib/mplayerprocess.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Maia Kozheva
  • Date: 2009-03-31 23:05:43 UTC
  • mfrom: (1.2.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20090331230543-0h2hfwpwlu9opbv2
* New upstream release. (Closes: #523791)
  - Reworked subtitle font preferences. (Closes: #503295)
  - No longer installs qt_fr.qm. (Closes: #486314)
* debian/control:
  - Bumped Standards-Version to 3.8.1.
  - Changed maintainer name (still the same person and GPG key).
  - Changed section to video.
  - Build-depend on zlib1g-dev for findsubtitles.
  - Require Qt >= 4.3 per readme.
  - Added ${misc:Depends}.
  - Make smplayer-translations depend on smplayer and smplayer recommend
    smplayer-translations, not the other way round. (Closes: #489375)
* debian/copyright:
  - Significantly expanded per-file with new upstream authors.
* debian/rules:
  - Make make use correct uic in install.
  - Clean svn_revision.
  - Removed get-orig-source - not needed with uscan --repack.
* debian/patches/01_gl_translation.patch:
  - Added patch to fix lrelease error on smplayer_gl.ts.
* Added debian/README.source for simple-patchsys.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  smplayer, GUI front-end for mplayer.
2
 
    Copyright (C) 2006-2008 Ricardo Villalba <rvm@escomposlinux.org>
3
 
 
4
 
    This program is free software; you can redistribute it and/or modify
5
 
    it under the terms of the GNU General Public License as published by
6
 
    the Free Software Foundation; either version 2 of the License, or
7
 
    (at your option) any later version.
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
16
 
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 
*/
18
 
 
19
 
#include "mplayerprocess.h"
20
 
#include <QRegExp>
21
 
#include <QStringList>
22
 
#include <QApplication>
23
 
 
24
 
#include "global.h"
25
 
#include "preferences.h"
26
 
#include "mplayerversion.h"
27
 
#include "helper.h"
28
 
 
29
 
using namespace Global;
30
 
 
31
 
MplayerProcess::MplayerProcess(QObject * parent) : MyProcess(parent) 
32
 
{
33
 
        connect( this, SIGNAL(lineAvailable(QByteArray)),
34
 
                         this, SLOT(parseLine(QByteArray)) );
35
 
 
36
 
        connect( this, SIGNAL(finished(int,QProcess::ExitStatus)), 
37
 
             this, SLOT(processFinished(int,QProcess::ExitStatus)) );
38
 
 
39
 
        connect( this, SIGNAL(error(QProcess::ProcessError)),
40
 
             this, SLOT(gotError(QProcess::ProcessError)) );
41
 
 
42
 
        notified_mplayer_is_running = false;
43
 
        last_sub_id = -1;
44
 
        mplayer_svn = -1; // Not found yet
45
 
 
46
 
        init_rx();
47
 
}
48
 
 
49
 
MplayerProcess::~MplayerProcess() {
50
 
}
51
 
 
52
 
bool MplayerProcess::start() {
53
 
        init_rx(); // Update configurable regular expressions
54
 
 
55
 
        md.reset();
56
 
        notified_mplayer_is_running = false;
57
 
        last_sub_id = -1;
58
 
        mplayer_svn = -1; // Not found yet
59
 
        received_end_of_file = false;
60
 
 
61
 
#if NOTIFY_AUDIO_SUB_CHANGES
62
 
        audio_tracks_changed = false;
63
 
        subtitle_tracks_changed = false;
64
 
#endif
65
 
 
66
 
        MyProcess::start();
67
 
        return waitForStarted();
68
 
}
69
 
 
70
 
void MplayerProcess::writeToStdin(QString text) {
71
 
        if (isRunning()) {
72
 
                //qDebug("MplayerProcess::writeToStdin");
73
 
                write( text.toLocal8Bit() + "\n");
74
 
        } else {
75
 
                qWarning("MplayerProcess::writeToStdin: process not running");
76
 
        }
77
 
}
78
 
 
79
 
static QRegExp rx_av("^[AV]: *([0-9,:.-]+)");
80
 
static QRegExp rx_frame("^[AV]:.* (\\d+)\\/.\\d+");// [0-9,.]+");
81
 
static QRegExp rx("^(.*)=(.*)");
82
 
static QRegExp rx_audio_mat("^ID_AID_(\\d+)_(LANG|NAME)=(.*)");
83
 
static QRegExp rx_title("^ID_DVD_TITLE_(\\d+)_(LENGTH|CHAPTERS|ANGLES)=(.*)");
84
 
static QRegExp rx_winresolution("^VO: \\[(.*)\\] (\\d+)x(\\d+) => (\\d+)x(\\d+)");
85
 
static QRegExp rx_ao("^AO: \\[(.*)\\]");
86
 
static QRegExp rx_paused("^ID_PAUSED");
87
 
static QRegExp rx_novideo("^Video: no video");
88
 
static QRegExp rx_cache("^Cache fill:.*");
89
 
static QRegExp rx_create_index("^Generating Index:.*");
90
 
static QRegExp rx_play("^Starting playback...");
91
 
static QRegExp rx_connecting("^Connecting to .*");
92
 
static QRegExp rx_resolving("^Resolving .*");
93
 
static QRegExp rx_screenshot("^\\*\\*\\* screenshot '(.*)'");
94
 
static QRegExp rx_endoffile("^Exiting... \\(End of file\\)");
95
 
static QRegExp rx_mkvchapters("\\[mkv\\] Chapter (\\d+) from");
96
 
static QRegExp rx_aspect2("^Movie-Aspect is ([0-9,.]+):1");
97
 
 
98
 
// VCD
99
 
static QRegExp rx_vcd("^ID_VCD_TRACK_(\\d+)_MSF=(.*)");
100
 
 
101
 
// Audio CD
102
 
static QRegExp rx_cdda("^ID_CDDA_TRACK_(\\d+)_MSF=(.*)");
103
 
 
104
 
 
105
 
//Subtitles
106
 
static QRegExp rx_subtitle("^ID_(SUBTITLE|FILE_SUB|VOBSUB)_ID=(\\d+)");
107
 
static QRegExp rx_sid("^ID_(SID|VSID)_(\\d+)_(LANG|NAME)=(.*)");
108
 
static QRegExp rx_subtitle_file("^ID_FILE_SUB_FILENAME=(.*)");
109
 
 
110
 
//Clip info
111
 
static QRegExp rx_clip_name("^ (name|title): (.*)", Qt::CaseInsensitive);
112
 
static QRegExp rx_clip_artist("^ artist: (.*)", Qt::CaseInsensitive);
113
 
static QRegExp rx_clip_author("^ author: (.*)", Qt::CaseInsensitive);
114
 
static QRegExp rx_clip_album("^ album: (.*)", Qt::CaseInsensitive);
115
 
static QRegExp rx_clip_genre("^ genre: (.*)", Qt::CaseInsensitive);
116
 
static QRegExp rx_clip_date("^ (creation date|year): (.*)", Qt::CaseInsensitive);
117
 
static QRegExp rx_clip_track("^ track: (.*)", Qt::CaseInsensitive);
118
 
static QRegExp rx_clip_copyright("^ copyright: (.*)", Qt::CaseInsensitive);
119
 
static QRegExp rx_clip_comment("^ comment: (.*)", Qt::CaseInsensitive);
120
 
static QRegExp rx_clip_software("^ software: (.*)", Qt::CaseInsensitive);
121
 
 
122
 
static QRegExp rx_stream_title("^.* StreamTitle='(.*)';StreamUrl='(.*)';");
123
 
 
124
 
void MplayerProcess::init_rx() {
125
 
        qDebug("MplayerProcess::init_rx");
126
 
 
127
 
        if (!pref->rx_endoffile.isEmpty()) 
128
 
                rx_endoffile.setPattern(pref->rx_endoffile);
129
 
 
130
 
        if (!pref->rx_novideo.isEmpty()) 
131
 
                rx_novideo.setPattern(pref->rx_novideo);
132
 
}
133
 
 
134
 
 
135
 
void MplayerProcess::parseLine(QByteArray ba) {
136
 
        //qDebug("MplayerProcess::parseLine: '%s'", ba.data() );
137
 
 
138
 
        QString tag;
139
 
        QString value;
140
 
 
141
 
#if COLOR_OUTPUT_SUPPORT
142
 
    QString line = Helper::stripColorsTags(QString::fromLocal8Bit(ba));
143
 
#else
144
 
        QString line = QString::fromLocal8Bit(ba);
145
 
#endif
146
 
 
147
 
        // Parse A: V: line
148
 
        //qDebug("%s", line.toUtf8().data());
149
 
    if (rx_av.indexIn(line) > -1) {
150
 
                double sec = rx_av.cap(1).toDouble();
151
 
                //qDebug("cap(1): '%s'", rx_av.cap(1).toUtf8().data() );
152
 
                //qDebug("sec: %f", sec);
153
 
                
154
 
                if (!notified_mplayer_is_running) {
155
 
                        qDebug("MplayerProcess::parseLine: starting sec: %f", sec);
156
 
                        emit receivedStartingTime(sec);
157
 
                        emit mplayerFullyLoaded();
158
 
                        notified_mplayer_is_running = true;
159
 
                }
160
 
                
161
 
            emit receivedCurrentSec( sec );
162
 
 
163
 
                // Check for frame
164
 
        if (rx_frame.indexIn(line) > -1) {
165
 
                        int frame = rx_frame.cap(1).toInt();
166
 
                        //qDebug(" frame: %d", frame);
167
 
                        emit receivedCurrentFrame(frame);
168
 
                }
169
 
        }
170
 
        else {
171
 
                // Emulates mplayer version in Ubuntu:
172
 
                //if (line.startsWith("MPlayer 1.0rc1")) line = "MPlayer 2:1.0~rc1-0ubuntu13.1 (C) 2000-2006 MPlayer Team";
173
 
 
174
 
                emit lineAvailable(line);
175
 
 
176
 
                // Parse other things
177
 
                qDebug("MplayerProcess::parseLine: '%s'", line.toUtf8().data() );
178
 
 
179
 
                // Screenshot
180
 
                if (rx_screenshot.indexIn(line) > -1) {
181
 
                        QString shot = rx_screenshot.cap(1);
182
 
                        qDebug("MplayerProcess::parseLine: screenshot: '%s'", shot.toUtf8().data());
183
 
                        emit receivedScreenshot( shot );
184
 
                }
185
 
                else
186
 
 
187
 
                // End of file
188
 
                if (rx_endoffile.indexIn(line) > -1) {
189
 
                        qDebug("MplayerProcess::parseLine: detected end of file");
190
 
 
191
 
                        // In case of playing VCDs or DVDs, maybe the first title
192
 
            // is not playable, so the GUI doesn't get the info about
193
 
            // available titles. So if we received the end of file
194
 
            // first let's pretend the file has started so the GUI can have
195
 
            // the data.
196
 
                        if ( !notified_mplayer_is_running) {
197
 
                                emit mplayerFullyLoaded();
198
 
                        }
199
 
 
200
 
                        //emit receivedEndOfFile();
201
 
                        // Send signal once the process is finished, not now!
202
 
                        received_end_of_file = true;
203
 
                }
204
 
                else
205
 
 
206
 
                // Window resolution
207
 
                if (rx_winresolution.indexIn(line) > -1) {
208
 
                        /*
209
 
                        md.win_width = rx_winresolution.cap(4).toInt();
210
 
                        md.win_height = rx_winresolution.cap(5).toInt();
211
 
                    md.video_aspect = (double) md.win_width / md.win_height;
212
 
                        */
213
 
 
214
 
                        int w = rx_winresolution.cap(4).toInt();
215
 
                        int h = rx_winresolution.cap(5).toInt();
216
 
 
217
 
                        emit receivedVO( rx_winresolution.cap(1) );
218
 
                        emit receivedWindowResolution( w, h );
219
 
                        //emit mplayerFullyLoaded();
220
 
                }
221
 
                else
222
 
 
223
 
                // No video
224
 
                if (rx_novideo.indexIn(line) > -1) {
225
 
                        md.novideo = TRUE;
226
 
                        emit receivedNoVideo();
227
 
                        //emit mplayerFullyLoaded();
228
 
                }
229
 
                else
230
 
 
231
 
                // Pause
232
 
                if (rx_paused.indexIn(line) > -1) {
233
 
                        emit receivedPause();
234
 
                }
235
 
 
236
 
                // Stream title
237
 
                if (rx_stream_title.indexIn(line) > -1) {
238
 
                        QString s = rx_stream_title.cap(1);
239
 
                        QString url = rx_stream_title.cap(2);
240
 
                        qDebug("MplayerProcess::parseLine: stream_title: '%s'", s.toUtf8().data());
241
 
                        qDebug("MplayerProcess::parseLine: stream_url: '%s'", url.toUtf8().data());
242
 
                        md.stream_title = s;
243
 
                        md.stream_url = url;
244
 
                        emit receivedStreamTitleAndUrl( s, url );
245
 
                }
246
 
 
247
 
                // The following things are not sent when the file has started to play
248
 
                // (or if sent, smplayer will ignore anyway...)
249
 
                // So not process anymore, if video is playing to save some time
250
 
                if (notified_mplayer_is_running) {
251
 
                        return;
252
 
                }
253
 
 
254
 
                if ( (mplayer_svn == -1) && (line.startsWith("MPlayer ")) ) {
255
 
                        mplayer_svn = MplayerVersion::mplayerVersion(line);
256
 
                        qDebug("MplayerProcess::parseLine: MPlayer SVN: %d", mplayer_svn);
257
 
                        if (mplayer_svn <= 0) {
258
 
                                qWarning("MplayerProcess::parseLine: couldn't parse mplayer version!");
259
 
                                emit failedToParseMplayerVersion(line);
260
 
                        }
261
 
                }
262
 
 
263
 
#if !NOTIFY_AUDIO_SUB_CHANGES
264
 
                // Subtitles
265
 
                if (rx_subtitle.indexIn(line) > -1) {
266
 
                        md.subs.process(line);
267
 
                }
268
 
                else
269
 
                if (rx_sid.indexIn(line) > -1) {
270
 
                        md.subs.process(line);
271
 
                }
272
 
                else
273
 
                if (rx_subtitle_file.indexIn(line) > -1) {
274
 
                        md.subs.process(line);
275
 
                }
276
 
#endif
277
 
 
278
 
                // AO
279
 
                if (rx_ao.indexIn(line) > -1) {
280
 
                        emit receivedAO( rx_ao.cap(1) );
281
 
                }
282
 
                else
283
 
 
284
 
                // Matroska audio
285
 
                if (rx_audio_mat.indexIn(line) > -1) {
286
 
                        int ID = rx_audio_mat.cap(1).toInt();
287
 
                        QString lang = rx_audio_mat.cap(3);
288
 
                        QString t = rx_audio_mat.cap(2);
289
 
                        qDebug("MplayerProcess::parseLine: Audio: ID: %d, Lang: '%s' Type: '%s'", 
290
 
                    ID, lang.toUtf8().data(), t.toUtf8().data());
291
 
 
292
 
                        if ( t == "NAME" ) 
293
 
                                md.audios.addName(ID, lang);
294
 
                        else
295
 
                                md.audios.addLang(ID, lang);
296
 
                }
297
 
                else
298
 
 
299
 
                // Matroshka chapters
300
 
                if (rx_mkvchapters.indexIn(line)!=-1) {
301
 
                        int c = rx_mkvchapters.cap(1).toInt();
302
 
                        qDebug("MplayerProcess::parseLine: mkv chapters: %d", c);
303
 
                        if ((c+1) > md.mkv_chapters) {
304
 
                                md.mkv_chapters = c+1;
305
 
                                qDebug("MplayerProcess::parseLine: mkv_chapters set to: %d", md.mkv_chapters);
306
 
                        }
307
 
                }
308
 
                else
309
 
 
310
 
                // VCD titles
311
 
                if (rx_vcd.indexIn(line) > -1 ) {
312
 
                        int ID = rx_vcd.cap(1).toInt();
313
 
                        QString length = rx_vcd.cap(2);
314
 
                        //md.titles.addID( ID );
315
 
                        md.titles.addName( ID, length );
316
 
                }
317
 
                else
318
 
 
319
 
                // Audio CD titles
320
 
                if (rx_cdda.indexIn(line) > -1 ) {
321
 
                        int ID = rx_cdda.cap(1).toInt();
322
 
                        QString length = rx_cdda.cap(2);
323
 
                        double duration = 0;
324
 
                        QRegExp r("(\\d+):(\\d+):(\\d+)");
325
 
                        if ( r.indexIn(length) > -1 ) {
326
 
                                duration = r.cap(1).toInt() * 60;
327
 
                                duration += r.cap(2).toInt();
328
 
                        }
329
 
                        md.titles.addID( ID );
330
 
                        /*
331
 
                        QString name = QString::number(ID) + " (" + length + ")";
332
 
                        md.titles.addName( ID, name );
333
 
                        */
334
 
                        md.titles.addDuration( ID, duration );
335
 
                }
336
 
                else
337
 
 
338
 
                // DVD titles
339
 
                if (rx_title.indexIn(line) > -1) {
340
 
                        int ID = rx_title.cap(1).toInt();
341
 
                        QString t = rx_title.cap(2);
342
 
 
343
 
                        if (t=="LENGTH") {
344
 
                                double length = rx_title.cap(3).toDouble();
345
 
                                qDebug("MplayerProcess::parseLine: Title: ID: %d, Length: '%f'", ID, length);
346
 
                                md.titles.addDuration(ID, length);
347
 
                        } 
348
 
                        else
349
 
                        if (t=="CHAPTERS") {
350
 
                                int chapters = rx_title.cap(3).toInt();
351
 
                                qDebug("MplayerProcess::parseLine: Title: ID: %d, Chapters: '%d'", ID, chapters);
352
 
                                md.titles.addChapters(ID, chapters);
353
 
                        }
354
 
                        else
355
 
                        if (t=="ANGLES") {
356
 
                                int angles = rx_title.cap(3).toInt();
357
 
                                qDebug("MplayerProcess::parseLine: Title: ID: %d, Angles: '%d'", ID, angles);
358
 
                                md.titles.addAngles(ID, angles);
359
 
                        }
360
 
                }
361
 
                else
362
 
 
363
 
                // Catch cache messages
364
 
                if (rx_cache.indexIn(line) > -1) {
365
 
                        emit receivedCacheMessage(line);
366
 
                }
367
 
                else
368
 
 
369
 
                // Creating index
370
 
                if (rx_create_index.indexIn(line) > -1) {
371
 
                        emit receivedCreatingIndex(line);
372
 
                }
373
 
                else
374
 
 
375
 
                // Catch connecting message
376
 
                if (rx_connecting.indexIn(line) > -1) {
377
 
                        emit receivedConnectingToMessage(line);
378
 
                }
379
 
                else
380
 
 
381
 
                // Catch resolving message
382
 
                if (rx_resolving.indexIn(line) > -1) {
383
 
                        emit receivedResolvingMessage(line);
384
 
                }
385
 
                else
386
 
 
387
 
                // Aspect ratio for old versions of mplayer
388
 
                if (rx_aspect2.indexIn(line) > -1) {
389
 
                        md.video_aspect = rx_aspect2.cap(1).toDouble();
390
 
                        qDebug("MplayerProcess::parseLine: md.video_aspect set to %f", md.video_aspect);
391
 
                }
392
 
                else
393
 
 
394
 
                // Clip info
395
 
 
396
 
                //QString::trimmed() is used for removing leading and trailing whitespaces
397
 
                //Some .mp3 files contain tags with starting and ending whitespaces
398
 
                //Unfortunately MPlayer gives us leading and trailing whitespaces, Winamp for example doesn't show them
399
 
 
400
 
                // Name
401
 
                if (rx_clip_name.indexIn(line) > -1) {
402
 
                        QString s = rx_clip_name.cap(2).trimmed();
403
 
                        qDebug("MplayerProcess::parseLine: clip_name: '%s'", s.toUtf8().data());
404
 
                        md.clip_name = s;
405
 
                }
406
 
                else
407
 
 
408
 
                // Artist
409
 
                if (rx_clip_artist.indexIn(line) > -1) {
410
 
                        QString s = rx_clip_artist.cap(1).trimmed();
411
 
                        qDebug("MplayerProcess::parseLine: clip_artist: '%s'", s.toUtf8().data());
412
 
                        md.clip_artist = s;
413
 
                }
414
 
                else
415
 
 
416
 
                // Author
417
 
                if (rx_clip_author.indexIn(line) > -1) {
418
 
                        QString s = rx_clip_author.cap(1).trimmed();
419
 
                        qDebug("MplayerProcess::parseLine: clip_author: '%s'", s.toUtf8().data());
420
 
                        md.clip_author = s;
421
 
                }
422
 
                else
423
 
 
424
 
                // Album
425
 
                if (rx_clip_album.indexIn(line) > -1) {
426
 
                        QString s = rx_clip_album.cap(1).trimmed();
427
 
                        qDebug("MplayerProcess::parseLine: clip_album: '%s'", s.toUtf8().data());
428
 
                        md.clip_album = s;
429
 
                }
430
 
                else
431
 
 
432
 
                // Genre
433
 
                if (rx_clip_genre.indexIn(line) > -1) {
434
 
                        QString s = rx_clip_genre.cap(1).trimmed();
435
 
                        qDebug("MplayerProcess::parseLine: clip_genre: '%s'", s.toUtf8().data());
436
 
                        md.clip_genre = s;
437
 
                }
438
 
                else
439
 
 
440
 
                // Date
441
 
                if (rx_clip_date.indexIn(line) > -1) {
442
 
                        QString s = rx_clip_date.cap(2).trimmed();
443
 
                        qDebug("MplayerProcess::parseLine: clip_date: '%s'", s.toUtf8().data());
444
 
                        md.clip_date = s;
445
 
                }
446
 
                else
447
 
 
448
 
                // Track
449
 
                if (rx_clip_track.indexIn(line) > -1) {
450
 
                        QString s = rx_clip_track.cap(1).trimmed();
451
 
                        qDebug("MplayerProcess::parseLine: clip_track: '%s'", s.toUtf8().data());
452
 
                        md.clip_track = s;
453
 
                }
454
 
                else
455
 
 
456
 
                // Copyright
457
 
                if (rx_clip_copyright.indexIn(line) > -1) {
458
 
                        QString s = rx_clip_copyright.cap(1).trimmed();
459
 
                        qDebug("MplayerProcess::parseLine: clip_copyright: '%s'", s.toUtf8().data());
460
 
                        md.clip_copyright = s;
461
 
                }
462
 
                else
463
 
 
464
 
                // Comment
465
 
                if (rx_clip_comment.indexIn(line) > -1) {
466
 
                        QString s = rx_clip_comment.cap(1).trimmed();
467
 
                        qDebug("MplayerProcess::parseLine: clip_comment: '%s'", s.toUtf8().data());
468
 
                        md.clip_comment = s;
469
 
                }
470
 
                else
471
 
 
472
 
                // Software
473
 
                if (rx_clip_software.indexIn(line) > -1) {
474
 
                        QString s = rx_clip_software.cap(1).trimmed();
475
 
                        qDebug("MplayerProcess::parseLine: clip_software: '%s'", s.toUtf8().data());
476
 
                        md.clip_software = s;
477
 
                }
478
 
                else
479
 
 
480
 
                // Catch starting message
481
 
                /*
482
 
                pos = rx_play.indexIn(line);
483
 
                if (pos > -1) {
484
 
                        emit mplayerFullyLoaded();
485
 
                }
486
 
                */
487
 
 
488
 
                //Generic things
489
 
                if (rx.indexIn(line) > -1) {
490
 
                        tag = rx.cap(1);
491
 
                        value = rx.cap(2);
492
 
                        //qDebug("MplayerProcess::parseLine: tag: %s, value: %s", tag.toUtf8().data(), value.toUtf8().data());
493
 
 
494
 
#if !NOTIFY_AUDIO_SUB_CHANGES
495
 
                        // Generic audio
496
 
                        if (tag == "ID_AUDIO_ID") {
497
 
                                int ID = value.toInt();
498
 
                                qDebug("MplayerProcess::parseLine: ID_AUDIO_ID: %d", ID);
499
 
                                md.audios.addID( ID );
500
 
                        }
501
 
                        else
502
 
#endif
503
 
                        if (tag == "ID_LENGTH") {
504
 
                                md.duration = value.toDouble();
505
 
                                qDebug("MplayerProcess::parseLine: md.duration set to %f", md.duration);
506
 
                        }
507
 
                        else
508
 
                        if (tag == "ID_VIDEO_WIDTH") {
509
 
                                md.video_width = value.toInt();
510
 
                                qDebug("MplayerProcess::parseLine: md.video_width set to %d", md.video_width);
511
 
                        }
512
 
                        else
513
 
                        if (tag == "ID_VIDEO_HEIGHT") {
514
 
                                md.video_height = value.toInt();
515
 
                                qDebug("MplayerProcess::parseLine: md.video_height set to %d", md.video_height);
516
 
                        }
517
 
                        else
518
 
                        if (tag == "ID_VIDEO_ASPECT") {
519
 
                                md.video_aspect = value.toDouble();
520
 
                                if ( md.video_aspect == 0.0 ) {
521
 
                                        // I hope width & height are already set.
522
 
                                        md.video_aspect = (double) md.video_width / md.video_height;
523
 
                                }
524
 
                                qDebug("MplayerProcess::parseLine: md.video_aspect set to %f", md.video_aspect);
525
 
                        }
526
 
                        else
527
 
                        if (tag == "ID_DVD_DISC_ID") {
528
 
                                md.dvd_id = value;
529
 
                                qDebug("MplayerProcess::parseLine: md.dvd_id set to '%s'", md.dvd_id.toUtf8().data());
530
 
                        }
531
 
                        else
532
 
                        if (tag == "ID_DEMUXER") {
533
 
                                md.demuxer = value;
534
 
                        }
535
 
                        else
536
 
                        if (tag == "ID_VIDEO_FORMAT") {
537
 
                                md.video_format = value;
538
 
                        }
539
 
                        else
540
 
                        if (tag == "ID_AUDIO_FORMAT") {
541
 
                                md.audio_format = value;
542
 
                        }
543
 
                        else
544
 
                        if (tag == "ID_VIDEO_BITRATE") {
545
 
                                md.video_bitrate = value.toInt();
546
 
                        }
547
 
                        else
548
 
                        if (tag == "ID_VIDEO_FPS") {
549
 
                                md.video_fps = value;
550
 
                        }
551
 
                        else
552
 
                        if (tag == "ID_AUDIO_BITRATE") {
553
 
                                md.audio_bitrate = value.toInt();
554
 
                        }
555
 
                        else
556
 
                        if (tag == "ID_AUDIO_RATE") {
557
 
                                md.audio_rate = value.toInt();
558
 
                        }
559
 
                        else
560
 
                        if (tag == "ID_AUDIO_NCH") {
561
 
                                md.audio_nch = value.toInt();
562
 
                        }
563
 
                        else
564
 
                        if (tag == "ID_VIDEO_CODEC") {
565
 
                                md.video_codec = value;
566
 
                        }
567
 
                        else
568
 
                        if (tag == "ID_AUDIO_CODEC") {
569
 
                                md.audio_codec = value;
570
 
                        }
571
 
                }
572
 
        }
573
 
}
574
 
 
575
 
// Called when the process is finished
576
 
void MplayerProcess::processFinished(int exitCode, QProcess::ExitStatus exitStatus) {
577
 
        qDebug("MplayerProcess::processFinished: exitCode: %d, status: %d", exitCode, (int) exitStatus);
578
 
        // Send this signal before the endoffile one, otherwise
579
 
        // the playlist will start to play next file before all
580
 
        // objects are notified that the process has exited.
581
 
        emit processExited();
582
 
        if (received_end_of_file) emit receivedEndOfFile();
583
 
}
584
 
 
585
 
void MplayerProcess::gotError(QProcess::ProcessError error) {
586
 
        qDebug("MplayerProcess::gotError: %d", (int) error);
587
 
}
588
 
 
589
 
#include "moc_mplayerprocess.cpp"