Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

SDPMediaDescription.h

Go to the documentation of this file.
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 SDP_MEDIA_DESCRIPTION_H 00025 #define SDP_MEDIA_DESCRIPTION_H 00026 00027 #include <stdlib.h> 00028 #include <vector> 00029 00030 #include "MNString.h" 00031 #include "MNArrayList.h" 00032 #include "MNList.h" 00033 #include "MNValid.h" 00034 #include "GCPtr.h" 00035 #include "sdp/PayloadTypes.h" 00036 #include "sdp/PayloadTypeEntry.h" 00037 00038 namespace SDP 00039 { 00040 /******************************************************************* 00041 * enum SDP::MNMediaType 00042 *******************************************************************/ 00043 00044 enum MNMediaType 00045 { 00046 audio, 00047 video, 00048 application, 00049 data, 00050 control, 00051 INVALIDTYPE 00052 }; 00053 00054 /******************************************************************* 00055 * enum SDP::SessionFieldName 00056 *******************************************************************/ 00057 00058 enum SessionFieldName 00059 { 00060 Version, 00061 Origin, 00062 SessionName, 00063 Information, 00064 Uri, 00065 Email, 00066 Phone, 00067 00076 A_Range 00077 }; 00078 00079 /******************************************************************* 00080 * SDP::Bandwidth 00081 *******************************************************************/ 00082 00083 class Bandwidth 00084 { 00085 DECLARE_VALID 00086 private: 00087 static const size_t _default = 150; 00088 00090 char* _s; 00091 00092 unsigned _ok : 1; 00093 unsigned _ct : 1; 00094 unsigned _as : 1; 00095 unsigned _x : 1; 00096 size_t _bw; 00097 00098 public: 00099 Bandwidth( ); 00100 Bandwidth( const char* in ); 00101 Bandwidth( const Bandwidth& orig ); 00102 00103 ~Bandwidth( ); 00104 00105 Bandwidth& operator=( const Bandwidth& orig ); 00106 00107 void dump( ostream& ostr ) const; 00108 00109 inline const char* getS() const { 00110 return _s; 00111 } 00112 00113 inline bool isCT() const { 00114 return ( _ct == 1 ); 00115 } 00116 00117 inline bool isAS() const { 00118 return ( _as == 1 ); 00119 } 00120 00121 inline size_t getBW() const { 00122 if( _ok ) return _bw; 00123 else return _default; 00124 } 00125 00126 friend ostream& operator<<( ostream& ostr, const Bandwidth& o ); 00127 00128 private: 00129 void private_parse( ); 00130 }; 00131 00132 /******************************************************************* 00133 * struct SDP::Bandwidths 00134 *******************************************************************/ 00135 00136 typedef std::vector<Bandwidth> Bandwidths; 00137 typedef std::vector<Bandwidth>::iterator Bandwidth_it; 00138 typedef std::vector<Bandwidth>::const_iterator Bandwidth_cit; 00139 00140 ostream& operator<<( ostream& ostr, const Bandwidths& orig ); 00141 00142 /******************************************************************* 00143 * struct SDP::RangeAttribute 00144 *******************************************************************/ 00145 00146 struct RangeAttribute 00147 { 00148 size_t _from_seconds; 00149 size_t _from_fraction; 00150 size_t _to_seconds; 00151 size_t _to_fraction; 00152 }; 00153 00154 }; // namespace SDP 00155 00156 enum MNTransportProtocol 00157 { 00158 RTP_AVP, 00159 UDP, 00160 INVALIDPROT 00161 }; 00162 00163 class Formatswitch 00164 { 00165 public: 00166 Formatswitch() 00167 { 00168 Ssrc_old=-1; 00169 Ssrc_new=-1; 00170 Bytepos_old=-1; 00171 Bytepos_new=-1; 00172 } 00173 00174 Formatswitch( const Formatswitch& orig ) 00175 { 00176 Ssrc_old=orig.Ssrc_old; 00177 Ssrc_new=orig.Ssrc_new; 00178 Bytepos_old=orig.Bytepos_old; 00179 Bytepos_new=orig.Bytepos_new; 00180 } 00181 00182 long Ssrc_old; 00183 long Ssrc_new; 00184 long Bytepos_old; 00185 long Bytepos_new; 00186 }; 00187 00188 /*********************************************************************** 00189 * SDPMediaDescription 00190 ***********************************************************************/ 00191 00192 class SDPMediaDescription 00193 { 00194 /******************************************************************* 00195 * SDPMediaDescription::MediaField 00196 *******************************************************************/ 00197 public: 00198 class MediaField 00199 { 00200 MNString _s; 00201 SDP::MNMediaType _mediaType; 00202 int _port; 00203 MNTransportProtocol _protocol; 00204 MNString _payloadFormatEntries; 00205 00206 DECLARE_VALID 00207 00208 public: 00209 MediaField( const MNString& in ); 00210 MediaField( const MediaField& ); 00211 00212 ~MediaField( ); 00213 00214 MediaField& operator=( const MediaField& ); 00215 00216 inline const MNString& getField() const { 00217 CHECK_VALID 00218 return _s; 00219 } 00220 00221 inline SDP::MNMediaType getMediaType() const { 00222 CHECK_VALID 00223 return _mediaType; 00224 } 00225 00226 inline int getPort() const { 00227 CHECK_VALID 00228 return _port; 00229 } 00230 00231 inline MNTransportProtocol getProtocol() const { 00232 CHECK_VALID 00233 return _protocol; 00234 } 00235 00236 inline const MNString& getPayloadFormatEntries() const { 00237 CHECK_VALID 00238 return _payloadFormatEntries; 00239 } 00240 00241 void dump( ostream& ostr ) const; 00242 00243 friend ostream& operator<<( ostream& ostr, const MediaField& o ); 00244 }; 00245 00246 MediaField* _media_field; 00247 00248 MNString* _information_field; 00249 MNString* _connection_field; 00250 00251 SDP::Bandwidths _bandwidths; 00252 00253 MNString* _key_field; 00254 MNList<MNString>* _attribute_fields; 00255 SDP::PayloadTypeTable _payloadTypes; 00256 Formatswitch* _f_switch; 00257 MNString* _trackIDString; 00258 00259 DECLARE_VALID 00260 00261 public: 00262 00263 SDPMediaDescription(); 00264 SDPMediaDescription( const SDPMediaDescription& orig ); 00265 SDPMediaDescription( const char* media ); 00266 virtual ~SDPMediaDescription(); 00267 00268 SDPMediaDescription& operator=( const SDPMediaDescription& orig ); 00269 00270 bool hasMedia() const; 00271 void setMedia( const MNString& in ); 00272 void setMedia( const char* in ); 00273 const MNString& getMedia() const; 00274 SDP::MNMediaType getMediaType() const; 00275 int getPort() const; 00276 MNTransportProtocol getTransportProtocol() const; 00277 const MNString& getPayloadFormatEntries() const; 00278 00279 00280 bool hasInformation() const; 00281 void setInformation( const MNString& in ); 00282 void setInformation( const char* in ); 00283 const MNString& getInformation() const; 00284 00285 bool hasConnection() const; 00286 void setConnection( const MNString& in ); 00287 void setConnection( const char* in ); 00288 const MNString& getConnection() const; 00289 00290 void addBandwidth( const char* in ); 00291 bool hasASBandwidth() const; 00292 size_t getASBandwidth(); 00293 00294 bool hasKey() const; 00295 void setKey( const MNString& in ); 00296 void setKey( const char* in ); 00297 const MNString& getKey() const; 00298 00299 bool hasAttributes() const; 00300 void insertAttribute( const MNString& in ); 00301 void insertAttribute( const char* in ); 00302 void insertRtpmapAttribute( const char* in ); 00303 const MNList<MNString>& getAttributes() const; 00304 bool hasLCRTPAttribute(); 00305 00306 // following functions: 00307 // no set functions, they are set when attributes are set and mediadesc 00308 // is set to avoid inconsisteny with the strings 00309 00310 int getNbFormats() const; 00311 00312 const SDP::PayloadTypeTable* getPayloadTypes() const 00313 { 00314 CHECK_VALID 00315 return &_payloadTypes; 00316 } 00317 00318 inline bool hasFormatswitch() const 00319 { 00320 return ( _f_switch!=NULL ); 00321 } 00322 00323 inline Formatswitch getFormatswitch() 00324 { 00325 return ( *_f_switch ); 00326 } 00327 00328 inline bool hasTrackIDString() const 00329 { 00330 return ( _trackIDString != NULL ); 00331 } 00332 00333 inline const MNString& getTrackIDString() const 00334 { 00335 return ( *_trackIDString ); 00336 } 00337 00338 void dump( MNString& desc ); 00339 00340 MNString toString(); 00341 00342 private: 00344 void private_delete_fields( ); 00345 00347 void private_clear_fields( ); 00348 00350 void private_copy_fields( const SDPMediaDescription& orig ); 00351 00353 // unsigned char* parseConfig( const char* confstr, unsigned& conflen); 00354 00355 }; 00356 00357 /* 00358 static bool getNibble(char const*& configStr, 00359 unsigned char& resultNibble); 00360 static bool getByte(char const*& configStr, unsigned char& resultByte); 00361 */ 00362 00363 /*********************************************************************** 00364 * MDescPtr 00365 ***********************************************************************/ 00366 00367 typedef OS::GCPtr<SDPMediaDescription> MDescPtr; 00368 00369 /*********************************************************************** 00370 * MDescList 00371 * This list is used for all operations after parsing 00372 ***********************************************************************/ 00373 00374 typedef std::vector<MDescPtr> MDescList; 00375 00376 #endif 00377

Generated on Sun Mar 6 13:35:50 2005 for Komssys by doxygen 1.3.8