00001 /* 00002 * Copyright (C) Massimo Cora' 2006 <maxcvs@email.it> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00019 00020 #ifndef _LINUXAUDIOINPUTDEVICE_H_ 00021 #define _LINUXAUDIOINPUTDEVICE_H_ 00022 00023 00024 #ifndef _AUDIO_INPUT_DEVICE_HH 00025 #include "AudioInputDevice.hh" 00026 #endif 00027 00029 #include <ffmpeg/avformat.h> 00030 #include <ffmpeg/avcodec.h> 00031 00032 #include "OStreamConfig.hh" 00033 00038 class LinuxAudioInputDevice : public AudioInputDevice 00039 { 00040 public: 00042 friend class AudioInputDevice; 00043 00056 LinuxAudioInputDevice ( UsageEnvironment& env, int input_port_number, 00057 unsigned char bits_per_sample, 00058 unsigned char num_channels, 00059 unsigned int sampling_frequency, 00060 unsigned int granularity_in_ms); 00061 virtual ~LinuxAudioInputDevice (); 00062 00063 protected: 00064 00065 00066 private: // functions 00073 virtual Boolean setInputPort(int port_index); 00074 00076 virtual void doGetNextFrame(); 00077 00079 virtual void doStopGettingFrames(); 00080 00082 virtual double getAverageLevel() const; 00083 00084 private: // data 00088 const char *_audio_grab_format; 00089 00091 bool _initialized; 00092 00094 AVFormatContext *_format_context; 00095 00100 AVFormatParameters *_ap; 00101 00103 AVInputFormat *_input_fmt; 00104 00106 AVCodec *_pcm_codec; 00107 }; 00108 00109 00110 #endif //_LINUXAUDIOINPUTDEVICE_H_ 00111