Rename "meta" to "metadata"

This commit is contained in:
badaix 2021-06-22 14:35:38 +02:00
parent 34c7068cd2
commit f817602a50
13 changed files with 159 additions and 132 deletions

View file

@ -387,8 +387,8 @@ class SnapcastWrapper(object):
logger.info(f'Stream id: {self._stream_id}') logger.info(f'Stream id: {self._stream_id}')
for stream in jmsg['result']['server']['streams']: for stream in jmsg['result']['server']['streams']:
if stream['id'] == self._stream_id: if stream['id'] == self._stream_id:
if 'meta' in stream: if 'metadata' in stream:
self.__update_metadata(stream['meta']) self.__update_metadata(stream['metadata'])
if 'properties' in stream: if 'properties' in stream:
self.__update_properties(stream['properties']) self.__update_properties(stream['properties'])
break break
@ -403,7 +403,7 @@ class SnapcastWrapper(object):
logger.info(f'Stream meta changed for "{stream_id}"') logger.info(f'Stream meta changed for "{stream_id}"')
if self._stream_id != stream_id: if self._stream_id != stream_id:
return return
meta = jmsg["params"]["meta"] meta = jmsg["params"]["metadata"]
self.__update_metadata(meta) self.__update_metadata(meta)
elif jmsg["method"] == "Stream.OnProperties": elif jmsg["method"] == "Stream.OnProperties":

View file

@ -134,7 +134,7 @@ To control the stream state, the following commands can be sent to the Snapcast
## Notifications: ## Notifications:
```json ```json
{"jsonrpc": "2.0", "method": "Stream.OnMetadata", "params": {"id": "Pipe", "meta": {}}} {"jsonrpc": "2.0", "method": "Stream.OnMetadata", "params": {"id": "Pipe", "metadata": {}}}
``` ```
```json ```json

View file

@ -383,12 +383,12 @@ The Server JSON object contains a list of Groups and Streams. Every Group holds
### Stream.SetMeta ### Stream.SetMeta
#### Request #### Request
```json ```json
{"id":4,"jsonrpc":"2.0","method":"Stream.SetMeta","params":{"id":"Spotify", "meta": {"album": "some album", "artist": "some artist", "track": "some track"...}}} {"id":4,"jsonrpc":"2.0","method":"Stream.SetMeta","params":{"id":"Spotify", "metadata": {"album": "some album", "artist": "some artist", "track": "some track"...}}}
``` ```
#### Response #### Response
```json ```json
{"id":4,"jsonrpc":"2.0","result":{"stream_id":"Spotify"}} {"id":4,"jsonrpc":"2.0","result":{"id":"Spotify"}}
``` ```
## Notifications ## Notifications
@ -439,7 +439,7 @@ The Server JSON object contains a list of Groups and Streams. Every Group holds
### Stream.OnMetadata ### Stream.OnMetadata
```json ```json
{"jsonrpc":"2.0","method":"Stream.OnMetadata","params":{"id":"stream 1", "meta": {"album": "some album", "artist": "some artist", "track": "some track"...}}} {"jsonrpc":"2.0","method":"Stream.OnMetadata","params":{"id":"stream 1", "metadata": {"album": "some album", "artist": "some artist", "track": "some track"...}}}
``` ```
### Server.OnUpdate ### Server.OnUpdate

View file

