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

alsad_net_lib.h

Go to the documentation of this file.
00001 #ifndef __ALSAD_NET_LIB_H
00002 #define __ALSAD_NET_LIB_H
00003 
00014 #include "alsad_defs.h"
00015 #include <netinet/in.h>
00016 #include <alsa/asoundlib.h>
00017 #include "socket_lib.h"
00018 
00019 
00020 #define ALSAD_MAX_DEV_LENGTH 40
00021 #define ALSAD_MAX_TEXT_DESC  65
00022 #define ALSAD_MAX_HOST_LEN   257
00023 
00024 /*
00025    Control structure for alsad network protocol
00026 */
00027 struct alsad_control{
00028   unsigned int ctrl;
00029   unsigned int code;
00030 }; 
00031 
00032 typedef struct alsad_control alsad_control_t;
00033 
00034 
00035 /*
00036    Structure for passing hardware parameters over the network
00037 */
00038 struct alsad_hw_params{
00039    snd_pcm_stream_t stream;
00040    int open_mode;
00041    unsigned int buffer_time;
00042    unsigned int period_time;
00043    unsigned long buffer_size;
00044    unsigned long period_size;
00045    char pcm_name[ALSAD_MAX_DEV_LENGTH];         // name of pcm device to open
00046 };
00047 
00048 typedef struct alsad_hw_params alsad_hw_params_t;
00049 
00050 
00051 /*
00052    Structure for passing software parameters over the network
00053 */
00054 struct alsad_sw_params{
00055    int foo;
00056    int bar;
00057 };
00058 
00059 typedef struct alsad_sw_params alsad_sw_params_t;
00060 
00061 
00062 /*
00063    Audio data header
00064 */
00065 struct alsad_audio_hdr{
00066    unsigned int payload_size;
00067 };
00068 
00069 typedef struct alsad_audio_hdr alsad_audio_hdr_t;
00070 
00071 
00072 /*
00073  * Channel header that contains properties of a channel
00074  */
00075 struct alsad_stream_props{
00076    unsigned int identifier;
00077    snd_pcm_format_t format;
00078    unsigned int channels;
00079    unsigned int rate;
00080    unsigned int frame_size;
00081    unsigned int circ_buff_size;
00082    unsigned int src_permission;
00083    char text_desc[ALSAD_MAX_TEXT_DESC];
00084 };
00085 typedef struct alsad_stream_props alsad_stream_props_t;
00086 
00087 
00088 /*
00089  * Address information of connected client.
00090  */
00091 struct alsad_connect_addr{
00092    int port;
00093    char hostname[ALSAD_MAX_HOST_LEN];
00094 };
00095 
00096 typedef struct alsad_connect_addr alsad_connect_addr_t;
00097 
00098 
00099 
00100 /*
00101  * Stored information for sources and sinks.
00102  */
00103 struct alsad_data_pipe{
00104    unsigned int identifier;
00105    alsad_connect_addr_t *connect_addr;  // Not sent over network
00106    alsad_hw_params_t *hw_params;                // Not sent over network
00107    alsad_sw_params_t *sw_params;                // Not sent over network
00108 };
00109 
00110 typedef struct alsad_data_pipe alsad_data_pipe_t;
00111 
00112 
00113 struct alsad_net_structs{
00114    alsad_hw_params_t *hw_params;
00115    alsad_sw_params_t *sw_params;
00116    alsad_stream_props_t *local_stream;
00117    alsad_stream_props_t *remote_stream;
00118    alsad_connect_addr_t *connect_addr;
00119    alsad_data_pipe_t *local_pipe;
00120    alsad_data_pipe_t *remote_pipe;
00121 };
00122  
00123 typedef struct alsad_net_structs alsad_net_structs_t;
00124 
00125 
00126 void alsad_initialize_hw_params(alsad_hw_params_t *init_hw_params);
00127 void alsad_initialize_sw_params(alsad_sw_params_t *init_sw_params); 
00128 void alsad_initialize_connect_addr(alsad_connect_addr_t *init_connect_addr);
00129 void alsad_initialize_stream_props(alsad_stream_props_t *init_audio_chan);
00130 void alsad_initialize_data_pipe(alsad_data_pipe_t *rcvd_data_pipe);
00131 
00132 int alsad_send_hw_params(int sock, alsad_hw_params_t *hd_params);
00133 int alsad_recv_hw_params(int sock, alsad_hw_params_t *hd_params);
00134 int alsad_send_hw_params_w_ctrl(int sock, alsad_hw_params_t *hd_params,
00135                                            alsad_control_t *send_control);
00136 
00137 int alsad_send_stream_props(int sock, alsad_stream_props_t *stream_prop);
00138 int alsad_recv_stream_props(int sock, alsad_stream_props_t *stream_prop);
00139 
00140 int alsad_send_conn_addr(int sock, alsad_connect_addr_t *conn_addr);
00141 int alsad_recv_conn_addr(int sock, alsad_connect_addr_t *conn_addr);
00142 int alsad_send_conn_addr_w_ctrl(int sock, alsad_connect_addr_t *conn_addr,
00143                                            alsad_control_t *send_control);
00144 
00145 int alsad_send_sw_params(int sock, alsad_sw_params_t *sw_params);
00146 int alsad_recv_sw_params(int sock, alsad_sw_params_t *sw_params);
00147 int alsad_send_sw_params_w_ctrl(int sock, alsad_sw_params_t *sw_params,
00148                                            alsad_control_t *send_control);
00149 
00150 int alsad_send_audio_hdr(int sock, alsad_audio_hdr_t *audio_hdr, char *audiobuf);
00151 int alsad_recv_audio_hdr(int sock, alsad_audio_hdr_t *audio_hdr);
00152 
00153 int alsad_send_control(int sock, alsad_control_t *control);
00154 int alsad_recv_control(int sock, alsad_control_t *control);
00155 
00159 int alsad_send_data_pipe(int sock, alsad_data_pipe_t *data_pipe);
00160 int alsad_recv_data_pipe(int sock, alsad_data_pipe_t *data_pipe);
00161 int alsad_send_data_pipe_w_ctrl(int sock, alsad_data_pipe_t *data_pipe,
00162                                            alsad_control_t *send_control);
00163                                            
00164 void alsad_free_net_structs(alsad_net_structs_t *free_structs);
00165 
00166 int alsad_request_structs(int sock, alsad_net_structs_t *net_structs, 
00167                                                alsad_control_t *control);
00168 int alsad_reply_structs(int sock, alsad_net_structs_t *net_structs); 
00169 
00170 
00173 #endif

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