2012-02-11 19:12:02 +01:00
|
|
|
/*
|
2020-01-18 19:22:19 +01:00
|
|
|
* Copyright 2003-2020 The Music Player Daemon Project
|
2012-02-11 19:12:02 +01:00
|
|
|
* http://www.musicpd.org
|
|
|
|
*
|
|
|
|
* This program 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 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2017-02-08 08:26:58 +01:00
|
|
|
#include "Handler.hxx"
|
|
|
|
#include "Builder.hxx"
|
2020-01-18 20:07:09 +01:00
|
|
|
#include "pcm/AudioFormat.hxx"
|
2019-06-06 12:02:55 +02:00
|
|
|
#include "util/CharUtil.hxx"
|
|
|
|
#include "util/StringView.hxx"
|
2012-02-12 18:25:10 +01:00
|
|
|
|
2019-06-06 12:02:55 +02:00
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
void
|
|
|
|
NullTagHandler::OnTag(TagType, StringView) noexcept
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NullTagHandler::OnPair(StringView, StringView) noexcept
|
|
|
|
{
|
|
|
|
}
|
2015-10-21 08:30:33 +02:00
|
|
|
|
2019-08-12 13:27:27 +02:00
|
|
|
void
|
|
|
|
NullTagHandler::OnPicture(const char *, ConstBuffer<void>) noexcept
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-07-05 19:06:28 +02:00
|
|
|
void
|
2020-03-12 20:56:11 +01:00
|
|
|
NullTagHandler::OnAudioFormat([[maybe_unused]] AudioFormat af) noexcept
|
2018-07-05 19:06:28 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-07-05 19:07:05 +02:00
|
|
|
void
|
|
|
|
AddTagHandler::OnDuration(SongTime duration) noexcept
|
2012-02-11 19:12:02 +01:00
|
|
|
{
|
2014-08-29 22:43:36 +02:00
|
|
|
tag.SetDuration(duration);
|
2012-02-11 19:12:02 +01:00
|
|
|
}
|
|
|
|
|
2019-06-06 12:02:55 +02:00
|
|
|
/**
|
|
|
|
* Skip leading zeroes and a non-decimal suffix.
|
|
|
|
*/
|
|
|
|
static StringView
|
|
|
|
NormalizeDecimal(StringView s)
|
|
|
|
{
|
|
|
|
auto start = std::find_if(s.begin(), s.end(),
|
|
|
|
[](char ch){ return ch != '0'; });
|
|
|
|
auto end = std::find_if(start, s.end(),
|
|
|
|
[](char ch){ return !IsDigitASCII(ch); });
|
|
|
|
return {start, end};
|
|
|
|
}
|
|
|
|
|
2018-07-05 19:07:05 +02:00
|
|
|
void
|
2019-06-06 12:02:55 +02:00
|
|
|
AddTagHandler::OnTag(TagType type, StringView value) noexcept
|
2012-02-11 19:12:02 +01:00
|
|
|
{
|
2015-10-21 08:30:33 +02:00
|
|
|
if (type == TAG_TRACK || type == TAG_DISC) {
|
|
|
|
/* filter out this extra data and leading zeroes */
|
2019-06-06 12:02:55 +02:00
|
|
|
|
|
|
|
value = NormalizeDecimal(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
tag.AddItem(type, value);
|
2012-02-11 19:12:02 +01:00
|
|
|
}
|
|
|
|
|
2018-07-05 19:07:05 +02:00
|
|
|
void
|
2019-06-06 12:02:55 +02:00
|
|
|
FullTagHandler::OnPair(StringView name, StringView) noexcept
|
2012-02-12 18:25:10 +01:00
|
|
|
{
|
2019-06-06 12:02:55 +02:00
|
|
|
if (name.EqualsIgnoreCase("cuesheet"))
|
2013-09-05 19:11:50 +02:00
|
|
|
tag.SetHasPlaylist(true);
|
2012-02-12 18:25:10 +01:00
|
|
|
}
|
|
|
|
|
2018-07-06 22:46:03 +02:00
|
|
|
void
|
|
|
|
FullTagHandler::OnAudioFormat(AudioFormat af) noexcept
|
|
|
|
{
|
|
|
|
if (audio_format != nullptr)
|
|
|
|
*audio_format = af;
|
|
|
|
}
|