Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

mediafmt.h

Go to the documentation of this file.
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.22  2004/07/07 08:04:54  csoutheren
00028  * Added video codecs to default codec list, but H.263 is only loaded if the .so/DLL is found
00029  *
00030  * Revision 1.21  2004/07/07 03:52:12  csoutheren
00031  * Fixed incorrect strings returned by GetFormatName on G.711 codecs
00032  *
00033  * Revision 1.20  2004/06/30 12:31:09  rjongbloed
00034  * Rewrite of plug in system to use single global variable for all factories to avoid all sorts
00035  *   of issues with startup orders and Windows DLL multiple instances.
00036  *
00037  * Revision 1.19  2004/05/23 12:49:20  rjongbloed
00038  * Tidied some of the OpalMediaFormat usage after abandoning some previous
00039  *   code due to MSVC6 compiler bug.
00040  *
00041  * Revision 1.18  2004/05/20 02:07:28  csoutheren
00042  * Use macro to work around MSVC internal compiler errors
00043  *
00044  * Revision 1.17  2004/05/19 07:38:22  csoutheren
00045  * Changed OpalMediaFormat handling to use abstract factory method functions
00046  *
00047  * Revision 1.16  2004/05/03 00:52:23  csoutheren
00048  * Fixed problem with OpalMediaFormat::GetMediaFormatsList
00049  * Added new version of OpalMediaFormat::GetMediaFormatsList that minimses copying
00050  *
00051  * Revision 1.15  2004/04/03 10:38:24  csoutheren
00052  * Added in initial cut at codec plugin code. Branches are for wimps :)
00053  *
00054  * Revision 1.14.2.1  2004/03/31 11:11:59  csoutheren
00055  * Initial public release of plugin codec code
00056  *
00057  * Revision 1.14  2004/02/26 08:19:31  csoutheren
00058  * Fixed threading problem with GetMediaFormatList
00059  *
00060  * Revision 1.13  2002/12/02 03:06:26  robertj
00061  * Fixed over zealous removal of code when NO_AUDIO_CODECS set.
00062  *
00063  * Revision 1.12  2002/09/16 01:14:15  robertj
00064  * Added #define so can select if #pragma interface/implementation is used on
00065  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00066  *
00067  * Revision 1.11  2002/09/03 06:19:37  robertj
00068  * Normalised the multi-include header prevention ifdef/define symbol.
00069  *
00070  * Revision 1.10  2002/08/05 10:03:47  robertj
00071  * Cosmetic changes to normalise the usage of pragma interface/implementation.
00072  *
00073  * Revision 1.9  2002/06/25 08:30:08  robertj
00074  * Changes to differentiate between stright G.723.1 and G.723.1 Annex A using
00075  *   the OLC dataType silenceSuppression field so does not send SID frames
00076  *   to receiver codecs that do not understand them.
00077  *
00078  * Revision 1.8  2002/03/21 02:39:15  robertj
00079  * Added backward compatibility define
00080  *
00081  * Revision 1.7  2002/02/11 04:15:56  robertj
00082  * Put G.723.1 at 6.3kbps back to old string value of "G.723.1" to improve
00083  *   backward compatibility. New #define is a synonym for it.
00084  *
00085  * Revision 1.6  2002/01/22 07:08:26  robertj
00086  * Added IllegalPayloadType enum as need marker for none set
00087  *   and MaxPayloadType is a legal value.
00088  *
00089  * Revision 1.5  2001/12/11 04:27:50  craigs
00090  * Added support for 5.3kbps G723.1
00091  *
00092  * Revision 1.4  2001/09/21 02:49:44  robertj
00093  * Implemented static object for all "known" media formats.
00094  * Added default session ID to media format description.
00095  *
00096  * Revision 1.3  2001/05/11 04:43:41  robertj
00097  * Added variable names for standard PCM-16 media format name.
00098  *
00099  * Revision 1.2  2001/02/09 05:16:24  robertj
00100  * Added #pragma interface for GNU C++.
00101  *
00102  * Revision 1.1  2001/01/25 07:27:14  robertj
00103  * Major changes to add more flexible OpalMediaFormat class to normalise
00104  *   all information about media types, especially codecs.
00105  *
00106  */
00107 
00108 #ifndef __OPAL_MEDIAFMT_H
00109 #define __OPAL_MEDIAFMT_H
00110 
00111 #ifdef P_USE_PRAGMA
00112 #pragma interface
00113 #endif
00114 
00115 
00116 #include "rtp.h"
00117 
00118 
00120 
00126 class OpalMediaFormat : public PCaselessString
00127 {
00128   PCLASSINFO(OpalMediaFormat, PCaselessString);
00129 
00130   public:
00131     PLIST(List, OpalMediaFormat);
00132 
00135     OpalMediaFormat();
00136 
00141     OpalMediaFormat(
00142       const char * search,  
00143       BOOL exact = TRUE     
00144     );
00145 
00150     BOOL IsValid() const { return rtpPayloadType <= RTP_DataFrame::MaxPayloadType; }
00151 
00157     RTP_DataFrame::PayloadTypes GetPayloadType() const { return rtpPayloadType; }
00158 
00159     enum {
00160       DefaultAudioSessionID = 1,
00161       DefaultVideoSessionID = 2,
00162       DefaultDataSessionID  = 3
00163     };
00164 
00167     unsigned GetDefaultSessionID() const { return defaultSessionID; }
00168 
00172     BOOL NeedsJitterBuffer() const { return needsJitter; }
00173 
00176     unsigned GetBandwidth() const { return bandwidth; }
00177 
00182     PINDEX GetFrameSize() const { return frameSize; }
00183 
00187     unsigned GetFrameTime() const { return frameTime; }
00188 
00191     unsigned GetTimeUnits() const { return timeUnits; }
00192 
00193     enum StandardTimeUnits {
00194       AudioTimeUnits = 8,  // 8kHz sample rate
00195       VideoTimeUnits = 90  // 90kHz sample rate
00196     };
00197 
00200     static List GetRegisteredMediaFormats();
00201     static void GetRegisteredMediaFormats(List & list);
00202 
00203     friend class OpalStaticMediaFormat;
00204 
00205   protected:
00219     OpalMediaFormat(
00220       const char * fullName,  
00221       unsigned defaultSessionID,  
00222       RTP_DataFrame::PayloadTypes rtpPayloadType, 
00223       BOOL     needsJitter,   
00224       unsigned bandwidth,     
00225       PINDEX   frameSize = 0, 
00226       unsigned frameTime = 0, 
00227       unsigned timeUnits = 0, 
00228       time_t timeStamp = 0    
00229     );
00230 
00231     RTP_DataFrame::PayloadTypes rtpPayloadType;
00232     unsigned defaultSessionID;
00233     BOOL     needsJitter;
00234     unsigned bandwidth;
00235     PINDEX   frameSize;
00236     unsigned frameTime;
00237     unsigned timeUnits;
00238     time_t codecBaseTime;
00239 };
00240 
00241 
00242 // List of known media formats
00243 
00244 #define OPAL_PCM16         "PCM-16"
00245 #define OPAL_G711_ULAW_64K "G.711-uLaw-64k"
00246 #define OPAL_G711_ALAW_64K "G.711-ALaw-64k"
00247 #define OPAL_G711_ULAW_56K "G.711-uLaw-56k"
00248 #define OPAL_G711_ALAW_56K "G.711-ALaw-56k"
00249 #define OPAL_G728          "G.728"
00250 #define OPAL_G729          "G.729"
00251 #define OPAL_G729A         "G.729A"
00252 #define OPAL_G729B         "G.729B"
00253 #define OPAL_G729AB        "G.729A/B"
00254 #define OPAL_G7231         "G.723.1"
00255 #define OPAL_G7231_6k3     OPAL_G7231
00256 #define OPAL_G7231_5k3     "G.723.1(5.3k)"
00257 #define OPAL_G7231A_6k3    "G.723.1A(6.3k)"
00258 #define OPAL_G7231A_5k3    "G.723.1A(5.3k)"
00259 #define OPAL_GSM0610       "GSM-06.10"
00260 
00261 extern char OpalPCM16[];
00262 extern char OpalG711uLaw64k[];
00263 extern char OpalG711ALaw64k[];
00264 extern char OpalG728[];
00265 extern char OpalG729[];
00266 extern char OpalG729A[];
00267 extern char OpalG729B[];
00268 extern char OpalG729AB[];
00269 extern char OpalG7231_6k3[];
00270 extern char OpalG7231_5k3[];
00271 extern char OpalG7231A_6k3[];
00272 extern char OpalG7231A_5k3[];
00273 extern char OpalGSM0610[];
00274 
00275 #define OpalG711uLaw      OpalG711uLaw64k
00276 #define OpalG711ALaw      OpalG711ALaw64k
00277 #define OpalG7231 OpalG7231_6k3
00278 
00279 //
00280 // Originally, the following inplace code was used instead of this macro:
00281 //
00282 // static PAbstractSingletonFactory<OpalMediaFormat, 
00283 //     OpalStaticMediaFormatTemplate<
00284 //          OpalPCM16,
00285 //          OpalMediaFormat::DefaultAudioSessionID,
00286 //          RTP_DataFrame::L16_Mono,
00287 //          TRUE,   // Needs jitter
00288 //          128000, // bits/sec
00289 //          16, // bytes/frame
00290 //          8, // 1 millisecond
00291 //          OpalMediaFormat::AudioTimeUnits,
00292 //          0
00293 //     > 
00294 // > opalPCM16Factory(OpalPCM16);
00295 //
00296 // This used the following macro:
00297 //
00298 //
00299 //  template <
00300 //        const char * _fullName,  /// Full name of media format
00301 //        unsigned _defaultSessionID,  /// Default session for codec type
00302 //        RTP_DataFrame::PayloadTypes _rtpPayloadType, /// RTP payload type code
00303 //        BOOL     _needsJitter,       /// Indicate format requires a jitter buffer
00304 //        unsigned _bandwidth,         /// Bandwidth in bits/second
00305 //        PINDEX   _frameSize,         /// Size of frame in bytes (if applicable)
00306 //        unsigned _frameTime,         /// Time for frame in RTP units (if applicable)
00307 //        unsigned _timeUnits,         /// RTP units for frameTime (if applicable)
00308 //        time_t _timeStamp            /// timestamp (for versioning)
00309 //  >
00310 //  class OpalStaticMediaFormatTemplate : public OpalStaticMediaFormat
00311 //  {
00312 //    public:
00313 //      OpalStaticMediaFormatTemplate()
00314 //        : OpalStaticMediaFormat(_fullName, _defaultSessionID, _rtpPayloadType, _needsJitter, _bandwidth
00315 //        , _frameSize, _frameTime, _timeUnits, _timeStamp )
00316 //      { }
00317 //  };
00318 //
00319 // Unfortauntely, MSVC 6 did not like this so this crappy macro has to be used instead of a template
00320 //
00321 
00322 typedef PFactory<OpalMediaFormat> OpalMediaFormatFactory;
00323 
00324 #define OPAL_MEDIA_FORMAT_DECLARE(classname, _fullName, _defaultSessionID, _rtpPayloadType, _needsJitter,_bandwidth, _frameSize, _frameTime, _timeUnits, _timeStamp) \
00325 class classname : public OpalMediaFormat \
00326 { \
00327   public: \
00328     classname() \
00329       : OpalMediaFormat(_fullName, _defaultSessionID, _rtpPayloadType, _needsJitter, _bandwidth, \
00330         _frameSize, _frameTime, _timeUnits, _timeStamp){} \
00331 }; \
00332 OpalMediaFormatFactory::Worker<classname> classname##Factory(_fullName, true); \
00333 
00334 
00335 #endif  // __OPAL_MEDIAFMT_H
00336 
00337 
00338 // End of File ///////////////////////////////////////////////////////////////

Generated on Tue Mar 15 11:17:08 2005 for OpenH323 by  doxygen 1.4.0