diff --git a/client/Makefile b/client/Makefile index 88009e7e..128c2b0f 100644 --- a/client/Makefile +++ b/client/Makefile @@ -1,4 +1,4 @@ -VERSION = 0.2.94 +VERSION = 0.2.95 TARGET = snapclient SHELL = /bin/bash diff --git a/server/Makefile b/server/Makefile index 2501955b..113c45d1 100644 --- a/server/Makefile +++ b/server/Makefile @@ -1,4 +1,4 @@ -VERSION = 0.2.94 +VERSION = 0.2.95 TARGET = snapserver SHELL = /bin/bash diff --git a/server/controlServer.h b/server/controlServer.h index 71db0e2e..7ce6531c 100644 --- a/server/controlServer.h +++ b/server/controlServer.h @@ -52,7 +52,7 @@ struct ControlServerSettings /// Forwars PCM data to the connected clients /** - * Reads PCM data with pipereader, implements PipeListener to get the (encoded) PCM stream. + * Reads PCM data using PipeReader, implements PipeListener to get the (encoded) PCM stream. * Accepts and holds client connections (ServerSession) * Receives (via the MessageReceiver interface) and answers messages from the clients * Forwards PCM data to the clients @@ -65,8 +65,14 @@ public: void start(); void stop(); + + /// Send a message to all connceted clients void send(const msg::BaseMessage* message); + + /// Clients call this when they receive a message. Implementation of MessageReceiver::onMessageReceived virtual void onMessageReceived(ServerSession* connection, const msg::BaseMessage& baseMessage, char* buffer); + + /// Implementation of PipeListener virtual void onChunkRead(const PipeReader* pipeReader, const msg::PcmChunk* chunk); virtual void onResync(const PipeReader* pipeReader, double ms); diff --git a/server/encoder/encoder.h b/server/encoder/encoder.h index efc6e709..cb9c2379 100644 --- a/server/encoder/encoder.h +++ b/server/encoder/encoder.h @@ -29,6 +29,10 @@ class Encoder; +/// Callback interface for users of Encoder +/** + * Users of Encoder should implement this to get the encoded PCM data + */ class EncoderListener { public: @@ -37,9 +41,15 @@ public: +/// Abstract Encoder class +/** + * Stream encoder. PCM chunks are fed into the encoder. + * As soon as a frame is encoded, the encoded data is passed to the EncoderListener + */ class Encoder { public: + /// ctor. Codec options (E.g. compression level) are passed as string and are codec dependend Encoder(const std::string& codecOptions = "") : headerChunk_(NULL), codecOptions_(codecOptions) { } @@ -50,6 +60,7 @@ public: delete headerChunk_; } + /// The listener will receive the encoded stream virtual void init(EncoderListener* listener, const msg::SampleFormat& format) { if (codecOptions_ == "") @@ -59,6 +70,7 @@ public: initEncoder(); } + /// Here the work is done. Encoded data is passed to the EncoderListener. virtual void encode(const msg::PcmChunk* chunk) = 0; virtual std::string name() const = 0; @@ -73,6 +85,7 @@ public: return ""; } + /// Header information needed to decode the data virtual msg::Header* getHeader() const { return headerChunk_; diff --git a/server/pipeReader.h b/server/pipeReader.h index edf92a2d..bece634e 100644 --- a/server/pipeReader.h +++ b/server/pipeReader.h @@ -29,6 +29,11 @@ class PipeReader; + +/// Callback interface for users of PipeReader +/** + * Users of PipeReader should implement this to get the data + */ class PipeListener { public: @@ -47,12 +52,14 @@ public: class PipeReader : public EncoderListener { public: + /// ctor. Encoded PCM data is passed to the PipeListener PipeReader(PipeListener* pipeListener, const msg::SampleFormat& sampleFormat, const std::string& codec, const std::string& fifoName); virtual ~PipeReader(); void start(); void stop(); + /// Implementation of EncoderListener::onChunkEncoded virtual void onChunkEncoded(const Encoder* encoder, msg::PcmChunk* chunk, double duration); msg::Header* getHeader(); diff --git a/server/serverSession.h b/server/serverSession.h index 298be75e..3d362d1d 100644 --- a/server/serverSession.h +++ b/server/serverSession.h @@ -54,11 +54,16 @@ public: class ServerSession { public: + /// ctor. Received message from the client are passed to MessageReceiver ServerSession(MessageReceiver* receiver, std::shared_ptr socket); ~ServerSession(); void start(); void stop(); + + /// Sends a message to the client (synchronous) bool send(const msg::BaseMessage* message) const; + + /// Sends a message to the client (asynchronous) void add(const std::shared_ptr& message); bool active() const @@ -66,11 +71,14 @@ public: return active_; } + /// Client subscribed for the PCM stream, by sending the "startStream" command + /// TODO: Currently there is only one stream ("zone") void setStreamActive(bool active) { streamActive_ = active; } + /// Max playout latency. No need to send PCM data that is older than bufferMs void setBufferMs(size_t bufferMs) { bufferMs_ = bufferMs;