vidcodec.h

Go to the documentation of this file.
00001 /*
00002  * vidcodec.h
00003  *
00004  * Uncompressed video handler
00005  *
00006  * Open Phone Abstraction Library
00007  *
00008  * Copyright (c) 2003 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 Phone Abstraction Library.
00021  *
00022  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00023  *
00024  * Contributor(s): 
00025  *
00026  * $Log: vidcodec.h,v $
00027  * Revision 2.12  2005/11/30 13:35:26  csoutheren
00028  * Changed tags for Doxygen
00029  *
00030  * Revision 2.11  2005/10/21 17:58:31  dsandras
00031  * Applied patch from Hannes Friederich <hannesf AATT ee.ethz.ch> to fix OpalVideoUpdatePicture - PIsDescendant problems. Thanks!
00032  *
00033  * Revision 2.10  2005/09/06 12:44:49  rjongbloed
00034  * Many fixes to finalise the video processing: merging remote media
00035  *
00036  * Revision 2.9  2005/09/04 06:23:38  rjongbloed
00037  * Added OpalMediaCommand mechanism (via PNotifier) for media streams
00038  *   and media transcoders to send commands back to remote.
00039  *
00040  * Revision 2.8  2005/08/31 13:19:25  rjongbloed
00041  * Added mechanism for controlling media (especially codecs) including
00042  *   changing the OpalMediaFormat option list (eg bit rate) and a completely
00043  *   new OpalMediaCommand abstraction for things like video fast update.
00044  *
00045  * Revision 2.7  2005/08/28 07:59:17  rjongbloed
00046  * Converted OpalTranscoder to use factory, requiring sme changes in making sure
00047  *   OpalMediaFormat instances are initialised before use.
00048  *
00049  * Revision 2.6  2005/07/24 07:33:07  rjongbloed
00050  * Simplified "uncompressed" transcoder sp can test video media streams.
00051  *
00052  * Revision 2.5  2005/02/21 12:19:45  rjongbloed
00053  * Added new "options list" to the OpalMediaFormat class.
00054  *
00055  * Revision 2.4  2004/09/01 12:21:27  rjongbloed
00056  * Added initialisation of H323EndPoints capability table to be all codecs so can
00057  *   correctly build remote caps from fqast connect params. This had knock on effect
00058  *   with const keywords added in numerous places.
00059  *
00060  * Revision 2.3  2004/03/11 06:54:26  csoutheren
00061  * Added ability to disable SIP or H.323 stacks
00062  *
00063  * Revision 2.2  2004/01/18 15:35:20  rjongbloed
00064  * More work on video support
00065  *
00066  * Revision 2.1  2003/03/17 10:26:59  robertj
00067  * Added video support.
00068  *
00069  */
00070 
00071 #ifndef __OPAL_VIDCODEC_H
00072 #define __OPAL_VIDCODEC_H
00073 
00074 #ifdef P_USE_PRAGMA
00075 #pragma interface
00076 #endif
00077 
00078 
00079 #include <opal/transcoders.h>
00080 
00081 #ifndef NO_H323
00082 #include <h323/h323caps.h>
00083 #endif
00084 
00085 
00086 #define OPAL_RGB24   "RGB24"
00087 #define OPAL_RGB32   "RGB32"
00088 #define OPAL_YUV420P "YUV420P"
00089 
00090 extern const OpalVideoFormat & GetOpalRGB24();
00091 extern const OpalVideoFormat & GetOpalRGB32();
00092 extern const OpalVideoFormat & GetOpalYUV420P();
00093 
00094 #define OpalRGB24   GetOpalRGB24()
00095 #define OpalRGB32   GetOpalRGB32()
00096 #define OpalYUV420P GetOpalYUV420P()
00097 
00098 
00100 
00107 class OpalVideoTranscoder : public OpalTranscoder
00108 {
00109     PCLASSINFO(OpalVideoTranscoder, OpalTranscoder);
00110   public:
00111     struct FrameHeader {
00112       PInt32l  x;
00113       PInt32l  y;
00114       PUInt32l width;
00115       PUInt32l height;
00116       BYTE     data[1];
00117     };
00118 
00123     OpalVideoTranscoder(
00124       const OpalMediaFormat & inputMediaFormat,  
00125       const OpalMediaFormat & outputMediaFormat  
00126     );
00128 
00139     virtual BOOL UpdateOutputMediaFormat(
00140       const OpalMediaFormat & mediaFormat  
00141     );
00142 
00150     virtual BOOL ExecuteCommand(
00151       const OpalMediaCommand & command    
00152     );
00153 
00164     virtual BOOL Convert(
00165       const RTP_DataFrame & input,  
00166       RTP_DataFrame & output        
00167     );
00169 
00170   protected:
00171     unsigned frameWidth;
00172     unsigned frameHeight;
00173     unsigned videoQuality;
00174     unsigned targetBitRate;
00175     bool     dynamicVideoQuality;
00176     bool     adaptivePacketDelay;
00177     unsigned fillLevel;
00178     bool     updatePicture;
00179 };
00180 
00181 
00183 
00184 OPAL_DEFINE_MEDIA_COMMAND(OpalVideoFreezePicture, "Freeze Picture");
00185 
00186 class OpalVideoUpdatePicture : public OpalMediaCommand
00187 {
00188   PCLASSINFO(OpalVideoUpdatePicture, OpalMediaCommand);
00189   public:
00190     OpalVideoUpdatePicture(int firstGOB = -1, int firstMB = -1, int numBlocks = 0)
00191       : m_firstGOB(firstGOB), m_firstMB(firstMB), m_numBlocks(numBlocks) { }
00192 
00193     virtual PString GetName() const;
00194 
00195     int GetFirstGOB() const { return m_firstGOB; }
00196     int GetFirstMB() const { return m_firstMB; }
00197     int GetNumBlocks() const { return m_numBlocks; }
00198 
00199   protected:
00200     int m_firstGOB;
00201     int m_firstMB;
00202     int m_numBlocks;
00203 };
00204 
00205 
00206 class OpalTemporalSpatialTradeOff : public OpalMediaCommand
00207 {
00208   PCLASSINFO(OpalTemporalSpatialTradeOff, OpalMediaCommand);
00209   public:
00210     OpalTemporalSpatialTradeOff(int quality) : m_quality(quality) { }
00211 
00212     virtual PString GetName() const;
00213 
00214     int GetQuality() const { return m_quality; }
00215 
00216   protected:
00217     int m_quality;
00218 };
00219 
00220 
00222 
00223 #ifndef NO_H323
00224 
00227 class H323_UncompVideoCapability : public H323NonStandardVideoCapability
00228 {
00229   PCLASSINFO(H323_UncompVideoCapability, H323NonStandardVideoCapability)
00230 
00231   public:
00236     H323_UncompVideoCapability(
00237       const H323EndPoint & endpoint, 
00238       const PString & colourFormat   
00239     );
00241 
00246     virtual PObject * Clone() const;
00248 
00253     virtual PString GetFormatName() const;
00255 
00256   protected:
00257     PString colourFormat;
00258 };
00259 
00260 #define OPAL_REGISTER_UNCOMPRESSED_VIDEO_H323 \
00261   H323_REGISTER_CAPABILITY_FUNCTION(H323_RGB24, OPAL_RGB24, ep) \
00262     { return new H323_UncompVideoCapability(ep, OpalRGB24); } \
00263   H323_REGISTER_CAPABILITY_FUNCTION(H323_RGB32, OPAL_RGB32, ep) \
00264     { return new H323_UncompVideoCapability(ep, OpalRGB32); }
00265 
00266 #else // ifndef NO_H323
00267 
00268 #define OPAL_REGISTER_UNCOMPRESSED_VIDEO_H323
00269 
00270 #endif // ifndef NO_H323
00271 
00272 
00274 
00278 class OpalUncompVideoTranscoder : public OpalVideoTranscoder
00279 {
00280   PCLASSINFO(OpalUncompVideoTranscoder, OpalVideoTranscoder);
00281   public:
00286     OpalUncompVideoTranscoder(
00287       const OpalMediaFormat & inputMediaFormat,  
00288       const OpalMediaFormat & outputMediaFormat  
00289     );
00290 
00293     ~OpalUncompVideoTranscoder();
00295 
00304     virtual PINDEX GetOptimalDataFrameSize(
00305       BOOL input      
00306     ) const;
00307 
00318     virtual BOOL ConvertFrames(
00319       const RTP_DataFrame & input,  
00320       RTP_DataFrameList & output    
00321     );
00323 };
00324 
00325 
00326 class Opal_RGB24_RGB24 : public OpalUncompVideoTranscoder {
00327   PCLASSINFO(Opal_RGB24_RGB24, OpalUncompVideoTranscoder);
00328   public:
00329     Opal_RGB24_RGB24() : OpalUncompVideoTranscoder(OpalRGB24, OpalRGB24) { }
00330 };
00331 
00332 
00333 class Opal_RGB32_RGB32 : public OpalUncompVideoTranscoder {
00334   PCLASSINFO(Opal_RGB32_RGB32, OpalUncompVideoTranscoder);
00335   public:
00336     Opal_RGB32_RGB32() : OpalUncompVideoTranscoder(OpalRGB32, OpalRGB32) { }
00337 };
00338 
00339 
00341 
00342 #define OPAL_REGISTER_UNCOMPRESSED_VIDEO() \
00343           OPAL_REGISTER_UNCOMPRESSED_VIDEO_H323 \
00344           OPAL_REGISTER_TRANSCODER(Opal_RGB32_RGB32, OpalRGB32, OpalRGB32); \
00345           OPAL_REGISTER_TRANSCODER(Opal_RGB24_RGB24, OpalRGB24, OpalRGB24)
00346 
00347 
00348 #endif // __OPAL_VIDCODEC_H
00349 
00350 

Generated on Mon Sep 25 16:20:12 2006 for OPAL by  doxygen 1.4.7