~ubuntu-branches/ubuntu/oneiric/smplayer/oneiric

« back to all changes in this revision

Viewing changes to src/mplayerprocess.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Breuil Cyril
  • Date: 2007-06-24 16:35:29 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070624163529-hhckbmd24uicada7
Tags: 0.5.20-0ubuntu1
* New upstream release
* Change Maintainer Email

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include <qregexp.h>
21
21
#include <qstringlist.h>
22
22
#include <qapplication.h>
 
23
#include "global.h"
 
24
#include "preferences.h"
23
25
#include "config.h"
24
26
 
25
27
#if DONT_USE_SIGNALS
58
60
}
59
61
 
60
62
bool MplayerProcess::start( QStringList * env ) {
 
63
        init_rx(); // Update configurable regular expressions
 
64
 
61
65
        md.reset();
62
66
        notified_mplayer_is_running = FALSE;
63
67
        incomplete_line = "";
139
143
        //qDebug("incomplete_line: '%s'", incomplete_line.utf8().data());
140
144
}
141
145
 
142
 
QRegExp rx_av("^[AV]: *([0-9,:.-]+)");
143
 
QRegExp rx_frame("^[AV]:.* (\\d+)\\/.\\d+");// [0-9,.]+");
144
 
QRegExp rx("^(.*)=(.*)");
145
 
QRegExp rx_audio_mat("^ID_AID_(\\d+)_(LANG|NAME)=(.*)");
146
 
QRegExp rx_title("^ID_DVD_TITLE_(\\d+)_(LENGTH|CHAPTERS|ANGLES)=(.*)");
147
 
QRegExp rx_winresolution("^VO: \\[(.*)\\] (\\d+)x(\\d+) => (\\d+)x(\\d+)");
148
 
QRegExp rx_ao("^AO: \\[(.*)\\]");
149
 
QRegExp rx_paused("^ID_PAUSED");
150
 
QRegExp rx_novideo("^Video: no video");
151
 
QRegExp rx_cache("^Cache fill:.*");
152
 
QRegExp rx_create_index("^Generating Index:.*");
153
 
QRegExp rx_play("^Starting playback...");
154
 
QRegExp rx_connecting("^Connecting to .*");
155
 
QRegExp rx_resolving("^Resolving .*");
156
 
QRegExp rx_screenshot("^\\*\\*\\* screenshot '(.*)'");
157
 
QRegExp rx_endoffile("^Exiting... \\(End of file\\)");
158
 
QRegExp rx_mkvchapters("\\[mkv\\] Chapter (\\d+) from");
159
 
QRegExp rx_aspect2("^Movie-Aspect is ([0-9,.]+):1");
160
 
 
 
146
static QRegExp rx_av("^[AV]: *([0-9,:.-]+)");
 
147
static QRegExp rx_frame("^[AV]:.* (\\d+)\\/.\\d+");// [0-9,.]+");
 
148
static QRegExp rx("^(.*)=(.*)");
 
149
static QRegExp rx_audio_mat("^ID_AID_(\\d+)_(LANG|NAME)=(.*)");
 
150
static QRegExp rx_title("^ID_DVD_TITLE_(\\d+)_(LENGTH|CHAPTERS|ANGLES)=(.*)");
 
151
static QRegExp rx_winresolution("^VO: \\[(.*)\\] (\\d+)x(\\d+) => (\\d+)x(\\d+)");
 
152
static QRegExp rx_ao("^AO: \\[(.*)\\]");
 
153
static QRegExp rx_paused("^ID_PAUSED");
 
154
static QRegExp rx_novideo("^Video: no video");
 
155
static QRegExp rx_cache("^Cache fill:.*");
 
156
static QRegExp rx_create_index("^Generating Index:.*");
 
157
static QRegExp rx_play("^Starting playback...");
 
158
static QRegExp rx_connecting("^Connecting to .*");
 
159
static QRegExp rx_resolving("^Resolving .*");
 
160
static QRegExp rx_screenshot("^\\*\\*\\* screenshot '(.*)'");
 
161
static QRegExp rx_endoffile("^Exiting... \\(End of file\\)");
 
162
static QRegExp rx_mkvchapters("\\[mkv\\] Chapter (\\d+) from");
 
163
static QRegExp rx_aspect2("^Movie-Aspect is ([0-9,.]+):1");
 
164
 
161
165
// VCD
162
 
QRegExp rx_vcd("^ID_VCD_TRACK_(\\d+)_MSF=(.*)");
 
166
static QRegExp rx_vcd("^ID_VCD_TRACK_(\\d+)_MSF=(.*)");
 
167
 
 
168
// Audio CD
 
169
static QRegExp rx_cdda("^ID_CDDA_TRACK_(\\d+)_MSF=(.*)");
163
170
 
164
171
 
165
172
//Subtitles
166
173
#if SUBTITLES_BY_INDEX
167
 
QRegExp rx_subtitle("^ID_(SUBTITLE|FILE_SUB|VOBSUB)_ID=(\\d+)");
168
 
QRegExp rx_sid("^ID_(SID|VSID)_(\\d+)_(LANG|NAME)=(.*)");
169
 
QRegExp rx_subtitle_file("^ID_FILE_SUB_FILENAME=(.*)");
 
174
static QRegExp rx_subtitle("^ID_(SUBTITLE|FILE_SUB|VOBSUB)_ID=(\\d+)");
 
