| 1 | /* smplayer, GUI front-end for mplayer.
|
|---|
| 2 | Copyright (C) 2006-2016 Ricardo Villalba <[email protected]>
|
|---|
| 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 "playerprocess.h"
|
|---|
| 20 | #include <QFileInfo>
|
|---|
| 21 | #include <QDir>
|
|---|
| 22 | #include <QDebug>
|
|---|
| 23 |
|
|---|
| 24 | #ifdef MPV_SUPPORT
|
|---|
| 25 | #include "mpvprocess.h"
|
|---|
| 26 | #endif
|
|---|
| 27 |
|
|---|
| 28 | #ifdef MPLAYER_SUPPORT
|
|---|
| 29 | #include "mplayerprocess.h"
|
|---|
| 30 | #endif
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 | PlayerProcess::PlayerProcess(QObject * parent) : MyProcess(parent) {
|
|---|
| 34 | #if NOTIFY_SUB_CHANGES
|
|---|
| 35 | qRegisterMetaType<SubTracks>("SubTracks");
|
|---|
| 36 | #endif
|
|---|
| 37 |
|
|---|
| 38 | #if NOTIFY_AUDIO_CHANGES
|
|---|
| 39 | qRegisterMetaType<Tracks>("Tracks");
|
|---|
| 40 | #endif
|
|---|
| 41 |
|
|---|
| 42 | #if NOTIFY_CHAPTER_CHANGES
|
|---|
| 43 | qRegisterMetaType<Chapters>("Chapters");
|
|---|
| 44 | #endif
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | void PlayerProcess::writeToStdin(QString text) {
|
|---|
| 48 | if (isRunning()) {
|
|---|
| 49 | qDebug("PlayerProcess::writeToStdin: %s", text.toUtf8().constData());
|
|---|
| 50 | #ifdef Q_OS_WIN
|
|---|
| 51 | write( text.toUtf8() + "\n");
|
|---|
| 52 | #else
|
|---|
| 53 | write( text.toLocal8Bit() + "\n");
|
|---|
| 54 | #endif
|
|---|
| 55 | } else {
|
|---|
| 56 | qWarning("PlayerProcess::writeToStdin: process not running");
|
|---|
| 57 | }
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | PlayerProcess * PlayerProcess::createPlayerProcess(const QString & player_bin, QObject * parent) {
|
|---|
| 61 | PlayerProcess * proc = 0;
|
|---|
| 62 |
|
|---|
| 63 | #if defined(MPV_SUPPORT) && defined(MPLAYER_SUPPORT)
|
|---|
| 64 | if (PlayerID::player(player_bin) == PlayerID::MPLAYER) {
|
|---|
| 65 | qDebug() << "PlayerProcess::createPlayerProcess: creating MplayerProcess";
|
|---|
| 66 | proc = new MplayerProcess(parent);
|
|---|
| 67 | } else {
|
|---|
| 68 | qDebug() << "PlayerProcess::createPlayerProcess: creating MPVProcess";
|
|---|
| 69 | proc = new MPVProcess(parent);
|
|---|
| 70 | }
|
|---|
| 71 | #else
|
|---|
| 72 | #ifdef MPV_SUPPORT
|
|---|
| 73 | proc = new MPVProcess(parent);
|
|---|
| 74 | #endif
|
|---|
| 75 | #ifdef MPLAYER_SUPPORT
|
|---|
| 76 | proc = new MplayerProcess(parent);
|
|---|
| 77 | #endif
|
|---|
| 78 | #endif
|
|---|
| 79 |
|
|---|
| 80 | return proc;
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | #ifdef CAPTURE_STREAM
|
|---|
| 84 | void PlayerProcess::setCaptureDirectory(const QString & dir) {
|
|---|
| 85 | capture_filename = "";
|
|---|
| 86 | if (!dir.isEmpty() && (QFileInfo(dir).isDir())) {
|
|---|
| 87 | // Find a unique filename
|
|---|
| 88 | QString prefix = "capture";
|
|---|
| 89 | for (int n = 1; ; n++) {
|
|---|
| 90 | QString c = QDir::toNativeSeparators(QString("%1/%2_%3.dump").arg(dir).arg(prefix).arg(n, 4, 10, QChar('0')));
|
|---|
| 91 | if (!QFile::exists(c)) {
|
|---|
| 92 | capture_filename = c;
|
|---|
| 93 | return;
|
|---|
| 94 | }
|
|---|
| 95 | }
|
|---|
| 96 | }
|
|---|
| 97 | }
|
|---|
| 98 | #endif
|
|---|
| 99 |
|
|---|
| 100 | #include "moc_playerprocess.cpp"
|
|---|