h261codec.h

Go to the documentation of this file.
00001 /*
00002  * h261codec.h
00003  *
00004  * H.323 protocol handler
00005  *
00006  * Open H323 Library
00007  *
00008  * Copyright (c) 1999-2000 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): Michele Piccini (michele@piccini.com).
00025  *                 Derek Smithies (derek@indranet.co.nz)
00026  *
00027  * $Log: h261codec.h,v $
00028  * Revision 1.37  2006/03/28 05:15:01  csoutheren
00029  * Change video codecs to set grabber capture size rather than
00030  * grabber size setting codec size
00031  *
00032  * Revision 1.36  2005/11/30 13:05:01  csoutheren
00033  * Changed tags for Doxygen
00034  *
00035  * Revision 1.35  2004/01/02 00:31:42  dereksmithies
00036  * Fix test on presence/absence of video.
00037  *
00038  * Revision 1.34  2003/12/14 10:42:29  rjongbloed
00039  * Changes for compilability without video support.
00040  *
00041  * Revision 1.33  2003/10/02 23:37:56  dereksmithies
00042  * Add fix for fast update problem in h261 codec. Thanks to Martin André for doing the initial legwork.
00043  *
00044  * Revision 1.32  2003/04/03 23:54:11  robertj
00045  * Added fast update to H.261 codec, thanks Gustavo García Bernardo
00046  *
00047  * Revision 1.31  2002/12/16 09:11:15  robertj
00048  * Added new video bit rate control, thanks Walter H. Whitlock
00049  *
00050  * Revision 1.30  2002/09/16 01:14:15  robertj
00051  * Added #define so can select if #pragma interface/implementation is used on
00052  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00053  *
00054  * Revision 1.29  2002/09/03 06:19:36  robertj
00055  * Normalised the multi-include header prevention ifdef/define symbol.
00056  *
00057  * Revision 1.28  2002/08/05 10:03:47  robertj
00058  * Cosmetic changes to normalise the usage of pragma interface/implementation.
00059  *
00060  * Revision 1.27  2002/01/09 06:06:37  robertj
00061  * Fixed setting of RTP timestamp values on video transmission.
00062  *
00063  * Revision 1.26  2002/01/09 00:21:36  robertj
00064  * Changes to support outgoing H.245 RequstModeChange.
00065  *
00066  * Revision 1.25  2001/12/04 04:26:03  robertj
00067  * Added code to allow change of video quality in H.261, thanks Damian Sandras
00068  *
00069  * Revision 1.24  2001/10/23 02:18:06  dereks
00070  * Initial release of CU30 video codec.
00071  *
00072  * Revision 1.23  2001/09/25 03:14:47  dereks
00073  * Add constant bitrate control for the h261 video codec.
00074  * Thanks Tiziano Morganti for the code to set bit rate. Good work!
00075  *
00076  * Revision 1.22  2001/05/25 01:10:26  dereks
00077  * Remove unnecessary packet receive variable.
00078  * Alter the position of the check for change in frame size.
00079  *
00080  * Revision 1.21  2001/02/09 05:16:24  robertj
00081  * Added #pragma interface for GNU C++.
00082  *
00083  * Revision 1.20  2001/01/25 07:27:14  robertj
00084  * Major changes to add more flexible OpalMediaFormat class to normalise
00085  *   all information about media types, especially codecs.
00086  *
00087  * Revision 1.19  2000/12/19 22:33:44  dereks
00088  * Adjust so that the video channel is used for reading/writing raw video
00089  * data, which better modularizes the video codec.
00090  *
00091  * Revision 1.18  2000/08/21 04:45:06  dereks
00092  * Fix dangling pointer that caused segfaults for windows&unix users.
00093  * Improved the test image which is used when video grabber won't open.
00094  * Added code to handle setting of video Tx Quality.
00095  * Added code to set the number of background blocks sent with every frame.
00096  *
00097  * Revision 1.17  2000/07/04 13:00:36  craigs
00098  * Fixed problem with selecting large and small video sizes
00099  *
00100  * Revision 1.16  2000/05/18 11:53:33  robertj
00101  * Changes to support doc++ documentation generation.
00102  *
00103  * Revision 1.15  2000/05/10 04:05:26  robertj
00104  * Changed capabilities so has a function to get name of codec, instead of relying on PrintOn.
00105  *
00106  * Revision 1.14  2000/05/02 04:32:24  robertj
00107  * Fixed copyright notice comment.
00108  *
00109  * Revision 1.13  2000/03/30 23:10:50  robertj
00110  * Fixed error in comments regarding GetFramerate() function.
00111  *
00112  * Revision 1.12  2000/03/21 03:06:47  robertj
00113  * Changes to make RTP TX of exact numbers of frames in some codecs.
00114  *
00115  * Revision 1.11  2000/02/04 05:00:08  craigs
00116  * Changes for video transmission
00117  *
00118  * Revision 1.10  2000/01/13 04:03:45  robertj
00119  * Added video transmission
00120  *
00121  * Revision 1.9  1999/12/23 23:02:34  robertj
00122  * File reorganision for separating RTP from H.323 and creation of LID for VPB support.
00123  *
00124  * Revision 1.8  1999/11/29 08:59:56  craigs
00125  * Added new stuff for new video codec interface
00126  *
00127  * Revision 1.7  1999/11/01 00:52:00  robertj
00128  * Fixed various problems in video, especially ability to pass error return value.
00129  *
00130  * Revision 1.6  1999/10/08 09:59:02  robertj
00131  * Rewrite of capability for sending multiple audio frames
00132  *
00133  * Revision 1.5  1999/10/08 04:58:37  robertj
00134  * Added capability for sending multiple audio frames in single RTP packet
00135  *
00136  * Revision 1.4  1999/09/21 14:03:41  robertj
00137  * Changed RTP data frame parameter in Write() to be const.
00138  *
00139  * Revision 1.3  1999/09/21 08:12:50  craigs
00140  * Added support for video codecs and H261
00141  *
00142  * Revision 1.2  1999/09/18 13:27:24  craigs
00143  * Added ability disable jitter buffer for codecs
00144  * Added ability to access entire RTP frame from codec Write
00145  *
00146  * Revision 1.1  1999/09/08 04:05:48  robertj
00147  * Added support for video capabilities & codec, still needs the actual codec itself!
00148  *
00149  */
00150 
00151 #ifndef __OPAL_H261CODEC_H
00152 #define __OPAL_H261CODEC_H
00153 
00154 #ifdef P_USE_PRAGMA
00155 #pragma interface
00156 #endif
00157 
00158 
00159 #include "h323caps.h"
00160 
00161 #ifndef NO_H323_VIDEO
00162 
00163 
00164 class P64Decoder;
00165 class P64Encoder;
00166 
00167 
00168 
00170 
00173 class H323_H261Capability : public H323VideoCapability
00174 {
00175   PCLASSINFO(H323_H261Capability, H323VideoCapability)
00176 
00177   public:
00182     H323_H261Capability(
00183       unsigned qcifMPI,
00184       unsigned cifMPI,
00185       BOOL temporalSpatialTradeOffCapability = TRUE,
00186       BOOL stillImageTransmission = FALSE,
00187       unsigned maxBitRate = 850
00188     );
00190 
00195     virtual PObject * Clone() const;
00197 
00198   
00203    Comparison Compare(const PObject & obj) const;
00205 
00214     virtual unsigned GetSubType() const;
00215 
00218     virtual PString GetFormatName() const;
00220 
00230     virtual BOOL OnSendingPDU(
00231       H245_VideoCapability & pdu  
00232     ) const;
00233 
00241     virtual BOOL OnSendingPDU(
00242       H245_VideoMode & pdu  
00243     ) const;
00244 
00252     virtual BOOL OnReceivedPDU(
00253       const H245_VideoCapability & pdu  
00254     );
00255 
00258     virtual H323Codec * CreateCodec(
00259       H323Codec::Direction direction  
00260     ) const;
00261 
00264     BOOL GetTemporalSpatialTradeOffCapability() const
00265       { return temporalSpatialTradeOffCapability; }
00266 
00269     BOOL GetStillImageTransmission() const
00270       { return stillImageTransmission; }
00271 
00274     unsigned GetMaxBitRate() const
00275       { return maxBitRate; }
00276 
00279     unsigned GetQCIFMPI() const
00280       { return qcifMPI; }
00281 
00284     unsigned GetCIFMPI() const
00285       { return cifMPI; }
00286 
00288 
00289   protected:
00290     unsigned qcifMPI;                   // 1..4 units 1/29.97 Hz
00291     unsigned cifMPI;                    // 1..4 units 1/29.97 Hz
00292     BOOL     temporalSpatialTradeOffCapability;
00293     unsigned maxBitRate;                // units of 100 bit/s
00294     BOOL     stillImageTransmission;    // Annex D of H.261
00295 };
00296 
00297 
00300 class H323_H261Codec : public H323VideoCodec
00301 {
00302   PCLASSINFO(H323_H261Codec, H323VideoCodec)
00303 
00304   public:
00307     H323_H261Codec(
00308       Direction direction,        
00309       BOOL isqCIF
00310     );
00311     ~H323_H261Codec();
00312 
00329     virtual BOOL Read(
00330       BYTE * buffer,            
00331       unsigned & length,        
00332       RTP_DataFrame & rtpFrame  
00333     );
00334 
00347     virtual BOOL Write(
00348       const BYTE * buffer,        
00349       unsigned length,            
00350       const RTP_DataFrame & rtp,  
00351       unsigned & written          
00352     );
00353 
00356     virtual unsigned GetFrameRate() const { return timestampDelta; }
00357 
00363     void SetTxQualityLevel(int qLevel);
00364  
00368     void SetTxMinQuality(int qlevel);
00369 
00373     void SetTxMaxQuality(int qlevel);
00374 
00378     void SetBackgroundFill(int fillLevel);
00379 
00383     virtual void OnFastUpdatePicture();
00384 
00388     virtual void OnLostPartialPicture();
00389 
00393     virtual void OnLostPicture();
00394 
00396     //There is a problem with the H261codec. It needs to be able to 
00397     //carry out two tasks. 1)Grab data from the camera.
00398     //2)Render data from an array.
00399     //Thus, we either: two PVideoChannels, or one PVideoChannel to both
00400     //grab and render.
00401     //We use one PVideoChannel, which is not consistant with elsewhere,
00402     //but enables us to (later) have a grab and display process irrespective
00403     //of there being a H323 connection.
00404 
00405 
00406   protected:
00407     BOOL Resize(int width, int height);
00408     BOOL Redraw();
00409     BOOL RenderFrame();
00410 
00411     BOOL doFastUpdate;
00412     PMutex fastUpdateMutex;
00413 
00414     P64Decoder       * videoDecoder;
00415     P64Encoder       * videoEncoder;
00416 
00417     int now;
00418     BYTE * rvts;
00419     int ndblk, nblk;
00420     unsigned timestampDelta;
00421     BOOL isqCIF;
00422 };
00423 
00424 
00425 #endif // __OPAL_H261CODEC_H
00426 
00427 
00428 #endif // NO_H323_VIDEO
00429 
00430 

Generated on Wed Feb 6 09:02:38 2008 for OpenH323 by  doxygen 1.5.4