Make ffmpeg optional.
This commit is contained in:
		@@ -18,8 +18,12 @@ HEADERS += \
 | 
			
		||||
           singlecoreapplication.h \
 | 
			
		||||
           headlessmanager.h
 | 
			
		||||
 | 
			
		||||
DISABLE_FFMPEG {
 | 
			
		||||
    PKGCONFIG = libvitamtp
 | 
			
		||||
} else {
 | 
			
		||||
    # find packages using pkg-config
 | 
			
		||||
    PKGCONFIG = libvitamtp libavformat libavcodec libavutil libswscale
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
# Linux-only config
 | 
			
		||||
unix:!macx {
 | 
			
		||||
    man_cli.files = qcma_cli.1
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,6 @@
 | 
			
		||||
 | 
			
		||||
#include "cmaclient.h"
 | 
			
		||||
#include "capability.h"
 | 
			
		||||
#include "avdecoder.h"
 | 
			
		||||
#include "cmaevent.h"
 | 
			
		||||
#include "cmautils.h"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,6 @@
 | 
			
		||||
 | 
			
		||||
#include "cmaobject.h"
 | 
			
		||||
#include "sforeader.h"
 | 
			
		||||
#include "avdecoder.h"
 | 
			
		||||
#include "database.h"
 | 
			
		||||
#include "cmautils.h"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,10 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "cmautils.h"
 | 
			
		||||
 | 
			
		||||
#ifdef FFMPEG_ENABLED
 | 
			
		||||
#include "avdecoder.h"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <QBuffer>
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
@@ -100,6 +103,11 @@ bool removeRecursively(const QString &path)
 | 
			
		||||
static QByteArray findFolderAlbumArt(const QString path, metadata_t *metadata)
 | 
			
		||||
{
 | 
			
		||||
    QByteArray data;
 | 
			
		||||
 | 
			
		||||
#ifndef FFMPEG_ENABLED
 | 
			
		||||
    Q_UNUSED(path);
 | 
			
		||||
    Q_UNUSED(metadata);
 | 
			
		||||
#else
 | 
			
		||||
    QDir folder(path);
 | 
			
		||||
 | 
			
		||||
    QStringList files = folder.entryList(QDir::Files | QDir::Readable);
 | 
			
		||||
@@ -124,6 +132,7 @@ static QByteArray findFolderAlbumArt(const QString path, metadata_t *metadata)
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
    return data;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -137,6 +146,11 @@ QByteArray getThumbnail(const QString &path, DataType type, metadata_t *metadata
 | 
			
		||||
        if(file.open(QIODevice::ReadOnly)) {
 | 
			
		||||
            data = file.readAll();
 | 
			
		||||
        }
 | 
			
		||||
#ifndef FFMPEG_ENABLED
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Q_UNUSED(metadata);
 | 
			
		||||
#else
 | 
			
		||||
    } else if(MASK_SET(type, Photo)) {
 | 
			
		||||
        AVDecoder decoder;
 | 
			
		||||
 | 
			
		||||
@@ -173,6 +187,7 @@ QByteArray getThumbnail(const QString &path, DataType type, metadata_t *metadata
 | 
			
		||||
            metadata->data.thumbnail.height = height;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
    return data;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,6 @@ SOURCES += \
 | 
			
		||||
    sforeader.cpp \
 | 
			
		||||
    cmaclient.cpp \
 | 
			
		||||
    cmabroadcast.cpp \
 | 
			
		||||
    avdecoder.cpp \
 | 
			
		||||
    cmaevent.cpp \
 | 
			
		||||
    dds.cpp \
 | 
			
		||||
    sqlitedb.cpp \
 | 
			
		||||
@@ -37,9 +36,15 @@ HEADERS += \
 | 
			
		||||
    qlistdb.h \
 | 
			
		||||
    database.h
 | 
			
		||||
 | 
			
		||||
DISABLE_FFMPEG {
 | 
			
		||||
    PKGCONFIG = libvitamtp
 | 
			
		||||
} else {
 | 
			
		||||
    DEFINES += FFMPEG_ENABLED
 | 
			
		||||
    SOURCES += avdecoder.cpp
 | 
			
		||||
    PKGCONFIG = libvitamtp libavformat libavcodec libavutil libswscale
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
OTHER_FILES += \
 | 
			
		||||
    resources/xml/psp2-updatelist.xml
 | 
			
		||||
 | 
			
		||||
RESOURCES += commonrc.qrc translations.qrc
 | 
			
		||||
 | 
			
		||||
PKGCONFIG = libvitamtp libavformat libavcodec libavutil libswscale
 | 
			
		||||
 
 | 
			
		||||
@@ -18,13 +18,18 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "database.h"
 | 
			
		||||
 | 
			
		||||
#ifdef FFMPEG_ENABLED
 | 
			
		||||
#include "avdecoder.h"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
#include <QSettings>
 | 
			
		||||
#include <QTextStream>
 | 
			
		||||
#include <QThread>
 | 
			
		||||
 | 
			
		||||
#include <inttypes.h>
 | 
			
		||||
 | 
			
		||||
const file_type audio_list[] = {
 | 
			
		||||
    {"mp3", FILE_FORMAT_MP3, CODEC_TYPE_MP3},
 | 
			
		||||
    {"mp4", FILE_FORMAT_MP4, CODEC_TYPE_AAC},
 | 
			
		||||
@@ -110,12 +115,17 @@ int Database::checkFileType(const QString path, int ohfi_root)
 | 
			
		||||
 | 
			
		||||
void Database::loadMusicMetadata(const QString &path, metadata_t &metadata)
 | 
			
		||||
{
 | 
			
		||||
#ifndef FFMPEG_ENABLED
 | 
			
		||||
    Q_UNUSED(path);
 | 
			
		||||
    {
 | 
			
		||||
#else
 | 
			
		||||
    AVDecoder decoder;
 | 
			
		||||
    bool skipMetadata = QSettings().value("skipMetadata", false).toBool();
 | 
			
		||||
 | 
			
		||||
    if(!skipMetadata && decoder.open(path)) {
 | 
			
		||||
        decoder.getAudioMetadata(metadata);
 | 
			
		||||
    } else {
 | 
			
		||||
#endif
 | 
			
		||||
        metadata.data.music.album = strdup("");
 | 
			
		||||
        metadata.data.music.artist = strdup("");
 | 
			
		||||
        metadata.data.music.title = strdup(metadata.name);
 | 
			
		||||
@@ -124,12 +134,17 @@ void Database::loadMusicMetadata(const QString &path, metadata_t &metadata)
 | 
			
		||||
 | 
			
		||||
void Database::loadVideoMetadata(const QString &path, metadata_t &metadata)
 | 
			
		||||
{
 | 
			
		||||
#ifndef FFMPEG_ENABLED
 | 
			
		||||
    Q_UNUSED(path);
 | 
			
		||||
    {
 | 
			
		||||
#else
 | 
			
		||||
    AVDecoder decoder;
 | 
			
		||||
    bool skipMetadata = QSettings().value("skipMetadata", false).toBool();
 | 
			
		||||
 | 
			
		||||
    if(!skipMetadata && decoder.open(path)) {
 | 
			
		||||
        decoder.getVideoMetadata(metadata);
 | 
			
		||||
    } else {
 | 
			
		||||
#endif
 | 
			
		||||
        metadata.data.video.title = strdup(metadata.name);
 | 
			
		||||
        metadata.data.video.explanation = strdup("");
 | 
			
		||||
        metadata.data.video.copyright = strdup("");
 | 
			
		||||
 
 | 
			
		||||
@@ -20,7 +20,10 @@
 | 
			
		||||
#include "cmautils.h"
 | 
			
		||||
#include "sqlitedb.h"
 | 
			
		||||
#include "sforeader.h"
 | 
			
		||||
 | 
			
		||||
#ifdef FFMPEG_ENABLED
 | 
			
		||||
#include "avdecoder.h"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <QDateTime>
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
@@ -551,6 +554,14 @@ bool SQLiteDB::insertSourceEntry(uint object_id, const QString &path, const QStr
 | 
			
		||||
 | 
			
		||||
uint SQLiteDB::insertMusicEntry(const QString &path, const QString &name, int id_parent, int type)
 | 
			
		||||
{
 | 
			
		||||
#ifndef FFMPEG_ENABLED
 | 
			
		||||
    Q_UNUSED(path);
 | 
			
		||||
    Q_UNUSED(name);
 | 
			
		||||
    Q_UNUSED(id_parent);
 | 
			
		||||
    Q_UNUSED(type);
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
#else
 | 
			
		||||
    bool ok;
 | 
			
		||||
    int ohfi;
 | 
			
		||||
    AVDecoder decoder;
 | 
			
		||||
@@ -664,10 +675,19 @@ uint SQLiteDB::insertMusicEntry(const QString &path, const QString &name, int id
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return ohfi;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint SQLiteDB::insertVideoEntry(const QString &path, const QString &name, int id_parent, int type)
 | 
			
		||||
{
 | 
			
		||||
#ifndef FFMPEG_ENABLED
 | 
			
		||||
    Q_UNUSED(path);
 | 
			
		||||
    Q_UNUSED(name);
 | 
			
		||||
    Q_UNUSED(id_parent);
 | 
			
		||||
    Q_UNUSED(type);
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
#else
 | 
			
		||||
    int ohfi;
 | 
			
		||||
    AVDecoder decoder;
 | 
			
		||||
    quint64 duration;
 | 
			
		||||
@@ -735,6 +755,7 @@ uint SQLiteDB::insertVideoEntry(const QString &path, const QString &name, int id
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return ohfi;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint SQLiteDB::insertPhotoEntry(const QString &path, const QString &name, int id_parent, int type)
 | 
			
		||||
 
 | 
			
		||||
@@ -53,8 +53,12 @@ OTHER_FILES += \
 | 
			
		||||
 | 
			
		||||
RESOURCES += gui.qrc
 | 
			
		||||
 | 
			
		||||
DISABLE_FFMPEG {
 | 
			
		||||
    PKGCONFIG = libvitamtp
 | 
			
		||||
} else {
 | 
			
		||||
    # find packages using pkg-config
 | 
			
		||||
    PKGCONFIG = libvitamtp libavformat libavcodec libavutil libswscale
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#Linux-only config
 | 
			
		||||
unix:!macx {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user