00001 #ifndef _AUDIO__H_ 00002 #define _AUDIO__H_ 00003 00004 #include <string> 00005 #include <alsa/asoundlib.h> 00006 #include <pthread.h> 00007 #include "rtp_stream.h" 00008 00009 using namespace std; 00010 00011 #define SAMPLE_RATE 44100 00012 #define SAMPLE_CHANNELS 2 00013 //#define SAMPLE_RATE 22050 00014 //#define SAMPLE_CHANNELS 1 00015 00016 class Audio : public RTP_Stream { 00017 public: 00018 Audio(bool enable, int sample_rate = SAMPLE_RATE, int channels = SAMPLE_CHANNELS); 00019 virtual ~Audio(void); 00020 long sample_rate(void) { return _sample_rate; }; 00021 long channels(void) { return _channels; }; 00022 bool present(void) { return _present; }; 00023 // long ptype(void) { return _ptype; }; 00024 00025 void Start(string ip, long port); 00026 void Stop(void); 00027 protected: 00028 int fd; 00029 snd_pcm_t *capture_handle; 00030 int rtc_fd; 00031 short *sbuffer; 00032 long sbuffer_len; 00033 bool _present; 00034 long _sample_rate; 00035 long _channels; 00036 // long _ptype; 00037 // bool _play; 00038 // Socket *socket; 00039 // void *thread(void); 00040 00041 long capture(void); 00042 // bool process(void); 00043 long process(void); 00044 }; 00045 00046 //extern Audio *audio; 00047 00048 #endif // _AUDIO__H_