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

Generated on Sun Oct 22 13:32:21 2006 for OpenH323 by  doxygen 1.4.7