Audio file metadata and thumbnails
This commit is contained in:
+43
-28
@@ -8,10 +8,10 @@
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
|
||||
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
|
||||
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@@ -21,16 +21,16 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include "json.hpp"
|
||||
|
||||
|
||||
namespace pipedal
|
||||
{
|
||||
|
||||
namespace pipedal {
|
||||
#define GETTER_SETTER_REF(name) \
|
||||
const decltype(name##_) &name() const { return name##_; } \
|
||||
void name(const decltype(name##_) &value) { name##_ = value; }
|
||||
@@ -46,41 +46,56 @@ namespace pipedal
|
||||
decltype(name##_) name() const { return name##_; } \
|
||||
void name(decltype(name##_) value) { name##_ = value; }
|
||||
|
||||
|
||||
enum ThumbnailType
|
||||
{
|
||||
Unknown = 0,
|
||||
Embedded = 1, // embedded in the file
|
||||
Folder = 2, // from a albumArt.jpg or similar
|
||||
None = 3 // Use default thumbnail.
|
||||
};
|
||||
|
||||
class AudioFileMetadata
|
||||
{
|
||||
private:
|
||||
float duration_ = 0;
|
||||
std::string fileName_;
|
||||
int64_t lastModified_ = 0;
|
||||
std::string title_;
|
||||
std::string track_;
|
||||
int32_t track_ = -1; // track number, 0-based, -1 if not set
|
||||
std::string album_;
|
||||
std::string disc_;
|
||||
std::string artist_;
|
||||
std::string albumArtist_;
|
||||
std::string totalTracks_;
|
||||
std::string date_;
|
||||
std::string year_;
|
||||
float duration_ = 0;
|
||||
int32_t thumbnailType_ = 0; // 0 = unknown, 1 = embedded, 3 = folder, 4 = none
|
||||
std::string thumbnailFile_; // only when thumbnailType is 3= folder.
|
||||
int64_t thumbnailLastModified_ = 0;
|
||||
int32_t position_ = -1;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
AudioFileMetadata() = default;
|
||||
AudioFileMetadata(const std::filesystem::path &file);
|
||||
|
||||
GETTER_SETTER(duration);
|
||||
GETTER_SETTER_REF(title);
|
||||
GETTER_SETTER_REF(track);
|
||||
GETTER_SETTER_REF(album);
|
||||
GETTER_SETTER_REF(disc);
|
||||
GETTER_SETTER_REF(artist);
|
||||
GETTER_SETTER_REF(albumArtist);
|
||||
GETTER_SETTER(fileName)
|
||||
GETTER_SETTER(lastModified)
|
||||
GETTER_SETTER_REF(title)
|
||||
GETTER_SETTER_REF(track)
|
||||
GETTER_SETTER_REF(album)
|
||||
GETTER_SETTER(duration)
|
||||
ThumbnailType thumbnailType() const { return (ThumbnailType)thumbnailType_;}
|
||||
void thumbnailType(ThumbnailType value) { thumbnailType_ = (int32_t)value; }
|
||||
GETTER_SETTER(thumbnailFile)
|
||||
GETTER_SETTER(thumbnailLastModified)
|
||||
GETTER_SETTER(position)
|
||||
|
||||
|
||||
public:
|
||||
DECLARE_JSON_MAP(AudioFileMetadata);
|
||||
|
||||
};
|
||||
|
||||
std::string GetAudioFileMetadataString(const std::filesystem::path &path);
|
||||
|
||||
#undef GETTER_SETTER
|
||||
#undef GETTER_SETTER_VEC
|
||||
#undef GETTER_SETTER_REF
|
||||
#undef GETTER_SETTER
|
||||
#undef GETTER_SETTER_VEC
|
||||
#undef GETTER_SETTER_REF
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user