|
ofxDepthStream
|
Network stream receiver class. More...
#include <Receiver.h>
Public Types | |
| typedef std::function< void(const void *data, size_t size)> | FrameCallback |
Public Types inherited from depth::Buffer | |
| typedef std::function< void(const void *, size_t)> | NewDataCallback |
| A new data callback takes a void pointer to the memory block and a size_t with the number of bytes in the memory block. More... | |
Public Member Functions | |
| Receiver () | |
| Default constructor; does not start a network client. More... | |
| Receiver (const std::string &host, int port) | |
| This constructor immediately starts the network client in a separate thread. More... | |
| ~Receiver () | |
| void | start () |
| Starts network client, with host and port values provides in the constructor. More... | |
| void | start (const std::string &host, int port) |
| Starts network client with the specified host and port values. More... | |
| void | stop (bool wait=false) |
| Stops network client. More... | |
| char * | getData () |
| Provides a pointer to the incoming data memory block (never returns NULL) More... | |
| int | getSize () const |
| The size (in number of bytes) of the last package that was received (excluding the 4-byte package header) More... | |
| bool | hasNew () const |
| Whether a new package was received since the last call to reset() More... | |
| void | reset () |
| Resets the hasNew flag. More... | |
| void | setConnectAttemptInterval (unsigned int interval) |
| Configures the network client to attempt reconnect at the specified interval. More... | |
| void | setVerbose (bool v) |
| Enables/disables verbose logging output. More... | |
| void | setFrameCallback (FrameCallback func) |
| Registers a custom callback for incoming frame-data DEPRECATED: use the inherited Buffer::setOutputTo method. More... | |
Public Member Functions inherited from depth::Buffer | |
| virtual FrameRef | getRef () |
| virtual void | write (FrameRef f) |
| Updates the buffer with a new frame (triggers the output callback) More... | |
| virtual void | write (const void *data, size_t size) |
| Updates the buffer with a new frame (triggers the output callback) More... | |
| void | clear () |
| Clear the buffer (doesn't trigger the output callback) More... | |
| void | setOutputTo (Buffer *b) |
| Registers an output callback that updates the given buffer with this buffer's data whenever this buffer is updated. More... | |
Static Public Member Functions | |
| static ReceiverRef | createAndStart (const std::string &host) |
| Starts a Receiver instance which tries to connect to a server at the specified address, using the DEFAULT_PORT. More... | |
| static ReceiverRef | createAndStart (const std::string &host, int port) |
| Starts a Receiver instance which tries to connect to a server at the specified address and port. More... | |
Static Public Attributes | |
| static const int | DEFAULT_PORT = 4445 |
Protected Member Functions | |
| std::ostream & | cout () |
| std::ostream & | cerr () |
| void | error (const char *msg) |
| void | threadFunc () |
| bool | connectToServer (const std::string &address, int port) |
| void | disconnect () |
| bool | receive (size_t size) |
| bool | receive (char *buffer, size_t size) |
| bool | receiveInt (int &target) |
| bool | send_data (std::string data) |
Additional Inherited Members | |
Protected Attributes inherited from depth::Buffer | |
| NewDataCallback | newDataCallback =nullptr |
| FrameRef | buffered =nullptr |
Network stream receiver class.
The receiver class runs a network client on separate thread, which receives a (compressed) stream of Frames (probably sent by a Transmitter instance). The Receiver class inherits from the Buffer class and thus lets you automatically redirect newly received data using the setOutputTo method.
| typedef std::function<void(const void* data, size_t size)> depth::Receiver::FrameCallback |
|
inline |
Default constructor; does not start a network client.
|
inline |
This constructor immediately starts the network client in a separate thread.
| Receiver::~Receiver | ( | ) |
|
inlineprotected |
|
protected |
Referenced by threadFunc().
|
inlineprotected |
Referenced by connectToServer(), disconnect(), send_data(), and threadFunc().
|
inlinestatic |
Starts a Receiver instance which tries to connect to a server at the specified address, using the DEFAULT_PORT.
|
inlinestatic |
Starts a Receiver instance which tries to connect to a server at the specified address and port.
|
protected |
Referenced by stop(), and threadFunc().
|
protected |
Referenced by connectToServer().
|
inline |
Provides a pointer to the incoming data memory block (never returns NULL)
|
inline |
The size (in number of bytes) of the last package that was received (excluding the 4-byte package header)
|
inline |
Whether a new package was received since the last call to reset()
|
protected |
Referenced by receiveInt(), and threadFunc().
|
protected |
|
protected |
Referenced by threadFunc().
|
inline |
Resets the hasNew flag.
|
protected |
|
inline |
Configures the network client to attempt reconnect at the specified interval.
| interval | interval in milliseconds, default is 5000 |
|
inline |
Registers a custom callback for incoming frame-data DEPRECATED: use the inherited Buffer::setOutputTo method.
|
inline |
Enables/disables verbose logging output.
| v | enable or disables |
|
inline |
Starts network client, with host and port values provides in the constructor.
Referenced by Receiver().
| void Receiver::start | ( | const std::string & | host, |
| int | port | ||
| ) |
Starts network client with the specified host and port values.
| void Receiver::stop | ( | bool | wait = false | ) |
Stops network client.
| wait | When true blocks until the network-client thread has finished. False by default. |
Referenced by start(), and ~Receiver().
|
protected |
Referenced by start().
|
static |
Referenced by createAndStart().
1.8.14