Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

alsad_shared_lib.h

Go to the documentation of this file.
00001 #ifndef __ALSAD_SHARED_LIB_H
00002 #define __ALSAD_SHARED_LIB_H
00003 
00014 #include <stdio.h>
00015 #include <stdlib.h>
00016 #include <unistd.h>
00017 #include <sys/time.h>
00018 #include <netdb.h>
00019 #include <errno.h>
00020 #include "alsad_defs.h"
00021 #include "alsad_net_lib.h"
00022 #include "auth_lib.h"
00023 #include "config_file.h"
00024 
00025 #define ALSAD_PCM_WAIT_TIME 1000
00026 #define ALSAD_RESUME_COUNT 1000
00027 
00028 
00029 #define ALSAD_KEY_USERNAME "username"
00030 #define ALSAD_KEY_PRIV_KEY_FILE "private_key_file"
00031 #define ALSAD_KEY_PUB_KEY_DIR "public_key_dir"
00032 #define ALSAD_KEY_MAX_STREAM_SINKS "max_stream_sinks"
00033 #define ALSAD_KEY_PCM_FORMAT "pcm_format"
00034 #define ALSAD_KEY_CHANNELS "number_pcm_channels"
00035 #define ALSAD_KEY_OPEN_MODE "card_open_mode"
00036 #define ALSAD_KEY_CIRC_BUFF_SIZE "circ_buff_size"
00037 #define ALSAD_KEY_MAX_CIRC_BUFF_SIZE "max_circ_buff_size"
00038 #define ALSAD_KEY_CARD_BUF_TIME "card_buffer_time"
00039 #define ALSAD_KEY_CARD_PERIOD_TIME "card_period_time"
00040 #define ALSAD_KEY_CARD_DEVICE_NAME "card_device_name"
00041 #define ALSAD_KEY_PORT "alsad_port"
00042 
00043 #define ALSAD_DFLT_USERNAME "alsad"
00044 #define ALSAD_DFLT_PRIV_KEY_FILE "~/.ssh/alsad.priv"
00045 #define ALSAD_DFLT_PUB_KEY_DIR "/etc/alsad/pub/"
00046 #define ALSAD_DFLT_MAX_STREAM_SINKS "0"
00047 #define ALSAD_DFLT_PCM_FORMAT "S16_LE"
00048 #define ALSAD_DFLT_CHANNELS "1"
00049 #define ALSAD_DFLT_OPEN_MODE "0"
00050 #define ALSAD_DFLT_CIRC_BUFF_SIZE "1048576"
00051 #define ALSAD_DFLT_MAX_CIRC_BUFF_SIZE "4194304"
00052 #define ALSAD_DFLT_CARD_BUF_TIME "500000"
00053 #define ALSAD_DFLT_CARD_PERIOD_TIME "125000"
00054 #define ALSAD_DFLT_CARD_DEVICE_NAME "default"
00055 #define ALSAD_DFLT_PORT "5000"
00056 
00057 #define ALSAD_DFLT_HOSTNAME "localhost"
00058 #define ALSAD_DFLT_RATE 22000 
00059 #define ALSAD_DFLT_IDENTIFIER 123456
00060 #define ALSAD_DFLT_DP_IDENTIFIER 0 
00061 
00062 
00069 struct alsad_config_keys{
00070    char *config_username; 
00071    char *config_priv_key_file;
00072    char *config_pub_key_dir;
00073    char *config_max_stream_sinks;
00074    char *config_pcm_format;
00075    char *config_channels;
00076    char *config_open_mode;
00077    char *config_circ_buff_size;
00078    char *config_max_circ_buff_size;
00079    char *config_card_buf_time;
00080    char *config_card_period_time;
00081    char *config_card_device_name;
00082    char *config_port;
00083 };
00084 
00085 typedef struct alsad_config_keys alsad_config_keys_t;
00086 
00087 
00088 int alsad_config_key_load(char *config_file, alsad_config_keys_t *key_struct);
00089 
00090 int alsad_conn_with_host(alsad_connect_addr_t *conn_addr,
00091                 alsad_net_structs_t *send_structs,
00092                 char *userid, char *priv_key_file, 
00093                 alsad_control_t *conn_ctrl);
00094 
00095 
00096 
00108 int alsad_handle_client_protocol(int sock, int handle, alsad_control_t *conn_ctrl);
00109 
00110 int alsad_client_side_negotiation(int sock, alsad_hw_params_t *hw_params,
00111                                                            char **audiobuf);
00112 int alsad_server_side_negotiation(int sock, snd_pcm_t **handle,
00113                      alsad_hw_params_t *rcvd_hw_params, char **audiobuf);
00114 
00115 int alsad_configure_snd_card(snd_pcm_t **handle,
00116                        alsad_stream_props_t *rcvd_stream_props,
00117                         alsad_hw_params_t *rcvd_hw_params);
00118 
00119 int allocate_audiobuf(alsad_hw_params_t *configd_hw_params, char **audiobuf);
00120 
00121 int buffer_xrun(snd_pcm_t *handle, long err_val);
00122 
00123 void suspend(snd_pcm_t *handle);
00124 
00125 void print_pcm_state(snd_pcm_t *handle);
00126         
00127 int alsad_hw_playback(snd_pcm_t *handle, alsad_stream_props_t *stream_props,
00128                                       alsad_hw_params_t *configd_hw_params,
00129                                                 char *audio_buf);
00130 
00131 int alsad_hw_capture(snd_pcm_t *handle, alsad_stream_props_t *stream_props,
00132                                      alsad_hw_params_t *configd_hw_params,
00133                                                 char *audio_buf);
00134 
00135 ssize_t alsad_channel_write(void *channel, void *pipe, char *audiobuf,
00136                                                 size_t total_to_write);
00137 
00138 ssize_t alsad_channel_read(void *channel, void *pipe, char *audiobuf,
00139                                                 size_t total_to_read);
00140 
00141 ssize_t alsad_file_write(int handle, char *audiobuf,
00142                                             size_t total_to_write);
00143 
00144 ssize_t alsad_file_read(int handle, char *audiobuf,
00145                                             size_t total_to_read);
00146 
00147 int alsad_strerror(int errnum, char *error_buff, size_t buff_size);
00148 
00150 #endif

Generated on Thu Dec 16 23:07:31 2004 for alsad by doxygen 1.3.6