codecs.h

Go to the documentation of this file.
00001 /*
00002  * codecs.h
00003  *
00004  * H.323 protocol handler
00005  *
00006  * Open H323 Library
00007  *
00008  * Copyright (c) 1998-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  * Portions of this code were written with the assisance of funding from
00025  * Vovida Networks, Inc. http://www.vovida.com.
00026  *
00027  * Contributor(s): ______________________________________.
00028  *
00029  * $Log: codecs.h,v $
00030  * Revision 1.78  2005/11/30 13:05:01  csoutheren
00031  * Changed tags for Doxygen
00032  *
00033  * Revision 1.77  2005/06/07 07:09:13  csoutheren
00034  * Removed compiler warnings on Windows
00035  *
00036  * Revision 1.76  2005/06/07 03:22:22  csoutheren
00037  * Added patch 1198741 with support for plugin codecs with generic capabilities
00038  * Added patch 1198754 with support for setting quality level on audio codecs
00039  * Added patch 1198760 with GSM-AMR codec support
00040  * Many thanks to Richard van der Hoff for his work
00041  *
00042  * Revision 1.75  2005/01/03 06:25:52  csoutheren
00043  * Added extensive support for disabling code modules at compile time
00044  *
00045  * Revision 1.74  2004/07/03 06:48:26  rjongbloed
00046  * Split video temporal/spatial trade off H.245 packets to separate command and
00047  *   indication functions and added quality parameter, thanks Guilhem Tardy.
00048  *
00049  * Revision 1.73  2004/05/09 10:08:34  csoutheren
00050  * Changed new DecodeFrame to return bytes decoded rather than samples decoded
00051  * Added support for new DecodeFrame to plugin manager
00052  *
00053  * Revision 1.72  2004/05/02 04:52:23  rjongbloed
00054  * Fixed problems with G.711 caused by fixing problem with G.723.1-5k3 mode.
00055  *
00056  * Revision 1.71  2004/03/24 00:39:12  dereksmithies
00057  * Changes from Michael Smith for use in reporting frames/second. Many Thanks
00058  *
00059  * Revision 1.70  2003/12/14 10:42:29  rjongbloed
00060  * Changes for compilability without video support.
00061  *
00062  * Revision 1.69  2003/11/12 11:14:21  csoutheren
00063  * Added H323FramedAudioCodec::DecodeSilenceFrame thanks to Henry Harrison of AliceStreet
00064  *
00065  * Revision 1.68  2003/07/16 10:43:12  csoutheren
00066  * Added SwapChannel function to H323Codec to allow media hold channels
00067  * to work better. Thanks to Federico Pinna
00068  *
00069  * Revision 1.67  2003/05/27 09:39:15  dereksmithies
00070  * Add frames per sec variable to the videocodec class
00071  *
00072  * Revision 1.66  2002/12/16 09:11:15  robertj
00073  * Added new video bit rate control, thanks Walter H. Whitlock
00074  *
00075  * Revision 1.65  2002/09/16 01:14:15  robertj
00076  * Added #define so can select if #pragma interface/implementation is used on
00077  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00078  *
00079  * Revision 1.64  2002/08/05 10:03:47  robertj
00080  * Cosmetic changes to normalise the usage of pragma interface/implementation.
00081  *
00082  * Revision 1.63  2002/01/23 06:13:52  robertj
00083  * Added filter function hooks to codec raw data channel.
00084  *
00085  * Revision 1.62  2002/01/23 01:58:25  robertj
00086  * Added function to determine if codecs raw data channel is native format.
00087  *
00088  * Revision 1.61  2002/01/22 16:17:19  rogerh
00089  * Back out the DTMF Decoder class. There will soon be a better way
00090  * to do this.
00091  *
00092  * Revision 1.60  2002/01/22 16:09:38  rogerh
00093  * Back out the DTMF detection from H323FramedAudioCodec::Write().
00094  * There will shortly be a better place for it.
00095  *
00096  * Revision 1.59  2002/01/22 15:21:47  rogerh
00097  * Add DTMF decoding to PCM audio streams. This has been tested with
00098  * NetMeeting sending Dial Pad codes, using the G.711 codec.
00099  * At this time, DTMF codes (fron NetMeeting) are just displayed on the
00100  * screen and are not passed up to the users application.
00101  *
00102  * Revision 1.58  2002/01/13 23:56:01  robertj
00103  * Added mutex so can change raw data channel while reading/writing from codec.
00104  *
00105  * Revision 1.57  2001/12/04 05:13:09  robertj
00106  * Added videa bandwidth limiting code for H.261, thanks Jose Luis Urien.
00107  *
00108  * Revision 1.56  2001/11/16 01:05:21  craigs
00109  * Changed to allow access to uLaw/ALaw to/from linear functions
00110  *
00111  * Revision 1.55  2001/10/23 02:18:06  dereks
00112  * Initial release of CU30 video codec.
00113  *
00114  * Revision 1.54  2001/09/25 03:14:47  dereks
00115  * Add constant bitrate control for the h261 video codec.
00116  * Thanks Tiziano Morganti for the code to set bit rate. Good work!
00117  *
00118  * Revision 1.53  2001/09/11 01:24:36  robertj
00119  * Added conditional compilation to remove video and/or audio codecs.
00120  *
00121  * Revision 1.52  2001/08/28 09:27:38  robertj
00122  * Updated documentation to reflect some relationships between functions.
00123  *
00124  * Revision 1.51  2001/03/29 23:44:35  robertj
00125  * Added ability to get current silence detect state and threshold.
00126  * Changed silence detection to use G.723.1 SID frames as indicator of
00127  *   silence instead of using the average energy and adaptive threshold.
00128  * Changed default signal on deadband time to be much shorter.
00129  *
00130  * Revision 1.50  2001/02/09 05:16:24  robertj
00131  * Added #pragma interface for GNU C++.
00132  *
00133  * Revision 1.49  2001/01/25 07:27:14  robertj
00134  * Major changes to add more flexible OpalMediaFormat class to normalise
00135  *   all information about media types, especially codecs.
00136  *
00137  * Revision 1.48  2000/12/19 22:33:44  dereks
00138  * Adjust so that the video channel is used for reading/writing raw video
00139  * data, which better modularizes the video codec.
00140  *
00141  * Revision 1.47  2000/10/13 01:47:26  dereks
00142  * Include command option for setting the number of transmitted video
00143  * frames per second.   use --videotxfps n
00144  *
00145  * Revision 1.46  2000/09/08 06:41:37  craigs
00146  * Added ability to set video device
00147  * Added ability to select test input frames
00148  *
00149  * Revision 1.45  2000/08/31 08:15:32  robertj
00150  * Added support for dynamic RTP payload types in H.245 OpenLogicalChannel negotiations.
00151  *
00152  * Revision 1.44  2000/08/21 04:45:06  dereks
00153  * Fix dangling pointer that caused segfaults for windows&unix users.
00154  * Improved the test image which is used when video grabber won't open.
00155  * Added code to handle setting of video Tx Quality.
00156  * Added code to set the number of background blocks sent with every frame.
00157  *
00158  * Revision 1.43  2000/05/16 02:04:16  craigs
00159  * Added access functions for silence compression mode
00160  *
00161  * Revision 1.42  2000/05/02 04:32:24  robertj
00162  * Fixed copyright notice comment.
00163  *
00164  * Revision 1.41  2000/04/14 20:11:16  robertj
00165  * Removed redundent member variable from H323FramedAudioCodec.
00166  *
00167  * Revision 1.40  2000/03/30 23:10:50  robertj
00168  * Fixed error in comments regarding GetFramerate() function.
00169  *
00170  * Revision 1.39  2000/03/21 03:06:47  robertj
00171  * Changes to make RTP TX of exact numbers of frames in some codecs.
00172  *
00173  * Revision 1.38  2000/02/28 13:00:22  robertj
00174  * Added some virtual keywords at the request of Yura Ershov
00175  *
00176  * Revision 1.37  2000/02/10 03:08:02  craigs
00177  * Added ability to specify NTSC or PAL video format
00178  *
00179  * Revision 1.36  2000/02/04 05:00:08  craigs
00180  * Changes for video transmission
00181  *
00182  * Revision 1.35  2000/01/13 04:03:45  robertj
00183  * Added video transmission
00184  *
00185  * Revision 1.34  1999/12/31 00:05:36  robertj
00186  * Added Microsoft ACM G.723.1 codec capability.
00187  *
00188  * Revision 1.33  1999/12/29 01:19:16  craigs
00189  * Fixed problem with RTP payload type variable
00190  *
00191  * Revision 1.32  1999/12/23 23:02:34  robertj
00192  * File reorganision for separating RTP from H.323 and creation of LID for VPB support.
00193  *
00194  * Revision 1.31  1999/11/29 09:01:46  craigs
00195  * Added new code for new video code interface
00196  *
00197  * Revision 1.30  1999/11/29 04:50:11  robertj
00198  * Added adaptive threshold calculation to silence detection.
00199  *
00200  * Revision 1.29  1999/11/20 00:53:46  robertj
00201  * Fixed ability to have variable sized frames in single RTP packet under G.723.1
00202  *
00203  * Revision 1.28  1999/11/13 14:10:32  robertj
00204  * Changes to make silence detection selectable.
00205  *
00206  * Revision 1.27  1999/11/11 23:28:52  robertj
00207  * Added first cut silence detection algorithm.
00208  *
00209  * Revision 1.26  1999/11/04 00:43:42  robertj
00210  * Added extra constructors for nonStandard codecs.
00211  *
00212  * Revision 1.25  1999/10/14 12:03:08  robertj
00213  * Fixed comment.
00214  *
00215  * Revision 1.24  1999/10/08 09:59:01  robertj
00216  * Rewrite of capability for sending multiple audio frames
00217  *
00218  * Revision 1.23  1999/10/08 04:58:37  robertj
00219  * Added capability for sending multiple audio frames in single RTP packet
00220  *
00221  * Revision 1.22  1999/09/23 07:25:12  robertj
00222  * Added open audio and video function to connection and started multi-frame codec send functionality.
00223  *
00224  * Revision 1.21  1999/09/21 14:51:33  robertj
00225  * Fixed NonStandardCapabilityInfo class virtual destructor (and name).
00226  *
00227  * Revision 1.20  1999/09/21 14:04:41  robertj
00228  * Added non-standard codec capability classes
00229  *
00230  * Revision 1.19  1999/09/21 08:12:49  craigs
00231  * Added support for video codecs and H261
00232  *
00233  * Revision 1.18  1999/09/18 13:27:24  craigs
00234  * Added ability disable jitter buffer for codecs
00235  * Added ability to access entire RTP frame from codec Write
00236  *
00237  * Revision 1.17  1999/09/08 04:05:48  robertj
00238  * Added support for video capabilities & codec, still needs the actual codec itself!
00239  *
00240  * Revision 1.16  1999/08/31 12:34:18  robertj
00241  * Added gatekeeper support.
00242  *
00243  * Revision 1.15  1999/08/25 03:08:23  robertj
00244  * Added UserInput capability.
00245  * Allowed the attachment of a channel on a codec to optionally delete the channel object,
00246  *
00247  * Revision 1.14  1999/07/22 14:32:48  robertj
00248  * Fixed erroneous comments
00249  *
00250  * Revision 1.13  1999/07/16 16:05:48  robertj
00251  * Added "human readable" codec type name display.
00252  *
00253  * Revision 1.12  1999/07/15 14:45:35  robertj
00254  * Added propagation of codec open error to shut down logical channel.
00255  * Fixed control channel start up bug introduced with tunnelling.
00256  *
00257  * Revision 1.11  1999/07/13 09:53:24  robertj
00258  * Fixed some problems with jitter buffer and added more debugging.
00259  *
00260  * Revision 1.10  1999/07/09 06:09:49  robertj
00261  * Major implementation. An ENORMOUS amount of stuff added everywhere.
00262  *
00263  * Revision 1.9  1999/06/24 13:32:45  robertj
00264  * Fixed ability to change sound device on codec and fixed NM3 G.711 compatibility
00265  *
00266  * Revision 1.8  1999/06/22 13:49:40  robertj
00267  * Added GSM support and further RTP protocol enhancements.
00268  *
00269  * Revision 1.7  1999/06/14 15:08:40  robertj
00270  * Added GSM codec class frame work (still no actual codec).
00271  *
00272  * Revision 1.6  1999/06/14 06:39:08  robertj
00273  * Fixed problem with getting transmit flag to channel from PDU negotiator
00274  *
00275  * Revision 1.5  1999/06/14 05:15:55  robertj
00276  * Changes for using RTP sessions correctly in H323 Logical Channel context
00277  *
00278  * Revision 1.4  1999/06/13 12:41:14  robertj
00279  * Implement logical channel transmitter.
00280  * Fixed H245 connect on receiving call.
00281  *
00282  * Revision 1.3  1999/06/09 05:26:19  robertj
00283  * Major restructuring of classes.
00284  *
00285  * Revision 1.2  1999/06/06 06:06:36  robertj
00286  * Changes for new ASN compiler and v2 protocol ASN files.
00287  *
00288  * Revision 1.1  1999/01/16 01:31:01  robertj
00289  * Initial revision
00290  *
00291  */
00292 
00293 #ifndef __CODECS_H
00294 #define __CODECS_H
00295 
00296 #ifdef P_USE_PRAGMA
00297 #pragma interface
00298 #endif
00299 
00300 
00301 #include <mediafmt.h>
00302 #include <rtp.h>
00303 #include <channels.h>
00304 #include "openh323buildopts.h"
00305 
00306 
00307 /* The following classes have forward references to avoid including the VERY
00308    large header files for H225 and H245. If an application requires access
00309    to the protocol classes they can include them, but for simple usage their
00310    inclusion can be avoided.
00311  */
00312 class H245_MiscellaneousCommand_type;
00313 class H245_MiscellaneousIndication_type;
00314 class H323Connection;
00315 
00316 
00317 
00319 
00327 class H323Codec : public PObject
00328 {
00329   PCLASSINFO(H323Codec, PObject);
00330 
00331   public:
00332     enum Direction {
00333       Encoder,
00334       Decoder
00335     };
00336 
00337     H323Codec(
00338       const char * mediaFormat, 
00339       Direction direction       
00340     );
00341 
00342 
00355     virtual BOOL Open(
00356       H323Connection & connection 
00357     );
00358 
00361     virtual void Close() = 0;
00362 
00380     virtual BOOL Read(
00381       BYTE * buffer,            
00382       unsigned & length,        
00383       RTP_DataFrame & rtpFrame  
00384     ) = 0;
00385 
00397     virtual BOOL Write(
00398       const BYTE * buffer,          
00399       unsigned length,              
00400       const RTP_DataFrame & frame,  
00401       unsigned & written            
00402     ) = 0;
00403 
00406     virtual unsigned GetFrameRate() const;
00407 
00411     virtual void OnFlowControl(
00412       long bitRateRestriction   
00413     );
00414 
00418     virtual void OnMiscellaneousCommand(
00419       const H245_MiscellaneousCommand_type & type  
00420     );
00421 
00425     virtual void OnMiscellaneousIndication(
00426       const H245_MiscellaneousIndication_type & type  
00427     );
00428 
00429     Direction GetDirection()   const { return direction; }
00430 
00431     const OpalMediaFormat & GetMediaFormat() const { return mediaFormat; }
00432 
00440     virtual BOOL AttachChannel(
00441       PChannel * channel,     
00442       BOOL autoDelete = TRUE  
00443     );
00444 
00449     virtual PChannel * SwapChannel(
00450       PChannel * newChannel,  
00451       BOOL autoDelete = TRUE  
00452     );
00453 
00456     virtual BOOL CloseRawDataChannel();
00457 
00461     PChannel *GetRawDataChannel()
00462       { return rawDataChannel; }
00463 
00470     virtual BOOL IsRawDataChannelNative() const;
00471 
00474     BOOL ReadRaw(
00475       void * data,
00476       PINDEX size,
00477       PINDEX & length
00478     );
00479 
00482     BOOL WriteRaw(
00483       void * data,
00484       PINDEX length
00485     );
00486 
00493     BOOL AttachLogicalChannel(H323Channel *channel);
00494 
00495     class FilterInfo : public PObject {
00496         PCLASSINFO(FilterInfo, PObject);
00497       public:
00498         FilterInfo(H323Codec & c, void * b, PINDEX s, PINDEX l)
00499           : codec(c), buffer(b), bufferSize(s), bufferLength(l) { }
00500 
00501         H323Codec & codec;
00502         void      * buffer;
00503         PINDEX      bufferSize;
00504         PINDEX      bufferLength;
00505     };
00506 
00528     void AddFilter(
00529       const PNotifier & notifier
00530     );
00531 
00532   protected:
00533     Direction direction;
00534     OpalMediaFormat mediaFormat;
00535     
00536     H323Channel * logicalChannel; // sends messages from receive codec to tx codec.
00537 
00538     PChannel * rawDataChannel;  // connection to the hardware for reading/writing data.
00539     BOOL       deleteChannel;
00540     PMutex     rawChannelMutex;
00541 
00542     PINDEX     lastSequenceNumber;  // Detects lost RTP packets in the video codec.
00543 
00544     PLIST(FilterList, PNotifier);
00545     FilterList filters;
00546 };
00547 
00548 #ifndef NO_H323_AUDIO_CODECS
00549 
00550 
00557 class H323AudioCodec : public H323Codec
00558 {
00559   PCLASSINFO(H323AudioCodec, H323Codec);
00560 
00561   public:
00567     H323AudioCodec(
00568       const char * mediaFormat, 
00569       Direction direction       
00570     );
00571 
00572     ~H323AudioCodec();
00573 
00582     virtual BOOL Open(
00583       H323Connection & connection 
00584     );
00585 
00593     virtual void Close();
00594 
00597     virtual unsigned GetFrameRate() const;
00598 
00599     enum SilenceDetectionMode {
00600       NoSilenceDetection,
00601       FixedSilenceDetection,
00602       AdaptiveSilenceDetection
00603     };
00604 
00608     void SetSilenceDetectionMode(
00609       SilenceDetectionMode mode,   
00610       unsigned threshold = 0,      
00611       unsigned signalDeadband = 80,    
00612       unsigned silenceDeadband = 3200, 
00613       unsigned adaptivePeriod = 4800   
00614     );
00615 
00624     SilenceDetectionMode GetSilenceDetectionMode(
00625       BOOL * isInTalkBurst = NULL,        
00626       unsigned * currentThreshold = NULL  
00627     ) const;
00628 
00629     
00636     virtual void SetTxQualityLevel(int /*qlevel*/) {}
00637 
00641     virtual int GetTxQualityLevel(int /*qlevel*/) { return 1; }
00642     
00649     virtual BOOL DetectSilence();
00650 
00658     virtual unsigned GetAverageSignalLevel();
00659 
00660   protected:
00661     unsigned samplesPerFrame;
00662 
00663     SilenceDetectionMode silenceDetectMode;
00664 
00665     unsigned signalDeadbandFrames;  // Frames of signal before talk burst starts
00666     unsigned silenceDeadbandFrames; // Frames of silence before talk burst ends
00667     unsigned adaptiveThresholdFrames; // Frames to min/max over for adaptive threshold
00668 
00669     BOOL     inTalkBurst;           // Currently sending RTP data
00670     unsigned framesReceived;        // Signal/Silence frames received so far.
00671     unsigned levelThreshold;        // Threshold level for silence/signal
00672     unsigned signalMinimum;         // Minimum of frames above threshold
00673     unsigned silenceMaximum;        // Maximum of frames below threshold
00674     unsigned signalFramesReceived;  // Frames of signal received
00675     unsigned silenceFramesReceived; // Frames of silence received
00676 };
00677 
00678 
00687 class H323FramedAudioCodec : public H323AudioCodec
00688 {
00689   PCLASSINFO(H323FramedAudioCodec, H323AudioCodec);
00690 
00691   public:
00697     H323FramedAudioCodec(
00698       const char * mediaFormat, 
00699       Direction direction       
00700     );
00701 
00719     virtual BOOL Read(
00720       BYTE * buffer,            
00721       unsigned & length,        
00722       RTP_DataFrame & rtpFrame  
00723     );
00724 
00737     virtual BOOL Write(
00738       const BYTE * buffer,            
00739       unsigned length,                
00740       const RTP_DataFrame & rtpFrame, 
00741       unsigned & written              
00742     );
00743 
00744 
00749     virtual unsigned GetAverageSignalLevel();
00750 
00751 
00757     virtual BOOL EncodeFrame(
00758       BYTE * buffer,    
00759       unsigned & length 
00760     ) = 0;
00761 
00766     virtual BOOL DecodeFrame(
00767       const BYTE * buffer,   
00768       unsigned length,       
00769       unsigned & written,    
00770       unsigned & bytesOutput 
00771     );
00772     virtual BOOL DecodeFrame(
00773       const BYTE * buffer,  
00774       unsigned length,      
00775       unsigned & written    
00776     );
00777 
00782     virtual void DecodeSilenceFrame(
00783       void * buffer,  
00784       unsigned length       
00785     )
00786     { memset(buffer, 0, length); }
00787 
00788   protected:
00789     PShortArray sampleBuffer;
00790     unsigned    bytesPerFrame;
00791 };
00792 
00793 
00802 class H323StreamedAudioCodec : public H323FramedAudioCodec
00803 {
00804   PCLASSINFO(H323StreamedAudioCodec, H323FramedAudioCodec);
00805 
00806   public:
00812     H323StreamedAudioCodec(
00813       const char * mediaFormat, 
00814       Direction direction,      
00815       unsigned samplesPerFrame, 
00816       unsigned bits             
00817     );
00818 
00824     virtual BOOL EncodeFrame(
00825       BYTE * buffer,    
00826       unsigned & length 
00827     );
00828 
00834     virtual BOOL DecodeFrame(
00835       const BYTE * buffer,  
00836       unsigned length,      
00837       unsigned & written,   
00838       unsigned & samples    
00839     );
00840 
00843     virtual int Encode(short sample) const = 0;
00844 
00847     virtual short Decode(int sample) const = 0;
00848 
00849   protected:
00850     unsigned bitsPerSample;
00851 };
00852 
00853 #endif // NO_H323_AUDIO_CODECS
00854 
00855 
00856 #ifndef NO_H323_VIDEO
00857 
00864 class H323VideoCodec : public H323Codec
00865 {
00866   PCLASSINFO(H323VideoCodec, H323Codec);
00867 
00868   public:
00874     H323VideoCodec(
00875       const char * mediaFormat, 
00876       Direction direction      
00877     );
00878 
00879     ~H323VideoCodec();
00880 
00889     virtual BOOL Open(
00890       H323Connection & connection 
00891     );
00892 
00900     virtual void Close();
00901 
00902 
00906     virtual void OnMiscellaneousCommand(
00907       const H245_MiscellaneousCommand_type & type  
00908     );
00909 
00913     virtual void OnMiscellaneousIndication(
00914       const H245_MiscellaneousIndication_type & type  
00915     );
00916 
00917     //    /**Attach the raw data device for use by codec.
00918     //   Note the device provided will be deleted on destruction of the codec.
00919     //   */
00920     // virtual BOOL AttachDevice(
00921     //  H323VideoDevice * device, ///< Device to read/write data
00922     //  BOOL autoDelete = TRUE    ///< Device is to be automatically deleted
00923     // );
00924 
00928     virtual void OnFreezePicture();
00929 
00933     virtual void OnFastUpdatePicture();
00934 
00938     virtual void OnFastUpdateGOB(unsigned firstGOB, unsigned numberOfGOBs);
00939 
00943     virtual void OnFastUpdateMB(int firstGOB, int firstMB, unsigned numberOfMBs);
00944 
00948     virtual void OnVideoIndicateReadyToActivate();
00949 
00953     virtual void OnVideoTemporalSpatialTradeOffCommand(int newQuality);
00954 
00958     virtual void OnVideoTemporalSpatialTradeOffIndication(int newQuality);
00959 
00963     virtual void OnVideoNotDecodedMBs(
00964       unsigned firstMB,
00965       unsigned numberOfMBs,
00966       unsigned temporalReference
00967     );
00968 
00972     virtual void OnLostPartialPicture();
00973 
00977     virtual void OnLostPicture();
00978 
00981     int GetWidth() const { return frameWidth; }
00982 
00985     int GetHeight() const { return frameHeight; }
00986 
00989     virtual void SetTxQualityLevel(int qlevel) {videoQuality = qlevel; }
00990 
00994     virtual void SetTxMinQuality(int qlevel) {videoQMin = qlevel; }
00995 
00999     virtual void SetTxMaxQuality(int qlevel) {videoQMax = qlevel; }
01000 
01003     virtual void SetBackgroundFill(int idle) {fillLevel= idle; }
01004  
01005     enum BitRateModeBits {
01006       None                = 0x00,
01007       DynamicVideoQuality = 0x01,
01008       AdaptivePacketDelay = 0x02
01009     };
01010 
01013     unsigned GetVideoMode(void) {return videoBitRateControlModes;}
01014 
01018     unsigned SetVideoMode(unsigned mode) {return videoBitRateControlModes = mode;}
01019     
01024     virtual BOOL SetMaxBitRate(
01025       unsigned bitRate 
01026     );
01027 
01036     virtual BOOL SetTargetFrameTimeMs(
01037       unsigned ms 
01038     );
01039 
01044     void SendMiscCommand(unsigned command);
01045  
01049    virtual int GetFrameNum() { return frameNum; }
01050 
01051 
01052   protected:
01053 
01054     int frameWidth;
01055     int frameHeight;
01056     int fillLevel;
01057 
01058     // used in h261codec.cxx
01059     unsigned videoBitRateControlModes;
01060     // variables used for video bit rate control
01061     int bitRateHighLimit; // maximum instantaneous bit rate allowed
01062     unsigned oldLength;
01063     PTimeInterval oldTime;
01064     PTimeInterval newTime;
01065     // variables used for dynamic video quality control
01066     int targetFrameTimeMs; //targetFrameTimeMs = 1000 / videoSendFPS
01067     int frameBytes; // accumulate count of bytes per frame
01068     int sumFrameTimeMs, sumAdjFrameTimeMs, sumFrameBytes; // accumulate running average
01069     int videoQMax, videoQMin; // dynamic video quality min/max limits
01070     int videoQuality; // current video encode quality setting, 1..31
01071     PTimeInterval frameStartTime;
01072     PTimeInterval grabInterval;
01073     
01074     int frameNum, packetNum, oldPacketNum;
01075     int framesPerSec;
01076 
01077     PMutex  videoHandlerActive;    
01078 };
01079 
01080 #endif // NO_H323_VIDEO
01081 
01082 #ifndef NO_H323_AUDIO_CODECS
01083 
01085 // The simplest codec is the G.711 PCM codec.
01086 
01089 class H323_ALawCodec : public H323StreamedAudioCodec
01090 {
01091   PCLASSINFO(H323_ALawCodec, H323StreamedAudioCodec)
01092 
01093   public:
01098     H323_ALawCodec(
01099       Direction direction,  
01100       BOOL at56kbps,        
01101       unsigned frameSize    
01102     );
01104 
01105     virtual int   Encode(short sample) const { return EncodeSample(sample); }
01106     virtual short Decode(int   sample) const { return DecodeSample(sample); }
01107 
01108     static int   EncodeSample(short sample);
01109     static short DecodeSample(int   sample);
01110 
01111   protected:
01112     BOOL sevenBit;
01113 };
01114 
01115 
01118 class H323_muLawCodec : public H323StreamedAudioCodec
01119 {
01120   PCLASSINFO(H323_muLawCodec, H323StreamedAudioCodec)
01121 
01122   public:
01127     H323_muLawCodec(
01128       Direction direction,  
01129       BOOL at56kbps,        
01130       unsigned frameSize    
01131     );
01133 
01134     virtual int   Encode(short sample) const { return EncodeSample(sample); }
01135     virtual short Decode(int   sample) const { return DecodeSample(sample); }
01136 
01137     static int   EncodeSample(short sample);
01138     static short DecodeSample(int   sample);
01139 
01140   protected:
01141     BOOL sevenBit;
01142 };
01143 
01144 #endif // NO_H323_AUDIO_CODECS
01145 
01146 
01147 #endif // __CODECS_H
01148 
01149 

Generated on Thu May 18 00:24:08 2006 for OpenH323 by  doxygen 1.4.6