The codec interface of the Serveez core API supplies routines for setting up socket structures to perform encoding or decoding of its receive or send buffers. It is a transparent layer of buffer transition. The interface itself tries to unify different types of codecs. In order to add a new codec the programmer needs to write some wrapper functions around the actual implementation to fulfill certain entry and exit semantics of this interface.
Call func for each codec, passing additionally the second arg closure. If func returns a negative value, return immediately with that value (breaking out of the loop), otherwise, return 0.
Find an appropriate codec for the given description and type
(one of either
NULL if there is no such codec registered.
Print a text representation of a codec’s current ratio in percent if possible.
Register codec. Does not register invalid or duplicate codecs. Return zero on success, non-zero otherwise.
Remove codec from the list of known codecs. Return zero if the codec could be successfully removed, non-zero otherwise.
Arrange for sock to decode or encode its receive data via codec. Return zero on success, non-zero otherwise.
(You need to have set the
check_request method previously
for this to work.)
“This routine is the new
check_request callback for reading
codecs. It is applied in
Usually it gets called whenever there is data in the receive buffer.
It lets the current receive buffer be the input of the codec. The
output buffer of the codec gets the new receive buffer of sock.
check_request callback of sock gets called
afterwards. When leaving this function, the receive buffer gets
restored again with the bytes snipped consumed by the codec itself.”
[ttn sez: huh?]
Arrange for sock to encode or decode its send buffer via codec. Return zero on success, non-zero otherwise.
(You need to have properly set the
write_socket member of
sock previously for this to work.)
“This is the new
write_socket callback for sock which is
called whenever there is data within the send buffer available and
sock is scheduled for writing. It uses the current send buffer
as input buffer for the codec. The output buffer of the codec is
used to invoke the
write_socket callback saved within
svz_codec_sock_send_setup. After this the send buffer is
restored again without the bytes consumed by the codec.”
[ttn sez: huh?]
Try to release the resources of both the receiving and sending codec of sock.
This callback is used as the
disconnected_socket callback of
the socket structure sock. It is called by default if the
codec socket structure sock gets disconnected for some external
Return a valid codec detected by scanning the receive buffer
of sock, or
NULL if no codec could be detected.