ekg/audio.c File Reference

#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include "audio.h"
#include "commands.h"
#include "debug.h"
#include "dynstuff.h"
#include "dynstuff_inline.h"
#include "plugins.h"
#include "themes.h"
#include "stuff.h"
#include "xmalloc.h"
#include "audio_wav.h"

Data Structures

struct  stream_private_t

Defines

#define __SET(args...)

Functions

 AUDIO_DEFINE (stream)
 DYNSTUFF_LIST_DECLARE_NF (audio_inputs, audio_t, static __DYNSTUFF_LIST_ADD, static __DYNSTUFF_LIST_UNLINK) DYNSTUFF_LIST_DECLARE_NF(audio_codecs
static static static __DYNSTUFF_LIST_UNLINK __DYNSTUFF_LIST_ADD (streams, stream_t, NULL)
int cmd_streams (const char *name, const char **params, session_t *session, const char *target, int quiet)
codec_tcodec_find (const char *name)
int codec_register (codec_t *codec)
void codec_unregister (codec_t *codec)
audio_taudio_find (const char *name)
int audio_register (audio_t *audio)
void audio_unregister (audio_t *audio)
int stream_audio_read (int type, int fd, string_t buf, void *data)
int stream_audio_write (int type, int fd, string_t buf, void *data)
 AUDIO_CONTROL (stream_audio_control)
int stream_handle_write (int type, int fd, const char *watch, void *data)
int stream_handle (int type, int fd, watch_type_t watch, void *data)
int stream_create (char *name, audio_io_t *in, audio_codec_t *co, audio_io_t *out)
audio_io_tstream_as_audio (stream_t *s)
int audio_initialize ()
int audio_deinitialize ()

Variables

codec_taudio_codecs
audio_taudio_inputs
stream_tstreams
 codec_t
static __DYNSTUFF_LIST_ADD

Define Documentation

#define __SET ( args...   ) 

Value:

(co) ? co->c->control_handler(AUDIO_CONTROL_SET, AUDIO_RDWR, co, args) : \
                                out->a->control_handler(AUDIO_CONTROL_SET, AUDIO_RDWR, co, args)


Function Documentation

static static static __DYNSTUFF_LIST_UNLINK __DYNSTUFF_LIST_ADD ( streams  ,
stream_t  ,
NULL   
) [static]

AUDIO_CONTROL ( stream_audio_control   ) 

AUDIO_DEFINE ( stream   ) 

int audio_deinitialize (  ) 

audio_t* audio_find ( const char *  name  ) 

audio_find()

Find audio_t by name

Parameters:
name - name of audio_t
Returns:
if name founded, return struct describing it. else NULL

int audio_initialize (  ) 

int audio_register ( audio_t audio  ) 

audio_register()

Register new audio I/O (audio)

Note:
This should be done @ *_plugin_init() and just before plugin_register() If audio_register() fails (return not 0) than you should NOT call plugin_register() only display some info... and return -1
Parameters:
audio - audio_t to register
See also:
audio_unregister() - to unregister audio_t
Returns:
-1 if invalid params (audio NULL)
-2 if audio with such name already exists
0 on success

void audio_unregister ( audio_t audio  ) 

audio_unregister()

Unregister audio_t

Note:
This should be done @ *_plugin_destroy() just before plugin_unregister()
Parameters:
audio - audio_t to unregister

int cmd_streams ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)

codec_t* codec_find ( const char *  name  ) 

codec_find()

Find codec_t by name

Parameters:
name - name of codec_t
Returns:
if name founded, return struct describing it, else NULL

int codec_register ( codec_t codec  ) 

codec_register()

Register new codec_t (codec)

Note:
This should be done @ *_plugin_init() and just before plugin_register() If codec_register() fails (return not 0) than you should NOT call plugin_register() only display some info... and return -1
Parameters:
codec - codec_t to register
See also:
codec_unregister() - to unregister codec_t
Returns:
-1 if invalid params (codec NULL)
-2 if codec with such name already exists
0 on success

void codec_unregister ( codec_t codec  ) 

audio_unregister()

Unregister codec_t

Note:
This should be done @ *_plugin_destroy() just before plugin_unregister()
Parameters:
codec - codec_t to unregister

DYNSTUFF_LIST_DECLARE_NF ( audio_inputs  ,
audio_t  ,
static  __DYNSTUFF_LIST_ADD,
static  __DYNSTUFF_LIST_UNLINK 
)

audio_io_t* stream_as_audio ( stream_t s  ) 

stream_as_audio()

Todo:
Ever not begin.
Note:
This is not implemented, that was only idea howto do multiple encoding/decoding for example we want to decode MPEG 1 Layer 3 stream and reencode it to OGG so we could do:
stream_create("Reencoding from MPEG to OGG",
__AINIT_F("stream", AUDIO_READ, "file", "plik.mp3", "format", "mp3"), READING FROM FILE: plik.mp3 WITH FORMAT mp3
__CINIT_F("lame", ....), INIT LAME CODEC
__AINI(stream_as_audio( INIT ANOTHER STREAM, HERE WE HAVE DATA IN PCM FORMAT
stream_create("Reencoding from MPEG to OGG (part II)",
NULL, WE PASS AS INPUT HERE NULL.
__CINIT_F("ogg", .....), INIT OGG CODEC
__AINIT_F("stream", AUDIO_WRITE, "file", "plik.ogg", "format", "ogg") WRITE OGG FILE TO DISK
))
)
);
But it was only idea... and i had/have no time for it. For now... So if you really want this feature. implement it ;)
Parameters:
s - stream_t to convert.
Returns:
audio_io_t struct. [NULL for now]

int stream_audio_read ( int  type,
int  fd,
string_t  buf,
void *  data 
)

int stream_audio_write ( int  type,
int  fd,
string_t  buf,
void *  data 
)

int stream_create ( char *  name,
audio_io_t in,
audio_codec_t co,
audio_io_t out 
)

stream_create()

Function to create streams /input fd/ --> [codec function] --> /output fd or function/

Note:
in->fd must != -1, out->fd can be -1
Todo:
Implement errors. make param , char **error
Pass it to AUDIO_CONTROL_INIT and if smth fail, there should be allocated description of error.
Todo:
Implement stream_close()
Returns:
1 on sucess [created stream_t] or 0 if fail.

int stream_handle ( int  type,
int  fd,
watch_type_t  watch,
void *  data 
)

int stream_handle_write ( int  type,
int  fd,
const char *  watch,
void *  data 
)


Variable Documentation

__DYNSTUFF_LIST_ADD [static]

codec_t* audio_codecs

audio_t* audio_inputs

codec_t

stream_t* streams


Generated on Sat Nov 22 22:30:43 2008 for ekg2 by  doxygen 1.5.1