00001 /* 00002 * mediafmt.h 00003 * 00004 * Media Format descriptions 00005 * 00006 * Open H323 Library 00007 * 00008 * Copyright (c) 1998-2001 Equivalence Pty. Ltd. 00009 * 00010 * The contents of this file are subject to the Mozilla Public License 00011 * Version 1.0 (the "License"); you may not use this file except in 00012 * compliance with the License. You may obtain a copy of the License at 00013 * http://www.mozilla.org/MPL/ 00014 * 00015 * Software distributed under the License is distributed on an "AS IS" 00016 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00017 * the License for the specific language governing rights and limitations 00018 * under the License. 00019 * 00020 * The Original Code is Open H323 Library. 00021 * 00022 * The Initial Developer of the Original Code is Equivalence Pty. Ltd. 00023 * 00024 * Contributor(s): ______________________________________. 00025 * 00026 * $Log: mediafmt.h,v $ 00027 * Revision 1.26 2006/09/05 23:56:57 csoutheren 00028 * Convert media format and capability factories to use std::string 00029 * 00030 * Revision 1.25 2006/06/23 03:18:23 shorne 00031 * Backport FECC (H.224) from Opal 00032 * 00033 * Revision 1.24 2005/11/30 13:05:01 csoutheren 00034 * Changed tags for Doxygen 00035 * 00036 * Revision 1.23 2005/08/13 19:35:57 shorne 00037 * Fix compile error on MSVC6 00038 * 00039 * Revision 1.22 2004/07/07 08:04:54 csoutheren 00040 * Added video codecs to default codec list, but H.263 is only loaded if the .so/DLL is found 00041 * 00042 * Revision 1.21 2004/07/07 03:52:12 csoutheren 00043 * Fixed incorrect strings returned by GetFormatName on G.711 codecs 00044 * 00045 * Revision 1.20 2004/06/30 12:31:09 rjongbloed 00046 * Rewrite of plug in system to use single global variable for all factories to avoid all sorts 00047 * of issues with startup orders and Windows DLL multiple instances. 00048 * 00049 * Revision 1.19 2004/05/23 12:49:20 rjongbloed 00050 * Tidied some of the OpalMediaFormat usage after abandoning some previous 00051 * code due to MSVC6 compiler bug. 00052 * 00053 * Revision 1.18 2004/05/20 02:07:28 csoutheren 00054 * Use macro to work around MSVC internal compiler errors 00055 * 00056 * Revision 1.17 2004/05/19 07:38:22 csoutheren 00057 * Changed OpalMediaFormat handling to use abstract factory method functions 00058 * 00059 * Revision 1.16 2004/05/03 00:52:23 csoutheren 00060 * Fixed problem with OpalMediaFormat::GetMediaFormatsList 00061 * Added new version of OpalMediaFormat::GetMediaFormatsList that minimses copying 00062 * 00063 * Revision 1.15 2004/04/03 10:38:24 csoutheren 00064 * Added in initial cut at codec plugin code. Branches are for wimps :) 00065 * 00066 * Revision 1.14.2.1 2004/03/31 11:11:59 csoutheren 00067 * Initial public release of plugin codec code 00068 * 00069 * Revision 1.14 2004/02/26 08:19:31 csoutheren 00070 * Fixed threading problem with GetMediaFormatList 00071 * 00072 * Revision 1.13 2002/12/02 03:06:26 robertj 00073 * Fixed over zealous removal of code when NO_AUDIO_CODECS set. 00074 * 00075 * Revision 1.12 2002/09/16 01:14:15 robertj 00076 * Added #define so can select if #pragma interface/implementation is used on 00077 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00078 * 00079 * Revision 1.11 2002/09/03 06:19:37 robertj 00080 * Normalised the multi-include header prevention ifdef/define symbol. 00081 * 00082 * Revision 1.10 2002/08/05 10:03:47 robertj 00083 * Cosmetic changes to normalise the usage of pragma interface/implementation. 00084 * 00085 * Revision 1.9 2002/06/25 08:30:08 robertj 00086 * Changes to differentiate between stright G.723.1 and G.723.1 Annex A using 00087 * the OLC dataType silenceSuppression field so does not send SID frames 00088 * to receiver codecs that do not understand them. 00089 * 00090 * Revision 1.8 2002/03/21 02:39:15 robertj 00091 * Added backward compatibility define 00092 * 00093 * Revision 1.7 2002/02/11 04:15:56 robertj 00094 * Put G.723.1 at 6.3kbps back to old string value of "G.723.1" to improve 00095 * backward compatibility. New #define is a synonym for it. 00096 * 00097 * Revision 1.6 2002/01/22 07:08:26 robertj 00098 * Added IllegalPayloadType enum as need marker for none set 00099 * and MaxPayloadType is a legal value. 00100 * 00101 * Revision 1.5 2001/12/11 04:27:50 craigs 00102 * Added support for 5.3kbps G723.1 00103 * 00104 * Revision 1.4 2001/09/21 02:49:44 robertj 00105 * Implemented static object for all "known" media formats. 00106 * Added default session ID to media format description. 00107 * 00108 * Revision 1.3 2001/05/11 04:43:41 robertj 00109 * Added variable names for standard PCM-16 media format name. 00110 * 00111 * Revision 1.2 2001/02/09 05:16:24 robertj 00112 * Added #pragma interface for GNU C++. 00113 * 00114 * Revision 1.1 2001/01/25 07:27:14 robertj 00115 * Major changes to add more flexible OpalMediaFormat class to normalise 00116 * all information about media types, especially codecs. 00117 * 00118 */ 00119 00120 #ifndef __OPAL_MEDIAFMT_H 00121 #define __OPAL_MEDIAFMT_H 00122 00123 #ifdef P_USE_PRAGMA 00124 #pragma interface 00125 #endif 00126 00127 00128 #include "rtp.h" 00129 00130 00132 00138 class OpalMediaFormat : public PCaselessString 00139 { 00140 PCLASSINFO(OpalMediaFormat, PCaselessString); 00141 00142 public: 00143 PLIST(List, OpalMediaFormat); 00144 00147 OpalMediaFormat(); 00148 00153 OpalMediaFormat( 00154 const char * search, 00155 BOOL exact = TRUE 00156 ); 00157 00162 BOOL IsValid() const { return rtpPayloadType <= RTP_DataFrame::MaxPayloadType; } 00163 00169 RTP_DataFrame::PayloadTypes GetPayloadType() const { return rtpPayloadType; } 00170 00171 enum { 00172 DefaultAudioSessionID = 1, 00173 DefaultVideoSessionID = 2, 00174 DefaultDataSessionID = 3, 00175 DefaultH224SessionID = 4 00176 }; 00177 00180 unsigned GetDefaultSessionID() const { return defaultSessionID; } 00181 00185 BOOL NeedsJitterBuffer() const { return needsJitter; } 00186 00189 unsigned GetBandwidth() const { return bandwidth; } 00190 00195 PINDEX GetFrameSize() const { return frameSize; } 00196 00200 unsigned GetFrameTime() const { return frameTime; } 00201 00204 unsigned GetTimeUnits() const { return timeUnits; } 00205 00206 enum StandardTimeUnits { 00207 AudioTimeUnits = 8, 00208 VideoTimeUnits = 90 00209 }; 00210 00213 static List GetRegisteredMediaFormats(); 00214 static void GetRegisteredMediaFormats(List & list); 00215 00216 friend class OpalStaticMediaFormat; 00217 00231 OpalMediaFormat( 00232 const char * fullName, 00233 unsigned defaultSessionID, 00234 RTP_DataFrame::PayloadTypes rtpPayloadType, 00235 BOOL needsJitter, 00236 unsigned bandwidth, 00237 PINDEX frameSize = 0, 00238 unsigned frameTime = 0, 00239 unsigned timeUnits = 0, 00240 time_t timeStamp = 0 00241 ); 00242 protected: 00243 RTP_DataFrame::PayloadTypes rtpPayloadType; 00244 unsigned defaultSessionID; 00245 BOOL needsJitter; 00246 unsigned bandwidth; 00247 PINDEX frameSize; 00248 unsigned frameTime; 00249 unsigned timeUnits; 00250 time_t codecBaseTime; 00251 }; 00252 00253 00254 // List of known media formats 00255 00256 #define OPAL_PCM16 "PCM-16" 00257 #define OPAL_G711_ULAW_64K "G.711-uLaw-64k" 00258 #define OPAL_G711_ALAW_64K "G.711-ALaw-64k" 00259 #define OPAL_G711_ULAW_56K "G.711-uLaw-56k" 00260 #define OPAL_G711_ALAW_56K "G.711-ALaw-56k" 00261 #define OPAL_G728 "G.728" 00262 #define OPAL_G729 "G.729" 00263 #define OPAL_G729A "G.729A" 00264 #define OPAL_G729B "G.729B" 00265 #define OPAL_G729AB "G.729A/B" 00266 #define OPAL_G7231 "G.723.1" 00267 #define OPAL_G7231_6k3 OPAL_G7231 00268 #define OPAL_G7231_5k3 "G.723.1(5.3k)" 00269 #define OPAL_G7231A_6k3 "G.723.1A(6.3k)" 00270 #define OPAL_G7231A_5k3 "G.723.1A(5.3k)" 00271 #define OPAL_GSM0610 "GSM-06.10" 00272 00273 extern char OpalPCM16[]; 00274 extern char OpalG711uLaw64k[]; 00275 extern char OpalG711ALaw64k[]; 00276 extern char OpalG728[]; 00277 extern char OpalG729[]; 00278 extern char OpalG729A[]; 00279 extern char OpalG729B[]; 00280 extern char OpalG729AB[]; 00281 extern char OpalG7231_6k3[]; 00282 extern char OpalG7231_5k3[]; 00283 extern char OpalG7231A_6k3[]; 00284 extern char OpalG7231A_5k3[]; 00285 extern char OpalGSM0610[]; 00286 00287 #define OpalG711uLaw OpalG711uLaw64k 00288 #define OpalG711ALaw OpalG711ALaw64k 00289 #define OpalG7231 OpalG7231_6k3 00290 00291 // 00292 // Originally, the following inplace code was used instead of this macro: 00293 // 00294 // static PAbstractSingletonFactory<OpalMediaFormat, 00295 // OpalStaticMediaFormatTemplate< 00296 // OpalPCM16, 00297 // OpalMediaFormat::DefaultAudioSessionID, 00298 // RTP_DataFrame::L16_Mono, 00299 // TRUE, // Needs jitter 00300 // 128000, // bits/sec 00301 // 16, // bytes/frame 00302 // 8, // 1 millisecond 00303 // OpalMediaFormat::AudioTimeUnits, 00304 // 0 00305 // > 00306 // > opalPCM16Factory(OpalPCM16); 00307 // 00308 // This used the following macro: 00309 // 00310 // 00311 // template < 00312 // const char * _fullName, /// Full name of media format 00313 // unsigned _defaultSessionID, /// Default session for codec type 00314 // RTP_DataFrame::PayloadTypes _rtpPayloadType, /// RTP payload type code 00315 // BOOL _needsJitter, /// Indicate format requires a jitter buffer 00316 // unsigned _bandwidth, /// Bandwidth in bits/second 00317 // PINDEX _frameSize, /// Size of frame in bytes (if applicable) 00318 // unsigned _frameTime, /// Time for frame in RTP units (if applicable) 00319 // unsigned _timeUnits, /// RTP units for frameTime (if applicable) 00320 // time_t _timeStamp /// timestamp (for versioning) 00321 // > 00322 // class OpalStaticMediaFormatTemplate : public OpalStaticMediaFormat 00323 // { 00324 // public: 00325 // OpalStaticMediaFormatTemplate() 00326 // : OpalStaticMediaFormat(_fullName, _defaultSessionID, _rtpPayloadType, _needsJitter, _bandwidth 00327 // , _frameSize, _frameTime, _timeUnits, _timeStamp ) 00328 // { } 00329 // }; 00330 // 00331 // Unfortauntely, MSVC 6 did not like this so this crappy macro has to be used instead of a template 00332 // 00333 00334 typedef PFactory<OpalMediaFormat, std::string> OpalMediaFormatFactory; 00335 00336 #define OPAL_MEDIA_FORMAT_DECLARE(classname, _fullName, _defaultSessionID, _rtpPayloadType, _needsJitter,_bandwidth, _frameSize, _frameTime, _timeUnits, _timeStamp) \ 00337 class classname : public OpalMediaFormat \ 00338 { \ 00339 public: \ 00340 classname() \ 00341 : OpalMediaFormat(_fullName, _defaultSessionID, _rtpPayloadType, _needsJitter, _bandwidth, \ 00342 _frameSize, _frameTime, _timeUnits, _timeStamp){} \ 00343 }; \ 00344 OpalMediaFormatFactory::Worker<classname> classname##Factory(_fullName, true); \ 00345 00346 00347 #endif // __OPAL_MEDIAFMT_H 00348 00349 00350 // End of File ///////////////////////////////////////////////////////////////