Code comments

This commit is contained in:
badaix 2015-08-13 22:25:51 +02:00
parent 4db8696889
commit c1cb395eb0
6 changed files with 37 additions and 3 deletions

View file

@ -1,4 +1,4 @@
VERSION = 0.2.94
VERSION = 0.2.95
TARGET = snapclient
SHELL = /bin/bash

View file

@ -1,4 +1,4 @@
VERSION = 0.2.94
VERSION = 0.2.95
TARGET = snapserver
SHELL = /bin/bash

View file

@ -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);

View file

@ -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_;

View file

@ -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();

View file

@ -54,11 +54,16 @@ public:
class ServerSession
{
public:
/// ctor. Received message from the client are passed to MessageReceiver
ServerSession(MessageReceiver* receiver, std::shared_ptr<tcp::socket> 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<const msg::BaseMessage>& 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;