mirror of
https://github.com/badaix/snapcast.git
synced 2025-08-02 16:19:09 +02:00
Rename MetaTags to MetaData
This commit is contained in:
parent
607f1db77f
commit
8e1f92acb1
13 changed files with 54 additions and 62 deletions
|
@ -160,7 +160,7 @@ void AirplayStream::push()
|
|||
|
||||
if (is_cover)
|
||||
{
|
||||
setMetaData(meta_.art_data, Metatags::ArtData{data, "jpg"});
|
||||
setMetaData(meta_.art_data, Metadata::ArtData{data, "jpg"});
|
||||
// LOG(INFO, LOG_TAG) << "Metadata type: " << entry_->type << " code: " << entry_->code << " data length: " << data.length() << "\n";
|
||||
}
|
||||
else
|
||||
|
@ -179,7 +179,7 @@ void AirplayStream::push()
|
|||
if (metadata_dirty_ && entry_->type == "ssnc" && (entry_->code == "mden" || entry_->code == "pcen"))
|
||||
{
|
||||
Properties properties;
|
||||
properties.metatags = meta_;
|
||||
properties.metadata = meta_;
|
||||
setProperties(properties);
|
||||
metadata_dirty_ = false;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ protected:
|
|||
std::unique_ptr<TageEntry> entry_;
|
||||
std::string buf_;
|
||||
/// set whenever metadata_ has changed
|
||||
Metatags meta_;
|
||||
Metadata meta_;
|
||||
bool metadata_dirty_;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -158,21 +158,21 @@ void LibrespotStream::onStderrMsg(const std::string& line)
|
|||
// Patched version
|
||||
LOG(INFO, LOG_TAG) << "metadata: <" << m[1] << ">\n";
|
||||
json j = json::parse(m[1].str());
|
||||
Metatags meta;
|
||||
Metadata meta;
|
||||
meta.artist = std::vector<std::string>{j["ARTIST"].get<std::string>()};
|
||||
meta.title = j["TITLE"].get<std::string>();
|
||||
Properties properties;
|
||||
properties.metatags = meta;
|
||||
properties.metadata = std::move(meta);
|
||||
setProperties(properties);
|
||||
}
|
||||
else if (regex_search(line, m, re_track_loaded))
|
||||
{
|
||||
LOG(INFO, LOG_TAG) << "metadata: <" << m[1] << ">\n";
|
||||
Metatags meta;
|
||||
Metadata meta;
|
||||
meta.title = string(m[1]);
|
||||
meta.duration = cpt::stod(m[2]) / 1000.;
|
||||
Properties properties;
|
||||
properties.metatags = meta;
|
||||
properties.metadata = std::move(meta);
|
||||
setProperties(properties);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include "metatags.hpp"
|
||||
#include "metadata.hpp"
|
||||
|
||||
static constexpr auto LOG_TAG = "Metatags";
|
||||
static constexpr auto LOG_TAG = "Metadata";
|
||||
|
||||
|
||||
namespace
|
||||
|
@ -60,13 +60,13 @@ void addTag(json& j, const std::string& tag, const std::optional<T>& source)
|
|||
} // namespace
|
||||
|
||||
|
||||
Metatags::Metatags(const json& j)
|
||||
Metadata::Metadata(const json& j)
|
||||
{
|
||||
fromJson(j);
|
||||
}
|
||||
|
||||
|
||||
json Metatags::toJson() const
|
||||
json Metadata::toJson() const
|
||||
{
|
||||
json j(json::object());
|
||||
addTag(j, "trackId", track_id);
|
||||
|
@ -118,7 +118,7 @@ json Metatags::toJson() const
|
|||
}
|
||||
|
||||
|
||||
void Metatags::fromJson(const json& j)
|
||||
void Metadata::fromJson(const json& j)
|
||||
{
|
||||
static std::set<std::string> supported_tags = {"trackId",
|
||||
"duration",
|
||||
|
@ -217,8 +217,8 @@ void Metatags::fromJson(const json& j)
|
|||
}
|
||||
|
||||
|
||||
bool Metatags::operator==(const Metatags& other) const
|
||||
bool Metadata::operator==(const Metadata& other) const
|
||||
{
|
||||
// expensive, but not called ofetn and less typing
|
||||
// expensive, but not called often and less typing
|
||||
return (toJson() == other.toJson());
|
||||
}
|
|
@ -16,19 +16,19 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#ifndef METATAGS_HPP
|
||||
#define METATAGS_HPP
|
||||
#ifndef METADATA_HPP
|
||||
#define METADATA_HPP
|
||||
|
||||
#include "common/aixlog.hpp"
|
||||
#include "common/json.hpp"
|
||||
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include "common/aixlog.hpp"
|
||||
#include "common/json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
class Metatags
|
||||
class Metadata
|
||||
{
|
||||
public:
|
||||
struct ArtData
|
||||
|
@ -47,8 +47,8 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
Metatags() = default;
|
||||
Metatags(const json& j);
|
||||
Metadata() = default;
|
||||
Metadata(const json& j);
|
||||
|
||||
/// https://www.musicpd.org/doc/html/protocol.html#tags
|
||||
/// the duration of the song
|
||||
|
@ -143,7 +143,7 @@ public:
|
|||
|
||||
json toJson() const;
|
||||
void fromJson(const json& j);
|
||||
bool operator==(const Metatags& other) const;
|
||||
bool operator==(const Metadata& other) const;
|
||||
};
|
||||
|
||||
|
|
@ -16,11 +16,7 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <memory>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <boost/asio/ip/host_name.hpp>
|
||||
#include "pcm_stream.hpp"
|
||||
|
||||
#include "base64.h"
|
||||
#include "common/aixlog.hpp"
|
||||
|
@ -30,7 +26,12 @@
|
|||
#include "common/utils/string_utils.hpp"
|
||||
#include "control_error.hpp"
|
||||
#include "encoder/encoder_factory.hpp"
|
||||
#include "pcm_stream.hpp"
|
||||
|
||||
#include <boost/asio/ip/host_name.hpp>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <memory>
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
@ -444,20 +445,20 @@ void PcmStream::setProperties(const Properties& properties)
|
|||
Properties props = properties;
|
||||
// Missing metadata means the data didn't change, so
|
||||
// enrich the new properites with old metadata
|
||||
if (!props.metatags.has_value() && properties_.metatags.has_value())
|
||||
props.metatags = properties_.metatags;
|
||||
if (!props.metadata.has_value() && properties_.metadata.has_value())
|
||||
props.metadata = properties_.metadata;
|
||||
|
||||
// If the cover image is availbale as raw data, cache it on the HTTP Server to make it also available via HTTP
|
||||
if (props.metatags.has_value() && props.metatags->art_data.has_value() && !props.metatags->art_url.has_value())
|
||||
if (props.metadata.has_value() && props.metadata->art_data.has_value() && !props.metadata->art_url.has_value())
|
||||
{
|
||||
auto data = base64_decode(props.metatags->art_data.value().data);
|
||||
auto md5 = server_settings_.http.image_cache.setImage(getName(), std::move(data), props.metatags->art_data.value().extension);
|
||||
auto data = base64_decode(props.metadata->art_data.value().data);
|
||||
auto md5 = server_settings_.http.image_cache.setImage(getName(), std::move(data), props.metadata->art_data.value().extension);
|
||||
|
||||
std::stringstream url;
|
||||
url << "http://" << server_settings_.http.host << ":" << server_settings_.http.port << "/__image_cache?name=" << md5;
|
||||
props.metatags->art_url = url.str();
|
||||
props.metadata->art_url = url.str();
|
||||
}
|
||||
else if (!props.metatags->art_data.has_value())
|
||||
else if (!props.metadata->art_data.has_value())
|
||||
{
|
||||
server_settings_.http.image_cache.clear(getName());
|
||||
}
|
||||
|
|
|
@ -101,8 +101,8 @@ json Properties::toJson() const
|
|||
addTag(j, "canPause", can_pause);
|
||||
addTag(j, "canSeek", can_seek);
|
||||
addTag(j, "canControl", can_control);
|
||||
if (metatags.has_value())
|
||||
addTag(j, "metadata", metatags->toJson());
|
||||
if (metadata.has_value())
|
||||
addTag(j, "metadata", metadata->toJson());
|
||||
return j;
|
||||
}
|
||||
|
||||
|
@ -147,12 +147,12 @@ void Properties::fromJson(const json& j)
|
|||
|
||||
if (j.contains("metadata"))
|
||||
{
|
||||
Metatags m;
|
||||
Metadata m;
|
||||
m.fromJson(j["metadata"]);
|
||||
metatags = m;
|
||||
metadata = m;
|
||||
}
|
||||
else
|
||||
metatags = std::nullopt;
|
||||
metadata = std::nullopt;
|
||||
}
|
||||
|
||||
bool Properties::operator==(const Properties& other) const
|
||||
|
|
|
@ -19,14 +19,13 @@
|
|||
#ifndef PROPERTIES_HPP
|
||||
#define PROPERTIES_HPP
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "common/aixlog.hpp"
|
||||
#include "common/json.hpp"
|
||||
#include "metatags.hpp"
|
||||
#include "metadata.hpp"
|
||||
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
@ -152,7 +151,7 @@ public:
|
|||
Properties(const json& j);
|
||||
|
||||
/// Meta data
|
||||
std::optional<Metatags> metatags;
|
||||
std::optional<Metadata> metadata;
|
||||
/// https://www.musicpd.org/doc/html/protocol.html#tags
|
||||
/// The current playback status
|
||||
std::optional<PlaybackStatus> playback_status;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue