AmPrecodedFile.h

00001 /*
00002  * $Id: AmUtils.h 744 2008-02-21 18:40:01Z sayer $
00003  *
00004  * Copyright (C) 2008 iptego GmbH
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  */
00027 
00028 #ifndef _AmPrecodedFile_H
00029 #define _AmPrecodedFile_H
00030 
00031 #include "AmPlugIn.h"
00032 #include "AmSdp.h"
00033 #include "amci/amci.h"
00034 #include "AmAudioFile.h"
00035 #include "AmAudio.h"
00036 
00037 #include <string>
00038 #include <map>
00039 
00040 #define PRECODED_CODEC_ID   100 // could go into amci/codecs.h
00041 
00042 struct precoded_payload_t : public amci_payload_t {
00043  public:
00044   string c_name;
00045   string format_parameters;
00046   unsigned int frame_ms;
00047   unsigned int frame_bytes;
00048   string filename;
00049 };
00050 
00051 class AmPrecodedFileFormat : public AmAudioFileFormat {
00052 
00053   precoded_payload_t& precoded_payload;
00054   amci_subtype_t subtype;
00055 
00056  public:
00057   AmPrecodedFileFormat(precoded_payload_t& precoded_payload);
00058   ~AmPrecodedFileFormat();
00059   amci_subtype_t*  getSubtype() { return &subtype; }
00060 
00061  protected:
00062   virtual int getCodecId();
00063 };
00064 
00065 class AmPrecodedRtpFormat : public AmAudioRtpFormat {
00066   precoded_payload_t& precoded_payload;
00067   
00068  public:
00069   AmPrecodedRtpFormat(precoded_payload_t& precoded_payload,
00070                       const vector<SdpPayload *>& payloads);
00071   ~AmPrecodedRtpFormat();
00072 
00073  protected:
00074   int getCodecId();
00075 };
00076 
00077 class AmPrecodedFileInstance
00078 : public AmAudioFile {
00079  
00080   precoded_payload_t& precoded_payload;
00081   const vector<SdpPayload*>&  payloads;
00082   amci_inoutfmt_t m_iofmt;
00083 
00084  public:
00085  AmPrecodedFileInstance(precoded_payload_t& precoded_payload, 
00086                         const vector<SdpPayload*>&  payloads);
00087  ~AmPrecodedFileInstance();
00088 
00089  AmPrecodedRtpFormat* getRtpFormat();
00090 
00091   int open();
00092   
00093  protected:
00094   AmAudioFileFormat* fileName2Fmt(const string& name);
00095 };
00096 
00097 class AmPrecodedFile 
00098 : public AmPayloadProviderInterface {
00099 
00100   std::map<int,precoded_payload_t>  payloads;
00101 
00102  public: 
00103   AmPrecodedFile();
00104   ~AmPrecodedFile();
00105   static void initPrecodedCodec();
00106 
00107   int open(std::string filename);
00108 
00109   amci_payload_t*  payload(int payload_id);
00110   int getDynPayload(const string& name, int rate, int encoding_param);
00111 
00112   AmPrecodedFileInstance* getFileInstance(int payload_id, const vector<SdpPayload*>&  m_payloads);
00113 };
00114 
00115 #endif

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