D:/Storage/CVS_Head/h323plus/include/mediafmt.h

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.3  2007/10/19 19:53:44  shorne
00028  * ported latest Video updates in OpenH323 committed after h323plus initial fork thanks
00029  *  Robert
00030  *
00031  * Revision 1.2  2007/08/20 19:13:28  shorne
00032  * Added Generic Capability support. Fixed Linux compile errors
00033  *
00034  * Revision 1.1  2007/08/06 20:50:50  shorne
00035  * First commit of h323plus
00036  *
00037  * Revision 1.26.2.4  2007/10/03 13:10:00  rjongbloed
00038  * Removed duplicate OpalMediaFormat list caused by merge clash from OPAL
00039  *
00040  * Revision 1.26.2.3  2007/08/17 08:38:22  rjongbloed
00041  * Back ported OPAL meda options based plug ins and H.323 generic capabilties.
00042  *
00043  * Revision 1.26.2.2  2007/03/24 23:39:42  shorne
00044  * More H.239 work
00045  *
00046  * Revision 1.26.2.1  2006/12/23 19:08:02  shorne
00047  * Plugin video codecs & sundry
00048  *
00049  * Revision 1.26  2006/09/05 23:56:57  csoutheren
00050  * Convert media format and capability factories to use std::string
00051  *
00052  * Revision 1.25  2006/06/23 03:18:23  shorne
00053  * Backport FECC (H.224) from Opal
00054  *
00055  * Revision 1.24  2005/11/30 13:05:01  csoutheren
00056  * Changed tags for Doxygen
00057  *
00058  * Revision 1.23  2005/08/13 19:35:57  shorne
00059  * Fix compile error on MSVC6
00060  *
00061  * Revision 1.22  2004/07/07 08:04:54  csoutheren
00062  * Added video codecs to default codec list, but H.263 is only loaded if the .so/DLL is found
00063  *
00064  * Revision 1.21  2004/07/07 03:52:12  csoutheren
00065  * Fixed incorrect strings returned by GetFormatName on G.711 codecs
00066  *
00067  * Revision 1.20  2004/06/30 12:31:09  rjongbloed
00068  * Rewrite of plug in system to use single global variable for all factories to avoid all sorts
00069  *   of issues with startup orders and Windows DLL multiple instances.
00070  *
00071  * Revision 1.19  2004/05/23 12:49:20  rjongbloed
00072  * Tidied some of the OpalMediaFormat usage after abandoning some previous
00073  *   code due to MSVC6 compiler bug.
00074  *
00075  * Revision 1.18  2004/05/20 02:07:28  csoutheren
00076  * Use macro to work around MSVC internal compiler errors
00077  *
00078  * Revision 1.17  2004/05/19 07:38:22  csoutheren
00079  * Changed OpalMediaFormat handling to use abstract factory method functions
00080  *
00081  * Revision 1.16  2004/05/03 00:52:23  csoutheren
00082  * Fixed problem with OpalMediaFormat::GetMediaFormatsList
00083  * Added new version of OpalMediaFormat::GetMediaFormatsList that minimses copying
00084  *
00085  * Revision 1.15  2004/04/03 10:38:24  csoutheren
00086  * Added in initial cut at codec plugin code. Branches are for wimps :)
00087  *
00088  * Revision 1.14.2.1  2004/03/31 11:11:59  csoutheren
00089  * Initial public release of plugin codec code
00090  *
00091  * Revision 1.14  2004/02/26 08:19:31  csoutheren
00092  * Fixed threading problem with GetMediaFormatList
00093  *
00094  * Revision 1.13  2002/12/02 03:06:26  robertj
00095  * Fixed over zealous removal of code when NO_AUDIO_CODECS set.
00096  *
00097  * Revision 1.12  2002/09/16 01:14:15  robertj
00098  * Added #define so can select if #pragma interface/implementation is used on
00099  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00100  *
00101  * Revision 1.11  2002/09/03 06:19:37  robertj
00102  * Normalised the multi-include header prevention ifdef/define symbol.
00103  *
00104  * Revision 1.10  2002/08/05 10:03:47  robertj
00105  * Cosmetic changes to normalise the usage of pragma interface/implementation.
00106  *
00107  * Revision 1.9  2002/06/25 08:30:08  robertj
00108  * Changes to differentiate between stright G.723.1 and G.723.1 Annex A using
00109  *   the OLC dataType silenceSuppression field so does not send SID frames
00110  *   to receiver codecs that do not understand them.
00111  *
00112  * Revision 1.8  2002/03/21 02:39:15  robertj
00113  * Added backward compatibility define
00114  *
00115  * Revision 1.7  2002/02/11 04:15:56  robertj
00116  * Put G.723.1 at 6.3kbps back to old string value of "G.723.1" to improve
00117  *   backward compatibility. New #define is a synonym for it.
00118  *
00119  * Revision 1.6  2002/01/22 07:08:26  robertj
00120  * Added IllegalPayloadType enum as need marker for none set
00121  *   and MaxPayloadType is a legal value.
00122  *
00123  * Revision 1.5  2001/12/11 04:27:50  craigs
00124  * Added support for 5.3kbps G723.1
00125  *
00126  * Revision 1.4  2001/09/21 02:49:44  robertj
00127  * Implemented static object for all "known" media formats.
00128  * Added default session ID to media format description.
00129  *
00130  * Revision 1.3  2001/05/11 04:43:41  robertj
00131  * Added variable names for standard PCM-16 media format name.
00132  *
00133  * Revision 1.2  2001/02/09 05:16:24  robertj
00134  * Added #pragma interface for GNU C++.
00135  *
00136  * Revision 1.1  2001/01/25 07:27:14  robertj
00137  * Major changes to add more flexible OpalMediaFormat class to normalise
00138  *   all information about media types, especially codecs.
00139  *
00140  */
00141 
00142 #ifndef __OPAL_MEDIAFMT_H
00143 #define __OPAL_MEDIAFMT_H
00144 
00145 #ifdef P_USE_PRAGMA
00146 #pragma interface
00147 #endif
00148 
00149 
00150 #include "rtp.h"
00151 
00152 #include <limits>
00153 
00154 #ifdef min
00155 #undef min
00156 #endif
00157 #ifdef max
00158 #undef max
00159 #endif
00160 
00161 class OpalMediaFormat;
00162 
00163 
00165 
00168 class OpalMediaOption : public PObject
00169 {
00170     PCLASSINFO(OpalMediaOption, PObject);
00171   public:
00172     enum MergeType {
00173       NoMerge,
00174       MinMerge,
00175       MaxMerge,
00176       EqualMerge,
00177       NotEqualMerge,
00178       AlwaysMerge,
00179 
00180       // Synonyms
00181       AndMerge = MaxMerge,
00182       OrMerge  = MinMerge,
00183       XorMerge = NotEqualMerge,
00184       NotXorMerge = EqualMerge
00185     };
00186 
00187   protected:
00188     OpalMediaOption(
00189       const char * name,
00190       bool readOnly,
00191       MergeType merge
00192     );
00193 
00194   public:
00195     virtual Comparison Compare(const PObject & obj) const;
00196 
00197     bool Merge(
00198       const OpalMediaOption & option
00199     );
00200     virtual Comparison CompareValue(
00201       const OpalMediaOption & option
00202     ) const = 0;
00203     virtual void Assign(
00204       const OpalMediaOption & option
00205     ) = 0;
00206 
00207     PString AsString() const;
00208     bool FromString(const PString & value);
00209 
00210     const PString & GetName() const { return m_name; }
00211 
00212     bool IsReadOnly() const { return m_readOnly; }
00213     void SetReadOnly(bool readOnly) { m_readOnly = readOnly; }
00214 
00215     MergeType GetMerge() const { return m_merge; }
00216     void SetMerge(MergeType merge) { m_merge = merge; }
00217 
00218     const PString & GetFMTPName() const { return m_FMTPName; }
00219     void SetFMTPName(const char * name) { m_FMTPName = name; }
00220 
00221     const PString & GetFMTPDefault() const { return m_FMTPDefault; }
00222     void SetFMTPDefault(const char * value) { m_FMTPDefault = value; }
00223 
00224     struct H245GenericInfo {
00225       unsigned ordinal:16;
00226       enum Modes {
00227         None,
00228         Collapsing,
00229         NonCollapsing
00230       } mode:3;
00231       enum IntegerTypes {
00232         UnsignedInt,
00233         Unsigned32,
00234         BooleanArray
00235       } integerType:3;
00236       bool excludeTCS:1;
00237       bool excludeOLC:1;
00238       bool excludeReqMode:1;
00239     };
00240 
00241     const H245GenericInfo & GetH245Generic() const { return m_H245Generic; }
00242     void SetH245Generic(const H245GenericInfo & generic) { m_H245Generic = generic; }
00243 
00244   protected:
00245     PCaselessString m_name;
00246     bool            m_readOnly;
00247     MergeType       m_merge;
00248     PCaselessString m_FMTPName;
00249     PString         m_FMTPDefault;
00250     H245GenericInfo m_H245Generic;
00251 };
00252 
00253 #ifndef __USE_STL__
00254 __inline istream & operator>>(istream & strm, bool& b)
00255 {
00256    int i;strm >> i;b = i; return strm;
00257 }
00258 #endif
00259 
00260 template <typename T>
00261 class OpalMediaOptionValue : public OpalMediaOption
00262 {
00263     PCLASSINFO(OpalMediaOptionValue, OpalMediaOption);
00264   public:
00265     OpalMediaOptionValue(
00266       const char * name,
00267       bool readOnly,
00268       MergeType merge = MinMerge,
00269       T value = 0,
00270       T minimum = std::numeric_limits<T>::min(),
00271       T maximum = std::numeric_limits<T>::max()
00272     ) : OpalMediaOption(name, readOnly, merge),
00273         m_value(value),
00274         m_minimum(minimum),
00275         m_maximum(maximum)
00276     { }
00277 
00278     virtual PObject * Clone() const
00279     {
00280       return new OpalMediaOptionValue(*this);
00281     }
00282 
00283     virtual void PrintOn(ostream & strm) const
00284     {
00285       strm << m_value;
00286     }
00287 
00288     virtual void ReadFrom(istream & strm)
00289     {
00290       T temp;
00291       strm >> temp;
00292       if (temp >= m_minimum && temp <= m_maximum)
00293         m_value = temp;
00294       else {
00295 #ifdef __USE_STL__
00296            strm.setstate(ios::badbit);
00297 #else
00298            strm.setf(ios::badbit , ios::badbit);
00299 #endif
00300        }
00301     }
00302 
00303     virtual Comparison CompareValue(const OpalMediaOption & option) const {
00304       const OpalMediaOptionValue * otherOption = PDownCast(const OpalMediaOptionValue, &option);
00305       if (otherOption == NULL)
00306         return GreaterThan;
00307       if (m_value < otherOption->m_value)
00308         return LessThan;
00309       if (m_value > otherOption->m_value)
00310         return GreaterThan;
00311       return EqualTo;
00312     }
00313 
00314     virtual void Assign(
00315       const OpalMediaOption & option
00316     ) {
00317       const OpalMediaOptionValue * otherOption = PDownCast(const OpalMediaOptionValue, &option);
00318       if (otherOption != NULL)
00319         m_value = otherOption->m_value;
00320     }
00321 
00322     T GetValue() const { return m_value; }
00323     void SetValue(T value) { m_value = value; }
00324 
00325   protected:
00326     T m_value;
00327     T m_minimum;
00328     T m_maximum;
00329 };
00330 
00331 
00332 typedef OpalMediaOptionValue<bool>     OpalMediaOptionBoolean;
00333 typedef OpalMediaOptionValue<int>      OpalMediaOptionInteger;
00334 typedef OpalMediaOptionValue<unsigned> OpalMediaOptionUnsigned;
00335 typedef OpalMediaOptionValue<double>   OpalMediaOptionReal;
00336 
00337 
00338 class OpalMediaOptionEnum : public OpalMediaOption
00339 {
00340     PCLASSINFO(OpalMediaOptionEnum, OpalMediaOption);
00341   public:
00342     OpalMediaOptionEnum(
00343       const char * name,
00344       bool readOnly,
00345       const char * const * enumerations,
00346       PINDEX count,
00347       MergeType merge = EqualMerge,
00348       PINDEX value = 0
00349     );
00350 
00351     virtual PObject * Clone() const;
00352     virtual void PrintOn(ostream & strm) const;
00353     virtual void ReadFrom(istream & strm);
00354 
00355     virtual Comparison CompareValue(const OpalMediaOption & option) const;
00356     virtual void Assign(const OpalMediaOption & option);
00357 
00358     PINDEX GetValue() const { return m_value; }
00359     void SetValue(PINDEX value);
00360 
00361   protected:
00362     PStringArray m_enumerations;
00363     PINDEX       m_value;
00364 };
00365 
00366 
00367 class OpalMediaOptionString : public OpalMediaOption
00368 {
00369     PCLASSINFO(OpalMediaOptionString, OpalMediaOption);
00370   public:
00371     OpalMediaOptionString(
00372       const char * name,
00373       bool readOnly
00374     );
00375     OpalMediaOptionString(
00376       const char * name,
00377       bool readOnly,
00378       const PString & value
00379     );
00380 
00381     virtual PObject * Clone() const;
00382     virtual void PrintOn(ostream & strm) const;
00383     virtual void ReadFrom(istream & strm);
00384 
00385     virtual Comparison CompareValue(const OpalMediaOption & option) const;
00386     virtual void Assign(const OpalMediaOption & option);
00387 
00388     const PString & GetValue() const { return m_value; }
00389     void SetValue(const PString & value);
00390 
00391   protected:
00392     PString m_value;
00393 };
00394 
00395 
00396 class OpalMediaOptionOctets : public OpalMediaOption
00397 {
00398     PCLASSINFO(OpalMediaOptionOctets, OpalMediaOption);
00399   public:
00400     OpalMediaOptionOctets(
00401       const char * name,
00402       bool readOnly,
00403       bool base64
00404     );
00405     OpalMediaOptionOctets(
00406       const char * name,
00407       bool readOnly,
00408       bool base64,
00409       const PBYTEArray & value
00410     );
00411     OpalMediaOptionOctets(
00412       const char * name,
00413       bool readOnly,
00414       bool base64,
00415       const BYTE * data,
00416       PINDEX length
00417     );
00418 
00419     virtual PObject * Clone() const;
00420     virtual void PrintOn(ostream & strm) const;
00421     virtual void ReadFrom(istream & strm);
00422 
00423     virtual Comparison CompareValue(const OpalMediaOption & option) const;
00424     virtual void Assign(const OpalMediaOption & option);
00425 
00426     const PBYTEArray & GetValue() const { return m_value; }
00427     void SetValue(const PBYTEArray & value);
00428     void SetValue(const BYTE * data, PINDEX length);
00429 
00430   protected:
00431     PBYTEArray m_value;
00432     bool       m_base64;
00433 };
00434 
00435 
00437 
00443 class OpalMediaFormat : public PCaselessString
00444 {
00445   PCLASSINFO(OpalMediaFormat, PCaselessString);
00446 
00447   public:
00448     PLIST(List, OpalMediaFormat);
00449 
00452     OpalMediaFormat();
00453 
00458     OpalMediaFormat(
00459       const char * search,  
00460       BOOL exact = TRUE     
00461     );
00462 
00467     BOOL IsValid() const { return rtpPayloadType <= RTP_DataFrame::MaxPayloadType; }
00468 
00471     OpalMediaFormat & operator=(
00472       const OpalMediaFormat & fmt 
00473     );
00474 
00485     virtual bool Merge(
00486       const OpalMediaFormat & mediaFormat
00487     );
00488 
00494     RTP_DataFrame::PayloadTypes GetPayloadType() const { return rtpPayloadType; }
00495 
00496     void SetPayloadType(RTP_DataFrame::PayloadTypes type) { rtpPayloadType = type; }
00497     enum {
00498       FirstSessionID            = 1,
00499       DefaultAudioSessionID     = 1,
00500       DefaultVideoSessionID     = 2,
00501       DefaultDataSessionID      = 3,
00502       DefaultH224SessionID      = 4,
00503       DefaultExtVideoSessionID  = 5,
00504       LastSessionID             = 5
00505     };
00506 
00509     unsigned GetDefaultSessionID() const { return defaultSessionID; }
00510 
00514     BOOL NeedsJitterBuffer() const { return needsJitter; }
00515 
00518     unsigned GetBandwidth() const { return bandwidth; }
00519 
00524     PINDEX GetFrameSize() const { return frameSize; }
00525         void SetFrameSize(PINDEX size) { frameSize = size; }
00526 
00530     unsigned GetFrameTime() const { return frameTime; }
00531 
00534         void SetFrameTime(unsigned ft) { frameTime = ft; }
00535 
00538     virtual unsigned GetTimeUnits() const { return timeUnits; }
00539     virtual void SetTimeUnits(unsigned units) { timeUnits = units; }
00540 
00541     enum StandardTimeUnits {
00542       AudioTimeUnits = 8,  
00543       VideoTimeUnits = 90  
00544     };
00545  
00548     static List GetRegisteredMediaFormats();
00549     static void GetRegisteredMediaFormats(List & list);
00550 
00551     friend class OpalStaticMediaFormat;
00552 
00566     OpalMediaFormat(
00567       const char * fullName,  
00568       unsigned defaultSessionID,  
00569       RTP_DataFrame::PayloadTypes rtpPayloadType, 
00570       BOOL     needsJitter,   
00571       unsigned bandwidth,     
00572       PINDEX   frameSize = 0, 
00573       unsigned frameTime = 0, 
00574       unsigned timeUnits = 0, 
00575       time_t timeStamp = 0    
00576 
00577     );
00578     
00579     bool GetOptionValue(
00580       const PString & name,   
00581       PString & value         
00582     ) const;
00583 
00590     bool SetOptionValue(
00591       const PString & name,   
00592       const PString & value   
00593     );
00594 
00598     bool GetOptionBoolean(
00599       const PString & name,   
00600       bool dflt = FALSE       
00601     ) const;
00602 
00609     bool SetOptionBoolean(
00610       const PString & name,   
00611       bool value              
00612     );
00613 
00617     int GetOptionInteger(
00618       const PString & name,   
00619       int dflt = 0            
00620     ) const;
00621 
00629     bool SetOptionInteger(
00630       const PString & name,   
00631       int value               
00632     );
00633 
00637     double GetOptionReal(
00638       const PString & name,   
00639       double dflt = 0         
00640     ) const;
00641 
00648     bool SetOptionReal(
00649       const PString & name,   
00650       double value            
00651     );
00652 
00657     PINDEX GetOptionEnum(
00658       const PString & name,   
00659       PINDEX dflt = 0         
00660     ) const;
00661 
00668     bool SetOptionEnum(
00669       const PString & name,   
00670       PINDEX value            
00671     );
00672 
00676     PString GetOptionString(
00677       const PString & name,                   
00678       const PString & dflt = PString::Empty() 
00679     ) const;
00680 
00687     bool SetOptionString(
00688       const PString & name,   
00689       const PString & value   
00690     );
00691 
00695     bool GetOptionOctets(
00696       const PString & name, 
00697       PBYTEArray & octets   
00698     ) const;
00699 
00706     bool SetOptionOctets(
00707       const PString & name,       
00708       const PBYTEArray & octets   
00709     );
00710     bool SetOptionOctets(
00711       const PString & name,       
00712       const BYTE * data,          
00713       PINDEX length               
00714     );
00715 
00719     static bool SetRegisteredMediaFormat(
00720       const OpalMediaFormat & mediaFormat  
00721     );
00722 
00726     bool AddOption(
00727       OpalMediaOption * option,
00728       BOOL overwrite = FALSE
00729     );
00730     
00734     bool HasOption(const PString & name) const
00735     { return FindOption(name) != NULL; }
00736 
00741     OpalMediaOption * FindOption(
00742       const PString & name
00743     ) const;
00744 
00745         OpalMediaOption & GetOption(PINDEX i) const
00746         { return options[i];  }
00747 
00748         PINDEX GetOptionCount() const
00749         { return options.GetSize(); }
00750 
00751 #if PTRACING
00752         static void DebugOptionList(const OpalMediaFormat & fmt);
00753 #endif
00754 
00755   protected:
00756     RTP_DataFrame::PayloadTypes rtpPayloadType;
00757     unsigned defaultSessionID;
00758     BOOL     needsJitter;
00759     unsigned bandwidth;
00760     PINDEX   frameSize;
00761     unsigned frameTime;
00762     unsigned timeUnits;
00763     PMutex   media_format_mutex;
00764     PSortedList<OpalMediaOption> options;
00765     time_t codecBaseTime;
00766 
00767 };
00768 
00769 #ifdef H323_VIDEO
00770 class OpalVideoFormat : public OpalMediaFormat
00771 {
00772   friend class OpalPluginCodecManager;
00773     PCLASSINFO(OpalVideoFormat, OpalMediaFormat);
00774   public:
00775     OpalVideoFormat(
00776       const char * fullName,    
00777       RTP_DataFrame::PayloadTypes rtpPayloadType, 
00778       unsigned frameWidth,      
00779       unsigned frameHeight,     
00780       unsigned frameRate,       
00781       unsigned bitRate,         
00782       time_t timeStamp = 0        
00783     );
00784 
00785     virtual PObject * Clone() const;
00786 
00787     virtual bool Merge(const OpalMediaFormat & mediaFormat);
00788 
00789     static const char * const FrameWidthOption;
00790     static const char * const FrameHeightOption;
00791     static const char * const EncodingQualityOption;
00792     static const char * const TargetBitRateOption;
00793     static const char * const DynamicVideoQualityOption;
00794     static const char * const AdaptivePacketDelayOption;
00795 
00796     static const char * const NeedsJitterOption;
00797     static const char * const MaxBitRateOption;
00798     static const char * const MaxFrameSizeOption;
00799     static const char * const FrameTimeOption;
00800         static const char * const ClockRateOption;
00801 
00802 };
00803 #endif
00804 // List of known media formats
00805 
00806 #define OPAL_PCM16         "PCM-16"
00807 #define OPAL_G711_ULAW_64K "G.711-uLaw-64k"
00808 #define OPAL_G711_ALAW_64K "G.711-ALaw-64k"
00809 #define OPAL_G711_ULAW_56K "G.711-uLaw-56k"
00810 #define OPAL_G711_ALAW_56K "G.711-ALaw-56k"
00811 #define OPAL_G728          "G.728"
00812 #define OPAL_G729          "G.729"
00813 #define OPAL_G729A         "G.729A"
00814 #define OPAL_G729B         "G.729B"
00815 #define OPAL_G729AB        "G.729A/B"
00816 #define OPAL_G7231         "G.723.1"
00817 #define OPAL_G7231_6k3     OPAL_G7231
00818 #define OPAL_G7231_5k3     "G.723.1(5.3k)"
00819 #define OPAL_G7231A_6k3    "G.723.1A(6.3k)"
00820 #define OPAL_G7231A_5k3    "G.723.1A(5.3k)"
00821 #define OPAL_GSM0610       "GSM-06.10"
00822 
00823 extern char OpalPCM16[];
00824 extern char OpalG711uLaw64k[];
00825 extern char OpalG711ALaw64k[];
00826 extern char OpalG728[];
00827 extern char OpalG729[];
00828 extern char OpalG729A[];
00829 extern char OpalG729B[];
00830 extern char OpalG729AB[];
00831 extern char OpalG7231_6k3[];
00832 extern char OpalG7231_5k3[];
00833 extern char OpalG7231A_6k3[];
00834 extern char OpalG7231A_5k3[];
00835 extern char OpalGSM0610[];
00836 
00837 #define OpalG711uLaw      OpalG711uLaw64k
00838 #define OpalG711ALaw      OpalG711ALaw64k
00839 #define OpalG7231 OpalG7231_6k3
00840 
00841 //
00842 // Originally, the following inplace code was used instead of this macro:
00843 //
00844 // static PAbstractSingletonFactory<OpalMediaFormat, 
00845 //     OpalStaticMediaFormatTemplate<
00846 //          OpalPCM16,
00847 //          OpalMediaFormat::DefaultAudioSessionID,
00848 //          RTP_DataFrame::L16_Mono,
00849 //          TRUE,   // Needs jitter
00850 //          128000, // bits/sec
00851 //          16, // bytes/frame
00852 //          8, // 1 millisecond
00853 //          OpalMediaFormat::AudioTimeUnits,
00854 //          0
00855 //     > 
00856 // > opalPCM16Factory(OpalPCM16);
00857 //
00858 // This used the following macro:
00859 //
00860 //
00861 //  template <
00862 //        const char * _fullName,  /// Full name of media format
00863 //        unsigned _defaultSessionID,  /// Default session for codec type
00864 //        RTP_DataFrame::PayloadTypes _rtpPayloadType, /// RTP payload type code
00865 //        BOOL     _needsJitter,       /// Indicate format requires a jitter buffer
00866 //        unsigned _bandwidth,         /// Bandwidth in bits/second
00867 //        PINDEX   _frameSize,         /// Size of frame in bytes (if applicable)
00868 //        unsigned _frameTime,         /// Time for frame in RTP units (if applicable)
00869 //        unsigned _timeUnits,         /// RTP units for frameTime (if applicable)
00870 //        time_t _timeStamp            /// timestamp (for versioning)
00871 //  >
00872 //  class OpalStaticMediaFormatTemplate : public OpalStaticMediaFormat
00873 //  {
00874 //    public:
00875 //      OpalStaticMediaFormatTemplate()
00876 //        : OpalStaticMediaFormat(_fullName, _defaultSessionID, _rtpPayloadType, _needsJitter, _bandwidth
00877 //        , _frameSize, _frameTime, _timeUnits, _timeStamp )
00878 //      { }
00879 //  };
00880 //
00881 // Unfortauntely, MSVC 6 did not like this so this crappy macro has to be used instead of a template
00882 //
00883 
00884 typedef PFactory<OpalMediaFormat, std::string> OpalMediaFormatFactory;
00885 
00886 #define OPAL_MEDIA_FORMAT_DECLARE(classname, _fullName, _defaultSessionID, _rtpPayloadType, _needsJitter,_bandwidth, _frameSize, _frameTime, _timeUnits, _timeStamp) \
00887 class classname : public OpalMediaFormat \
00888 { \
00889   public: \
00890     classname() \
00891       : OpalMediaFormat(_fullName, _defaultSessionID, _rtpPayloadType, _needsJitter, _bandwidth, \
00892         _frameSize, _frameTime, _timeUnits, _timeStamp){} \
00893 }; \
00894 OpalMediaFormatFactory::Worker<classname> classname##Factory(_fullName, true); \
00895 
00896 
00897 #endif  // __OPAL_MEDIAFMT_H
00898 
00899 
00900 // End of File ///////////////////////////////////////////////////////////////

Generated on Thu Oct 25 13:42:36 2007 for h323plus by  doxygen 1.5.2