AmAudioFile.h

Go to the documentation of this file.
00001 /*
00002  * $Id: AmAudio.h 633 2008-01-28 18:17:36Z sayer $
00003  *
00004  * Copyright (C) 2002-2003 Fhg Fokus
00005  *
00006  * This file is part of sems, a free SIP media server.
00007  *
00008  * sems is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version
00012  *
00013  * For a license to use the ser software under conditions
00014  * other than those described here, or to purchase support for this
00015  * software, please contact iptel.org by e-mail at the following addresses:
00016  *    info@iptel.org
00017  *
00018  * sems is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License 
00024  * along with this program; if not, write to the Free Software 
00025  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026  */
00028 #ifndef _AmAudioFile_h_
00029 #define _AmAudioFile_h_
00030 
00031 #include "AmAudio.h"
00032 #include "AmBufferedAudio.h"
00033 
00035 class AmAudioFileFormat: public AmAudioFormat
00036 {
00038   string          name;
00039     
00041   int             subtype;
00042 
00044   amci_subtype_t* p_subtype;
00045 
00046 protected:
00047   int getCodecId();
00048 
00049 public:
00056   AmAudioFileFormat(const string& name, int subtype = -1);
00057 
00058   virtual ~AmAudioFileFormat()  { }
00059 
00061   string        getName() { return name; }
00063   int           getSubtypeId() { return subtype; }
00065   virtual amci_subtype_t*  getSubtype();
00066 
00067   void setSubtypeId(int subtype_id);
00068 };
00069 
00073 class AmAudioFile: public AmBufferedAudio
00074 {
00075 public:
00077   enum OpenMode { Read=1, Write=2 };
00078 
00079 protected:
00081   FILE* fp;
00082   long begin;
00083 
00085   amci_inoutfmt_t* iofmt;
00087   int open_mode;
00088 
00090   int data_size;
00091 
00092   bool on_close_done;
00093   bool close_on_exit;
00094 
00096   int read(unsigned int user_ts, unsigned int size);
00097 
00099   int write(unsigned int user_ts, unsigned int size);
00100 
00102   virtual AmAudioFileFormat* fileName2Fmt(const string& name);
00103 
00105   int fpopen_int(const string& filename, OpenMode mode, FILE* n_fp);
00106 
00107 public:
00108   AmSharedVar<bool> loop;
00109 
00110   AmAudioFile();
00111   ~AmAudioFile();
00112 
00128   int open(const string& filename, OpenMode mode, 
00129            bool is_tmp=false);
00130 
00131   int fpopen(const string& filename, OpenMode mode, FILE* n_fp);
00132 
00136   void rewind();
00137 
00139   void close();
00140 
00142   void on_close();
00143 
00145   FILE* getfp() { return fp; }
00146 
00147   OpenMode getMode() { return (OpenMode)open_mode; }
00148 
00150   int getDataSize() { return data_size; }
00151 
00153   int getLength();
00154 
00158   string getMimeType();
00159 
00160   void setCloseOnDestroy(bool cod){
00161     close_on_exit = cod;
00162   }
00163 };
00164 
00165 #endif
00166 
00167 // Local Variables:
00168 // mode:C++
00169 // End:

Generated on Fri May 16 12:02:05 2008 for SEMS by  doxygen 1.5.1
Home |  Recent changes |  Search |  Glossary |  Sitemap |  Login