@ -49,19 +49,19 @@ void Server::onNewSession(std::shared_ptr<StreamSession> session)
} }
void Server::onMetaChanged(const PcmStream* pcmStream) void Server::onMetadataChanged(const PcmStream* pcmStream)
{ {
// clang-format off // clang-format off
// Notification: {"jsonrpc":"2.0","method":"Stream.OnMetadata","params":{"id":"stream 1", "meta": {"album": "some album", "artist": "some artist", "track": "some track"...}}} // Notification: {"jsonrpc":"2.0","method":"Stream.OnMetadata","params":{"id":"stream 1", "metadata": {"album": "some album", "artist": "some artist", "track": "some track"...}}}
// clang-format on // clang-format on
const auto meta = pcmStream->getMeta(); const auto metadata = pcmStream->getMetadata();
LOG(DEBUG, LOG_TAG) << "Metadata changed, stream: " << pcmStream->getName() << ", meta: " << meta->toJson().dump(3) << "\n"; LOG(DEBUG, LOG_TAG) << "Metadata changed, stream: " << pcmStream->getName() << ", meta: " << metadata.toJson().dump(3) << "\n";
// streamServer_->onMetaChanged(pcmStream, meta); // streamServer_->onMetadataChanged(pcmStream, meta);
// Send meta to all connected clients // Send meta to all connected clients
json notification = jsonrpcpp::Notification("Stream.OnMetadata", jsonrpcpp::Parameter("id", pcmStream->getId(), "meta", meta->toJson())).to_json(); json notification = jsonrpcpp::Notification("Stream.OnMetadata", jsonrpcpp::Parameter("id", pcmStream->getId(), "metadata", metadata.toJson())).to_json();
controlServer_->send(notification.dump(), nullptr); controlServer_->send(notification.dump(), nullptr);
// cout << "Notification: " << notification.dump() << "\n"; // cout << "Notification: " << notification.dump() << "\n";
} }
@ -70,10 +70,10 @@ void Server::onMetaChanged(const PcmStream* pcmStream)
void Server::onPropertiesChanged(const PcmStream* pcmStream) void Server::onPropertiesChanged(const PcmStream* pcmStream)
{ {
const auto props = pcmStream->getProperties(); const auto props = pcmStream->getProperties();
LOG(DEBUG, LOG_TAG) << "Properties changed, stream: " << pcmStream->getName() << ", properties: " << props->toJson().dump(3) << "\n"; LOG(DEBUG, LOG_TAG) << "Properties changed, stream: " << pcmStream->getName() << ", properties: " << props.toJson().dump(3) << "\n";
// Send propeties to all connected control clients // Send propeties to all connected control clients
json notification = jsonrpcpp::Notification("Stream.OnProperties", jsonrpcpp::Parameter("id", pcmStream->getId(), "properties", props->toJson())).to_json(); json notification = jsonrpcpp::Notification("Stream.OnProperties", jsonrpcpp::Parameter("id", pcmStream->getId(), "properties", props.toJson())).to_json();
controlServer_->send(notification.dump(), nullptr); controlServer_->send(notification.dump(), nullptr);
} }
@ -422,11 +422,11 @@ void Server::processRequest(const jsonrpcpp::request_ptr request, const OnRespon
// if (request->method().find("Stream.SetMeta") == 0) // if (request->method().find("Stream.SetMeta") == 0)
// { // {
// clang-format off // clang-format off
// Request: {"id":4,"jsonrpc":"2.0","method":"Stream.SetMeta","params":{"id":"Spotify", "meta": {"album": "some album", "artist": "some artist", "track": "some track"...}}} // Request: {"id":4,"jsonrpc":"2.0","method":"Stream.SetMeta","params":{"id":"Spotify", "metadata": {"album": "some album", "artist": "some artist", "track": "some track"...}}}
// Response: {"id":4,"jsonrpc":"2.0","result":{"id":"Spotify"}} // Response: {"id":4,"jsonrpc":"2.0","result":{"id":"Spotify"}}
// clang-format on // clang-format on
// LOG(INFO, LOG_TAG) << "Stream.SetMeta id: " << request->params().get<std::string>("id") << ", meta: " << request->params().get("meta") << // LOG(INFO, LOG_TAG) << "Stream.SetMeta id: " << request->params().get<std::string>("id") << ", meta: " << request->params().get("metadata") <<
// "\n"; // "\n";
// // Find stream // // Find stream
@ -436,7 +436,7 @@ void Server::processRequest(const jsonrpcpp::request_ptr request, const OnRespon
// throw jsonrpcpp::InternalErrorException("Stream not found", request->id()); // throw jsonrpcpp::InternalErrorException("Stream not found", request->id());
// // Set metadata from request // // Set metadata from request
// stream->setMeta(request->params().get("meta")); // stream->setMetadata(request->params().get("metadata"));
// // Setup response // // Setup response
// result["id"] = streamId; // result["id"] = streamId;

View file

@ -78,7 +78,7 @@ private:
void onNewSession(std::shared_ptr<StreamSession> session) override; void onNewSession(std::shared_ptr<StreamSession> session) override;
/// Implementation of PcmListener /// Implementation of PcmListener
void onMetaChanged(const PcmStream* pcmStream) override; void onMetadataChanged(const PcmStream* pcmStream) override;
void onPropertiesChanged(const PcmStream* pcmStream) override; void onPropertiesChanged(const PcmStream* pcmStream) override;
void onStateChanged(const PcmStream* pcmStream, ReaderState state) override; void onStateChanged(const PcmStream* pcmStream, ReaderState state) override;
void onChunkRead(const PcmStream* pcmStream, const msg::PcmChunk& chunk) override; void onChunkRead(const PcmStream* pcmStream, const msg::PcmChunk& chunk) override;

View file

@ -66,7 +66,7 @@ void StreamServer::addSession(std::shared_ptr<StreamSession> session)
} }
// void StreamServer::onMetaChanged(const PcmStream* pcmStream, std::shared_ptr<msg::StreamTags> meta) // void StreamServer::onMetadataChanged(const PcmStream* pcmStream, std::shared_ptr<msg::StreamTags> meta)
// { // {
// // Send meta to all connected clients // // Send meta to all connected clients

