From 06d1877811fa6aa97dddc0e03bcde4e766928c87 Mon Sep 17 00:00:00 2001 From: vovanec Date: Thu, 7 Feb 2008 13:36:34 +0000 Subject: new directory structure git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@232 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/Input/vorbis/CMakeLists.txt | 96 +++++ src/plugins/Input/vorbis/decoder_vorbis.cpp | 425 +++++++++++++++++++++ src/plugins/Input/vorbis/decoder_vorbis.h | 63 +++ src/plugins/Input/vorbis/decodervorbisfactory.cpp | 105 +++++ src/plugins/Input/vorbis/decodervorbisfactory.h | 54 +++ src/plugins/Input/vorbis/detailsdialog.cpp | 120 ++++++ src/plugins/Input/vorbis/detailsdialog.h | 49 +++ src/plugins/Input/vorbis/detailsdialog.ui | 384 +++++++++++++++++++ .../Input/vorbis/translations/translations.qrc | 6 + .../Input/vorbis/translations/vorbis_plugin_ru.qm | Bin 0 -> 2569 bytes .../Input/vorbis/translations/vorbis_plugin_ru.ts | 164 ++++++++ src/plugins/Input/vorbis/vorbis.pro | 35 ++ 12 files changed, 1501 insertions(+) create mode 100644 src/plugins/Input/vorbis/CMakeLists.txt create mode 100644 src/plugins/Input/vorbis/decoder_vorbis.cpp create mode 100644 src/plugins/Input/vorbis/decoder_vorbis.h create mode 100644 src/plugins/Input/vorbis/decodervorbisfactory.cpp create mode 100644 src/plugins/Input/vorbis/decodervorbisfactory.h create mode 100644 src/plugins/Input/vorbis/detailsdialog.cpp create mode 100644 src/plugins/Input/vorbis/detailsdialog.h create mode 100644 src/plugins/Input/vorbis/detailsdialog.ui create mode 100644 src/plugins/Input/vorbis/translations/translations.qrc create mode 100644 src/plugins/Input/vorbis/translations/vorbis_plugin_ru.qm create mode 100644 src/plugins/Input/vorbis/translations/vorbis_plugin_ru.ts create mode 100644 src/plugins/Input/vorbis/vorbis.pro (limited to 'src/plugins/Input/vorbis') diff --git a/src/plugins/Input/vorbis/CMakeLists.txt b/src/plugins/Input/vorbis/CMakeLists.txt new file mode 100644 index 000000000..baf5bad8c --- /dev/null +++ b/src/plugins/Input/vorbis/CMakeLists.txt @@ -0,0 +1,96 @@ +project(libvorbis) + +cmake_minimum_required(VERSION 2.4.0) + + +INCLUDE(UsePkgConfig) +INCLUDE(FindQt4) + +find_package(Qt4 REQUIRED) # find and setup Qt4 for this project +include(${QT_USE_FILE}) + +# qt plugin +ADD_DEFINITIONS( -Wall ) +ADD_DEFINITIONS(${QT_DEFINITIONS}) +ADD_DEFINITIONS(-DQT_PLUGIN) +ADD_DEFINITIONS(-DQT_NO_DEBUG) +ADD_DEFINITIONS(-DQT_SHARED) +ADD_DEFINITIONS(-DQT_THREAD) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +SET(QT_INCLUDES + ${QT_INCLUDES} + ${CMAKE_CURRENT_BINARY_DIR}/../../../ +) + +# libqmmp +include_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../) +link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../) + +# libvorbis and taglib +PKGCONFIG(ogg OGG_INCLUDE_DIR OGG_LINK_DIR OGG_LINK_FLAGS OGG_CFLAGS) +PKGCONFIG(vorbis VORBIS_INCLUDE_DIR VORBIS_LINK_DIR VORBIS_LINK_FLAGS VORBIS_CFLAGS) +PKGCONFIG(vorbisfile VORBISFILE_INCLUDE_DIR VORBISFILE_LINK_DIR VORBISFILE_LINK_FLAGS VORBISFILE_CFLAGS) + +PKGCONFIG(taglib TAGLIB_INCLUDE_DIR TAGLIB_LINK_DIR TAGLIB_LINK_FLAGS TAGLIB_CFLAGS) + +IF(NOT OGG_LINK_FLAGS) + SET(OGG_LINK_FLAGS -logg) +ENDIF(NOT OGG_LINK_FLAGS) + +IF(NOT VORBIS_LINK_FLAGS) + SET(VORBIS_LINK_FLAGS -lvorbis) +ENDIF(NOT VORBIS_LINK_FLAGS) + +IF(NOT VORBISFILE_LINK_FLAGS) + SET(VORBISFILE_LINK_FLAGS -lvorbisfile) +ENDIF(NOT VORBISFILE_LINK_FLAGS) + +IF(NOT TAGLIB_LINK_FLAGS) + SET(TAGLIB_LINK_FLAGS -ltag) + SET(TAGLIB_INCLUDE_DIR /usr/include/taglib) + SET(TAGLIB_CFLAGS -I/usr/include/taglib) +ENDIF(NOT TAGLIB_LINK_FLAGS) + +include_directories(${VORBIS_INCLUDE_DIR} ${TAGLIB_INCLUDE_DIR}) +link_directories(${VORBIS_LINK_DIR} ${TAGLIB_LINK_DIR}) + +#ADD_DEFINITIONS(${VORBIS_CFLAGS}) +ADD_DEFINITIONS(${TAGLIB_CFLAGS}) + + +SET(libvorbis_SRCS + decoder_vorbis.cpp + decodervorbisfactory.cpp + detailsdialog.cpp +) + +SET(libvorbis_MOC_HDRS + decodervorbisfactory.h + decoder_vorbis.h + detailsdialog.h +) + +SET(libvorbis_RCCS translations/translations.qrc) + +QT4_ADD_RESOURCES(libvorbis_RCC_SRCS ${libvorbis_RCCS}) + +QT4_WRAP_CPP(libvorbis_MOC_SRCS ${libvorbis_MOC_HDRS}) + +# user interface + + +SET(libvorbis_UIS + detailsdialog.ui +) + +QT4_WRAP_UI(libvorbis_UIS_H ${libvorbis_UIS}) +# Don't forget to include output directory, otherwise +# the UI file won't be wrapped! +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +ADD_LIBRARY(vorbis SHARED ${libvorbis_SRCS} ${libvorbis_MOC_SRCS} ${libvorbis_UIS_H} + ${libvorbis_RCC_SRCS}) +target_link_libraries(vorbis ${QT_LIBRARIES} -lqmmp ${VORBIS_LINK_FLAGS} ${VORBISFILE_LINK_FLAGS} ${OGG_LINK_FLAGS} ${TAGLIB_LINK_FLAGS} ${TAGLIB_CFLAGS}) +install(TARGETS vorbis DESTINATION ${LIB_DIR}/qmmp/Input PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ) diff --git a/src/plugins/Input/vorbis/decoder_vorbis.cpp b/src/plugins/Input/vorbis/decoder_vorbis.cpp new file mode 100644 index 000000000..31fb99c6f --- /dev/null +++ b/src/plugins/Input/vorbis/decoder_vorbis.cpp @@ -0,0 +1,425 @@ +// Copyright (c) 2000-2001 Brad Hughes +// +// Use, modification and distribution is allowed without limitation, +// warranty, or liability of any kind. +// + +#include "decoder_vorbis.h" +#include "constants.h" +#include "buffer.h" +#include "output.h" +#include "recycler.h" +#include "filetag.h" + +#include +#include + + +// ic functions for OggVorbis + +static size_t oggread (void *buf, size_t size, size_t nmemb, void *src) +{ + if (! src) return 0; + + DecoderVorbis *dogg = (DecoderVorbis *) src; + int len = dogg->input()->read((char *) buf, (size * nmemb)); + return len / size; +} + + +static int oggseek(void *src, int64_t offset, int whence) +{ + DecoderVorbis *dogg = (DecoderVorbis *) src; + + if ( dogg->input()->isSequential ()) + return -1; + + long start = 0; + switch (whence) + { + case SEEK_END: + start = dogg->input()->size(); + break; + + case SEEK_CUR: + start = dogg->input()->pos(); + break; + + case SEEK_SET: + default: + start = 0; + } + + if (dogg->input()->seek(start + offset)) + return 0; + return -1; +} + + +static int oggclose(void *src) +{ + DecoderVorbis *dogg = (DecoderVorbis *) src; + dogg->input()->close(); + return 0; +} + + +static long oggtell(void *src) +{ + DecoderVorbis *dogg = (DecoderVorbis *) src; + long t = dogg->input()->pos(); + return t; +} + + +// Decoder class + +DecoderVorbis::DecoderVorbis(QObject *parent, DecoderFactory *d, QIODevice *i, Output *o) + : Decoder(parent, d, i, o) +{ + inited = FALSE; + user_stop = FALSE; + stat = 0; + output_buf = 0; + output_bytes = 0; + output_at = 0; + bks = 0; + done = FALSE; + finish = FALSE; + len = 0; + freq = 0; + bitrate = 0; + seekTime = -1.0; + totalTime = 0.0; + chan = 0; + output_size = 0; +} + + +DecoderVorbis::~DecoderVorbis() +{ + deinit(); + + if (output_buf) + delete [] output_buf; + output_buf = 0; +} + + +void DecoderVorbis::stop() +{ + user_stop = TRUE; +} + + +void DecoderVorbis::flush(bool final) +{ + ulong min = final ? 0 : bks; + + while ((! done && ! finish) && output_bytes > min) + { + output()->recycler()->mutex()->lock (); + + while ((! done && ! finish) && output()->recycler()->full()) + { + mutex()->unlock(); + + output()->recycler()->cond()->wait(output()->recycler()->mutex()); + + mutex()->lock (); + done = user_stop; + } + + if (user_stop || finish) + { + inited = FALSE; + done = TRUE; + } + else + { + /*ulong sz = output_bytes < bks ? output_bytes : bks; + Buffer *b = output()->recycler()->get(); + + memcpy(b->data, output_buf, sz); + if (sz != bks) memset(b->data + sz, 0, bks - sz); + + b->nbytes = bks; + b->rate = bitrate; + output_size += b->nbytes; + output()->recycler()->add(); + + output_bytes -= sz; + memmove(output_buf, output_buf + sz, output_bytes);*/ + output_bytes -= produceSound(output_buf, output_bytes, bitrate, chan); + output_size += bks; + output_at = output_bytes; + } + + if (output()->recycler()->full()) + { + output()->recycler()->cond()->wakeOne(); + } + + output()->recycler()->mutex()->unlock(); + } +} + + +bool DecoderVorbis::initialize() +{ + qDebug("DecoderVorbis: initialize"); + bks = blockSize(); + + inited = user_stop = done = finish = FALSE; + len = freq = bitrate = 0; + stat = chan = 0; + output_size = 0; + seekTime = -1.0; + totalTime = 0.0; + if (! input()) + { + qDebug("DecoderVorbis: cannot initialize. No input"); + + return FALSE; + } + + if (! output_buf) + output_buf = new char[globalBufferSize]; + output_at = 0; + output_bytes = 0; + + if (! input()->isOpen()) + { + if (! input()->open(QIODevice::ReadOnly)) + { + qWarning(qPrintable("DecoderVorbis: failed to open input. " + + input()->errorString () + ".")); + return FALSE; + } + } + + ov_callbacks oggcb = + { + oggread, + oggseek, + oggclose, + oggtell + }; + if (ov_open_callbacks(this, &oggfile, NULL, 0, oggcb) < 0) + { + qWarning("DecoderVorbis: cannot open stream"); + + return FALSE; + } + + freq = 0; + bitrate = ov_bitrate(&oggfile, -1) / 1000; + chan = 0; + + totalTime = long(ov_time_total(&oggfile, 0)); + totalTime = totalTime < 0 ? 0 : totalTime; + + vorbis_info *ogginfo = ov_info(&oggfile, -1); + if (ogginfo) + { + freq = ogginfo->rate; + chan = ogginfo->channels; + } + + configure(freq, chan, 16, bitrate); + + inited = TRUE; + return TRUE; +} + + +double DecoderVorbis::lengthInSeconds() +{ + if (! inited) + return 0; + + return totalTime; +} + + +void DecoderVorbis::seek(double pos) +{ + seekTime = pos; +} + + +void DecoderVorbis::deinit() +{ + if (inited) + ov_clear(&oggfile); + inited = user_stop = done = finish = FALSE; + len = freq = bitrate = 0; + stat = chan = 0; + output_size = 0; +} + +void DecoderVorbis::updateTags() +{ + int i; + vorbis_comment *comments; + + FileTag tag; + comments = ov_comment (&oggfile, -1); + for (i = 0; i < comments->comments; i++) + { + if (!strncasecmp(comments->user_comments[i], "title=", + strlen ("title="))) + tag.setValue(FileTag::TITLE, QString::fromUtf8(comments->user_comments[i] + + strlen ("title="))); + else if (!strncasecmp(comments->user_comments[i], + "artist=", strlen ("artist="))) + tag.setValue(FileTag::ARTIST, + QString::fromUtf8(comments->user_comments[i] + + strlen ("artist="))); + else if (!strncasecmp(comments->user_comments[i], + "album=", strlen ("album="))) + tag.setValue(FileTag::ALBUM, + QString::fromUtf8(comments->user_comments[i] + + strlen ("album="))); + else if (!strncasecmp(comments->user_comments[i], + "comment=", strlen ("comment="))) + tag.setValue(FileTag::COMMENT, + QString::fromUtf8(comments->user_comments[i] + + strlen ("comment="))); + else if (!strncasecmp(comments->user_comments[i], + "genre=", strlen ("genre="))) + tag.setValue(FileTag::GENRE, QString::fromUtf8 (comments->user_comments[i] + + strlen ("genre="))); + else if (!strncasecmp(comments->user_comments[i], + "tracknumber=", + strlen ("tracknumber="))) + tag.setValue(FileTag::TRACK, atoi (comments->user_comments[i] + + strlen ("tracknumber="))); + else if (!strncasecmp(comments->user_comments[i], + "track=", strlen ("track="))) + tag.setValue(FileTag::TRACK, atoi (comments->user_comments[i] + + strlen ("track="))); + else if (!strncasecmp(comments->user_comments[i], + "date=", strlen ("date="))) + tag.setValue(FileTag::YEAR, atoi (comments->user_comments[i] + + strlen ("date="))); + + } + tag.setValue(FileTag::LENGTH, uint(totalTime)); + dispatch(tag); +} + +void DecoderVorbis::run() +{ + mutex()->lock (); + + if (! inited) + { + mutex()->unlock(); + + return; + } + + //stat = DecoderEvent::Decoding; + stat = DecoderState::Decoding; + mutex()->unlock(); + + { + //DecoderEvent e((DecoderEvent::Type) stat); + //dispatch(e); + //DecoderStatus st ((DecoderStatus::Type) stat); + dispatch(DecoderState ((DecoderState::Type) stat)); + + //emit statusChanged(stat); + } + + int section = 0; + int last_section = -1; + + while (! done && ! finish) + { + mutex()->lock (); + // decode + + if (seekTime >= 0.0) + { + ov_time_seek(&oggfile, double(seekTime)); + seekTime = -1.0; + + output_size = long(ov_time_tell(&oggfile)) * long(freq * chan * 2); + } + len = -1; + while (len < 0) + { + len = ov_read(&oggfile, (char *) (output_buf + output_at), bks, 0, 2, 1, + §ion); + } + if (section != last_section) + updateTags(); + last_section = section; + + if (len > 0) + { + bitrate = ov_bitrate_instant(&oggfile) / 1000; + + output_at += len; + output_bytes += len; + + if (output()) + flush(); + } + else if (len == 0) + { + flush(TRUE); + + if (output()) + { + output()->recycler()->mutex()->lock (); + // end of stream + while (! output()->recycler()->empty() && ! user_stop) + { + output()->recycler()->cond()->wakeOne(); + mutex()->unlock(); + output()->recycler()->cond()->wait(output()->recycler()->mutex()); + mutex()->lock (); + } + output()->recycler()->mutex()->unlock(); + } + + done = TRUE; + if (! user_stop) + { + finish = TRUE; + } + } + else + { + // error in read + error("DecoderVorbis: Error while decoding stream, File appears to be " + "corrupted"); + + finish = TRUE; + } + + mutex()->unlock(); + } + + mutex()->lock (); + + if (finish) + stat = DecoderState::Finished; + else if (user_stop) + stat = DecoderState::Stopped; + + mutex()->unlock(); + + { + /*DecoderEvent e((DecoderEvent::Type) stat); + dispatch(e);*/ + //DecoderStatus st ((DecoderStatus::Type) stat); + //emit statusChanged(st); + dispatch(DecoderState ((DecoderState::Type) stat)); + } + + deinit(); +} diff --git a/src/plugins/Input/vorbis/decoder_vorbis.h b/src/plugins/Input/vorbis/decoder_vorbis.h new file mode 100644 index 000000000..091d856ff --- /dev/null +++ b/src/plugins/Input/vorbis/decoder_vorbis.h @@ -0,0 +1,63 @@ +// Copyright (c) 2000-2001 Brad Hughes +// +// Use, modification and distribution is allowed without limitation, +// warranty, or liability of any kind. +// + +#ifndef __decoder_vorbis_h +#define __decoder_vorbis_h + +#include "decoder.h" + +#include + + +class DecoderVorbis : public Decoder +{ +public: + DecoderVorbis(QObject *, DecoderFactory *, QIODevice *, Output *); + virtual ~DecoderVorbis(); + + // Standard Decoder API + bool initialize(); + double lengthInSeconds(); + void seek(double); + void stop(); + + // Equalizer + bool isEQSupported() const { return FALSE; } + void setEQEnabled(bool) { ; } + void setEQGain(int) { ; } + void setEQBands(int[10]) { ; } + + +private: + // thread run function + void run(); + + // helper functions + void flush(bool = FALSE); + void deinit(); + + void updateTags(); + + bool inited, user_stop; + int stat; + + // output buffer + char *output_buf; + ulong output_bytes, output_at; + + // OggVorbis Decoder + OggVorbis_File oggfile; + + unsigned int bks; + bool done, finish; + long len, freq, bitrate; + int chan; + unsigned long output_size; + double totalTime, seekTime; +}; + + +#endif // __decoder_vorbis_h diff --git a/src/plugins/Input/vorbis/decodervorbisfactory.cpp b/src/plugins/Input/vorbis/decodervorbisfactory.cpp new file mode 100644 index 000000000..c3b31ec52 --- /dev/null +++ b/src/plugins/Input/vorbis/decodervorbisfactory.cpp @@ -0,0 +1,105 @@ +#include +#include +#include +#include + +#include "detailsdialog.h" +#include "decoder_vorbis.h" +#include "decodervorbisfactory.h" + + +// DecoderOggFactory + +bool DecoderVorbisFactory::supports(const QString &source) const +{ + return source.right(4).toLower() == ".ogg"; +} + +bool DecoderVorbisFactory::canDecode(QIODevice *input) const +{ + char buf[36]; + if (input->peek(buf, 36) == 36 && !memcmp(buf, "OggS", 4) + && !memcmp(buf + 29, "vorbis", 6)) + return TRUE; + + return FALSE; +} + +const DecoderProperties DecoderVorbisFactory::properties() const +{ + DecoderProperties properties; + properties.name = tr("Ogg Vorbis Plugin"); + properties.filter = "*.ogg"; + properties.description = tr("Ogg Vorbis Files"); + properties.contentType = "application/ogg;audio/x-vorbis+ogg"; + properties.hasAbout = TRUE; + properties.hasSettings = FALSE; + return properties; +} + +Decoder *DecoderVorbisFactory::create(QObject *parent, QIODevice *input, + Output *output) +{ + return new DecoderVorbis(parent, this, input, output); +} + +FileTag *DecoderVorbisFactory::createTag(const QString &source) +{ + FileTag *ftag = new FileTag(); + + TagLib::FileRef fileRef(source.toLocal8Bit ()); + TagLib::Tag *tag = fileRef.tag(); + + if (tag && !tag->isEmpty()) + { + ftag->setValue(FileTag::ALBUM, + QString::fromUtf8(tag->album().toCString(TRUE)).trimmed()); + ftag->setValue(FileTag::ARTIST, + QString::fromUtf8(tag->artist().toCString(TRUE)).trimmed()); + ftag->setValue(FileTag::COMMENT, + QString::fromUtf8(tag->comment().toCString(TRUE)).trimmed()); + ftag->setValue(FileTag::GENRE, + QString::fromUtf8(tag->genre().toCString(TRUE)).trimmed()); + ftag->setValue(FileTag::TITLE, + QString::fromUtf8(tag->title().toCString(TRUE)).trimmed()); + ftag->setValue(FileTag::YEAR, tag->year()); + ftag->setValue(FileTag::TRACK, tag->track()); + } + + if (fileRef.audioProperties()) + ftag->setValue(FileTag::LENGTH, fileRef.audioProperties()->length()); + + return ftag; +} + +QObject* DecoderVorbisFactory::showDetails(QWidget *parent, const QString &path) +{ + DetailsDialog *d = new DetailsDialog(parent, path); + d -> show(); + return d; +} + +void DecoderVorbisFactory::showSettings(QWidget *) +{ + /*SettingsDialog *s = new SettingsDialog(parent); + s -> show();*/ +} + +void DecoderVorbisFactory::showAbout(QWidget *parent) +{ + QMessageBox::about (parent, tr("About Ogg Vorbis Audio Plugin"), + tr("Qmmp Ogg Vorbis Audio Plugin")+"\n"+ + tr("Writen by: Ilya Kotov ")+"\n"+ + tr("Source code based on mq3 progect") + ); +} + +QTranslator *DecoderVorbisFactory::createTranslator(QObject *parent) +{ + QTranslator *translator = new QTranslator(parent); + QString locale = QLocale::system().name(); + translator->load(QString(":/vorbis_plugin_") + locale); + return translator; +} + +Q_EXPORT_PLUGIN(DecoderVorbisFactory) diff --git a/src/plugins/Input/vorbis/decodervorbisfactory.h b/src/plugins/Input/vorbis/decodervorbisfactory.h new file mode 100644 index 000000000..6830fc102 --- /dev/null +++ b/src/plugins/Input/vorbis/decodervorbisfactory.h @@ -0,0 +1,54 @@ +/*************************************************************************** + * Copyright (C) 2006 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 DECODERVORBISFACTORY_H +#define DECODERVORBISFACTORY_H + +#include +#include +#include +#include + +#include +#include +#include +#include + + + + +class DecoderVorbisFactory : 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 *); + FileTag *createTag(const QString &source); + 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/vorbis/detailsdialog.cpp b/src/plugins/Input/vorbis/detailsdialog.cpp new file mode 100644 index 000000000..bbe441703 --- /dev/null +++ b/src/plugins/Input/vorbis/detailsdialog.cpp @@ -0,0 +1,120 @@ +/*************************************************************************** + * Copyright (C) 2007 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 +#include +#include + +#include +#include + +#include "detailsdialog.h" + +#define QStringToTString_qt4(s) TagLib::String(s.toUtf8().constData(), TagLib::String::UTF8) + +DetailsDialog::DetailsDialog(QWidget *parent, const QString &path) + : QDialog(parent) +{ + ui.setupUi(this); + setAttribute(Qt::WA_DeleteOnClose); + m_path = path; + setWindowTitle (path.section('/',-1)); + path.section('/',-1); + ui.pathLineEdit->setText(m_path); + if(QFile::exists(m_path)) + { + loadVorbisInfo(); + loadTag(); + } +} + + +DetailsDialog::~DetailsDialog() +{} + +void DetailsDialog::loadVorbisInfo() +{ + TagLib::Ogg::Vorbis::File f (m_path.toLocal8Bit()); + //l.label + //ui. f.audioProperties()->level(); + QString text; + text = QString("%1").arg(f.audioProperties()->length()/60); + text +=":"+QString("%1").arg(f.audioProperties()->length()%60,2,10,QChar('0')); + ui.lengthLabel->setText(text); + text = QString("%1").arg(f.audioProperties()->sampleRate()); + ui.sampleRateLabel->setText(text+" "+tr("Hz")); + text = QString("%1").arg(f.audioProperties()->channels()); + ui.channelsLabel->setText(text); + text = QString("%1").arg(f.audioProperties()->bitrateNominal()); + ui.nominalLabel->setText(text+" "+tr("kbps")); + text = QString("%1").arg(f.audioProperties()->bitrateMaximum()); + ui.maximumLabel->setText(text+" "+tr("kbps")); + text = QString("%1").arg(f.audioProperties()->bitrateMinimum()); + ui.minimumLabel->setText(text+" "+tr("kbps")); + text = QString("%1 "+tr("KB")).arg(f.length()/1024); + ui.fileSizeLabel->setText(text); + +} + +void DetailsDialog::loadTag() +{ + TagLib::FileRef f (m_path.toLocal8Bit()); + + if (f.tag()) + { //TODO: load codec name from config + + TagLib::String title = f.tag()->title(); + TagLib::String artist = f.tag()->artist(); + TagLib::String album = f.tag()->album(); + TagLib::String comment = f.tag()->comment(); + TagLib::String genre = f.tag()->genre(); + QString string = QString::fromUtf8(title.toCString(TRUE)).trimmed(); + ui.titleLineEdit->setText(string); + string = QString::fromUtf8(artist.toCString(TRUE)).trimmed(); + ui.artistLineEdit->setText(string); + string = QString::fromUtf8(album.toCString(TRUE)).trimmed(); + ui.albumLineEdit->setText(string); + string = QString::fromUtf8(comment.toCString(TRUE)).trimmed(); + ui.commentLineEdit->setText(string); + string = QString("%1").arg(f.tag()->year()); + ui.yearLineEdit->setText(string); + string = QString("%1").arg(f.tag()->track()); + ui.trackLineEdit->setText(string); + string = QString::fromUtf8(genre.toCString(TRUE)).trimmed(); + ui.genreLineEdit->setText(string); + } + QFileInfo info(m_path); + ui.saveButton->setEnabled(info.isWritable()); + connect(ui.saveButton, SIGNAL(clicked()), SLOT(saveTag())); +} + +void DetailsDialog::saveTag() +{ + TagLib::FileRef f (m_path.toLocal8Bit()); + + f.tag()->setTitle(QStringToTString_qt4(ui.titleLineEdit->text())); + f.tag()->setArtist(QStringToTString_qt4(ui.artistLineEdit->text())); + f.tag()->setAlbum(QStringToTString_qt4(ui.albumLineEdit->text())); + f.tag()->setComment(QStringToTString_qt4(ui.commentLineEdit->text())); + f.tag()->setGenre(QStringToTString_qt4(ui.genreLineEdit->text())); + f.tag()->setYear(ui.yearLineEdit->text().toUInt()); + f.tag()->setTrack(ui.trackLineEdit->text().toUInt()); + + f.save(); +} diff --git a/src/plugins/Input/vorbis/detailsdialog.h b/src/plugins/Input/vorbis/detailsdialog.h new file mode 100644 index 000000000..94d4243b8 --- /dev/null +++ b/src/plugins/Input/vorbis/detailsdialog.h @@ -0,0 +1,49 @@ +/*************************************************************************** + * Copyright (C) 2007 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 DETAILSDIALOG_H +#define DETAILSDIALOG_H + +#include + +#include "ui_detailsdialog.h" + +/** + @author Ilya Kotov +*/ +class DetailsDialog : public QDialog +{ +Q_OBJECT +public: + DetailsDialog(QWidget *parent = 0, const QString &path = 0); + + ~DetailsDialog(); + +private slots: + void saveTag(); + +private: + void loadVorbisInfo(); + void loadTag(); + Ui::DetailsDialog ui; + QString m_path; + +}; + +#endif diff --git a/src/plugins/Input/vorbis/detailsdialog.ui b/src/plugins/Input/vorbis/detailsdialog.ui new file mode 100644 index 000000000..1804ab268 --- /dev/null +++ b/src/plugins/Input/vorbis/detailsdialog.ui @@ -0,0 +1,384 @@ + + DetailsDialog + + + + 0 + 0 + 536 + 375 + + + + Details + + + + 8 + + + 6 + + + + + + 220 + 16 + + + + Ogg Vorbis Info + + + + 8 + + + 6 + + + + + - + + + + + + + Qt::LeftToRight + + + - + + + + + + + Length: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + - + + + + + + + Sample rate: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + - + + + + + + + Qt::LeftToRight + + + Channels: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Bit Rate + + + Qt::AlignHCenter + + + + 8 + + + 6 + + + + + - + + + + + + + - + + + + + + + Qt::LeftToRight + + + Minimum: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + - + + + + + + + Maximum: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Nominal: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + File size: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + true + + + + + + + File path: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Close + + + + + + + Qt::Horizontal + + + + 111 + 20 + + + + + + + + + 5 + 5 + 0 + 0 + + + + Ogg Vorbis Tag + + + + 8 + + + 6 + + + + + false + + + Save + + + + + + + + + + Track number: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Year: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Genre: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Comment: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Album: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Artist: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Title: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + + + + + + + + + + + + + + pushButton_3 + clicked() + DetailsDialog + close() + + + 623 + 353 + + + 539 + 352 + + + + + diff --git a/src/plugins/Input/vorbis/translations/translations.qrc b/src/plugins/Input/vorbis/translations/translations.qrc new file mode 100644 index 000000000..c5cacdfb0 --- /dev/null +++ b/src/plugins/Input/vorbis/translations/translations.qrc @@ -0,0 +1,6 @@ + + + + vorbis_plugin_ru.qm + + diff --git a/src/plugins/Input/vorbis/translations/vorbis_plugin_ru.qm b/src/plugins/Input/vorbis/translations/vorbis_plugin_ru.qm new file mode 100644 index 000000000..a6a3a77b7 Binary files /dev/null and b/src/plugins/Input/vorbis/translations/vorbis_plugin_ru.qm differ diff --git a/src/plugins/Input/vorbis/translations/vorbis_plugin_ru.ts b/src/plugins/Input/vorbis/translations/vorbis_plugin_ru.ts new file mode 100644 index 000000000..16cf81ea3 --- /dev/null +++ b/src/plugins/Input/vorbis/translations/vorbis_plugin_ru.ts @@ -0,0 +1,164 @@ + + + + DecoderVorbisFactory + + + Ogg Vorbis Plugin + Модуль Ogg Vorbis + + + + Ogg Vorbis Files + Файлы Ogg Vorbis + + + + About Ogg Vorbis Audio Plugin + Об аудио-модуле Ogg Vorbis + + + + Qmmp Ogg Vorbis Audio Plugin + Аудио-модуль Ogg Vorbis для Qmmp + + + + Writen by: Ilya Kotov <forkotov02@hotmail.ru> + Разработчик: Илья Котов <forkotov02@hotmail.ru> + + + + Source code based on mq3 progect + Исходный код основан на проекте mq3 + + + + DetailsDialog + + + Hz + Гц + + + + Save + Сохранить + + + + Track number: + Номер трека: + + + + Year: + Год: + + + + Genre: + Жанр: + + + + Comment: + Комментарий: + + + + Album: + Альбом: + + + + Artist: + Исполнитель: + + + + Title: + Название: + + + + Close + Закрыть + + + + - + + + + + File size: + Размер файла: + + + + Sample rate: + Дискретизация: + + + + File path: + Путь к файлу: + + + + Ogg Vorbis Info + Информация Ogg Vorbis + + + + Length: + Длительность: + + + + Channels: + Каналов: + + + + Bit Rate + Битовая частота + + + + Minimum: + Минимальная: + + + + Maximum: + Максимальная: + + + + Nominal: + Номинальная: + + + + Ogg Vorbis Tag + Оgg Vorbis-тег + + + + kbps + Кб/с + + + + KB + Кб + + + + Details + Информация + + + diff --git a/src/plugins/Input/vorbis/vorbis.pro b/src/plugins/Input/vorbis/vorbis.pro new file mode 100644 index 000000000..afd7b6510 --- /dev/null +++ b/src/plugins/Input/vorbis/vorbis.pro @@ -0,0 +1,35 @@ +# ???? ?????? ? KDevelop ?????????? qmake. +# ------------------------------------------- +# ?????????? ???????????? ???????? ???????? ???????: ./Plugins/Input/ogg +# ???? - ??????????: + +include(../../plugins.pri) + +FORMS += detailsdialog.ui +HEADERS += decodervorbisfactory.h \ + decoder_vorbis.h \ + detailsdialog.h +SOURCES += decoder_vorbis.cpp \ + decodervorbisfactory.cpp \ + detailsdialog.cpp + +TARGET=$$PLUGINS_PREFIX/Input/vorbis +QMAKE_CLEAN =$$PLUGINS_PREFIX/Input/libvorbis.so + +INCLUDEPATH += ../../../qmmp +CONFIG += release \ +warn_on \ +plugin \ +link_pkgconfig +TEMPLATE = lib +QMAKE_LIBDIR += ../../../../lib +LIBS += -lqmmp -L/usr/lib +PKGCONFIG += taglib ogg vorbisfile vorbis +#TRANSLATIONS = translations/vorbis_plugin_ru.ts +#RESOURCES = translations/translations.qrc + +isEmpty (LIB_DIR){ +LIB_DIR = /lib +} +target.path = $$LIB_DIR/qmmp/Input +INSTALLS += target -- cgit v1.2.3-13-gbd6f