| 1 | /* smplayer, GUI front-end for mplayer.
|
|---|
| 2 | Copyright (C) 2006-2013 Ricardo Villalba <rvm@users.sourceforge.net>
|
|---|
| 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 "colorutils.h"
|
|---|
| 28 |
|
|---|
| 29 | using namespace Global;
|
|---|
| 30 |
|
|---|
| 31 | #define TOO_CHAPTERS_WORKAROUND
|
|---|
| 32 |
|
|---|
| 33 | MplayerProcess::MplayerProcess(QObject * parent) : MyProcess(parent)
|
|---|
| 34 | {
|
|---|
| 35 | #if NOTIFY_SUB_CHANGES
|
|---|
| 36 | qRegisterMetaType<SubTracks>("SubTracks");
|
|---|
| 37 | #endif
|
|---|
| 38 |
|
|---|
| 39 | #if NOTIFY_AUDIO_CHANGES
|
|---|
| 40 | qRegisterMetaType<Tracks>("Tracks");
|
|---|
| 41 | #endif
|
|---|
| 42 |
|
|---|
| 43 | connect( this, SIGNAL(lineAvailable(QByteArray)),
|
|---|
| 44 | this, SLOT(parseLine(QByteArray)) );
|
|---|
| 45 |
|
|---|
| 46 | connect( this, SIGNAL(finished(int,QProcess::ExitStatus)),
|
|---|
| 47 | this, SLOT(processFinished(int,QProcess::ExitStatus)) );
|
|---|
| 48 |
|
|---|
| 49 | connect( this, SIGNAL(error(QProcess::ProcessError)),
|
|---|
| 50 | this, SLOT(gotError(QProcess::ProcessError)) );
|
|---|
| 51 |
|
|---|
| 52 | notified_mplayer_is_running = false;
|
|---|
| 53 | last_sub_id = -1;
|
|---|
| 54 | mplayer_svn = -1; // Not found yet
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | MplayerProcess::~MplayerProcess() {
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | bool MplayerProcess::start() {
|
|---|
| 61 | md.reset();
|
|---|
| 62 | notified_mplayer_is_running = false;
|
|---|
| 63 | last_sub_id = -1;
|
|---|
| 64 | mplayer_svn = -1; // Not found yet
|
|---|
| 65 | received_end_of_file = false;
|
|---|
| 66 |
|
|---|
| 67 | #if NOTIFY_SUB_CHANGES
|
|---|
| 68 | subs.clear();
|
|---|
| 69 | subtitle_info_received = false;
|
|---|
| 70 | subtitle_info_changed = false;
|
|---|
| 71 | #endif
|
|---|
| 72 |
|
|---|
| 73 | #if NOTIFY_AUDIO_CHANGES
|
|---|
| 74 | audios.clear();
|
|---|
| 75 | audio_info_changed = false;
|
|---|
| 76 | #endif
|
|---|
| 77 |
|
|---|
| 78 | dvd_current_title = -1;
|
|---|
| 79 |
|
|---|
| 80 | MyProcess::start();
|
|---|
| 81 |
|
|---|
| 82 | #if !defined(Q_OS_OS2)
|
|---|
| 83 | return waitForStarted();
|
|---|
| 84 | #else
|
|---|
| 85 | bool r = waitForStarted();
|
|---|
| 86 | if (r) {
|
|---|
| 87 | pidMP = QProcess::pid();
|
|---|
| 88 | qDebug("MPlayer PID %i", pidMP);
|
|---|
| 89 | MPpipeOpen();
|
|---|
| 90 | }
|
|---|
| 91 | return r;
|
|---|
| 92 | #endif
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | void MplayerProcess::writeToStdin(QString text) {
|
|---|
| 96 | if (isRunning()) {
|
|---|
| 97 | //qDebug("MplayerProcess::writeToStdin");
|
|---|
| 98 | #if !defined(Q_OS_OS2)
|
|---|
| 99 | #ifdef Q_OS_WIN
|
|---|
| 100 | write( text.toUtf8() + "\n");
|
|---|
| 101 | #else
|
|---|
| 102 | write( text.toLocal8Bit() + "\n");
|
|---|
| 103 | #endif
|
|---|
| 104 | #else
|
|---|
| 105 | MPpipeWrite( text.toLocal8Bit() + "\n");
|
|---|
| 106 | #endif
|
|---|
| 107 | } else {
|
|---|
| 108 | qWarning("MplayerProcess::writeToStdin: process not running");
|
|---|
| 109 | }
|
|---|
| 110 | #ifdef Q_OS_OS2
|
|---|
| 111 | if (text == "quit" || text == "quit\n") {
|
|---|
| 112 | MPpipeClose();
|
|---|
| 113 | }
|
|---|
| 114 | #endif
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | #ifdef Q_OS_OS2
|
|---|
| 118 | void MplayerProcess::MPpipeOpen() {
|
|---|
| 119 | char szPipeName[ 100 ];
|
|---|
| 120 | sprintf( szPipeName, "\\PIPE\\MPLAYER\\%x", pidMP );
|
|---|
| 121 | DosCreateNPipe( szPipeName, &hpipe, NP_ACCESS_DUPLEX, 1, 1024, 1024, 0 );
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | void MplayerProcess::MPpipeClose( void ) {
|
|---|
| 125 | DosClose( hpipe );
|
|---|
| 126 | }
|
|---|
| 127 |
|
|---|
| 128 | void MplayerProcess::MPpipeWrite( const QByteArray text ) {
|
|---|
| 129 | // MPlayer quitted ?
|
|---|
| 130 | if ( !isRunning() )
|
|---|
| 131 | return;
|
|---|
| 132 |
|
|---|
| 133 | // as things could hang when pipe communication is done direct here, i do a seperate thread for it
|
|---|
| 134 | pipeThread = new PipeThread(text, hpipe);
|
|---|
| 135 |
|
|---|
| 136 | pipeThread->start();
|
|---|
| 137 | while (!pipeThread->isRunning() && !pipeThread->isFinished()) {
|
|---|
| 138 | qDebug("we sleep");
|
|---|
| 139 | DosSleep(10);
|
|---|
| 140 | }
|
|---|
| 141 | // we wait for max 2 seconds for the thread to be ended (we to this with max 20 loops)
|
|---|
| 142 | int count = 0;
|
|---|
| 143 | while (!pipeThread->wait(100) && count < 20) {
|
|---|
| 144 | count ++;
|
|---|
| 145 | }
|
|---|
| 146 | if (count >= 20) {
|
|---|
| 147 | pipeThread->terminate();
|
|---|
| 148 | qDebug("pipe communication terminated");
|
|---|
| 149 | }
|
|---|
| 150 | delete pipeThread;
|
|---|
| 151 | }
|
|---|
| 152 | #endif
|
|---|
| 153 |
|
|---|
| 154 | static QRegExp rx_av("^[AV]: *([0-9,:.-]+)");
|
|---|
| 155 | static QRegExp rx_frame("^[AV]:.* (\\d+)\\/.\\d+");// [0-9,.]+");
|
|---|
| 156 | static QRegExp rx("^(.*)=(.*)");
|
|---|
| 157 | #if !NOTIFY_AUDIO_CHANGES
|
|---|
| 158 | static QRegExp rx_audio_mat("^ID_AID_(\\d+)_(LANG|NAME)=(.*)");
|
|---|
| 159 | #endif
|
|---|
| 160 | static QRegExp rx_video("^ID_VID_(\\d+)_(LANG|NAME)=(.*)");
|
|---|
| 161 | static QRegExp rx_title("^ID_DVD_TITLE_(\\d+)_(LENGTH|CHAPTERS|ANGLES)=(.*)");
|
|---|
| 162 | static QRegExp rx_chapters("^ID_CHAPTER_(\\d+)_(START|END|NAME)=(.+)");
|
|---|
| 163 | static QRegExp rx_winresolution("^VO: \\[(.*)\\] (\\d+)x(\\d+) => (\\d+)x(\\d+)");
|
|---|
| 164 | static QRegExp rx_ao("^AO: \\[(.*)\\]");
|
|---|
| 165 | static QRegExp rx_paused("^ID_PAUSED");
|
|---|
| 166 | #if !CHECK_VIDEO_CODEC_FOR_NO_VIDEO
|
|---|
| 167 | static QRegExp rx_novideo("^Video: no video");
|
|---|
| 168 | #endif
|
|---|
| 169 | static QRegExp rx_cache("^Cache fill:.*");
|
|---|
| 170 | static QRegExp rx_cache_empty("^Cache empty.*|^Cache not filling.*");
|
|---|
| 171 | static QRegExp rx_create_index("^Generating Index:.*");
|
|---|
| 172 | static QRegExp rx_play("^Starting playback...");
|
|---|
| 173 | static QRegExp rx_connecting("^Connecting to .*");
|
|---|
| 174 | static QRegExp rx_resolving("^Resolving .*");
|
|---|
| 175 | static QRegExp rx_screenshot("^\\*\\*\\* screenshot '(.*)'");
|
|---|
| 176 | static QRegExp rx_endoffile("^Exiting... \\(End of file\\)|^ID_EXIT=EOF");
|
|---|
| 177 | static QRegExp rx_mkvchapters("\\[mkv\\] Chapter (\\d+) from");
|
|---|
| 178 | static QRegExp rx_aspect2("^Movie-Aspect is ([0-9,.]+):1");
|
|---|
| 179 | static QRegExp rx_fontcache("^\\[ass\\] Updating font cache|^\\[ass\\] Init");
|
|---|
| 180 | static QRegExp rx_scanning_font("Scanning file");
|
|---|
| 181 | #if DVDNAV_SUPPORT
|
|---|
| 182 | static QRegExp rx_dvdnav_switch_title("^DVDNAV, switched to title: (\\d+)");
|
|---|
| 183 | static QRegExp rx_dvdnav_length("^ANS_length=(.*)");
|
|---|
| 184 | static QRegExp rx_dvdnav_title_is_menu("^DVDNAV_TITLE_IS_MENU");
|
|---|
| 185 | static QRegExp rx_dvdnav_title_is_movie("^DVDNAV_TITLE_IS_MOVIE");
|
|---|
| 186 | #endif
|
|---|
| 187 |
|
|---|
| 188 | // VCD
|
|---|
| 189 | static QRegExp rx_vcd("^ID_VCD_TRACK_(\\d+)_MSF=(.*)");
|
|---|
| 190 |
|
|---|
| 191 | // Audio CD
|
|---|
| 192 | static QRegExp rx_cdda("^ID_CDDA_TRACK_(\\d+)_MSF=(.*)");
|
|---|
| 193 |
|
|---|
| 194 | //Subtitles
|
|---|
| 195 | static QRegExp rx_subtitle("^ID_(SUBTITLE|FILE_SUB|VOBSUB)_ID=(\\d+)");
|
|---|
| 196 | static QRegExp rx_sid("^ID_(SID|VSID)_(\\d+)_(LANG|NAME)=(.*)");
|
|---|
| 197 | static QRegExp rx_subtitle_file("^ID_FILE_SUB_FILENAME=(.*)");
|
|---|
| 198 |
|
|---|
| 199 | // Audio
|
|---|
| 200 | #if NOTIFY_AUDIO_CHANGES
|
|---|
| 201 | static QRegExp rx_audio("^ID_AUDIO_ID=(\\d+)");
|
|---|
| 202 | static QRegExp rx_audio_info("^ID_AID_(\\d+)_(LANG|NAME)=(.*)");
|
|---|
| 203 | #endif
|
|---|
| 204 |
|
|---|
| 205 | #if PROGRAM_SWITCH
|
|---|
| 206 | static QRegExp rx_program("^PROGRAM_ID=(\\d+)");
|
|---|
| 207 | #endif
|
|---|
| 208 |
|
|---|
| 209 | //Clip info
|
|---|
| 210 | static QRegExp rx_clip_name("^ (name|title): (.*)", Qt::CaseInsensitive);
|
|---|
| 211 | static QRegExp rx_clip_artist("^ artist: (.*)", Qt::CaseInsensitive);
|
|---|
| 212 | static QRegExp rx_clip_author("^ author: (.*)", Qt::CaseInsensitive);
|
|---|
| 213 | static QRegExp rx_clip_album("^ album: (.*)", Qt::CaseInsensitive);
|
|---|
| 214 | static QRegExp rx_clip_genre("^ genre: (.*)", Qt::CaseInsensitive);
|
|---|
| 215 | static QRegExp rx_clip_date("^ (creation date|year): (.*)", Qt::CaseInsensitive);
|
|---|
| 216 | static QRegExp rx_clip_track("^ track: (.*)", Qt::CaseInsensitive);
|
|---|
| 217 | static QRegExp rx_clip_copyright("^ copyright: (.*)", Qt::CaseInsensitive);
|
|---|
| 218 | static QRegExp rx_clip_comment("^ comment: (.*)", Qt::CaseInsensitive);
|
|---|
| 219 | static QRegExp rx_clip_software("^ software: (.*)", Qt::CaseInsensitive);
|
|---|
| 220 |
|
|---|
| 221 | static QRegExp rx_stream_title("^.* StreamTitle='(.*)';");
|
|---|
| 222 | static QRegExp rx_stream_title_and_url("^.* StreamTitle='(.*)';StreamUrl='(.*)';");
|
|---|
| 223 |
|
|---|
| 224 |
|
|---|
| 225 | void MplayerProcess::parseLine(QByteArray ba) {
|
|---|
| 226 | //qDebug("MplayerProcess::parseLine: '%s'", ba.data() );
|
|---|
| 227 |
|
|---|
| 228 | QString tag;
|
|---|
| 229 | QString value;
|
|---|
| 230 |
|
|---|
| 231 | #if COLOR_OUTPUT_SUPPORT
|
|---|
| 232 | QString line = ColorUtils::stripColorsTags(QString::fromLocal8Bit(ba));
|
|---|
| 233 | #else
|
|---|
| 234 | #ifdef Q_OS_WIN
|
|---|
| 235 | QString line = QString::fromUtf8(ba);
|
|---|
| 236 | #else
|
|---|
| 237 | QString line = QString::fromLocal8Bit(ba);
|
|---|
| 238 | #endif
|
|---|
| 239 | #endif
|
|---|
| 240 |
|
|---|
| 241 | // Parse A: V: line
|
|---|
| 242 | //qDebug("%s", line.toUtf8().data());
|
|---|
| 243 | if (rx_av.indexIn(line) > -1) {
|
|---|
| 244 | double sec = rx_av.cap(1).toDouble();
|
|---|
| 245 | //qDebug("cap(1): '%s'", rx_av.cap(1).toUtf8().data() );
|
|---|
| 246 | //qDebug("sec: %f", sec);
|
|---|
| 247 |
|
|---|
| 248 | #if NOTIFY_SUB_CHANGES
|
|---|
| 249 | if (notified_mplayer_is_running) {
|
|---|
| 250 | if (subtitle_info_changed) {
|
|---|
| 251 | qDebug("MplayerProcess::parseLine: subtitle_info_changed");
|
|---|
| 252 | subtitle_info_changed = false;
|
|---|
| 253 | subtitle_info_received = false;
|
|---|
| 254 | emit subtitleInfoChanged(subs);
|
|---|
| 255 | }
|
|---|
| 256 | if (subtitle_info_received) {
|
|---|
| 257 | qDebug("MplayerProcess::parseLine: subtitle_info_received");
|
|---|
| 258 | subtitle_info_received = false;
|
|---|
| 259 | emit subtitleInfoReceivedAgain(subs);
|
|---|
| 260 | }
|
|---|
| 261 | }
|
|---|
| 262 | #endif
|
|---|
| 263 |
|
|---|
| 264 | #if NOTIFY_AUDIO_CHANGES
|
|---|
| 265 | if (notified_mplayer_is_running) {
|
|---|
| 266 | if (audio_info_changed) {
|
|---|
| 267 | qDebug("MplayerProcess::parseLine: audio_info_changed");
|
|---|
| 268 | audio_info_changed = false;
|
|---|
| 269 | emit audioInfoChanged(audios);
|
|---|
| 270 | }
|
|---|
| 271 | }
|
|---|
| 272 | #endif
|
|---|
| 273 |
|
|---|
| 274 | if (!notified_mplayer_is_running) {
|
|---|
| 275 | qDebug("MplayerProcess::parseLine: starting sec: %f", sec);
|
|---|
| 276 | if ( (md.n_chapters <= 0) && (dvd_current_title > 0) &&
|
|---|
| 277 | (md.titles.find(dvd_current_title) != -1) )
|
|---|
| 278 | {
|
|---|
| 279 | int idx = md.titles.find(dvd_current_title);
|
|---|
| 280 | md.n_chapters = md.titles.itemAt(idx).chapters();
|
|---|
| 281 | qDebug("MplayerProcess::parseLine: setting chapters to %d", md.n_chapters);
|
|---|
| 282 | }
|
|---|
| 283 |
|
|---|
| 284 | #if CHECK_VIDEO_CODEC_FOR_NO_VIDEO
|
|---|
| 285 | // Another way to find out if there's no video
|
|---|
| 286 | if (md.video_codec.isEmpty()) {
|
|---|
| 287 | md.novideo = true;
|
|---|
| 288 | emit receivedNoVideo();
|
|---|
| 289 | }
|
|---|
| 290 | #endif
|
|---|
| 291 |
|
|---|
| 292 | emit receivedStartingTime(sec);
|
|---|
| 293 | emit mplayerFullyLoaded();
|
|---|
| 294 |
|
|---|
| 295 | emit receivedCurrentFrame(0); // Ugly hack: set the frame counter to 0
|
|---|
| 296 |
|
|---|
| 297 | notified_mplayer_is_running = true;
|
|---|
| 298 | }
|
|---|
| 299 |
|
|---|
| 300 | emit receivedCurrentSec( sec );
|
|---|
| 301 |
|
|---|
| 302 | // Check for frame
|
|---|
| 303 | if (rx_frame.indexIn(line) > -1) {
|
|---|
| 304 | int frame = rx_frame.cap(1).toInt();
|
|---|
| 305 | //qDebug(" frame: %d", frame);
|
|---|
| 306 | emit receivedCurrentFrame(frame);
|
|---|
| 307 | }
|
|---|
| 308 | }
|
|---|
| 309 | else {
|
|---|
| 310 | // Emulates mplayer version in Ubuntu:
|
|---|
| 311 | //if (line.startsWith("MPlayer 1.0rc1")) line = "MPlayer 2:1.0~rc1-0ubuntu13.1 (C) 2000-2006 MPlayer Team";
|
|---|
| 312 | //if (line.startsWith("MPlayer2")) line = "mplayer2 d0305da (C) 2000-2012 MPlayer & mplayer2 teams";
|
|---|
| 313 | //if (line.startsWith("MPlayer SVN")) line = "MPlayer svn r34540 (Ubuntu), built with gcc-4.6 (C) 2000-2012 MPlayer Team";
|
|---|
| 314 |
|
|---|
| 315 | // Emulates unknown version
|
|---|
| 316 | //if (line.startsWith("MPlayer SVN")) line = "MPlayer lalksklsjjakksja";
|
|---|
| 317 |
|
|---|
| 318 | emit lineAvailable(line);
|
|---|
| 319 |
|
|---|
| 320 | // Parse other things
|
|---|
| 321 | qDebug("MplayerProcess::parseLine: '%s'", line.toUtf8().data() );
|
|---|
| 322 |
|
|---|
| 323 | // Screenshot
|
|---|
| 324 | if (rx_screenshot.indexIn(line) > -1) {
|
|---|
| 325 | QString shot = rx_screenshot.cap(1);
|
|---|
| 326 | qDebug("MplayerProcess::parseLine: screenshot: '%s'", shot.toUtf8().data());
|
|---|
| 327 | emit receivedScreenshot( shot );
|
|---|
| 328 | }
|
|---|
| 329 | else
|
|---|
| 330 |
|
|---|
| 331 | // End of file
|
|---|
| 332 | if (rx_endoffile.indexIn(line) > -1) {
|
|---|
| 333 | qDebug("MplayerProcess::parseLine: detected end of file");
|
|---|
| 334 | if (!received_end_of_file) {
|
|---|
| 335 | // In case of playing VCDs or DVDs, maybe the first title
|
|---|
| 336 | // is not playable, so the GUI doesn't get the info about
|
|---|
| 337 | // available titles. So if we received the end of file
|
|---|
| 338 | // first let's pretend the file has started so the GUI can have
|
|---|
| 339 | // the data.
|
|---|
| 340 | if ( !notified_mplayer_is_running) {
|
|---|
| 341 | emit mplayerFullyLoaded();
|
|---|
| 342 | }
|
|---|
| 343 |
|
|---|
| 344 | //emit receivedEndOfFile();
|
|---|
| 345 | // Send signal once the process is finished, not now!
|
|---|
| 346 | received_end_of_file = true;
|
|---|
| 347 | }
|
|---|
| 348 | }
|
|---|
| 349 | else
|
|---|
| 350 |
|
|---|
| 351 | // Window resolution
|
|---|
| 352 | if (rx_winresolution.indexIn(line) > -1) {
|
|---|
| 353 | /*
|
|---|
| 354 | md.win_width = rx_winresolution.cap(4).toInt();
|
|---|
| 355 | md.win_height = rx_winresolution.cap(5).toInt();
|
|---|
| 356 | md.video_aspect = (double) md.win_width / md.win_height;
|
|---|
| 357 | */
|
|---|
| 358 |
|
|---|
| 359 | int w = rx_winresolution.cap(4).toInt();
|
|---|
| 360 | int h = rx_winresolution.cap(5).toInt();
|
|---|
| 361 |
|
|---|
| 362 | emit receivedVO( rx_winresolution.cap(1) );
|
|---|
| 363 | emit receivedWindowResolution( w, h );
|
|---|
| 364 | //emit mplayerFullyLoaded();
|
|---|
| 365 | }
|
|---|
| 366 | else
|
|---|
| 367 |
|
|---|
| 368 | #if !CHECK_VIDEO_CODEC_FOR_NO_VIDEO
|
|---|
| 369 | // No video
|
|---|
| 370 | if (rx_novideo.indexIn(line) > -1) {
|
|---|
| 371 | md.novideo = TRUE;
|
|---|
| 372 | emit receivedNoVideo();
|
|---|
| 373 | //emit mplayerFullyLoaded();
|
|---|
| 374 | }
|
|---|
| 375 | else
|
|---|
| 376 | #endif
|
|---|
| 377 |
|
|---|
| 378 | // Pause
|
|---|
| 379 | if (rx_paused.indexIn(line) > -1) {
|
|---|
| 380 | emit receivedPause();
|
|---|
| 381 | }
|
|---|
| 382 |
|
|---|
| 383 | // Stream title
|
|---|
| 384 | if (rx_stream_title_and_url.indexIn(line) > -1) {
|
|---|
| 385 | QString s = rx_stream_title_and_url.cap(1);
|
|---|
| 386 | QString url = rx_stream_title_and_url.cap(2);
|
|---|
| 387 | qDebug("MplayerProcess::parseLine: stream_title: '%s'", s.toUtf8().data());
|
|---|
| 388 | qDebug("MplayerProcess::parseLine: stream_url: '%s'", url.toUtf8().data());
|
|---|
| 389 | md.stream_title = s;
|
|---|
| 390 | md.stream_url = url;
|
|---|
| 391 | emit receivedStreamTitleAndUrl( s, url );
|
|---|
| 392 | }
|
|---|
| 393 | else
|
|---|
| 394 | if (rx_stream_title.indexIn(line) > -1) {
|
|---|
| 395 | QString s = rx_stream_title.cap(1);
|
|---|
| 396 | qDebug("MplayerProcess::parseLine: stream_title: '%s'", s.toUtf8().data());
|
|---|
| 397 | md.stream_title = s;
|
|---|
| 398 | emit receivedStreamTitle( s );
|
|---|
| 399 | }
|
|---|
| 400 |
|
|---|
| 401 | #if NOTIFY_SUB_CHANGES
|
|---|
| 402 | // Subtitles
|
|---|
| 403 | if ((rx_subtitle.indexIn(line) > -1) || (rx_sid.indexIn(line) > -1) || (rx_subtitle_file.indexIn(line) > -1)) {
|
|---|
| 404 | int r = subs.parse(line);
|
|---|
| 405 | //qDebug("MplayerProcess::parseLine: result of parse: %d", r);
|
|---|
| 406 | subtitle_info_received = true;
|
|---|
| 407 | if ((r == SubTracks::SubtitleAdded) || (r == SubTracks::SubtitleChanged)) subtitle_info_changed = true;
|
|---|
| 408 | }
|
|---|
| 409 | #endif
|
|---|
| 410 |
|
|---|
| 411 | #if NOTIFY_AUDIO_CHANGES
|
|---|
| 412 | // Audio
|
|---|
| 413 | if (rx_audio.indexIn(line) > -1) {
|
|---|
| 414 | int ID = rx_audio.cap(1).toInt();
|
|---|
| 415 | qDebug("MplayerProcess::parseLine: ID_AUDIO_ID: %d", ID);
|
|---|
| 416 | if (audios.find(ID) == -1) audio_info_changed = true;
|
|---|
| 417 | audios.addID( ID );
|
|---|
| 418 | }
|
|---|
| 419 |
|
|---|
| 420 | if (rx_audio_info.indexIn(line) > -1) {
|
|---|
| 421 | int ID = rx_audio_info.cap(1).toInt();
|
|---|
| 422 | QString lang = rx_audio_info.cap(3);
|
|---|
| 423 | QString t = rx_audio_info.cap(2);
|
|---|
| 424 | qDebug("MplayerProcess::parseLine: Audio: ID: %d, Lang: '%s' Type: '%s'",
|
|---|
| 425 | ID, lang.toUtf8().data(), t.toUtf8().data());
|
|---|
| 426 |
|
|---|
| 427 | int idx = audios.find(ID);
|
|---|
| 428 | if (idx == -1) {
|
|---|
| 429 | qDebug("MplayerProcess::parseLine: audio %d doesn't exist, adding it", ID);
|
|---|
| 430 |
|
|---|
| 431 | audio_info_changed = true;
|
|---|
| 432 | if ( t == "NAME" )
|
|---|
| 433 | audios.addName(ID, lang);
|
|---|
| 434 | else
|
|---|
| 435 | audios.addLang(ID, lang);
|
|---|
| 436 | } else {
|
|---|
| 437 | qDebug("MplayerProcess::parseLine: audio %d exists, modifing it", ID);
|
|---|
| 438 |
|
|---|
| 439 | if (t == "NAME") {
|
|---|
| 440 | //qDebug("MplayerProcess::parseLine: name of audio %d: %s", ID, audios.itemAt(idx).name().toUtf8().constData());
|
|---|
| 441 | if (audios.itemAt(idx).name() != lang) {
|
|---|
| 442 | audio_info_changed = true;
|
|---|
| 443 | audios.addName(ID, lang);
|
|---|
| 444 | }
|
|---|
| 445 | } else {
|
|---|
| 446 | //qDebug("MplayerProcess::parseLine: language of audio %d: %s", ID, audios.itemAt(idx).lang().toUtf8().constData());
|
|---|
| 447 | if (audios.itemAt(idx).lang() != lang) {
|
|---|
| 448 | audio_info_changed = true;
|
|---|
| 449 | audios.addLang(ID, lang);
|
|---|
| 450 | }
|
|---|
| 451 | }
|
|---|
| 452 | }
|
|---|
| 453 | }
|
|---|
| 454 | #endif
|
|---|
| 455 |
|
|---|
| 456 | #if DVDNAV_SUPPORT
|
|---|
| 457 | if (rx_dvdnav_switch_title.indexIn(line) > -1) {
|
|---|
| 458 | int title = rx_dvdnav_switch_title.cap(1).toInt();
|
|---|
| 459 | qDebug("MplayerProcess::parseLine: dvd title: %d", title);
|
|---|
| 460 | emit receivedDVDTitle(title);
|
|---|
| 461 | }
|
|---|
| 462 | if (rx_dvdnav_length.indexIn(line) > -1) {
|
|---|
| 463 | double length = rx_dvdnav_length.cap(1).toDouble();
|
|---|
| 464 | qDebug("MplayerProcess::parseLine: length: %f", length);
|
|---|
| 465 | if (length != md.duration) {
|
|---|
| 466 | md.duration = length;
|
|---|
| 467 | emit receivedDuration(length);
|
|---|
| 468 | }
|
|---|
| 469 | }
|
|---|
| 470 | if (rx_dvdnav_title_is_menu.indexIn(line) > -1) {
|
|---|
| 471 | emit receivedTitleIsMenu();
|
|---|
| 472 | }
|
|---|
| 473 | if (rx_dvdnav_title_is_movie.indexIn(line) > -1) {
|
|---|
| 474 | emit receivedTitleIsMovie();
|
|---|
| 475 | }
|
|---|
| 476 | #endif
|
|---|
| 477 |
|
|---|
| 478 | if (rx_cache_empty.indexIn(line) > -1) {
|
|---|
| 479 | emit receivedCacheEmptyMessage(line);
|
|---|
| 480 | }
|
|---|
| 481 |
|
|---|
| 482 | // The following things are not sent when the file has started to play
|
|---|
| 483 | // (or if sent, smplayer will ignore anyway...)
|
|---|
| 484 | // So not process anymore, if video is playing to save some time
|
|---|
| 485 | if (notified_mplayer_is_running) {
|
|---|
| 486 | return;
|
|---|
| 487 | }
|
|---|
| 488 |
|
|---|
| 489 | if ( (mplayer_svn == -1) && ((line.startsWith("MPlayer ")) || (line.startsWith("MPlayer2 ", Qt::CaseInsensitive))) ) {
|
|---|
| 490 | mplayer_svn = MplayerVersion::mplayerVersion(line);
|
|---|
| 491 | qDebug("MplayerProcess::parseLine: MPlayer SVN: %d", mplayer_svn);
|
|---|
| 492 | if (mplayer_svn <= 0) {
|
|---|
| 493 | qWarning("MplayerProcess::parseLine: couldn't parse mplayer version!");
|
|---|
| 494 | emit failedToParseMplayerVersion(line);
|
|---|
| 495 | }
|
|---|
| 496 | }
|
|---|
| 497 |
|
|---|
| 498 | #if !NOTIFY_SUB_CHANGES
|
|---|
| 499 | // Subtitles
|
|---|
| 500 | if (rx_subtitle.indexIn(line) > -1) {
|
|---|
| 501 | md.subs.parse(line);
|
|---|
| 502 | }
|
|---|
| 503 | else
|
|---|
| 504 | if (rx_sid.indexIn(line) > -1) {
|
|---|
| 505 | md.subs.parse(line);
|
|---|
| 506 | }
|
|---|
| 507 | else
|
|---|
| 508 | if (rx_subtitle_file.indexIn(line) > -1) {
|
|---|
| 509 | md.subs.parse(line);
|
|---|
| 510 | }
|
|---|
| 511 | #endif
|
|---|
| 512 | // AO
|
|---|
| 513 | if (rx_ao.indexIn(line) > -1) {
|
|---|
| 514 | emit receivedAO( rx_ao.cap(1) );
|
|---|
| 515 | }
|
|---|
| 516 | else
|
|---|
| 517 |
|
|---|
| 518 | #if !NOTIFY_AUDIO_CHANGES
|
|---|
| 519 | // Matroska audio
|
|---|
| 520 | if (rx_audio_mat.indexIn(line) > -1) {
|
|---|
| 521 | int ID = rx_audio_mat.cap(1).toInt();
|
|---|
| 522 | QString lang = rx_audio_mat.cap(3);
|
|---|
| 523 | QString t = rx_audio_mat.cap(2);
|
|---|
| 524 | qDebug("MplayerProcess::parseLine: Audio: ID: %d, Lang: '%s' Type: '%s'",
|
|---|
| 525 | ID, lang.toUtf8().data(), t.toUtf8().data());
|
|---|
| 526 |
|
|---|
| 527 | if ( t == "NAME" )
|
|---|
| 528 | md.audios.addName(ID, lang);
|
|---|
| 529 | else
|
|---|
| 530 | md.audios.addLang(ID, lang);
|
|---|
| 531 | }
|
|---|
| 532 | else
|
|---|
| 533 | #endif
|
|---|
| 534 |
|
|---|
| 535 | #if PROGRAM_SWITCH
|
|---|
| 536 | // Program
|
|---|
| 537 | if (rx_program.indexIn(line) > -1) {
|
|---|
| 538 | int ID = rx_program.cap(1).toInt();
|
|---|
| 539 | qDebug("MplayerProcess::parseLine: Program: ID: %d", ID);
|
|---|
| 540 | md.programs.addID( ID );
|
|---|
| 541 | }
|
|---|
| 542 | else
|
|---|
| 543 | #endif
|
|---|
| 544 |
|
|---|
| 545 | // Video tracks
|
|---|
| 546 | if (rx_video.indexIn(line) > -1) {
|
|---|
| 547 | int ID = rx_video.cap(1).toInt();
|
|---|
| 548 | QString lang = rx_video.cap(3);
|
|---|
| 549 | QString t = rx_video.cap(2);
|
|---|
| 550 | qDebug("MplayerProcess::parseLine: Video: ID: %d, Lang: '%s' Type: '%s'",
|
|---|
| 551 | ID, lang.toUtf8().data(), t.toUtf8().data());
|
|---|
| 552 |
|
|---|
| 553 | if ( t == "NAME" )
|
|---|
| 554 | md.videos.addName(ID, lang);
|
|---|
| 555 | else
|
|---|
| 556 | md.videos.addLang(ID, lang);
|
|---|
| 557 | }
|
|---|
| 558 | else
|
|---|
| 559 |
|
|---|
| 560 | // Matroshka chapters
|
|---|
| 561 | if (rx_mkvchapters.indexIn(line)!=-1) {
|
|---|
| 562 | int c = rx_mkvchapters.cap(1).toInt();
|
|---|
| 563 | qDebug("MplayerProcess::parseLine: mkv chapters: %d", c);
|
|---|
| 564 | if ((c+1) > md.n_chapters) {
|
|---|
| 565 | md.n_chapters = c+1;
|
|---|
| 566 | qDebug("MplayerProcess::parseLine: chapters set to: %d", md.n_chapters);
|
|---|
| 567 | }
|
|---|
| 568 | }
|
|---|
| 569 | else
|
|---|
| 570 | // Chapter info
|
|---|
| 571 | if (rx_chapters.indexIn(line) > -1) {
|
|---|
| 572 | int const chap_ID = rx_chapters.cap(1).toInt();
|
|---|
| 573 | QString const chap_type = rx_chapters.cap(2);
|
|---|
| 574 | QString const chap_value = rx_chapters.cap(3);
|
|---|
| 575 | double const chap_value_d = chap_value.toDouble();
|
|---|
| 576 |
|
|---|
| 577 | if(!chap_type.compare("START"))
|
|---|
| 578 | {
|
|---|
| 579 | md.chapters.addStart(chap_ID, chap_value_d/1000);
|
|---|
| 580 | qDebug("MplayerProcess::parseLine: Chapter (ID: %d) starts at: %g",chap_ID, chap_value_d/1000);
|
|---|
| 581 | }
|
|---|
| 582 | else if(!chap_type.compare("END"))
|
|---|
| 583 | {
|
|---|
| 584 | md.chapters.addEnd(chap_ID, chap_value_d/1000);
|
|---|
| 585 | qDebug("MplayerProcess::parseLine: Chapter (ID: %d) ends at: %g",chap_ID, chap_value_d/1000);
|
|---|
| 586 | }
|
|---|
| 587 | else if(!chap_type.compare("NAME"))
|
|---|
| 588 | {
|
|---|
| 589 | md.chapters.addName(chap_ID, chap_value);
|
|---|
| 590 | qDebug("MplayerProcess::parseLine: Chapter (ID: %d) name: %s",chap_ID, chap_value.toUtf8().data());
|
|---|
| 591 | }
|
|---|
| 592 | }
|
|---|
| 593 | else
|
|---|
| 594 |
|
|---|
| 595 | // VCD titles
|
|---|
| 596 | if (rx_vcd.indexIn(line) > -1 ) {
|
|---|
| 597 | int ID = rx_vcd.cap(1).toInt();
|
|---|
| 598 | QString length = rx_vcd.cap(2);
|
|---|
| 599 | //md.titles.addID( ID );
|
|---|
| 600 | md.titles.addName( ID, length );
|
|---|
| 601 | }
|
|---|
| 602 | else
|
|---|
| 603 |
|
|---|
| 604 | // Audio CD titles
|
|---|
| 605 | if (rx_cdda.indexIn(line) > -1 ) {
|
|---|
| 606 | int ID = rx_cdda.cap(1).toInt();
|
|---|
| 607 | QString length = rx_cdda.cap(2);
|
|---|
| 608 | double duration = 0;
|
|---|
| 609 | QRegExp r("(\\d+):(\\d+):(\\d+)");
|
|---|
| 610 | if ( r.indexIn(length) > -1 ) {
|
|---|
| 611 | duration = r.cap(1).toInt() * 60;
|
|---|
| 612 | duration += r.cap(2).toInt();
|
|---|
| 613 | }
|
|---|
| 614 | md.titles.addID( ID );
|
|---|
| 615 | /*
|
|---|
| 616 | QString name = QString::number(ID) + " (" + length + ")";
|
|---|
| 617 | md.titles.addName( ID, name );
|
|---|
| 618 | */
|
|---|
| 619 | md.titles.addDuration( ID, duration );
|
|---|
| 620 | }
|
|---|
| 621 | else
|
|---|
| 622 |
|
|---|
| 623 | // DVD titles
|
|---|
| 624 | if (rx_title.indexIn(line) > -1) {
|
|---|
| 625 | int ID = rx_title.cap(1).toInt();
|
|---|
| 626 | QString t = rx_title.cap(2);
|
|---|
| 627 |
|
|---|
| 628 | if (t=="LENGTH") {
|
|---|
| 629 | double length = rx_title.cap(3).toDouble();
|
|---|
| 630 | qDebug("MplayerProcess::parseLine: Title: ID: %d, Length: '%f'", ID, length);
|
|---|
| 631 | md.titles.addDuration(ID, length);
|
|---|
| 632 | }
|
|---|
| 633 | else
|
|---|
| 634 | if (t=="CHAPTERS") {
|
|---|
| 635 | int chapters = rx_title.cap(3).toInt();
|
|---|
| 636 | qDebug("MplayerProcess::parseLine: Title: ID: %d, Chapters: '%d'", ID, chapters);
|
|---|
| 637 | md.titles.addChapters(ID, chapters);
|
|---|
| 638 | }
|
|---|
| 639 | else
|
|---|
| 640 | if (t=="ANGLES") {
|
|---|
| 641 | int angles = rx_title.cap(3).toInt();
|
|---|
| 642 | qDebug("MplayerProcess::parseLine: Title: ID: %d, Angles: '%d'", ID, angles);
|
|---|
| 643 | md.titles.addAngles(ID, angles);
|
|---|
| 644 | }
|
|---|
| 645 | }
|
|---|
| 646 | else
|
|---|
| 647 |
|
|---|
| 648 | // Catch cache messages
|
|---|
| 649 | if (rx_cache.indexIn(line) > -1) {
|
|---|
| 650 | emit receivedCacheMessage(line);
|
|---|
| 651 | }
|
|---|
| 652 | else
|
|---|
| 653 |
|
|---|
| 654 | // Creating index
|
|---|
| 655 | if (rx_create_index.indexIn(line) > -1) {
|
|---|
| 656 | emit receivedCreatingIndex(line);
|
|---|
| 657 | }
|
|---|
| 658 | else
|
|---|
| 659 |
|
|---|
| 660 | // Catch connecting message
|
|---|
| 661 | if (rx_connecting.indexIn(line) > -1) {
|
|---|
| 662 | emit receivedConnectingToMessage(line);
|
|---|
| 663 | }
|
|---|
| 664 | else
|
|---|
| 665 |
|
|---|
| 666 | // Catch resolving message
|
|---|
| 667 | if (rx_resolving.indexIn(line) > -1) {
|
|---|
| 668 | emit receivedResolvingMessage(line);
|
|---|
| 669 | }
|
|---|
| 670 | else
|
|---|
| 671 |
|
|---|
| 672 | // Aspect ratio for old versions of mplayer
|
|---|
| 673 | if (rx_aspect2.indexIn(line) > -1) {
|
|---|
| 674 | md.video_aspect = rx_aspect2.cap(1).toDouble();
|
|---|
| 675 | qDebug("MplayerProcess::parseLine: md.video_aspect set to %f", md.video_aspect);
|
|---|
| 676 | }
|
|---|
| 677 | else
|
|---|
| 678 |
|
|---|
| 679 | // Clip info
|
|---|
| 680 |
|
|---|
| 681 | //QString::trimmed() is used for removing leading and trailing whitespaces
|
|---|
| 682 | //Some .mp3 files contain tags with starting and ending whitespaces
|
|---|
| 683 | //Unfortunately MPlayer gives us leading and trailing whitespaces, Winamp for example doesn't show them
|
|---|
| 684 |
|
|---|
| 685 | // Name
|
|---|
| 686 | if (rx_clip_name.indexIn(line) > -1) {
|
|---|
| 687 | QString s = rx_clip_name.cap(2).trimmed();
|
|---|
| 688 | qDebug("MplayerProcess::parseLine: clip_name: '%s'", s.toUtf8().data());
|
|---|
| 689 | md.clip_name = s;
|
|---|
| 690 | }
|
|---|
| 691 | else
|
|---|
| 692 |
|
|---|
| 693 | // Artist
|
|---|
| 694 | if (rx_clip_artist.indexIn(line) > -1) {
|
|---|
| 695 | QString s = rx_clip_artist.cap(1).trimmed();
|
|---|
| 696 | qDebug("MplayerProcess::parseLine: clip_artist: '%s'", s.toUtf8().data());
|
|---|
| 697 | md.clip_artist = s;
|
|---|
| 698 | }
|
|---|
| 699 | else
|
|---|
| 700 |
|
|---|
| 701 | // Author
|
|---|
| 702 | if (rx_clip_author.indexIn(line) > -1) {
|
|---|
| 703 | QString s = rx_clip_author.cap(1).trimmed();
|
|---|
| 704 | qDebug("MplayerProcess::parseLine: clip_author: '%s'", s.toUtf8().data());
|
|---|
| 705 | md.clip_author = s;
|
|---|
| 706 | }
|
|---|
| 707 | else
|
|---|
| 708 |
|
|---|
| 709 | // Album
|
|---|
| 710 | if (rx_clip_album.indexIn(line) > -1) {
|
|---|
| 711 | QString s = rx_clip_album.cap(1).trimmed();
|
|---|
| 712 | qDebug("MplayerProcess::parseLine: clip_album: '%s'", s.toUtf8().data());
|
|---|
| 713 | md.clip_album = s;
|
|---|
| 714 | }
|
|---|
| 715 | else
|
|---|
| 716 |
|
|---|
| 717 | // Genre
|
|---|
| 718 | if (rx_clip_genre.indexIn(line) > -1) {
|
|---|
| 719 | QString s = rx_clip_genre.cap(1).trimmed();
|
|---|
| 720 | qDebug("MplayerProcess::parseLine: clip_genre: '%s'", s.toUtf8().data());
|
|---|
| 721 | md.clip_genre = s;
|
|---|
| 722 | }
|
|---|
| 723 | else
|
|---|
| 724 |
|
|---|
| 725 | // Date
|
|---|
| 726 | if (rx_clip_date.indexIn(line) > -1) {
|
|---|
| 727 | QString s = rx_clip_date.cap(2).trimmed();
|
|---|
| 728 | qDebug("MplayerProcess::parseLine: clip_date: '%s'", s.toUtf8().data());
|
|---|
| 729 | md.clip_date = s;
|
|---|
| 730 | }
|
|---|
| 731 | else
|
|---|
| 732 |
|
|---|
| 733 | // Track
|
|---|
| 734 | if (rx_clip_track.indexIn(line) > -1) {
|
|---|
| 735 | QString s = rx_clip_track.cap(1).trimmed();
|
|---|
| 736 | qDebug("MplayerProcess::parseLine: clip_track: '%s'", s.toUtf8().data());
|
|---|
| 737 | md.clip_track = s;
|
|---|
| 738 | }
|
|---|
| 739 | else
|
|---|
| 740 |
|
|---|
| 741 | // Copyright
|
|---|
| 742 | if (rx_clip_copyright.indexIn(line) > -1) {
|
|---|
| 743 | QString s = rx_clip_copyright.cap(1).trimmed();
|
|---|
| 744 | qDebug("MplayerProcess::parseLine: clip_copyright: '%s'", s.toUtf8().data());
|
|---|
| 745 | md.clip_copyright = s;
|
|---|
| 746 | }
|
|---|
| 747 | else
|
|---|
| 748 |
|
|---|
| 749 | // Comment
|
|---|
| 750 | if (rx_clip_comment.indexIn(line) > -1) {
|
|---|
| 751 | QString s = rx_clip_comment.cap(1).trimmed();
|
|---|
| 752 | qDebug("MplayerProcess::parseLine: clip_comment: '%s'", s.toUtf8().data());
|
|---|
| 753 | md.clip_comment = s;
|
|---|
| 754 | }
|
|---|
| 755 | else
|
|---|
| 756 |
|
|---|
| 757 | // Software
|
|---|
| 758 | if (rx_clip_software.indexIn(line) > -1) {
|
|---|
| 759 | QString s = rx_clip_software.cap(1).trimmed();
|
|---|
| 760 | qDebug("MplayerProcess::parseLine: clip_software: '%s'", s.toUtf8().data());
|
|---|
| 761 | md.clip_software = s;
|
|---|
| 762 | }
|
|---|
| 763 | else
|
|---|
| 764 |
|
|---|
| 765 | if (rx_fontcache.indexIn(line) > -1) {
|
|---|
| 766 | //qDebug("MplayerProcess::parseLine: updating font cache");
|
|---|
| 767 | emit receivedUpdatingFontCache();
|
|---|
| 768 | }
|
|---|
| 769 | else
|
|---|
| 770 | if (rx_scanning_font.indexIn(line) > -1) {
|
|---|
| 771 | emit receivedScanningFont(line);
|
|---|
| 772 | }
|
|---|
| 773 | else
|
|---|
| 774 |
|
|---|
| 775 | // Catch starting message
|
|---|
| 776 | /*
|
|---|
| 777 | pos = rx_play.indexIn(line);
|
|---|
| 778 | if (pos > -1) {
|
|---|
| 779 | emit mplayerFullyLoaded();
|
|---|
| 780 | }
|
|---|
| 781 | */
|
|---|
| 782 |
|
|---|
| 783 | //Generic things
|
|---|
| 784 | if (rx.indexIn(line) > -1) {
|
|---|
| 785 | tag = rx.cap(1);
|
|---|
| 786 | value = rx.cap(2);
|
|---|
| 787 | //qDebug("MplayerProcess::parseLine: tag: %s, value: %s", tag.toUtf8().data(), value.toUtf8().data());
|
|---|
| 788 |
|
|---|
| 789 | #if !NOTIFY_AUDIO_CHANGES
|
|---|
| 790 | // Generic audio
|
|---|
| 791 | if (tag == "ID_AUDIO_ID") {
|
|---|
| 792 | int ID = value.toInt();
|
|---|
| 793 | qDebug("MplayerProcess::parseLine: ID_AUDIO_ID: %d", ID);
|
|---|
| 794 | md.audios.addID( ID );
|
|---|
| 795 | }
|
|---|
| 796 | else
|
|---|
| 797 | #endif
|
|---|
| 798 |
|
|---|
| 799 | // Video
|
|---|
| 800 | if (tag == "ID_VIDEO_ID") {
|
|---|
| 801 | int ID = value.toInt();
|
|---|
| 802 | qDebug("MplayerProcess::parseLine: ID_VIDEO_ID: %d", ID);
|
|---|
| 803 | md.videos.addID( ID );
|
|---|
| 804 | }
|
|---|
| 805 | else
|
|---|
| 806 | if (tag == "ID_LENGTH") {
|
|---|
| 807 | md.duration = value.toDouble();
|
|---|
| 808 | qDebug("MplayerProcess::parseLine: md.duration set to %f", md.duration);
|
|---|
| 809 | }
|
|---|
| 810 | else
|
|---|
| 811 | if (tag == "ID_VIDEO_WIDTH") {
|
|---|
| 812 | md.video_width = value.toInt();
|
|---|
| 813 | qDebug("MplayerProcess::parseLine: md.video_width set to %d", md.video_width);
|
|---|
| 814 | }
|
|---|
| 815 | else
|
|---|
| 816 | if (tag == "ID_VIDEO_HEIGHT") {
|
|---|
| 817 | md.video_height = value.toInt();
|
|---|
| 818 | qDebug("MplayerProcess::parseLine: md.video_height set to %d", md.video_height);
|
|---|
| 819 | }
|
|---|
| 820 | else
|
|---|
| 821 | if (tag == "ID_VIDEO_ASPECT") {
|
|---|
| 822 | md.video_aspect = value.toDouble();
|
|---|
| 823 | if ( md.video_aspect == 0.0 ) {
|
|---|
| 824 | // I hope width & height are already set.
|
|---|
| 825 | md.video_aspect = (double) md.video_width / md.video_height;
|
|---|
| 826 | }
|
|---|
| 827 | qDebug("MplayerProcess::parseLine: md.video_aspect set to %f", md.video_aspect);
|
|---|
| 828 | }
|
|---|
| 829 | else
|
|---|
| 830 | if (tag == "ID_DVD_DISC_ID") {
|
|---|
| 831 | md.dvd_id = value;
|
|---|
| 832 | qDebug("MplayerProcess::parseLine: md.dvd_id set to '%s'", md.dvd_id.toUtf8().data());
|
|---|
| 833 | }
|
|---|
| 834 | else
|
|---|
| 835 | if (tag == "ID_DEMUXER") {
|
|---|
| 836 | md.demuxer = value;
|
|---|
| 837 | }
|
|---|
| 838 | else
|
|---|
| 839 | if (tag == "ID_VIDEO_FORMAT") {
|
|---|
| 840 | md.video_format = value;
|
|---|
| 841 | }
|
|---|
| 842 | else
|
|---|
| 843 | if (tag == "ID_AUDIO_FORMAT") {
|
|---|
| 844 | md.audio_format = value;
|
|---|
| 845 | }
|
|---|
| 846 | else
|
|---|
| 847 | if (tag == "ID_VIDEO_BITRATE") {
|
|---|
| 848 | md.video_bitrate = value.toInt();
|
|---|
| 849 | }
|
|---|
| 850 | else
|
|---|
| 851 | if (tag == "ID_VIDEO_FPS") {
|
|---|
| 852 | md.video_fps = value;
|
|---|
| 853 | }
|
|---|
| 854 | else
|
|---|
| 855 | if (tag == "ID_AUDIO_BITRATE") {
|
|---|
| 856 | md.audio_bitrate = value.toInt();
|
|---|
| 857 | }
|
|---|
| 858 | else
|
|---|
| 859 | if (tag == "ID_AUDIO_RATE") {
|
|---|
| 860 | md.audio_rate = value.toInt();
|
|---|
| 861 | }
|
|---|
| 862 | else
|
|---|
| 863 | if (tag == "ID_AUDIO_NCH") {
|
|---|
| 864 | md.audio_nch = value.toInt();
|
|---|
| 865 | }
|
|---|
| 866 | else
|
|---|
| 867 | if (tag == "ID_VIDEO_CODEC") {
|
|---|
| 868 | md.video_codec = value;
|
|---|
| 869 | }
|
|---|
| 870 | else
|
|---|
| 871 | if (tag == "ID_AUDIO_CODEC") {
|
|---|
| 872 | md.audio_codec = value;
|
|---|
| 873 | }
|
|---|
| 874 | else
|
|---|
| 875 | if (tag == "ID_CHAPTERS") {
|
|---|
| 876 | md.n_chapters = value.toInt();
|
|---|
| 877 | #ifdef TOO_CHAPTERS_WORKAROUND
|
|---|
| 878 | if (md.n_chapters > 1000) {
|
|---|
| 879 | qDebug("MplayerProcess::parseLine: warning too many chapters: %d", md.n_chapters);
|
|---|
| 880 | qDebug(" chapters will be ignored");
|
|---|
| 881 | md.n_chapters = 0;
|
|---|
| 882 | }
|
|---|
| 883 | #endif
|
|---|
| 884 | }
|
|---|
| 885 | else
|
|---|
| 886 | if (tag == "ID_DVD_CURRENT_TITLE") {
|
|---|
| 887 | dvd_current_title = value.toInt();
|
|---|
| 888 | }
|
|---|
| 889 | }
|
|---|
| 890 | }
|
|---|
| 891 | }
|
|---|
| 892 |
|
|---|
| 893 | // Called when the process is finished
|
|---|
| 894 | void MplayerProcess::processFinished(int exitCode, QProcess::ExitStatus exitStatus) {
|
|---|
| 895 | qDebug("MplayerProcess::processFinished: exitCode: %d, status: %d", exitCode, (int) exitStatus);
|
|---|
| 896 | // Send this signal before the endoffile one, otherwise
|
|---|
| 897 | // the playlist will start to play next file before all
|
|---|
| 898 | // objects are notified that the process has exited.
|
|---|
| 899 | emit processExited();
|
|---|
| 900 | if (received_end_of_file) emit receivedEndOfFile();
|
|---|
| 901 | }
|
|---|
| 902 |
|
|---|
| 903 | void MplayerProcess::gotError(QProcess::ProcessError error) {
|
|---|
| 904 | qDebug("MplayerProcess::gotError: %d", (int) error);
|
|---|
| 905 | }
|
|---|
| 906 |
|
|---|
| 907 | #ifdef Q_OS_OS2
|
|---|
| 908 | PipeThread::PipeThread(const QByteArray t, const HPIPE pipe) {
|
|---|
| 909 | text = t;
|
|---|
| 910 | hpipe = pipe;
|
|---|
| 911 | }
|
|---|
| 912 |
|
|---|
| 913 | PipeThread::~PipeThread() {
|
|---|
| 914 | }
|
|---|
| 915 |
|
|---|
| 916 | void PipeThread::run() {
|
|---|
| 917 | ULONG cbActual;
|
|---|
| 918 | APIRET rc = NO_ERROR;
|
|---|
| 919 |
|
|---|
| 920 | rc = DosConnectNPipe( hpipe );
|
|---|
| 921 | if (rc != NO_ERROR)
|
|---|
| 922 | return;
|
|---|
| 923 |
|
|---|
| 924 | // qDebug("pipe connected");
|
|---|
| 925 | DosWrite( hpipe, text.data(), strlen( text.data() ), &cbActual );
|
|---|
| 926 |
|
|---|
| 927 | // Wait for ACK
|
|---|
| 928 | DosRead( hpipe, &cbActual, sizeof( ULONG ), &cbActual );
|
|---|
| 929 | DosDisConnectNPipe( hpipe );
|
|---|
| 930 | return;
|
|---|
| 931 | }
|
|---|
| 932 | #endif
|
|---|
| 933 |
|
|---|
| 934 | #include "moc_mplayerprocess.cpp"
|
|---|