View file

@ -64,7 +64,7 @@ public:
// void send(const msg::BaseMessage* message); // void send(const msg::BaseMessage* message);
void addSession(std::shared_ptr<StreamSession> session); void addSession(std::shared_ptr<StreamSession> session);
// void onMetaChanged(const PcmStream* pcmStream, std::shared_ptr<msg::StreamTags> meta); // void onMetadataChanged(const PcmStream* pcmStream, std::shared_ptr<msg::StreamTags> meta);
void onChunkEncoded(const PcmStream* pcmStream, bool isDefaultStream, std::shared_ptr<msg::PcmChunk> chunk, double duration); void onChunkEncoded(const PcmStream* pcmStream, bool isDefaultStream, std::shared_ptr<msg::PcmChunk> chunk, double duration);
session_ptr getStreamSession(const std::string& clientId) const; session_ptr getStreamSession(const std::string& clientId) const;

View file

@ -155,7 +155,7 @@ void AirplayStream::push()
// - cover art message (2) // - cover art message (2)
// //
// As can be seen, the order of metadata (1) and cover (2) messages is non-deterministic. // As can be seen, the order of metadata (1) and cover (2) messages is non-deterministic.
// That is why we call setMeta() on both end of message (1) and (2). // That is why we call setMetadata() on both end of message (1) and (2).
string data = entry_->data; string data = entry_->data;
// Do not base64 decode cover art // Do not base64 decode cover art
@ -183,7 +183,7 @@ void AirplayStream::push()
// mden = metadata end, pcen == picture end // mden = metadata end, pcen == picture end
if (metadata_dirty_ && entry_->type == "ssnc" && (entry_->code == "mden" || entry_->code == "pcen")) if (metadata_dirty_ && entry_->type == "ssnc" && (entry_->code == "mden" || entry_->code == "pcen"))
{ {
setMeta(metadata_); setMetadata(metadata_);
metadata_dirty_ = false; metadata_dirty_ = false;
} }
} }

View file

