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.16  2007/09/25 09:49:54  rjongbloed
00028  * Fixed videoFastUpdate, is not a count but a simple boolean.
00029  *
00030  * Revision 2.15  2007/08/17 11:14:17  csoutheren
00031  * Add OnLostPicture and OnLostPartialPicture commands
00032  *
00033  * Revision 2.14  2007/02/16 07:56:02  dereksmithies
00034  * Change flag used so H.323 capabiliites are included  if H.323 was enabled
00035  * when the library was configured.
00036  *
00037  * Revision 2.13  2006/07/24 14:03:38  csoutheren
00038  * Merged in audio and video plugins from CVS branch PluginBranch
00039  *
00040  * Revision 2.12.4.2  2006/04/19 07:52:30  csoutheren
00041  * Add ability to have SIP-only and H.323-only codecs, and implement for H.261
00042  *
00043  * Revision 2.12.4.1  2006/04/06 01:21:16  csoutheren
00044  * More implementation of video codec plugins
00045  *
00046  * Revision 2.12  2005/11/30 13:35:26  csoutheren
00047  * Changed tags for Doxygen
00048  *
00049  * Revision 2.11  2005/10/21 17:58:31  dsandras
00050  * Applied patch from Hannes Friederich <hannesf AATT ee.ethz.ch> to fix OpalVideoUpdatePicture - PIsDescendant problems. Thanks!
00051  *
00052  * Revision 2.10  2005/09/06 12:44:49  rjongbloed
00053  * Many fixes to finalise the video processing: merging remote media
00054  *
00055  * Revision 2.9  2005/09/04 06:23:38  rjongbloed
00056  * Added OpalMediaCommand mechanism (via PNotifier) for media streams
00057  *   and media transcoders to send commands back to remote.
00058  *
00059  * Revision 2.8  2005/08/31 13:19:25  rjongbloed
00060  * Added mechanism for controlling media (especially codecs) including
00061  *   changing the OpalMediaFormat option list (eg bit rate) and a completely
00062  *   new OpalMediaCommand abstraction for things like video fast update.
00063  *
00064  * Revision 2.7  2005/08/28 07:59:17  rjongbloed
00065  * Converted OpalTranscoder to use factory, requiring sme changes in making sure
00066  *   OpalMediaFormat instances are initialised before use.
00067  *
00068  * Revision 2.6  2005/07/24 07:33:07  rjongbloed
00069  * Simplified "uncompressed" transcoder sp can test video media streams.
00070  *
00071  * Revision 2.5  2005/02/21 12:19:45  rjongbloed
00072  * Added new "options list" to the OpalMediaFormat class.
00073  *
00074  * Revision 2.4  2004/09/01 12:21:27  rjongbloed
00075  * Added initialisation of H323EndPoints capability table to be all codecs so can
00076  *   correctly build remote caps from fqast connect params. This had knock on effect
00077  *   with const keywords added in numerous places.
00078  *
00079  * Revision 2.3  2004/03/11 06:54:26  csoutheren
00080  * Added ability to disable SIP or H.323 stacks
00081  *
00082  * Revision 2.2  2004/01/18 15:35:20  rjongbloed
00083  * More work on video support
00084  *
00085  * Revision 2.1  2003/03/17 10:26:59  robertj
00086  * Added video support.
00087  *
00088  */
00089 
00090 #ifndef __OPAL_VIDCODEC_H
00091 #define __OPAL_VIDCODEC_H
00092 
00093 #ifdef P_USE_PRAGMA
00094 #pragma interface
00095 #endif
00096 
00097 
00098 #include <opal/transcoders.h>
00099 
00100 #if OPAL_H323
00101 #include <h323/h323caps.h>
00102 #endif
00103 
00104 #include <codec/opalplugin.h>
00105 
00106 
00107 #define OPAL_RGB24   "RGB24"
00108 #define OPAL_RGB32   "RGB32"
00109 #define OPAL_YUV420P "YUV420P"
00110 
00111 extern const OpalVideoFormat & GetOpalRGB24();
00112 extern const OpalVideoFormat & GetOpalRGB32();
00113 extern const OpalVideoFormat & GetOpalYUV420P();
00114 
00115 #define OpalRGB24   GetOpalRGB24()
00116 #define OpalRGB32   GetOpalRGB32()
00117 #define OpalYUV420P GetOpalYUV420P()
00118 
00119 
00121 
00128 class OpalVideoTranscoder : public OpalTranscoder
00129 {
00130     PCLASSINFO(OpalVideoTranscoder, OpalTranscoder);
00131   public:
00132     typedef PluginCodec_Video_FrameHeader FrameHeader;
00133 
00138     OpalVideoTranscoder(
00139       const OpalMediaFormat & inputMediaFormat,  
00140       const OpalMediaFormat & outputMediaFormat  
00141     );
00143 
00154     virtual BOOL UpdateOutputMediaFormat(
00155       const OpalMediaFormat & mediaFormat  
00156     );
00157 
00165     virtual BOOL ExecuteCommand(
00166       const OpalMediaCommand & command    
00167     );
00168 
00179     virtual BOOL Convert(
00180       const RTP_DataFrame & input,  
00181       RTP_DataFrame & output        
00182     );
00184 
00185   protected:
00186     unsigned frameWidth;
00187     unsigned frameHeight;
00188     unsigned videoQuality;
00189     unsigned targetBitRate;
00190     bool     dynamicVideoQuality;
00191     bool     adaptivePacketDelay;
00192     unsigned fillLevel;
00193 
00194     bool     forceIFrame;
00195 };
00196 
00197 
00199 
00200 OPAL_DEFINE_MEDIA_COMMAND(OpalVideoFreezePicture, "Freeze Picture");
00201 
00202 class OpalVideoUpdatePicture : public OpalMediaCommand
00203 {
00204   PCLASSINFO(OpalVideoUpdatePicture, OpalMediaCommand);
00205   public:
00206     OpalVideoUpdatePicture(int firstGOB = -1, int firstMB = -1, int numBlocks = 0)
00207       : m_firstGOB(firstGOB), m_firstMB(firstMB), m_numBlocks(numBlocks) { }
00208 
00209     virtual PString GetName() const;
00210 
00211     int GetFirstGOB() const { return m_firstGOB; }
00212     int GetFirstMB() const { return m_firstMB; }
00213     int GetNumBlocks() const { return m_numBlocks; }
00214 
00215   protected:
00216     int m_firstGOB;
00217     int m_firstMB;
00218     int m_numBlocks;
00219 };
00220 
00221 
00222 class OpalTemporalSpatialTradeOff : public OpalMediaCommand
00223 {
00224   PCLASSINFO(OpalTemporalSpatialTradeOff, OpalMediaCommand);
00225   public:
00226     OpalTemporalSpatialTradeOff(int quality) : m_quality(quality) { }
00227 
00228     virtual PString GetName() const;
00229 
00230     int GetQuality() const { return m_quality; }
00231 
00232   protected:
00233     int m_quality;
00234 };
00235 
00236 
00237 class OpalLostPartialPicture : public OpalMediaCommand
00238 {
00239   PCLASSINFO(OpalLostPartialPicture, OpalMediaCommand);
00240   public:
00241     OpalLostPartialPicture() { }
00242     virtual PString GetName() const;
00243 };
00244 
00245 
00246 class OpalLostPicture : public OpalMediaCommand
00247 {
00248   PCLASSINFO(OpalLostPicture, OpalMediaCommand);
00249   public:
00250     OpalLostPicture() { }
00251     virtual PString GetName() const;
00252 };
00253 
00254 
00256 
00257 #if OPAL_H323
00258 /* This code is only built if the user has enabled the H.323 voip
00259    protocol in the configure step. The default configuration enables
00260    H.323 */
00261 
00264 class H323_UncompVideoCapability : public H323NonStandardVideoCapability
00265 {
00266   PCLASSINFO(H323_UncompVideoCapability, H323NonStandardVideoCapability)
00267 
00268   public:
00273     H323_UncompVideoCapability(
00274       const H323EndPoint & endpoint, 
00275       const PString & colourFormat   
00276     );
00278 
00283     virtual PObject * Clone() const;
00285 
00290     virtual PString GetFormatName() const;
00292 
00293   protected:
00294     PString colourFormat;
00295 };
00296 
00297 #define OPAL_REGISTER_UNCOMPRESSED_VIDEO_H323 \
00298   H323_REGISTER_CAPABILITY_FUNCTION(H323_RGB24, OPAL_RGB24, ep) \
00299     { return new H323_UncompVideoCapability(ep, OpalRGB24); } \
00300   H323_REGISTER_CAPABILITY_FUNCTION(H323_RGB32, OPAL_RGB32, ep) \
00301     { return new H323_UncompVideoCapability(ep, OpalRGB32); }
00302 
00303 #else // ifndef NO_H323
00304 
00305 #define OPAL_REGISTER_UNCOMPRESSED_VIDEO_H323
00306 
00307 #endif // ifndef NO_H323
00308 
00309 
00311 
00315 class OpalUncompVideoTranscoder : public OpalVideoTranscoder
00316 {
00317   PCLASSINFO(OpalUncompVideoTranscoder, OpalVideoTranscoder);
00318   public:
00323     OpalUncompVideoTranscoder(
00324       const OpalMediaFormat & inputMediaFormat,  
00325       const OpalMediaFormat & outputMediaFormat  
00326     );
00327 
00330     ~OpalUncompVideoTranscoder();
00332 
00341     virtual PINDEX GetOptimalDataFrameSize(
00342       BOOL input      
00343     ) const;
00344 
00355     virtual BOOL ConvertFrames(
00356       const RTP_DataFrame & input,  
00357       RTP_DataFrameList & output    
00358     );
00360 };
00361 
00362 
00363 class Opal_RGB24_RGB24 : public OpalUncompVideoTranscoder {
00364   PCLASSINFO(Opal_RGB24_RGB24, OpalUncompVideoTranscoder);
00365   public:
00366     Opal_RGB24_RGB24() : OpalUncompVideoTranscoder(OpalRGB24, OpalRGB24) { }
00367 };
00368 
00369 
00370 class Opal_RGB32_RGB32 : public OpalUncompVideoTranscoder {
00371   PCLASSINFO(Opal_RGB32_RGB32, OpalUncompVideoTranscoder);
00372   public:
00373     Opal_RGB32_RGB32() : OpalUncompVideoTranscoder(OpalRGB32, OpalRGB32) { }
00374 };
00375 
00376 
00378 
00379 #define OPAL_REGISTER_UNCOMPRESSED_VIDEO() \
00380           OPAL_REGISTER_UNCOMPRESSED_VIDEO_H323 \
00381           OPAL_REGISTER_TRANSCODER(Opal_RGB32_RGB32, OpalRGB32, OpalRGB32); \
00382           OPAL_REGISTER_TRANSCODER(Opal_RGB24_RGB24, OpalRGB24, OpalRGB24)
00383 
00384 
00385 #endif // __OPAL_VIDCODEC_H
00386 
00387 

Generated on Fri Mar 7 06:33:42 2008 for OPAL by  doxygen 1.5.1