diff options
| -rw-r--r-- | src/plugins/Input/mplayer/decoder_mplayer.cpp | 207 | ||||
| -rw-r--r-- | src/plugins/Input/mplayer/decoder_mplayer.h | 81 | ||||
| -rw-r--r-- | src/plugins/Input/mplayer/decodermplayerfactory.cpp | 103 | ||||
| -rw-r--r-- | src/plugins/Input/mplayer/decodermplayerfactory.h | 50 | ||||
| -rw-r--r-- | src/plugins/Input/mplayer/mplayer.pro | 35 | ||||
| -rw-r--r-- | src/plugins/Input/phonon/decoder_phonon.cpp | 219 | ||||
| -rw-r--r-- | src/plugins/Input/phonon/decoder_phonon.h | 103 | ||||
| -rw-r--r-- | src/plugins/Input/phonon/decoderphononfactory.cpp | 109 | ||||
| -rw-r--r-- | src/plugins/Input/phonon/decoderphononfactory.h | 50 | ||||
| -rw-r--r-- | src/plugins/Input/phonon/phonon.pro | 38 |
10 files changed, 995 insertions, 0 deletions
diff --git a/src/plugins/Input/mplayer/decoder_mplayer.cpp b/src/plugins/Input/mplayer/decoder_mplayer.cpp new file mode 100644 index 000000000..924b3c7ea --- /dev/null +++ b/src/plugins/Input/mplayer/decoder_mplayer.cpp @@ -0,0 +1,207 @@ +/*************************************************************************** + * Copyright (C) 2008 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include <qmmp/constants.h> +#include <qmmp/buffer.h> +#include <qmmp/output.h> +#include <qmmp/recycler.h> +#include <qmmp/fileinfo.h> +#include <qmmp/decoderfactory.h> + +#include <QObject> +#include <QProcess> +#include <QFile> +#include <QApplication> +#include <QAction> +#include <QMetaObject> +#include <QKeyEvent> +#include <QMenu> +#include <QRegExp> + +#include "decoder_mplayer.h" + +#define MPLAYER_DEBUG + +static QRegExp rx_av("^[AV]: *([0-9,:.-]+)"); +static QRegExp rx_pause("^(.*)=(.*)PAUSE(.*)"); +static QRegExp rx_end("^(.*)End of file(.*)"); +static QRegExp rx_quit("^(.*)Quit(.*)"); +static QRegExp rx_audio("^AUDIO: *([0-9,.]+) *Hz.*([0-9,.]+) *ch.*([0-9]+).* ([0-9,.]+) *kbit.*"); + + +FileInfo *MplayerInfo::createFileInfo(const QString &path) +{ + QRegExp rx_id_length("^ID_LENGTH=([0-9,.]+)*"); + QStringList args; + args << "-slave"; + args << "-identify"; + args << "-frames"; + args << "0"; + args << "-vo"; + args << "null"; + args << "-ao"; + args << "null"; + args << path; + QProcess mplayer_process; + mplayer_process.start("mplayer", args); + mplayer_process.waitForFinished(); + QString str = QString::fromLocal8Bit(mplayer_process.readAll()).trimmed(); + FileInfo *info = new FileInfo(path); + QStringList lines = str.split("\n"); + foreach(QString line, lines) + { + if (rx_id_length.indexIn(line) > -1) + info->setLength((qint64) rx_id_length.cap(1).toDouble()); + } +#ifdef MPLAYER_DEBUG + qDebug(qPrintable(str)); +#endif + return info; +} + +QStringList MplayerInfo::filters() +{ + QStringList filters; + filters << "*.avi" << "*.mpg" << "*.mpeg" << "*.divx" << "*.qt" << "*.mov" << "*.wmv" << "*.asf"; + return filters; +} + +DecoderMplayer::DecoderMplayer(QObject *parent, DecoderFactory *d, const QString &url) + : Decoder(parent, d) +{ + m_url = url; + m_bitrate = 0; + m_samplerate = 0; + m_channels = 0; + m_bitsPerSample = 0; + m_length = 0; + m_currentTime = 0; + m_process = new QProcess(this); +} + +DecoderMplayer::~DecoderMplayer() +{ + qDebug(__FUNCTION__); + m_process->close(); +} + +bool DecoderMplayer::initialize() +{ + FileInfo *info = MplayerInfo::createFileInfo(m_url); + m_length = info->length(); + delete info; + m_args.clear(); + m_args << "-slave"; + m_args << m_url; + connect(m_process, SIGNAL(readyReadStandardOutput()), SLOT(readStdOut())); + return TRUE; +} + +qint64 DecoderMplayer::lengthInSeconds() +{ + return m_length; +} + +void DecoderMplayer::seek(qint64 pos) +{ + if (m_process->state() == QProcess::Running) + m_process->write(QString("seek %1 \n").arg(pos - m_currentTime).toLocal8Bit ()); +} + +void DecoderMplayer::stop() +{ + if (m_process->state() == QProcess::Running) + { + m_process->write("quit\n"); + m_process->waitForFinished(200); + } + StateHandler::instance()->dispatch(Qmmp::Stopped); +} + +void DecoderMplayer::pause() +{ + m_process->write("pause\n"); +} + +void DecoderMplayer::setEQ(double bands[10], double preamp) +{ +} + +void DecoderMplayer::setEQEnabled(bool on) +{ +} + +void DecoderMplayer::run() +{ + QMetaObject::invokeMethod(this, "startMplayerProcess"); + StateHandler::instance()->dispatch(Qmmp::Playing); +} + +void DecoderMplayer::readStdOut() +{ + QString line = QString::fromLocal8Bit(m_process->readAll ()).trimmed(); + QStringList lines = line.split("\n"); + foreach(line, lines) + { + if (rx_av.indexIn(line) > -1) + { + StateHandler::instance()->dispatch(Qmmp::Playing); + m_currentTime = (qint64) rx_av.cap(1).toDouble(); + StateHandler::instance()->dispatch(m_currentTime, + m_length, + m_bitrate, + m_samplerate, + m_bitsPerSample, + m_channels); + } + else if (rx_pause.indexIn(line) > -1) + { + StateHandler::instance()->dispatch(Qmmp::Paused); + } + else if (rx_end.indexIn(line) > -1) + { + if (m_process->state() == QProcess::Running) + m_process->waitForFinished(500); + finish(); + } + else if (rx_quit.indexIn(line) > -1) + { + if (m_process->state() == QProcess::Running) + m_process->waitForFinished(500); + StateHandler::instance()->dispatch(Qmmp::Stopped); + } + else if (rx_audio.indexIn(line) > -1) + { + m_samplerate = rx_audio.cap(1).toInt(); + m_channels = rx_audio.cap(2).toInt(); + m_bitsPerSample = rx_audio.cap(3).toDouble(); + m_bitrate = rx_audio.cap(4).toDouble(); + } +#ifdef MPLAYER_DEBUG + else + qDebug(qPrintable(line)); +#endif + } +} + +void DecoderMplayer::startMplayerProcess() +{ + m_process->start ("mplayer", m_args); +} diff --git a/src/plugins/Input/mplayer/decoder_mplayer.h b/src/plugins/Input/mplayer/decoder_mplayer.h new file mode 100644 index 000000000..2a754239e --- /dev/null +++ b/src/plugins/Input/mplayer/decoder_mplayer.h @@ -0,0 +1,81 @@ +/*************************************************************************** + * Copyright (C) 2008 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef DECODER_MPLAYER_H +#define DECODER_MPLAYER_H + +#include <qmmp/decoder.h> +#include <qmmp/statehandler.h> + +class Output; +class QIDevice; +class DecoderPhonon; +class QMenu; +class QProcess; + + +class MplayerInfo +{ +public: + static FileInfo *createFileInfo(const QString &path); + static QStringList filters(); +}; + + + +class DecoderMplayer : public Decoder +{ + Q_OBJECT +public: + DecoderMplayer(QObject *, DecoderFactory *, const QString &url); + virtual ~DecoderMplayer(); + + // Standard Decoder API + bool initialize(); + qint64 lengthInSeconds(); + void seek(qint64); + void stop(); + void pause(); + + // Equalizer + void setEQ(double bands[10], double preamp); + void setEQEnabled(bool on); + +private slots: + void readStdOut(); + void startMplayerProcess(); + +private: + // thread run function + void run(); + int mplayer_pipe[2]; + QString m_url; + QStringList m_args; + QProcess *m_process; + int m_bitrate; + int m_samplerate; + int m_channels; + int m_bitsPerSample; + qint64 m_currentTime; + qint64 m_length; +}; + + +#endif // DECODER_MPLAYER_H diff --git a/src/plugins/Input/mplayer/decodermplayerfactory.cpp b/src/plugins/Input/mplayer/decodermplayerfactory.cpp new file mode 100644 index 000000000..b274cdb07 --- /dev/null +++ b/src/plugins/Input/mplayer/decodermplayerfactory.cpp @@ -0,0 +1,103 @@ +/*************************************************************************** + * Copyright (C) 2008 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include <QtGui> + +#include "decoder_mplayer.h" +#include "decodermplayerfactory.h" + + +// DecoderMplayerFactory + +bool DecoderMplayerFactory::supports(const QString &source) const +{ + QStringList filters = MplayerInfo::filters(); + foreach(QString filter, filters) + { + QRegExp regexp(filter, Qt::CaseInsensitive, QRegExp::Wildcard); + if (regexp.exactMatch(source)) + return TRUE; + } + return FALSE; +} + +bool DecoderMplayerFactory::canDecode(QIODevice *) const +{ + return FALSE; +} + +const DecoderProperties DecoderMplayerFactory::properties() const +{ + DecoderProperties properties; + properties.name = tr("Mplayer Plugin"); + properties.shortName = "mplayer"; + properties.filter = MplayerInfo::filters().join(" "); + properties.description = tr("Video Files"); + //properties.contentType = "application/ogg;audio/x-vorbis+ogg"; + properties.protocols = "file"; + properties.hasAbout = TRUE; + properties.hasSettings = FALSE; + properties.noInput = TRUE; + properties.noOutput = TRUE; + return properties; +} + +Decoder *DecoderMplayerFactory::create(QObject *parent, QIODevice *input, + Output *output, const QString &url) +{ + Q_UNUSED(input); + Q_UNUSED(output); + return new DecoderMplayer(parent, this, url); +} + +QList<FileInfo *> DecoderMplayerFactory::createPlayList(const QString &fileName, bool useMetaData) +{ + Q_UNUSED(useMetaData); + QList<FileInfo *> info; + info << MplayerInfo::createFileInfo(fileName); + return info; +} + +QObject* DecoderMplayerFactory::showDetails(QWidget *, const QString &) +{ + return 0; +} + +void DecoderMplayerFactory::showSettings(QWidget *) +{ + /*SettingsDialog *s = new SettingsDialog(parent); + s->show();*/ +} + +void DecoderMplayerFactory::showAbout(QWidget *parent) +{ + QMessageBox::about (parent, tr("About Mplayer Audio Plugin"), + tr("Qmmp Mplayer Audio Plugin")+"\n"+ + tr("Writen by: Ilya Kotov <forkotov02@hotmail.ru>")); +} + +QTranslator *DecoderMplayerFactory::createTranslator(QObject *parent) +{ + QTranslator *translator = new QTranslator(parent); + QString locale = QLocale::system().name(); + translator->load(QString(":/phonon_plugin_") + locale); + return translator; +} + +Q_EXPORT_PLUGIN(DecoderMplayerFactory) diff --git a/src/plugins/Input/mplayer/decodermplayerfactory.h b/src/plugins/Input/mplayer/decodermplayerfactory.h new file mode 100644 index 000000000..a752d5a43 --- /dev/null +++ b/src/plugins/Input/mplayer/decodermplayerfactory.h @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2006-2008 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef DECODERMPLAYERFACTORY_H +#define DECODERMPLAYERFACTORY_H + +#include <QObject> +#include <QString> +#include <QIODevice> +#include <QWidget> + +#include <qmmp/decoder.h> +#include <qmmp/output.h> +#include <qmmp/decoderfactory.h> +#include <qmmp/fileinfo.h> + +class DecoderMplayerFactory : public QObject, DecoderFactory +{ +Q_OBJECT +Q_INTERFACES(DecoderFactory); + +public: + bool supports(const QString &source) const; + bool canDecode(QIODevice *input) const; + const DecoderProperties properties() const; + Decoder *create(QObject *, QIODevice *, Output *, const QString &); + QList<FileInfo *> createPlayList(const QString &fileName, bool useMetaData); + QObject* showDetails(QWidget *parent, const QString &path); + void showSettings(QWidget *parent); + void showAbout(QWidget *parent); + QTranslator *createTranslator(QObject *parent); +}; + +#endif diff --git a/src/plugins/Input/mplayer/mplayer.pro b/src/plugins/Input/mplayer/mplayer.pro new file mode 100644 index 000000000..c3472ebd8 --- /dev/null +++ b/src/plugins/Input/mplayer/mplayer.pro @@ -0,0 +1,35 @@ +include(../../plugins.pri) + +HEADERS += decodermplayerfactory.h \ + decoder_mplayer.h + +SOURCES += decoder_mplayer.cpp \ + decodermplayerfactory.cpp + +TARGET =$$PLUGINS_PREFIX/Input/mplayer +QMAKE_CLEAN =$$PLUGINS_PREFIX/Input/libmplayer.so + +INCLUDEPATH += ../../../ +CONFIG += release \ +warn_on \ +plugin + +TEMPLATE = lib + +QMAKE_LIBDIR += ../../../../lib +LIBS += -lqmmp -L/usr/lib + +#TRANSLATIONS = translations/mplayer_plugin_ru.ts +# translations/mplayer_plugin_uk_UA.ts +# translations/mplayer_plugin_zh_CN.ts +# translations/mplayer_plugin_zh_TW.ts +# translations/mplayer_plugin_cs.ts +# translations/mplayer_plugin_de.ts +#RESOURCES = translations/translations.qrc + +isEmpty(LIB_DIR){ + LIB_DIR = /lib +} +target.path = $$LIB_DIR/qmmp/Input +INSTALLS += target + diff --git a/src/plugins/Input/phonon/decoder_phonon.cpp b/src/plugins/Input/phonon/decoder_phonon.cpp new file mode 100644 index 000000000..c6781035b --- /dev/null +++ b/src/plugins/Input/phonon/decoder_phonon.cpp @@ -0,0 +1,219 @@ +/*************************************************************************** + * Copyright (C) 2008 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include <qmmp/constants.h> +#include <qmmp/buffer.h> +#include <qmmp/output.h> +#include <qmmp/recycler.h> +#include <qmmp/fileinfo.h> +#include <qmmp/decoderfactory.h> + +#include <QObject> +#include <QBasicTimer> +#include <QFile> +#include <QApplication> +#include <QAction> +#include <QKeyEvent> +#include <QMenu> + +#include "decoder_phonon.h" + + +VideoWindow::VideoWindow(DecoderPhonon *decoder, QWidget *parent) : + Phonon::VideoWidget(parent) +{ + m_decoder = decoder; + //create menu + m_menu = new QMenu (this); + //actions + m_fullScreenAction = new QAction(tr("Full Screen"), this); + m_fullScreenAction->setShortcut(tr("Alt+Return")); + m_fullScreenAction->setCheckable(TRUE); + m_fullScreenAction->setChecked(FALSE); + m_fullScreenAction->setShortcutContext(Qt::WindowShortcut); + connect(m_fullScreenAction, SIGNAL(triggered(bool)), SLOT(changeScreen(bool))); + m_menu->addAction(m_fullScreenAction); + addAction(m_fullScreenAction); + setMouseTracking (FALSE); +} + +void VideoWindow::mouseDoubleClickEvent(QMouseEvent *e) +{ + changeScreen(!isFullScreen()); + Phonon::VideoWidget::mouseDoubleClickEvent(e); +} + +void VideoWindow::closeEvent (QCloseEvent *event) +{ + if (event->spontaneous()) + m_decoder->stop(); + Phonon::VideoWidget::closeEvent(event); +} + +void VideoWindow::mousePressEvent(QMouseEvent *event) +{ + switch ((int) event->button ()) + { + case Qt::LeftButton: + m_pos = event->pos(); + break; + case Qt::RightButton: + m_menu->exec(event->globalPos()); + break; + } + Phonon::VideoWidget::mousePressEvent(event); +} + +void VideoWindow::mouseReleaseEvent(QMouseEvent *event) +{ + Phonon::VideoWidget::mouseReleaseEvent(event); +} + +void VideoWindow::mouseMoveEvent(QMouseEvent *event) +{ + QPoint npos = (event->globalPos() - m_pos + (frameGeometry ().topLeft() - geometry().topLeft())); + move(npos); + Phonon::VideoWidget::mouseMoveEvent(event); +} + + +void VideoWindow::changeScreen(bool fullScreen) +{ + m_fullScreenAction->setChecked(fullScreen); + setFullScreen(fullScreen); + if (!fullScreen) + resize(sizeHint()); +} + + +DecoderPhonon::DecoderPhonon(QObject *parent, DecoderFactory *d, const QString &url) + : Decoder(parent, d) +{ + m_mediaObject = 0; + m_audioOutput = 0; + m_videoWidget = 0; + m_url = url; +} + +DecoderPhonon::~DecoderPhonon() +{ + qDebug("DecoderPhonon::~DecoderPhonon"); + m_videoWidget->hide(); + delete m_videoWidget; +} + +bool DecoderPhonon::initialize() +{ + m_videoWidget = new VideoWindow(this);//Phonon::VideoWidget(); + m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatioAuto); + m_videoWidget->resize(300,200); + m_videoWidget->setWindowTitle("Phonon Plugin"); + m_mediaObject = new Phonon::MediaObject(this); + m_audioOutput = new Phonon::AudioOutput(this); + m_audioOutputPath = Phonon::createPath(m_mediaObject, m_audioOutput); + Phonon::createPath(m_mediaObject, m_videoWidget); + connect(m_mediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), SLOT(updateState(Phonon::State, Phonon::State))); + connect(m_mediaObject, SIGNAL(tick (qint64)), SLOT(updateTime(qint64))); + connect(m_mediaObject, SIGNAL(finished ()), SLOT(finish ())); + m_mediaObject->setTickInterval(1000); + m_mediaObject->clearQueue(); + m_mediaObject->enqueue(Phonon::MediaSource(m_url)); + m_stop = FALSE; + return TRUE; +} + +qint64 DecoderPhonon::lengthInSeconds() +{ + return m_mediaObject->totalTime () / 1000; +} + +void DecoderPhonon::seek(qint64 pos) +{ + m_mediaObject->seek(pos * 1000); +} + +void DecoderPhonon::stop() +{ + m_mediaObject->stop(); + m_videoWidget->close(); + while (m_mediaObject->state() == Phonon::PlayingState) + { + qApp->processEvents(); + usleep(100); + } + StateHandler::instance()->dispatch(Qmmp::Stopped); +} + +void DecoderPhonon::pause() +{ + if (m_mediaObject->state() == Phonon::PausedState) + m_mediaObject->play(); + else if (m_mediaObject->state() == Phonon::PlayingState) + m_mediaObject->pause(); +} + +void DecoderPhonon::setEQ(double bands[10], double preamp) +{ +} + +void DecoderPhonon::setEQEnabled(bool on) +{ +} + +void DecoderPhonon::run() +{ + if (!m_stop) + m_mediaObject->play(); + else + { + //m_mediaObject.stop(); + while (m_mediaObject->state() == Phonon::PlayingState) + { + qApp->processEvents(); + usleep(500); + } + } +} + +void DecoderPhonon::updateState(Phonon::State newstate, Phonon::State) +{ + switch ((int) newstate) + { + case Phonon::PlayingState: + StateHandler::instance()->dispatch(Qmmp::Playing); + m_videoWidget->resize(m_videoWidget->sizeHint()); + m_videoWidget->show(); + break; + case Phonon::PausedState: + StateHandler::instance()->dispatch(Qmmp::Paused); + break; + case Phonon::StoppedState: + //StateHandler::instance()->dispatch(Qmmp::Stopped); + //m_videoWidget->close(); + qApp->processEvents(); + break; + } +} + +void DecoderPhonon::updateTime(qint64 time) +{ + StateHandler::instance()->dispatch(time / 1000, m_mediaObject->totalTime () / 1000, 0, 0, 0, 0); +} + diff --git a/src/plugins/Input/phonon/decoder_phonon.h b/src/plugins/Input/phonon/decoder_phonon.h new file mode 100644 index 000000000..2af9ccce8 --- /dev/null +++ b/src/plugins/Input/phonon/decoder_phonon.h @@ -0,0 +1,103 @@ +/*************************************************************************** + * Copyright (C) 2008 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef DECODER_PHONON_H +#define DECODER_PHONON_H + +#include <phonon/phononnamespace.h> +#include <phonon/audiooutput.h> +#include <phonon/seekslider.h> +#include <phonon/mediaobject.h> +#include <phonon/volumeslider.h> +#include <phonon/backendcapabilities.h> +#include <phonon/videowidget.h> +#include <phonon/effect.h> +#include <phonon/effectparameter.h> + +#include <qmmp/decoder.h> +#include <qmmp/statehandler.h> + +class Output; +class QIDevice; +class DecoderPhonon; +class QMenu; + +class VideoWindow : public Phonon::VideoWidget +{ +Q_OBJECT +public: + VideoWindow(DecoderPhonon *decoder, QWidget *parent = 0); + +protected: + void mouseDoubleClickEvent(QMouseEvent *e); + void closeEvent (QCloseEvent *event); + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + +private slots: + void changeScreen(bool fullScreen); + +private: + DecoderPhonon *m_decoder; + QAction *m_fullScreenAction; + QPoint m_pos; + QMenu *m_menu; + QByteArray m_geometry; +}; + + +class DecoderPhonon : public Decoder +{ + Q_OBJECT +public: + DecoderPhonon(QObject *, DecoderFactory *, const QString &url); + virtual ~DecoderPhonon(); + + // Standard Decoder API + bool initialize(); + qint64 lengthInSeconds(); + void seek(qint64); + void stop(); + void pause(); + + // Equalizer + void setEQ(double bands[10], double preamp); + void setEQEnabled(bool on); + +private slots: + void updateState(Phonon::State newstate, Phonon::State oldstate); + void updateTime(qint64 time); + +private: + // thread run function + void run(); + // phonon object + Phonon::MediaObject *m_mediaObject; + Phonon::AudioOutput *m_audioOutput; + Phonon::VideoWidget *m_videoWidget; + Phonon::Path m_audioOutputPath; + bool m_stop; + + QString m_url; +}; + + +#endif // DECODER_PHONON_H diff --git a/src/plugins/Input/phonon/decoderphononfactory.cpp b/src/plugins/Input/phonon/decoderphononfactory.cpp new file mode 100644 index 000000000..7b089491c --- /dev/null +++ b/src/plugins/Input/phonon/decoderphononfactory.cpp @@ -0,0 +1,109 @@ +/*************************************************************************** + * Copyright (C) 2008 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include <QtGui> + +#include <phonon/phononnamespace.h> +#include <phonon/audiooutput.h> +#include <phonon/seekslider.h> +#include <phonon/mediaobject.h> +#include <phonon/volumeslider.h> +#include <phonon/backendcapabilities.h> +#include <phonon/videowidget.h> +#include <phonon/effect.h> +#include <phonon/effectparameter.h> + +#include "decoder_phonon.h" +#include "settingsdialog.h" +#include "decoderphononfactory.h" + + +// DecoderPhononFactory + +bool DecoderPhononFactory::supports(const QString &source) const +{ + QStringList filters; + QStringList mimeTypes = Phonon::BackendCapabilities::availableMimeTypes(); + return source.right(4).toLower() == ".avi"; +} + +bool DecoderPhononFactory::canDecode(QIODevice *) const +{ + return FALSE; +} + +const DecoderProperties DecoderPhononFactory::properties() const +{ + DecoderProperties properties; + properties.name = tr("Phonon Plugin"); + properties.shortName = "phonon"; + properties.filter = "*.avi"; + properties.description = tr("Phonon Files"); + //properties.contentType = "application/ogg;audio/x-vorbis+ogg"; + properties.protocols = "file"; + properties.hasAbout = FALSE; + properties.hasSettings = FALSE; + properties.noInput = TRUE; + properties.noOutput = TRUE; + return properties; +} + +Decoder *DecoderPhononFactory::create(QObject *parent, QIODevice *input, + Output *output, const QString &url) +{ + Q_UNUSED(input); + Q_UNUSED(output); + return new DecoderPhonon(parent, this, url); +} + +QList<FileInfo *> DecoderPhononFactory::createPlayList(const QString &fileName, bool useMetaData) +{ + Q_UNUSED(useMetaData); + QList<FileInfo *> info; + info << new FileInfo(fileName); + return info; +} + +QObject* DecoderPhononFactory::showDetails(QWidget *, const QString &) +{ + return 0; +} + +void DecoderPhononFactory::showSettings(QWidget *parent) +{ + /*SettingsDialog *s = new SettingsDialog(parent); + s->show();*/ +} + +void DecoderPhononFactory::showAbout(QWidget *parent) +{ + QMessageBox::about (parent, tr("About Phonon Audio Plugin"), + tr("Qmmp Phonon Audio Plugin")+"\n"+ + tr("Writen by: Ilya Kotov <forkotov02@hotmail.ru>")); +} + +QTranslator *DecoderPhononFactory::createTranslator(QObject *parent) +{ + QTranslator *translator = new QTranslator(parent); + QString locale = QLocale::system().name(); + translator->load(QString(":/phonon_plugin_") + locale); + return translator; +} + +Q_EXPORT_PLUGIN(DecoderPhononFactory) diff --git a/src/plugins/Input/phonon/decoderphononfactory.h b/src/plugins/Input/phonon/decoderphononfactory.h new file mode 100644 index 000000000..65a100347 --- /dev/null +++ b/src/plugins/Input/phonon/decoderphononfactory.h @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2006-2008 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef DECODERPHONONFACTORY_H +#define DECODERPHONONFACTORY_H + +#include <QObject> +#include <QString> +#include <QIODevice> +#include <QWidget> + +#include <qmmp/decoder.h> +#include <qmmp/output.h> +#include <qmmp/decoderfactory.h> +#include <qmmp/fileinfo.h> + +class DecoderPhononFactory : public QObject, DecoderFactory +{ +Q_OBJECT +Q_INTERFACES(DecoderFactory); + +public: + bool supports(const QString &source) const; + bool canDecode(QIODevice *input) const; + const DecoderProperties properties() const; + Decoder *create(QObject *, QIODevice *, Output *, const QString &); + QList<FileInfo *> createPlayList(const QString &fileName, bool useMetaData); + QObject* showDetails(QWidget *parent, const QString &path); + void showSettings(QWidget *parent); + void showAbout(QWidget *parent); + QTranslator *createTranslator(QObject *parent); +}; + +#endif diff --git a/src/plugins/Input/phonon/phonon.pro b/src/plugins/Input/phonon/phonon.pro new file mode 100644 index 000000000..2da95c88e --- /dev/null +++ b/src/plugins/Input/phonon/phonon.pro @@ -0,0 +1,38 @@ +include(../../plugins.pri) + +HEADERS += decoderphononfactory.h \ + decoder_phonon.h + +SOURCES += decoder_phonon.cpp \ + decoderphononfactory.cpp + +TARGET =$$PLUGINS_PREFIX/Input/phonon +QMAKE_CLEAN =$$PLUGINS_PREFIX/Input/libphonon.so + +INCLUDEPATH += ../../../ +CONFIG += release \ +warn_on \ +plugin + +TEMPLATE = lib + +QT += phonon + +QMAKE_LIBDIR += ../../../../lib +LIBS += -lqmmp -L/usr/lib + +#TRANSLATIONS = translations/phonon_plugin_ru.ts +# translations/phonon_plugin_uk_UA.ts +# translations/phonon_plugin_zh_CN.ts +# translations/phonon_plugin_zh_TW.ts +# translations/phonon_plugin_cs.ts +# translations/phonon_plugin_de.ts +#RESOURCES = translations/translations.qrc + +isEmpty(LIB_DIR){ + LIB_DIR = /lib +} +target.path = $$LIB_DIR/qmmp/Input +INSTALLS += target + + |