@ -161,7 +161,7 @@ void LibrespotStream::onStderrMsg(const std::string& line)
Metatags meta; Metatags meta;
meta.artist = std::vector<std::string>{j["ARTIST"].get<std::string>()}; meta.artist = std::vector<std::string>{j["ARTIST"].get<std::string>()};
meta.title = j["TITLE"].get<std::string>(); meta.title = j["TITLE"].get<std::string>();
setMeta(meta); setMetadata(meta);
} }
else if (regex_search(line, m, re_track_loaded)) else if (regex_search(line, m, re_track_loaded))
{ {
@ -169,7 +169,7 @@ void LibrespotStream::onStderrMsg(const std::string& line)
Metatags meta; Metatags meta;
meta.title = string(m[1]); meta.title = string(m[1]);
meta.duration = cpt::stod(m[2]) / 1000.; meta.duration = cpt::stod(m[2]) / 1000.;
setMeta(meta); setMetadata(meta);
Properties props; Properties props;
// props.can_seek = true; // props.can_seek = true;
// props.can_control = true; // props.can_control = true;

View file

@ -84,9 +84,9 @@ void MetaStream::stop()
} }
void MetaStream::onMetaChanged(const PcmStream* pcmStream) void MetaStream::onMetadataChanged(const PcmStream* pcmStream)
{ {
LOG(DEBUG, LOG_TAG) << "onMetaChanged: " << pcmStream->getName() << "\n"; LOG(DEBUG, LOG_TAG) << "onMetadataChanged: " << pcmStream->getName() << "\n";
std::lock_guard<std::mutex> lock(mutex_); std::lock_guard<std::mutex> lock(mutex_);
if (pcmStream != active_stream_.get()) if (pcmStream != active_stream_.get())
return; return;

View file

@ -46,7 +46,7 @@ public:
protected: protected:
/// Implementation of PcmListener /// Implementation of PcmListener
void onMetaChanged(const PcmStream* pcmStream) override; void onMetadataChanged(const PcmStream* pcmStream) override;
void onPropertiesChanged(const PcmStream* pcmStream) override; void onPropertiesChanged(const PcmStream* pcmStream) override;
void onStateChanged(const PcmStream* pcmStream, ReaderState state) override; void onStateChanged(const PcmStream* pcmStream, ReaderState state) override;
void onChunkRead(const PcmStream* pcmStream, const msg::PcmChunk& chunk) override; void onChunkRead(const PcmStream* pcmStream, const msg::PcmChunk& chunk) override;

View file

@ -208,8 +208,6 @@ PcmStream::PcmStream(PcmListener* pcmListener, boost::asio::io_context& ioc, con
if (uri_.query.find(kUriChunkMs) != uri_.query.end()) if (uri_.query.find(kUriChunkMs) != uri_.query.end())
chunk_ms_ = cpt::stoul(uri_.query[kUriChunkMs]); chunk_ms_ = cpt::stoul(uri_.query[kUriChunkMs]);
// setMeta(json());
} }
@ -263,11 +261,13 @@ void PcmStream::onControlRequest(const jsonrpcpp::Request& request)
void PcmStream::onControlNotification(const jsonrpcpp::Notification& notification) void PcmStream::onControlNotification(const jsonrpcpp::Notification& notification)
{ {
try
{
LOG(INFO, LOG_TAG) << "Notification method: " << notification.method() << ", params: " << notification.params().to_json() << "\n"; LOG(INFO, LOG_TAG) << "Notification method: " << notification.method() << ", params: " << notification.params().to_json() << "\n";
if (notification.method() == "Plugin.Stream.Player.Metadata") if (notification.method() == "Plugin.Stream.Player.Metadata")
{ {
LOG(DEBUG, LOG_TAG) << "Received metadata notification\n"; LOG(DEBUG, LOG_TAG) << "Received metadata notification\n";
setMeta(notification.params().to_json()); setMetadata(notification.params().to_json());
} }
else if (notification.method() == "Plugin.Stream.Player.Properties") else if (notification.method() == "Plugin.Stream.Player.Properties")
{ {
@ -285,7 +285,7 @@ void PcmStream::onControlNotification(const jsonrpcpp::Notification& notificatio
ctrl_script_->send({++req_id_, "Plugin.Stream.Player.GetMetadata"}, [this](const jsonrpcpp::Response& response) { ctrl_script_->send({++req_id_, "Plugin.Stream.Player.GetMetadata"}, [this](const jsonrpcpp::Response& response) {
LOG(INFO, LOG_TAG) << "Response for Plugin.Stream.Player.GetMetadata: " << response.to_json() << "\n"; LOG(INFO, LOG_TAG) << "Response for Plugin.Stream.Player.GetMetadata: " << response.to_json() << "\n";
if (response.error().code() == 0) if (response.error().code() == 0)
setMeta(response.result()); setMetadata(response.result());
}); });
} }
else if (notification.method() == "Plugin.Stream.Log") else if (notification.method() == "Plugin.Stream.Log")
@ -296,6 +296,11 @@ void PcmStream::onControlNotification(const jsonrpcpp::Notification& notificatio
} }
else else
LOG(WARNING, LOG_TAG) << "Received unknown notification method: '" << notification.method() << "'\n"; LOG(WARNING, LOG_TAG) << "Received unknown notification method: '" << notification.method() << "'\n";
}
catch (const std::exception& e)
{
LOG(ERROR, LOG_TAG) << "Error while receiving notification: " << e.what() << '\n';
}
} }
@ -419,10 +424,8 @@ json PcmStream::toJson() const
{"status", to_string(state_)}, {"status", to_string(state_)},
}; };
if (meta_) j["metadata"] = metadata_.toJson();
j["meta"] = meta_->toJson(); j["properties"] = properties_.toJson();
if (properties_)
j["properties"] = properties_->toJson();
return j; return j;
} }
@ -434,13 +437,13 @@ void PcmStream::addListener(PcmListener* pcmListener)
} }
std::shared_ptr<Metatags> PcmStream::getMeta() const const Metatags& PcmStream::getMetadata() const
{ {
return meta_; return metadata_;
} }
std::shared_ptr<Properties> PcmStream::getProperties() const const Properties& PcmStream::getProperties() const
{ {
return properties_; return properties_;
} }
@ -448,61 +451,78 @@ std::shared_ptr<Properties> PcmStream::getProperties() const
void PcmStream::setProperty(const jsonrpcpp::Request& request, const CtrlScript::OnResponse& response_handler) void PcmStream::setProperty(const jsonrpcpp::Request& request, const CtrlScript::OnResponse& response_handler)
{ {
try
{
if (!request.params().has("property"))
throw SnapException("Parameter 'property' is missing");
if (!request.params().has("value"))
throw SnapException("Parameter 'value' is missing");
auto name = request.params().get("property"); auto name = request.params().get("property");
auto value = request.params().get("value"); auto value = request.params().get("value");
LOG(INFO, LOG_TAG) << "Stream '" << getId() << "' set property: " << name << " = " << value << "\n"; LOG(INFO, LOG_TAG) << "Stream '" << getId() << "' set property: " << name << " = " << value << "\n";
// TODO: check validity
bool valid = true;
if (name == "loopStatus") if (name == "loopStatus")
{ {
auto val = value.get<std::string>(); auto val = value.get<std::string>();
valid = ((val == "none") || (val == "track") || (val == "playlist")); if ((val != "none") || (val != "track") || (val != "playlist"))
throw SnapException("Value for loopStatus must be one of 'none', 'track', 'playlist'");
} }
else if (name == "shuffle") else if (name == "shuffle")
{ {
valid = value.is_boolean(); if (!value.is_boolean())
throw SnapException("Value for shuffle must be bool");
} }
else if (name == "volume") else if (name == "volume")
{ {
valid = value.is_number_integer(); if (!value.is_number_integer())
throw SnapException("Value for volume must be an int");
} }
else if (name == "rate") else if (name == "rate")
{ {
valid = value.is_number_float(); if (!value.is_number_float())
} throw SnapException("Value for rate must be float");
else
{
valid = false;
} }
if (!valid) if (!properties_.can_control)
{ throw SnapException("CanControl is false");
auto error = jsonrpcpp::InvalidParamsException(request);
response_handler(error.to_json());
return;
}
if (ctrl_script_) if (ctrl_script_)
{ {
jsonrpcpp::Request req(++req_id_, "Plugin.Stream.Player.SetProperty", {name, value}); jsonrpcpp::Request req(++req_id_, "Plugin.Stream.Player.SetProperty", {name, value});
ctrl_script_->send(req, response_handler); ctrl_script_->send(req, response_handler);
} }
}
catch (const std::exception& e)
{
LOG(WARNING, LOG_TAG) << "Error in setProperty: " << e.what() << '\n';
auto error = jsonrpcpp::InvalidParamsException(e.what(), request.id());
response_handler(error.to_json());
}
} }
void PcmStream::control(const jsonrpcpp::Request& request, const CtrlScript::OnResponse& response_handler) void PcmStream::control(const jsonrpcpp::Request& request, const CtrlScript::OnResponse& response_handler)
{ {
try
{
if (!request.params().has("command"))
throw SnapException("Parameter 'command' is missing");
std::string command = request.params().get("command"); std::string command = request.params().get("command");
static std::set<std::string> supported_commands{"Next", "Previous", "Pause", "PlayPause", "Stop", "Play", "Seek", "SetPosition"}; static std::set<std::string> supported_commands{"Next", "Previous", "Pause", "PlayPause", "Stop", "Play", "Seek", "SetPosition"};
if ((supported_commands.find(command) == supported_commands.end()) || if (supported_commands.find(command) == supported_commands.end())
((command == "SetPosition") && throw SnapException("Command not supported");
(!request.params().has("params") || !request.params().get("params").contains("Position") || !request.params().get("params").contains("TrackId"))) ||
((command == "Seek") && (!request.params().has("params") || !request.params().get("params").contains("Offset")))) if (((command == "SetPosition") || (command == "Seek")) && !request.params().has("params"))
{ throw SnapException("Parameter 'params' is missing");
auto error = jsonrpcpp::InvalidParamsException(request);
response_handler(error.to_json()); if ((command == "SetPosition") && (!request.params().get("params").contains("Position") || !request.params().get("params").contains("TrackId")))
return; throw SnapException("SetPosition requires parameters 'Position' and 'TrackId'");
}
if ((command == "Seek") && !request.params().get("params").contains("Offset"))
throw SnapException("Seek requires parameter 'Offset'");
LOG(INFO, LOG_TAG) << "Stream '" << getId() << "' received command: '" << command << "', params: '" << request.params().to_json() << "'\n"; LOG(INFO, LOG_TAG) << "Stream '" << getId() << "' received command: '" << command << "', params: '" << request.params().to_json() << "'\n";
if (ctrl_script_) if (ctrl_script_)
@ -513,39 +533,46 @@ void PcmStream::control(const jsonrpcpp::Request& request, const CtrlScript::OnR
jsonrpcpp::Request req(++req_id_, "Plugin.Stream.Player.Control", params); jsonrpcpp::Request req(++req_id_, "Plugin.Stream.Player.Control", params);
ctrl_script_->send(req, response_handler); ctrl_script_->send(req, response_handler);
} }
}
catch (const std::exception& e)
{
LOG(WARNING, LOG_TAG) << "Error in control: " << e.what() << '\n';
auto error = jsonrpcpp::InvalidParamsException(e.what(), request.id());
response_handler(error.to_json());
}
} }
void PcmStream::setMeta(const Metatags& meta) void PcmStream::setMetadata(const Metatags& metadata)
{ {
if ((meta_ != nullptr) && (meta == *meta_)) if (metadata == metadata_)
{ {
LOG(DEBUG, LOG_TAG) << "setMeta: Meta data did not change\n"; LOG(DEBUG, LOG_TAG) << "setMetadata: Metadata did not change\n";
return; return;
} }
meta_ = std::make_shared<Metatags>(meta); metadata_ = metadata;
LOG(INFO, LOG_TAG) << "setMeta, stream: " << getId() << ", metadata: " << meta_->toJson() << "\n"; LOG(INFO, LOG_TAG) << "setMetadata, stream: " << getId() << ", metadata: " << metadata_.toJson() << "\n";
// Trigger a stream update // Trigger a stream update
for (auto* listener : pcmListeners_) for (auto* listener : pcmListeners_)
{ {
if (listener != nullptr) if (listener != nullptr)
listener->onMetaChanged(this); listener->onMetadataChanged(this);
} }
} }
void PcmStream::setProperties(const Properties& props) void PcmStream::setProperties(const Properties& props)
{ {
if ((properties_ != nullptr) && (props == *properties_)) if (props == properties_)
{ {
LOG(DEBUG, LOG_TAG) << "setProperties: Properties did not change\n"; LOG(DEBUG, LOG_TAG) << "setProperties: Properties did not change\n";
return; return;
} }
properties_ = std::make_shared<Properties>(props); properties_ = props;
LOG(INFO, LOG_TAG) << "setProperties, stream: " << getId() << ", properties: " << props.toJson() << "\n"; LOG(INFO, LOG_TAG) << "setProperties, stream: " << getId() << ", properties: " << properties_.toJson() << "\n";
// Trigger a stream update // Trigger a stream update
for (auto* listener : pcmListeners_) for (auto* listener : pcmListeners_)

View file

@ -104,7 +104,7 @@ static constexpr auto kControlScript = "controlscript";
class PcmListener class PcmListener
{ {
public: public:
virtual void onMetaChanged(const PcmStream* pcmStream) = 0; virtual void onMetadataChanged(const PcmStream* pcmStream) = 0;
virtual void onPropertiesChanged(const PcmStream* pcmStream) = 0; virtual void onPropertiesChanged(const PcmStream* pcmStream) = 0;
virtual void onStateChanged(const PcmStream* pcmStream, ReaderState state) = 0; virtual void onStateChanged(const PcmStream* pcmStream, ReaderState state) = 0;
virtual void onChunkRead(const PcmStream* pcmStream, const msg::PcmChunk& chunk) = 0; virtual void onChunkRead(const PcmStream* pcmStream, const msg::PcmChunk& chunk) = 0;
@ -177,8 +177,8 @@ public:
virtual const SampleFormat& getSampleFormat() const; virtual const SampleFormat& getSampleFormat() const;
virtual std::string getCodec() const; virtual std::string getCodec() const;
std::shared_ptr<Metatags> getMeta() const; const Metatags& getMetadata() const;
std::shared_ptr<Properties> getProperties() const; const Properties& getProperties() const;
virtual void setProperty(const jsonrpcpp::Request& request, const CtrlScript::OnResponse& response_handler); virtual void setProperty(const jsonrpcpp::Request& request, const CtrlScript::OnResponse& response_handler);
virtual void control(const jsonrpcpp::Request& request, const CtrlScript::OnResponse& response_handler); virtual void control(const jsonrpcpp::Request& request, const CtrlScript::OnResponse& response_handler);
@ -200,7 +200,7 @@ protected:
void resync(const std::chrono::nanoseconds& duration); void resync(const std::chrono::nanoseconds& duration);
void chunkEncoded(const encoder::Encoder& encoder, std::shared_ptr<msg::PcmChunk> chunk, double duration); void chunkEncoded(const encoder::Encoder& encoder, std::shared_ptr<msg::PcmChunk> chunk, double duration);
void setMeta(const Metatags& meta); void setMetadata(const Metatags& metadata);
void setProperties(const Properties& props); void setProperties(const Properties& props);
std::chrono::time_point<std::chrono::steady_clock> tvEncodedChunk_; std::chrono::time_point<std::chrono::steady_clock> tvEncodedChunk_;
@ -211,8 +211,8 @@ protected:
std::unique_ptr<encoder::Encoder> encoder_; std::unique_ptr<encoder::Encoder> encoder_;
std::string name_; std::string name_;
ReaderState state_; ReaderState state_;
std::shared_ptr<Metatags> meta_; Metatags metadata_;
std::shared_ptr<Properties> properties_; Properties properties_;
boost::asio::io_context& ioc_; boost::asio::io_context& ioc_;
ServerSettings server_settings_; ServerSettings server_settings_;
std::unique_ptr<CtrlScript> ctrl_script_; std::unique_ptr<CtrlScript> ctrl_script_;