libguac  0.9.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Data Structures | Functions
audio.h File Reference

Provides functions and structures used for providing simple streaming audio. More...

Go to the source code of this file.

Data Structures

struct  guac_audio_encoder
 Arbitrary audio codec encoder. More...
 
struct  guac_audio_stream
 Basic audio stream. More...
 

Functions

guac_audio_streamguac_audio_stream_alloc (guac_client *client, guac_audio_encoder *encoder)
 Allocates a new audio stream which encodes audio data using the given encoder. More...
 
void guac_audio_stream_free (guac_audio_stream *stream)
 Frees the given audio stream. More...
 
void guac_audio_stream_begin (guac_audio_stream *stream, int rate, int channels, int bps)
 Begins a new audio packet within the given audio stream. More...
 
void guac_audio_stream_end (guac_audio_stream *stream)
 Ends the current audio packet, writing the finished packet as an audio instruction. More...
 
void guac_audio_stream_write_pcm (guac_audio_stream *stream, const unsigned char *data, int length)
 Writes PCM data to the given audio stream. More...
 
void guac_audio_stream_flush (guac_audio_stream *stream)
 Flushes the given audio stream. More...
 
void guac_audio_stream_write_encoded (guac_audio_stream *audio, const unsigned char *data, int length)
 Appends arbitrarily-encoded data to the encoded_data buffer within the given audio stream. More...
 

Detailed Description

Provides functions and structures used for providing simple streaming audio.

Function Documentation

guac_audio_stream* guac_audio_stream_alloc ( guac_client client,
guac_audio_encoder encoder 
)

Allocates a new audio stream which encodes audio data using the given encoder.

If NULL is specified for the encoder, an appropriate encoder will be selected based on the encoders built into libguac and the level of client support.

Parameters
clientThe guac_client for which this audio stream is being allocated.
encoderThe guac_audio_encoder to use when encoding audio, or NULL if libguac should select an appropriate built-in encoder on its own.
Returns
The newly allocated guac_audio_stream, or NULL if no audio stream could be allocated due to lack of client support.
void guac_audio_stream_begin ( guac_audio_stream stream,
int  rate,
int  channels,
int  bps 
)

Begins a new audio packet within the given audio stream.

This packet will be built up with repeated writes of PCM data, finally being sent when complete via guac_audio_stream_end().

Parameters
streamThe guac_audio_stream which should start a new audio packet.
rateThe audio rate of the packet, in Hz.
channelsThe number of audio channels.
bpsThe number of bits per audio sample.
void guac_audio_stream_end ( guac_audio_stream stream)

Ends the current audio packet, writing the finished packet as an audio instruction.

Parameters
streamThe guac_audio_stream whose current audio packet should be completed and sent.
void guac_audio_stream_flush ( guac_audio_stream stream)

Flushes the given audio stream.

Parameters
streamThe guac_audio_stream to flush.
void guac_audio_stream_free ( guac_audio_stream stream)

Frees the given audio stream.

Parameters
streamThe guac_audio_stream to free.
void guac_audio_stream_write_encoded ( guac_audio_stream audio,
const unsigned char *  data,
int  length 
)

Appends arbitrarily-encoded data to the encoded_data buffer within the given audio stream.

This data must be encoded in the output format of the encoder used by the stream. This function is mainly for use by encoder implementations.

Parameters
audioThe guac_audio_stream to write data through.
dataArbitrary encoded data to write through the audio stream.
lengthThe number of bytes of data provided.
void guac_audio_stream_write_pcm ( guac_audio_stream stream,
const unsigned char *  data,
int  length 
)

Writes PCM data to the given audio stream.

This PCM data will be automatically encoded by the audio encoder associated with this stream. This function must only be called after an audio packet has been started with guac_audio_stream_begin().

Parameters
streamThe guac_audio_stream to write PCM data through.
dataThe PCM data to write.
lengthThe number of bytes of PCM data provided.