The bytestream is an abstraction of classes representing bytestream in/output devices like serial lines and TCP or UDP sockets.
Multiple i/o modules can refer to an FTS bytestream in order to receive bytes (listeners) or send bytes to an internal or external device or file. Mulitple MIDI port listeners can be registered for a single stream.
Different implementations of FTS bytestreams can be developed for different platforms and bytestream protocols. In many cases i/o modules might implement a protocol (encoding and decoding) in order to send more complex data structures via a serial bytestream.
The structure fts_bytestream_t itself must be included by a class implementing a bytestream:
typedef struct my_bytestream_type { fts_bytestream_t stream; ... } my_bytestream_type_t;
A bytestream class must call fts_bytestream_init() it the init Method. The API documented by this module permits to implement FTS bytestream classes. It contains the bytestream structure itself and the initialization functions for the FTS class implementing an FTS bytestream: fts_bytestream_class_init(), fts_bytestream_init().
A bytestream class allowing input, calls fts_bytestream_set_input() in the object's initialisation and uses the provided input function fts_bytestream_input() in the routines handling incoming data. These functions propagate the incoming data to the listening i/o modules refering to the bytestream.
For the output a bytestream class must implement two output functions for sending single characters and entire strings to the bytestream as well as an optional function to flush eventual output buffers. The functions are declared by fts_bytestream_set_output() in the object's initialization.
Modules | |
FTS bytestream i/o | |
FTS memory bytestream | |
Typedefs | |
typedef void(* | fts_bytestream_callback_t )(void *listener, int n, const unsigned char *c) |
FTS bytestream listerner callback function data type. | |
typedef void(* | fts_bytestream_output_t )(fts_bytestream_t *stream, int n, const unsigned char *c) |
FTS bytestream string output callback function. | |
typedef void(* | fts_bytestream_output_char_t )(fts_bytestream_t *stream, unsigned char c) |
FTS bytestream character output callback function. | |
typedef void(* | fts_bytestream_flush_t )(fts_bytestream_t *stream) |
FTS bytestream flush callback function. | |
typedef struct fts_bytestream | fts_bytestream_t |
FTS bytestream data type. | |
Functions | |
FTS_API void | fts_bytestream_class_init (fts_class_t *cl) |
Initialise a class implementing an FTS bytestream. | |
FTS_API void | fts_bytestream_init (fts_bytestream_t *stream) |
Initialise a bytestream structure. | |
FTS_API void | fts_bytestream_destroy (fts_bytestream_t *stream) |
Delete the ressource held by the bytestream. | |
FTS_API void | fts_bytestream_set_input (fts_bytestream_t *stream) |
Declare initialized bytestream as input. | |
FTS_API void | fts_bytestream_set_output (fts_bytestream_t *stream, fts_bytestream_output_t output, fts_bytestream_output_char_t output_char, fts_bytestream_flush_t flush) |
Declare an initialized bytestream as output and assign it's output functions. | |
FTS_API void | fts_bytestream_input (fts_bytestream_t *stream, int n, const unsigned char *c) |
Call the listeners of the bytestream. |
typedef void(* fts_bytestream_flush_t)(fts_bytestream_t *stream) |
FTS bytestream flush callback function.
Flush bytestreams output buffer. This function is optional and has not be declared only for bytestreams using an output buffer
typedef void(* fts_bytestream_output_char_t)(fts_bytestream_t *stream, unsigned char c) |
FTS bytestream character output callback function.
This function has to be implmented to enable the bytestream to send data via fts_bytestream_output_char().
typedef void(* fts_bytestream_output_t)(fts_bytestream_t *stream, int n, const unsigned char *c) |
FTS bytestream string output callback function.
This function has to be implemented to enable a bytestream to send data via fts_bytestream_output().
FTS_API void fts_bytestream_class_init | ( | fts_class_t * | cl | ) |
Initialise a class implementing an FTS bytestream.
cl | FTS bytestream sub-class. |
FTS_API void fts_bytestream_destroy | ( | fts_bytestream_t * | stream | ) |
Delete the ressource held by the bytestream.
stream | the bytestream |
FTS_API void fts_bytestream_init | ( | fts_bytestream_t * | stream | ) |
Initialise a bytestream structure.
stream | the bytestream |
FTS_API void fts_bytestream_input | ( | fts_bytestream_t * | stream, | |
int | n, | |||
const unsigned char * | c | |||
) |
Call the listeners of the bytestream.
This function is called For incoming data by the object implementing an input bytestream. It will call all listeners of the input bytestream.
stream | the bytestream itself | |
n | the number of characters | |
c | the characters |
FTS_API void fts_bytestream_set_input | ( | fts_bytestream_t * | stream | ) |
Declare initialized bytestream as input.
stream | the bytestream |
FTS_API void fts_bytestream_set_output | ( | fts_bytestream_t * | stream, | |
fts_bytestream_output_t | output, | |||
fts_bytestream_output_char_t | output_char, | |||
fts_bytestream_flush_t | flush | |||
) |
Declare an initialized bytestream as output and assign it's output functions.
stream | the bytestream | |
output | ||
output_char | ||
flush |