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

Generated on Fri Nov 17 03:03:33 2006 for OpenH323 by  doxygen 1.5.1