00001 /* Copyright (C) 2000 KOM/Darmstadt University of Technology 00002 * 00003 * You are allowed to use all other parts of the code under the following terms: 00004 * 00005 * For non-commercial use, code may be used in unmodified form provided 00006 * that this copyright notice and this permission notice appear in 00007 * supporting documentation. 00008 * 00009 * This software is provided "as is" and without any express or implied 00010 * warranties, including, without limitation, the implied warranty of 00011 * fitness for a particular purpose. 00012 * 00013 * The code may be subjected to the GNU General Public License, Version 2, 00014 * and re-distributed under the terms of this license. 00015 * As a special exception, permission is granted to link this code 00016 * with the Qt library and distribute executables, as long as you 00017 * follow the requirements of the GNU GPL in regard to all of the 00018 * software in the executable aside from Qt. 00019 * 00020 * Commercial use other than under the terms of the GNU General Public 00021 * License is allowed only after express negotiation of conditions 00022 * with the authors. 00023 */ 00024 #ifndef PAYLOAD_TYPE_ENTRY_H 00025 #define PAYLOAD_TYPE_ENTRY_H 00026 00027 #include <map> 00028 #include "mnstream.h" 00029 00030 #include "MNString.h" 00031 #include "MNValid.h" 00032 #include "sdp/PayloadTypes.h" 00033 00034 using std::map; 00035 using std::pair; 00036 00037 namespace SDP 00038 { 00039 00040 class PayloadTypeEntry 00041 { 00051 int _rpt; 00052 00056 PayloadTypes _ipt; 00057 00068 size_t _rate; 00069 00072 size_t _num_chan; 00073 00074 public: 00075 PayloadTypeEntry(); 00076 00082 PayloadTypeEntry( int rpt ); 00083 00085 PayloadTypeEntry( const PayloadTypeEntry& orig ); 00086 00088 PayloadTypeEntry& operator=( const PayloadTypeEntry& ); 00089 00090 void copyTo( PayloadTypeEntry& dest ) const; 00091 00092 long Ssrc; 00093 MNString File; 00094 00095 //VK: added a few values for the fmtp line relevant for mp4 00096 int pr_lev_id; // the profile-level id. 00097 MNString mode; // in case of a generic pt, the identification 00098 int sizelength; // for audio pt 00099 int indexlength; // for audio pt 00100 int indexdeltalength; // for audio pt 00101 MNString config; // configuration information 00102 unsigned configSize; // size of that 00103 00106 inline PayloadTypes ipt() const { 00107 return _ipt; 00108 } 00109 00110 inline size_t rate() const { 00111 return _rate; 00112 } 00113 00114 inline size_t num_channels( ) const { 00115 return _num_chan; 00116 } 00117 00118 inline int profile( ) const { 00119 return pr_lev_id; 00120 } 00121 00122 00135 void parse_rtpmap_info( int rpt, const char* buf ); 00136 00137 00138 friend ostream& operator<<( ostream& ostr, const PayloadTypeEntry& e ); 00139 }; 00140 00141 class PayloadTypeTable 00142 { 00143 DECLARE_VALID 00144 00145 typedef map<int, PayloadTypeEntry*> Map; 00146 typedef pair<int, PayloadTypeEntry*> pair; 00147 typedef Map::iterator iterator; 00148 typedef Map::const_iterator citerator; 00149 00150 Map x; 00151 public: 00154 PayloadTypeTable( ); 00155 ~PayloadTypeTable( ); 00156 00159 bool lookup( int pt ) const; 00160 00163 PayloadTypes get_pt( int pt ) const; 00164 00167 const char* get_name( int pt ) const; 00168 00171 bool get( int pt, PayloadTypeEntry& entry ) const; 00174 size_t get_keys( int*& out_keys ) const; 00177 bool get_key( size_t idx, int& out_key ) const; 00180 bool insert( int pt, const PayloadTypeEntry& entry ); 00183 bool update( int pt, const PayloadTypeEntry& entry ); 00186 size_t size( ) const; 00189 void clear( ); 00192 const char* getConfig(int pt) const; 00195 unsigned getConfigSize(int pt) const; 00198 int getSizelength(int pt) const; 00201 int getIndexlength(int pt) const; 00204 int getIndexdeltalength(int pt) const; 00207 size_t getRate(int pt) const; 00210 size_t getNumChannels(int pt) const; 00213 void add_rtpmap_info( MNString s ); 00214 00215 00216 PayloadTypeTable& operator=( const PayloadTypeTable& orig ); 00217 00218 private: 00220 PayloadTypeTable( const PayloadTypeTable& ); 00221 }; 00222 00223 }; // namespace SDP 00224 00225 #endif /* PAYLOAD_TYPE_ENTRY_H */ 00226