#include "QMediaInfo.h"
#include "MediaInfoDLL.h"

#include <QDebug>

QMediaInfo::QMediaInfo(QObject *parent){}

enum QMediaInfo::HDR_Type QMediaInfo::getHDRType(MediaInfoDLL::String fileName) {
    if (Open(fileName)) {
       MediaInfoDLL::String HDRtext = Get(MediaInfoDLL::Stream_Video, 0, __T("HDR_Format"), MediaInfoDLL::Info_Text, MediaInfoDLL::Info_Name);
       Close();

       uint32_t position =  HDRtext.find(__T("Dolby Vision"));

       if (HDRtext.length()) {
           return (position >= 0 && position < HDRtext.length()) ? DOVI : HDR;
       } else {
           return SDR;
       }
    }
    return ERR;
}

enum QMediaInfo::HDR_Type QMediaInfo::getHDRType(const QString fileName) {
    #ifdef linux
    return getHDRType(fileName.toStdString());
    #else
    return getHDRType(fileName.toStdWString());
#endif
}

QString QMediaInfo::fixFileName(QString fileName) {
    #ifdef linux
    return fileName.remove(0, 7);
    #else
    return fileName.remove(0, 8);
    #endif
}
