Factorized some container/codec handling code + removed the no longer needed transcode output formats mka and webm

This commit is contained in:
emeric
2025-11-30 18:48:04 +01:00
parent c3cd30f248
commit d834f34683
65 changed files with 1424 additions and 1003 deletions
+74
View File
@@ -0,0 +1,74 @@
/*
* Copyright (C) 2025 Emeric Poupon
*
* This file is part of LMS.
*
* LMS 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 3 of the License, or
* (at your option) any later version.
*
* LMS 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 LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include "core/media/CodecType.hpp"
namespace lms::core::media
{
core::LiteralString codecTypeToString(CodecType type)
{
switch (type)
{
case CodecType::AAC:
return "AAC";
case CodecType::AC3:
return "AC3";
case CodecType::ALAC:
return "ALAC";
case CodecType::APE:
return "APE";
case CodecType::DSD:
return "DSD";
case CodecType::EAC3:
return "E-AC3";
case CodecType::FLAC:
return "FLAC";
case CodecType::MP3:
return "MP3";
case CodecType::MP4ALS:
return "MP4ALS";
case CodecType::MPC7:
return "MPC7";
case CodecType::MPC8:
return "MPC8";
case CodecType::Opus:
return "Opus";
case CodecType::PCM:
return "PCM";
case CodecType::Shorten:
return "Shorten";
case CodecType::TrueAudio:
return "TrueAudio";
case CodecType::Vorbis:
return "Vorbis";
case CodecType::WavPack:
return "WavPack";
case CodecType::WMA1:
return "WMA1";
case CodecType::WMA2:
return "WMA2";
case CodecType::WMA9Pro:
return "WMA9Pro";
case CodecType::WMA9Lossless:
return "WMA9Lossless";
}
return "Unknown";
}
} // namespace lms::core::media
@@ -0,0 +1,58 @@
/*
* Copyright (C) 2025 Emeric Poupon
*
* This file is part of LMS.
*
* LMS 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 3 of the License, or
* (at your option) any later version.
*
* LMS 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 LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include "core/media/ContainerType.hpp"
namespace lms::core::media
{
core::LiteralString containerTypeToString(ContainerType type)
{
switch (type)
{
case ContainerType::AIFF:
return "AIFF";
case ContainerType::APE:
return "APE";
case ContainerType::ASF:
return "ASF";
case ContainerType::DSF:
return "DSF";
case ContainerType::FLAC:
return "FLAC";
case ContainerType::MP4:
return "MP4";
case ContainerType::MPC:
return "MPC";
case ContainerType::MPEG:
return "MPEG";
case ContainerType::Ogg:
return "Ogg";
case ContainerType::Shorten:
return "Shorten";
case ContainerType::TrueAudio:
return "TrueAudio";
case ContainerType::WAV:
return "WAV";
case ContainerType::WavPack:
return "WavPack";
}
return "Unknown";
}
} // namespace lms::core::media
+76
View File
@@ -0,0 +1,76 @@
/*
* Copyright (C) 2025 Emeric Poupon
*
* This file is part of LMS.
*
* LMS 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 3 of the License, or
* (at your option) any later version.
*
* LMS 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 LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include "core/media/ImageType.hpp"
namespace lms::core::media
{
core::LiteralString imageTypeToString(ImageType type)
{
switch (type)
{
case ImageType::Other:
return "Other";
case ImageType::FileIcon:
return "FileIcon";
case ImageType::OtherFileIcon:
return "OtherFileIcon";
case ImageType::FrontCover:
return "FrontCover";
case ImageType::BackCover:
return "BackCover";
case ImageType::LeafletPage:
return "LeafletPage";
case ImageType::Media:
return "Media";
case ImageType::LeadArtist:
return "LeadArtist";
case ImageType::Artist:
return "Artist";
case ImageType::Conductor:
return "Conductor";
case ImageType::Band:
return "Band";
case ImageType::Composer:
return "Composer";
case ImageType::Lyricist:
return "Lyricist";
case ImageType::RecordingLocation:
return "RecordingLocation";
case ImageType::DuringRecording:
return "DuringRecording";
case ImageType::DuringPerformance:
return "DuringPerformance";
case ImageType::MovieScreenCapture:
return "MovieScreenCapture";
case ImageType::ColouredFish:
return "ColouredFish";
case ImageType::Illustration:
return "Illustration";
case ImageType::BandLogo:
return "BandLogo";
case ImageType::PublisherLogo:
return "PublisherLogo";
case ImageType::Unknown:
break;
}
return "Unknown";
}
} // namespace lms::core::media
+80
View File
@@ -0,0 +1,80 @@
/*
* Copyright (C) 2025 Emeric Poupon
*
* This file is part of LMS.
*
* LMS 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 3 of the License, or
* (at your option) any later version.
*
* LMS 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 LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include "core/media/MimeType.hpp"
namespace lms::core::media
{
core::LiteralString getMimeType(ContainerType container, CodecType codec)
{
switch (container)
{
case ContainerType::AIFF:
return "audio/x-aiff";
case ContainerType::APE:
return "audio/x-monkeys-audio";
case ContainerType::ASF:
return "audio/x-ms-wma";
case ContainerType::DSF:
return "audio/x-dsd-dsf";
case ContainerType::FLAC:
return "audio/flac";
case ContainerType::MP4:
switch (codec)
{
case CodecType::AAC:
return "audio/mp4; codecs=\"mp4a.40.2\"";
case CodecType::ALAC:
return "audio/mp4; codecs=\"alac\"";
case CodecType::MP4ALS:
return "audio/mp4; codecs=\"mp4als\"";
default:
return "audio/mp4";
}
case ContainerType::MPC:
return "audio/x-musepack";
case ContainerType::MPEG:
return "audio/mpeg";
case ContainerType::Ogg:
switch (codec)
{
case CodecType::Opus:
return "audio/opus";
case CodecType::Vorbis:
return "audio/ogg; codecs=\"vorbis\"";
case CodecType::FLAC:
return "audio/ogg; codecs=\"flac\"";
default:
return "audio/ogg";
}
case ContainerType::Shorten:
return "audio/x-shn";
case ContainerType::TrueAudio:
return "audio/x-tta";
case ContainerType::WAV:
return "audio/wav";
case ContainerType::WavPack:
return "audio/x-wavpack";
}
return "application/octet-stream";
}
} // namespace lms::core::media