175
static QRegExp rx_sid("^ID_(SID|VSID)_(\\d+)_(LANG|NAME)=(.*)");
 
176
static QRegExp rx_subtitle_file("^ID_FILE_SUB_FILENAME=(.*)");
170
177
#else
171
 
QRegExp rx_subs("^ID_SID_(\\d+)_(LANG|NAME)=(.*)");
 
178
static QRegExp rx_subs("^ID_SID_(\\d+)_(LANG|NAME)=(.*)");
172
179
#endif
173
180
 
174
181
//Clip info
175
 
QRegExp rx_clip_name("^ (name|title): (.*)");
176
 
QRegExp rx_clip_artist("^ artist: (.*)");
177
 
QRegExp rx_clip_author("^ author: (.*)");
178
 
QRegExp rx_clip_album("^ album: (.*)");
179
 
QRegExp rx_clip_genre("^ genre: (.*)");
180
 
QRegExp rx_clip_date("^ (creation date|year): (.*)");
181
 
QRegExp rx_clip_track("^ track: (.*)");
182
 
QRegExp rx_clip_copyright("^ copyright: (.*)");
183
 
QRegExp rx_clip_comment("^ comment: (.*)");
184
 
QRegExp rx_clip_software("^ software: (.*)");
 
182
static QRegExp rx_clip_name("^ (name|title): (.*)", false);
 
183
static QRegExp rx_clip_artist("^ artist: (.*)", false);
 
184
static QRegExp rx_clip_author("^ author: (.*)", false);
 
185
static QRegExp rx_clip_album("^ album: (.*)", false);
 
186
static QRegExp rx_clip_genre("^ genre: (.*)", false);
 
187
static QRegExp rx_clip_date("^ (creation date|year): (.*)", false);
 
188
static QRegExp rx_clip_track("^ track: (.*)", false);
 
189
static QRegExp rx_clip_copyright("^ copyright: (.*)", false);
 
190
static QRegExp rx_clip_comment("^ comment: (.*)", false);
 
191
static QRegExp rx_clip_software("^ software: (.*)", false);
185
192
 
 
193
static QRegExp rx_stream_title("^.* StreamTitle='(.*)';StreamUrl='(.*)';");
186
194
 
187
195
void MplayerProcess::init_rx() {
188
 
        rx_clip_name.setCaseSensitive(FALSE);
189
 
        rx_clip_artist.setCaseSensitive(FALSE);
190
 
        rx_clip_author.setCaseSensitive(FALSE);
191
 
        rx_clip_album.setCaseSensitive(FALSE);
192
 
        rx_clip_genre.setCaseSensitive(FALSE);
193
 
        rx_clip_date.setCaseSensitive(FALSE);
194
 
        rx_clip_track.setCaseSensitive(FALSE);
195
 
        rx_clip_copyright.setCaseSensitive(FALSE);
196
 
        rx_clip_comment.setCaseSensitive(FALSE);
197
 
        rx_clip_software.setCaseSensitive(FALSE);
 
196
        qDebug("MplayerProcess::init_rx");
 
197
 
 
198
        if (!pref->rx_endoffile.isEmpty()) 
 
199
                rx_endoffile.setPattern(pref->rx_endoffile);
 
200
 
 
201
        if (!pref->rx_novideo.isEmpty()) 
 
202
                rx_novideo.setPattern(pref->rx_novideo);
198
203
}
199
204
 
200
205
 
285
290
                        emit receivedPause();
286
291
                }
287
292
 
 
293
                // Stream title
 
294
                if (rx_stream_title.search(line) > -1) {
 
295
                        QString s = rx_stream_title.cap(1);
 
296
                        QString url = rx_stream_title.cap(2);
 
297
                        qDebug("MplayerProcess::parseLine: stream_title: '%s'", s.utf8().data());
 
298
                        qDebug("MplayerProcess::parseLine: stream_url: '%s'", url.utf8().data());
 
299
                        md.stream_title = s;
 
300
                        md.stream_url = url;
 
301
                        emit receivedStreamTitleAndUrl( s, url );
 
302
                }
 
303
 
288
304
                // The following things are not sent when the file has started to play
289
305
                // (or if sent, smplayer will ignore anyway...)
290
306
                // So not process anymore, if video is playing to save some time
364
380
                }
365
381
                else
366
382
 
 
383
                // Audio CD titles
 
384
                if (rx_cdda.search(line) > -1 ) {
 
385
                        int ID = rx_cdda.cap(1).toInt();
 
386
                        QString length = rx_cdda.cap(2);
 
387
                        double duration = 0;
 
388
                        QRegExp r("(\\d+):(\\d+):(\\d+)");
 
389
                        if ( r.search(length) > -1 ) {
 
390
                                duration = r.cap(1).toInt() * 60;
 
391
                                duration += r.cap(2).toInt();
 
392
                        }
 
393
                        md.titles.addID( ID );
 
394
                        /*
 
395
                        QString name = QString::number(ID) + " (" + length + ")";
 
396
                        md.titles.addName( ID, name );
 
397
                        */
 
398
                        md.titles.addDuration( ID, duration );
 
399
                }
 
400
                else
 
401
 
367
402
                // DVD titles
368
403
                if (rx_title.search(line) > -1) {
369
404
                        int ID = rx_title.cap(1).toInt();