Fixed copilot comments
This commit is contained in:
@@ -57,26 +57,29 @@ namespace lms::audio::taglib
|
|||||||
AudioProperties computeAudioProperties(const ::TagLib::File& file)
|
AudioProperties computeAudioProperties(const ::TagLib::File& file)
|
||||||
{
|
{
|
||||||
assert(file.audioProperties());
|
assert(file.audioProperties());
|
||||||
const ::TagLib::AudioProperties& properties{ *file.audioProperties() };
|
|
||||||
|
|
||||||
AudioProperties audioProperties;
|
AudioProperties audioProperties;
|
||||||
|
|
||||||
// Common properties
|
{
|
||||||
audioProperties.bitrate = static_cast<std::size_t>(properties.bitrate() * 1000);
|
const ::TagLib::AudioProperties& properties{ *file.audioProperties() };
|
||||||
if (audioProperties.bitrate == 0)
|
|
||||||
throw AudioFileParsingException{ "Cannot determine bitrate" };
|
|
||||||
|
|
||||||
audioProperties.channelCount = static_cast<std::size_t>(properties.channels());
|
// Common properties
|
||||||
if (audioProperties.channelCount == 0)
|
audioProperties.bitrate = static_cast<std::size_t>(properties.bitrate() * 1000);
|
||||||
throw AudioFileParsingException{ "Cannot determine channel count" };
|
if (audioProperties.bitrate == 0)
|
||||||
|
throw AudioFileParsingException{ "Cannot determine bitrate" };
|
||||||
|
|
||||||
audioProperties.duration = std::chrono::milliseconds{ properties.lengthInMilliseconds() };
|
audioProperties.channelCount = static_cast<std::size_t>(properties.channels());
|
||||||
if (audioProperties.duration == decltype(audioProperties.duration)::zero())
|
if (audioProperties.channelCount == 0)
|
||||||
throw AudioFileParsingException{ "Cannot determine duration" };
|
throw AudioFileParsingException{ "Cannot determine channel count" };
|
||||||
|
|
||||||
audioProperties.sampleRate = static_cast<std::size_t>(properties.sampleRate());
|
audioProperties.duration = std::chrono::milliseconds{ properties.lengthInMilliseconds() };
|
||||||
if (audioProperties.sampleRate == 0)
|
if (audioProperties.duration == decltype(audioProperties.duration)::zero())
|
||||||
throw AudioFileParsingException{ "Cannot determine sample rate" };
|
throw AudioFileParsingException{ "Cannot determine duration" };
|
||||||
|
|
||||||
|
audioProperties.sampleRate = static_cast<std::size_t>(properties.sampleRate());
|
||||||
|
if (audioProperties.sampleRate == 0)
|
||||||
|
throw AudioFileParsingException{ "Cannot determine sample rate" };
|
||||||
|
}
|
||||||
|
|
||||||
// Guess container from the file type
|
// Guess container from the file type
|
||||||
if (const auto* apeFile{ dynamic_cast<const ::TagLib::APE::File*>(&file) })
|
if (const auto* apeFile{ dynamic_cast<const ::TagLib::APE::File*>(&file) })
|
||||||
@@ -104,7 +107,7 @@ namespace lms::audio::taglib
|
|||||||
audioProperties.codec = CodecType::WMA9Pro;
|
audioProperties.codec = CodecType::WMA9Pro;
|
||||||
break;
|
break;
|
||||||
case ::TagLib::ASF::Properties::Codec::Unknown:
|
case ::TagLib::ASF::Properties::Codec::Unknown:
|
||||||
throw AudioFileParsingException{ "Unhandled ASF codec type" };
|
throw AudioFileParsingException{ "Unhandled ASF codec" };
|
||||||
}
|
}
|
||||||
|
|
||||||
audioProperties.bitsPerSample = asfFile->audioProperties()->bitsPerSample();
|
audioProperties.bitsPerSample = asfFile->audioProperties()->bitsPerSample();
|
||||||
@@ -135,7 +138,7 @@ namespace lms::audio::taglib
|
|||||||
audioProperties.codec = CodecType::ALAC;
|
audioProperties.codec = CodecType::ALAC;
|
||||||
break;
|
break;
|
||||||
case ::TagLib::MP4::Properties::Codec::Unknown:
|
case ::TagLib::MP4::Properties::Codec::Unknown:
|
||||||
throw AudioFileParsingException{ "Unhandled MP4 codec type" };
|
throw AudioFileParsingException{ "Unhandled MP4 codec" };
|
||||||
}
|
}
|
||||||
|
|
||||||
audioProperties.bitsPerSample = mp4File->audioProperties()->bitsPerSample();
|
audioProperties.bitsPerSample = mp4File->audioProperties()->bitsPerSample();
|
||||||
@@ -152,6 +155,8 @@ namespace lms::audio::taglib
|
|||||||
case 8:
|
case 8:
|
||||||
audioProperties.codec = CodecType::MPC8;
|
audioProperties.codec = CodecType::MPC8;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
throw AudioFileParsingException{ "Unhandled MPC codec" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (const auto* mpegFile{ dynamic_cast<const ::TagLib::MPEG::File*>(&file) })
|
else if (const auto* mpegFile{ dynamic_cast<const ::TagLib::MPEG::File*>(&file) })
|
||||||
@@ -166,6 +171,8 @@ namespace lms::audio::taglib
|
|||||||
else if (mpegFile->audioProperties()->isADTS()) // likely AAC
|
else if (mpegFile->audioProperties()->isADTS()) // likely AAC
|
||||||
audioProperties.codec = CodecType::AAC;
|
audioProperties.codec = CodecType::AAC;
|
||||||
#endif
|
#endif
|
||||||
|
else
|
||||||
|
throw AudioFileParsingException{ "Unhandled MPEG codec" };
|
||||||
}
|
}
|
||||||
else if (dynamic_cast<const ::TagLib::Ogg::Opus::File*>(&file))
|
else if (dynamic_cast<const ::TagLib::Ogg::Opus::File*>(&file))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,11 +23,9 @@
|
|||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
// #include "AudioTypes.hpp"
|
|
||||||
|
|
||||||
namespace lms::audio
|
namespace lms::audio
|
||||||
{
|
{
|
||||||
// TODO deprecated
|
// TODO deprecate?
|
||||||
enum class OutputFormat
|
enum class OutputFormat
|
||||||
{
|
{
|
||||||
MP3,
|
MP3,
|
||||||
|
|||||||
@@ -44,8 +44,6 @@ namespace lms::transcoding
|
|||||||
public:
|
public:
|
||||||
virtual ~ITranscodeService() = default;
|
virtual ~ITranscodeService() = default;
|
||||||
|
|
||||||
// virtual std::unique_ptr<IAudioFileInfo> parseAudioFileInfo(const std::filesystem::path& p) const = 0;
|
|
||||||
|
|
||||||
virtual std::unique_ptr<core::IResourceHandler> createTranscodeResourceHandler(const audio::TranscodeParameters& parameters, bool estimateContentLength = false) = 0;
|
virtual std::unique_ptr<core::IResourceHandler> createTranscodeResourceHandler(const audio::TranscodeParameters& parameters, bool estimateContentLength = false) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user