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.81  2006/08/01 06:17:48  csoutheren
00031  * Fix bit rate control units
00032  * Add access function on code for max bit rate
00033  * Thanks to Paolo Amadini
00034  *
00035  * Revision 1.80  2006/05/16 11:28:58  shorne
00036  * added AEC support and  more call hold support.
00037  *
00038  * Revision 1.79  2006/01/26 03:31:08  shorne
00039  * Add the ability to remove a local input device when placing a call on hold
00040  *
00041  * Revision 1.78  2005/11/30 13:05:01  csoutheren
00042  * Changed tags for Doxygen
00043  *
00044  * Revision 1.77  2005/06/07 07:09:13  csoutheren
00045  * Removed compiler warnings on Windows
00046  *
00047  * Revision 1.76  2005/06/07 03:22:22  csoutheren
00048  * Added patch 1198741 with support for plugin codecs with generic capabilities
00049  * Added patch 1198754 with support for setting quality level on audio codecs
00050  * Added patch 1198760 with GSM-AMR codec support
00051  * Many thanks to Richard van der Hoff for his work
00052  *
00053  * Revision 1.75  2005/01/03 06:25:52  csoutheren
00054  * Added extensive support for disabling code modules at compile time
00055  *
00056  * Revision 1.74  2004/07/03 06:48:26  rjongbloed
00057  * Split video temporal/spatial trade off H.245 packets to separate command and
00058  *   indication functions and added quality parameter, thanks Guilhem Tardy.
00059  *
00060  * Revision 1.73  2004/05/09 10:08:34  csoutheren
00061  * Changed new DecodeFrame to return bytes decoded rather than samples decoded
00062  * Added support for new DecodeFrame to plugin manager
00063  *
00064  * Revision 1.72  2004/05/02 04:52:23  rjongbloed
00065  * Fixed problems with G.711 caused by fixing problem with G.723.1-5k3 mode.
00066  *
00067  * Revision 1.71  2004/03/24 00:39:12  dereksmithies
00068  * Changes from Michael Smith for use in reporting frames/second. Many Thanks
00069  *
00070  * Revision 1.70  2003/12/14 10:42:29  rjongbloed
00071  * Changes for compilability without video support.
00072  *
00073  * Revision 1.69  2003/11/12 11:14:21  csoutheren
00074  * Added H323FramedAudioCodec::DecodeSilenceFrame thanks to Henry Harrison of AliceStreet
00075  *
00076  * Revision 1.68  2003/07/16 10:43:12  csoutheren
00077  * Added SwapChannel function to H323Codec to allow media hold channels
00078  * to work better. Thanks to Federico Pinna
00079  *
00080  * Revision 1.67  2003/05/27 09:39:15  dereksmithies
00081  * Add frames per sec variable to the videocodec class
00082  *
00083  * Revision 1.66  2002/12/16 09:11:15  robertj
00084  * Added new video bit rate control, thanks Walter H. Whitlock
00085  *
00086  * Revision 1.65  2002/09/16 01:14:15  robertj
00087  * Added #define so can select if #pragma interface/implementation is used on
00088  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00089  *
00090  * Revision 1.64  2002/08/05 10:03:47  robertj
00091  * Cosmetic changes to normalise the usage of pragma interface/implementation.
00092  *
00093  * Revision 1.63  2002/01/23 06:13:52  robertj
00094  * Added filter function hooks to codec raw data channel.
00095  *
00096  * Revision 1.62  2002/01/23 01:58:25  robertj
00097  * Added function to determine if codecs raw data channel is native format.
00098  *
00099  * Revision 1.61  2002/01/22 16:17:19  rogerh
00100  * Back out the DTMF Decoder class. There will soon be a better way
00101  * to do this.
00102  *
00103  * Revision 1.60  2002/01/22 16:09:38  rogerh
00104  * Back out the DTMF detection from H323FramedAudioCodec::Write().
00105  * There will shortly be a better place for it.
00106  *
00107  * Revision 1.59  2002/01/22 15:21:47  rogerh
00108  * Add DTMF decoding to PCM audio streams. This has been tested with
00109  * NetMeeting sending Dial Pad codes, using the G.711 codec.
00110  * At this time, DTMF codes (fron NetMeeting) are just displayed on the
00111  * screen and are not passed up to the users application.
00112  *
00113  * Revision 1.58  2002/01/13 23:56:01  robertj
00114  * Added mutex so can change raw data channel while reading/writing from codec.
00115  *
00116  * Revision 1.57  2001/12/04 05:13:09  robertj
00117  * Added videa bandwidth limiting code for H.261, thanks Jose Luis Urien.
00118  *
00119  * Revision 1.56  2001/11/16 01:05:21  craigs
00120  * Changed to allow access to uLaw/ALaw to/from linear functions
00121  *
00122  * Revision 1.55  2001/10/23 02:18:06  dereks
00123  * Initial release of CU30 video codec.
00124  *
00125  * Revision 1.54  2001/09/25 03:14:47  dereks
00126  * Add constant bitrate control for the h261 video codec.
00127  * Thanks Tiziano Morganti for the code to set bit rate. Good work!
00128  *
00129  * Revision 1.53  2001/09/11 01:24:36  robertj
00130  * Added conditional compilation to remove video and/or audio codecs.
00131  *
00132  * Revision 1.52  2001/08/28 09:27:38  robertj
00133  * Updated documentation to reflect some relationships between functions.
00134  *
00135  * Revision 1.51  2001/03/29 23:44:35  robertj
00136  * Added ability to get current silence detect state and threshold.
00137  * Changed silence detection to use G.723.1 SID frames as indicator of
00138  *   silence instead of using the average energy and adaptive threshold.
00139  * Changed default signal on deadband time to be much shorter.
00140  *
00141  * Revision 1.50  2001/02/09 05:16:24  robertj
00142  * Added #pragma interface for GNU C++.
00143  *
00144  * Revision 1.49  2001/01/25 07:27:14  robertj
00145  * Major changes to add more flexible OpalMediaFormat class to normalise
00146  *   all information about media types, especially codecs.
00147  *
00148  * Revision 1.48  2000/12/19 22:33:44  dereks
00149  * Adjust so that the video channel is used for reading/writing raw video
00150  * data, which better modularizes the video codec.
00151  *
00152  * Revision 1.47  2000/10/13 01:47:26  dereks
00153  * Include command option for setting the number of transmitted video
00154  * frames per second.   use --videotxfps n
00155  *
00156  * Revision 1.46  2000/09/08 06:41:37  craigs
00157  * Added ability to set video device
00158  * Added ability to select test input frames
00159  *
00160  * Revision 1.45  2000/08/31 08:15:32  robertj
00161  * Added support for dynamic RTP payload types in H.245 OpenLogicalChannel negotiations.
00162  *
00163  * Revision 1.44  2000/08/21 04:45:06  dereks
00164  * Fix dangling pointer that caused segfaults for windows&unix users.
00165  * Improved the test image which is used when video grabber won't open.
00166  * Added code to handle setting of video Tx Quality.
00167  * Added code to set the number of background blocks sent with every frame.
00168  *
00169  * Revision 1.43  2000/05/16 02:04:16  craigs
00170  * Added access functions for silence compression mode
00171  *
00172  * Revision 1.42  2000/05/02 04:32:24  robertj
00173  * Fixed copyright notice comment.
00174  *
00175  * Revision 1.41  2000/04/14 20:11:16  robertj
00176  * Removed redundent member variable from H323FramedAudioCodec.
00177  *
00178  * Revision 1.40  2000/03/30 23:10:50  robertj
00179  * Fixed error in comments regarding GetFramerate() function.
00180  *
00181  * Revision 1.39  2000/03/21 03:06:47  robertj
00182  * Changes to make RTP TX of exact numbers of frames in some codecs.
00183  *
00184  * Revision 1.38  2000/02/28 13:00:22  robertj
00185  * Added some virtual keywords at the request of Yura Ershov
00186  *
00187  * Revision 1.37  2000/02/10 03:08:02  craigs
00188  * Added ability to specify NTSC or PAL video format
00189  *
00190  * Revision 1.36  2000/02/04 05:00:08  craigs
00191  * Changes for video transmission
00192  *
00193  * Revision 1.35  2000/01/13 04:03:45  robertj
00194  * Added video transmission
00195  *
00196  * Revision 1.34  1999/12/31 00:05:36  robertj
00197  * Added Microsoft ACM G.723.1 codec capability.
00198  *
00199  * Revision 1.33  1999/12/29 01:19:16  craigs
00200  * Fixed problem with RTP payload type variable
00201  *
00202  * Revision 1.32  1999/12/23 23:02:34  robertj
00203  * File reorganision for separating RTP from H.323 and creation of LID for VPB support.
00204  *
00205  * Revision 1.31  1999/11/29 09:01:46  craigs
00206  * Added new code for new video code interface
00207  *
00208  * Revision 1.30  1999/11/29 04:50:11  robertj
00209  * Added adaptive threshold calculation to silence detection.
00210  *
00211  * Revision 1.29  1999/11/20 00:53:46  robertj
00212  * Fixed ability to have variable sized frames in single RTP packet under G.723.1
00213  *
00214  * Revision 1.28  1999/11/13 14:10:32  robertj
00215  * Changes to make silence detection selectable.
00216  *
00217  * Revision 1.27  1999/11/11 23:28:52  robertj
00218  * Added first cut silence detection algorithm.
00219  *
00220  * Revision 1.26  1999/11/04 00:43:42  robertj
00221  * Added extra constructors for nonStandard codecs.
00222  *
00223  * Revision 1.25  1999/10/14 12:03:08  robertj
00224  * Fixed comment.
00225  *
00226  * Revision 1.24  1999/10/08 09:59:01  robertj
00227  * Rewrite of capability for sending multiple audio frames
00228  *
00229  * Revision 1.23  1999/10/08 04:58:37  robertj
00230  * Added capability for sending multiple audio frames in single RTP packet
00231  *
00232  * Revision 1.22  1999/09/23 07:25:12  robertj
00233  * Added open audio and video function to connection and started multi-frame codec send functionality.
00234  *
00235  * Revision 1.21  1999/09/21 14:51:33  robertj
00236  * Fixed NonStandardCapabilityInfo class virtual destructor (and name).
00237  *
00238  * Revision 1.20  1999/09/21 14:04:41  robertj
00239  * Added non-standard codec capability classes
00240  *
00241  * Revision 1.19  1999/09/21 08:12:49  craigs
00242  * Added support for video codecs and H261
00243  *
00244  * Revision 1.18  1999/09/18 13:27:24  craigs
00245  * Added ability disable jitter buffer for codecs
00246  * Added ability to access entire RTP frame from codec Write
00247  *
00248  * Revision 1.17  1999/09/08 04:05:48  robertj
00249  * Added support for video capabilities & codec, still needs the actual codec itself!
00250  *
00251  * Revision 1.16  1999/08/31 12:34:18  robertj
00252  * Added gatekeeper support.
00253  *
00254  * Revision 1.15  1999/08/25 03:08:23  robertj
00255  * Added UserInput capability.
00256  * Allowed the attachment of a channel on a codec to optionally delete the channel object,
00257  *
00258  * Revision 1.14  1999/07/22 14:32:48  robertj
00259  * Fixed erroneous comments
00260  *
00261  * Revision 1.13  1999/07/16 16:05:48  robertj
00262  * Added "human readable" codec type name display.
00263  *
00264  * Revision 1.12  1999/07/15 14:45:35  robertj
00265  * Added propagation of codec open error to shut down logical channel.
00266  * Fixed control channel start up bug introduced with tunnelling.
00267  *
00268  * Revision 1.11  1999/07/13 09:53:24  robertj
00269  * Fixed some problems with jitter buffer and added more debugging.
00270  *
00271  * Revision 1.10  1999/07/09 06:09:49  robertj
00272  * Major implementation. An ENORMOUS amount of stuff added everywhere.
00273  *
00274  * Revision 1.9  1999/06/24 13:32:45  robertj
00275  * Fixed ability to change sound device on codec and fixed NM3 G.711 compatibility
00276  *
00277  * Revision 1.8  1999/06/22 13:49:40  robertj
00278  * Added GSM support and further RTP protocol enhancements.
00279  *
00280  * Revision 1.7  1999/06/14 15:08:40  robertj
00281  * Added GSM codec class frame work (still no actual codec).
00282  *
00283  * Revision 1.6  1999/06/14 06:39:08  robertj
00284  * Fixed problem with getting transmit flag to channel from PDU negotiator
00285  *
00286  * Revision 1.5  1999/06/14 05:15:55  robertj
00287  * Changes for using RTP sessions correctly in H323 Logical Channel context
00288  *
00289  * Revision 1.4  1999/06/13 12:41:14  robertj
00290  * Implement logical channel transmitter.
00291  * Fixed H245 connect on receiving call.
00292  *
00293  * Revision 1.3  1999/06/09 05:26:19  robertj
00294  * Major restructuring of classes.
00295  *
00296  * Revision 1.2  1999/06/06 06:06:36  robertj
00297  * Changes for new ASN compiler and v2 protocol ASN files.
00298  *
00299  * Revision 1.1  1999/01/16 01:31:01  robertj
00300  * Initial revision
00301  *
00302  */
00303 
00304 #ifndef __CODECS_H
00305 #define __CODECS_H
00306 
00307 #ifdef P_USE_PRAGMA
00308 #pragma interface
00309 #endif
00310 
00311 
00312 #include <mediafmt.h>
00313 #include <rtp.h>
00314 #include <channels.h>
00315 #include "openh323buildopts.h"
00316 
00317 
00318 /* The following classes have forward references to avoid including the VERY
00319    large header files for H225 and H245. If an application requires access
00320    to the protocol classes they can include them, but for simple usage their
00321    inclusion can be avoided.
00322  */
00323 class H245_MiscellaneousCommand_type;
00324 class H245_MiscellaneousIndication_type;
00325 class H323Connection;
00326 
00327 
00328 
00330 
00338 class PAec;
00339 class H323Codec : public PObject
00340 {
00341   PCLASSINFO(H323Codec, PObject);
00342 
00343   public:
00344     enum Direction {
00345       Encoder,
00346       Decoder
00347     };
00348 
00349     H323Codec(
00350       const char * mediaFormat, 
00351       Direction direction       
00352     );
00353 
00354 
00367     virtual BOOL Open(
00368       H323Connection & connection 
00369     );
00370 
00373     virtual void Close() = 0;
00374 
00392     virtual BOOL Read(
00393       BYTE * buffer,            
00394       unsigned & length,        
00395       RTP_DataFrame & rtpFrame  
00396     ) = 0;
00397 
00409     virtual BOOL Write(
00410       const BYTE * buffer,          
00411       unsigned length,              
00412       const RTP_DataFrame & frame,  
00413       unsigned & written            
00414     ) = 0;
00415 
00418     virtual unsigned GetFrameRate() const;
00419 
00423     virtual void OnFlowControl(
00424       long bitRateRestriction   
00425     );
00426 
00430     virtual void OnMiscellaneousCommand(
00431       const H245_MiscellaneousCommand_type & type  
00432     );
00433 
00437     virtual void OnMiscellaneousIndication(
00438       const H245_MiscellaneousIndication_type & type  
00439     );
00440 
00441     Direction GetDirection()   const { return direction; }
00442 
00443     const OpalMediaFormat & GetMediaFormat() const { return mediaFormat; }
00444 
00452     virtual BOOL AttachChannel(
00453       PChannel * channel,     
00454       BOOL autoDelete = TRUE  
00455     );
00456 
00461     virtual PChannel * SwapChannel(
00462       PChannel * newChannel,  
00463       BOOL autoDelete = TRUE  
00464     );
00465 
00468     virtual BOOL CloseRawDataChannel();
00469 
00473     PChannel *GetRawDataChannel()
00474       { return rawDataChannel; }
00475 
00482     virtual BOOL IsRawDataChannelNative() const;
00483 
00486     BOOL ReadRaw(
00487       void * data,
00488       PINDEX size,
00489       PINDEX & length
00490     );
00491 
00494     BOOL WriteRaw(
00495       void * data,
00496       PINDEX length
00497     );
00498 
00505     BOOL AttachLogicalChannel(H323Channel *channel);
00506 
00507     class FilterInfo : public PObject {
00508         PCLASSINFO(FilterInfo, PObject);
00509       public:
00510         FilterInfo(H323Codec & c, void * b, PINDEX s, PINDEX l)
00511           : codec(c), buffer(b), bufferSize(s), bufferLength(l) { }
00512 
00513         H323Codec & codec;
00514         void      * buffer;
00515         PINDEX      bufferSize;
00516         PINDEX      bufferLength;
00517     };
00518 
00540     void AddFilter(
00541       const PNotifier & notifier
00542     );
00543 
00547     virtual BOOL SetRawDataHeld(BOOL hold );
00548 
00549   protected:
00550     Direction direction;
00551     OpalMediaFormat mediaFormat;
00552     
00553     H323Channel * logicalChannel; // sends messages from receive codec to tx codec.
00554 
00555     PChannel * rawDataChannel;  // connection to the hardware for reading/writing data.
00556     BOOL       deleteChannel;
00557     PMutex     rawChannelMutex;
00558 
00559     PINDEX     lastSequenceNumber;  // Detects lost RTP packets in the video codec.
00560 
00561     PLIST(FilterList, PNotifier);
00562     FilterList filters;
00563 };
00564 
00565 #ifndef NO_H323_AUDIO_CODECS
00566 
00567 
00574 class PAec;
00575 class H323AudioCodec : public H323Codec
00576 {
00577   PCLASSINFO(H323AudioCodec, H323Codec);
00578 
00579   public:
00585     H323AudioCodec(
00586       const char * mediaFormat, 
00587       Direction direction       
00588     );
00589 
00590     ~H323AudioCodec();
00591 
00600     virtual BOOL Open(
00601       H323Connection & connection 
00602     );
00603 
00611     virtual void Close();
00612 
00615     virtual unsigned GetFrameRate() const;
00616 
00617     enum SilenceDetectionMode {
00618       NoSilenceDetection,
00619       FixedSilenceDetection,
00620       AdaptiveSilenceDetection
00621     };
00622 
00626     void SetSilenceDetectionMode(
00627       SilenceDetectionMode mode,   
00628       unsigned threshold = 0,      
00629       unsigned signalDeadband = 80,    
00630       unsigned silenceDeadband = 3200, 
00631       unsigned adaptivePeriod = 4800   
00632     );
00633 
00642     SilenceDetectionMode GetSilenceDetectionMode(
00643       BOOL * isInTalkBurst = NULL,        
00644       unsigned * currentThreshold = NULL  
00645     ) const;
00646 
00647     
00654     virtual void SetTxQualityLevel(int /*qlevel*/) {}
00655 
00659     virtual int GetTxQualityLevel(int /*qlevel*/) { return 1; }
00660     
00667     virtual BOOL DetectSilence();
00668 
00676     virtual unsigned GetAverageSignalLevel();
00677 
00681     virtual BOOL SetRawDataHeld(BOOL hold);
00682 
00683 #if HAS_AEC     
00684 
00686         virtual void AttachAEC(
00687        PAec * /*_ARC*/   
00688     ) {};
00689 #endif
00690 
00691   protected:
00692     unsigned samplesPerFrame;
00693 
00694     SilenceDetectionMode silenceDetectMode;
00695 
00696     unsigned signalDeadbandFrames;  // Frames of signal before talk burst starts
00697     unsigned silenceDeadbandFrames; // Frames of silence before talk burst ends
00698     unsigned adaptiveThresholdFrames; // Frames to min/max over for adaptive threshold
00699 
00700     BOOL     inTalkBurst;           // Currently sending RTP data
00701     unsigned framesReceived;        // Signal/Silence frames received so far.
00702     unsigned levelThreshold;        // Threshold level for silence/signal
00703     unsigned signalMinimum;         // Minimum of frames above threshold
00704     unsigned silenceMaximum;        // Maximum of frames below threshold
00705     unsigned signalFramesReceived;  // Frames of signal received
00706     unsigned silenceFramesReceived; // Frames of silence received
00707     BOOL         IsRawDataHeld;
00708 };
00709 
00710 
00719 class PAec;
00720 class H323FramedAudioCodec : public H323AudioCodec
00721 {
00722   PCLASSINFO(H323FramedAudioCodec, H323AudioCodec);
00723 
00724   public:
00730     H323FramedAudioCodec(
00731       const char * mediaFormat, 
00732       Direction direction       
00733     );
00734 
00752     virtual BOOL Read(
00753       BYTE * buffer,            
00754       unsigned & length,        
00755       RTP_DataFrame & rtpFrame  
00756     );
00757 
00770     virtual BOOL Write(
00771       const BYTE * buffer,            
00772       unsigned length,                
00773       const RTP_DataFrame & rtpFrame, 
00774       unsigned & written              
00775     );
00776 
00777 
00782     virtual unsigned GetAverageSignalLevel();
00783 
00784 
00790     virtual BOOL EncodeFrame(
00791       BYTE * buffer,    
00792       unsigned & length 
00793     ) = 0;
00794 
00799     virtual BOOL DecodeFrame(
00800       const BYTE * buffer,   
00801       unsigned length,       
00802       unsigned & written,    
00803       unsigned & bytesOutput 
00804     );
00805     virtual BOOL DecodeFrame(
00806       const BYTE * buffer,  
00807       unsigned length,      
00808       unsigned & written    
00809     );
00810 
00815     virtual void DecodeSilenceFrame(
00816       void * buffer,  
00817       unsigned length       
00818     )
00819     { memset(buffer, 0, length); }
00820 
00821 #if HAS_AEC     
00822 
00824         virtual void AttachAEC(
00825        PAec * _ARC   
00826     );
00827 #endif
00828 
00829   protected:
00830         PAec * aec;     // Acoustic Echo Canceller
00831     PShortArray sampleBuffer;
00832     unsigned    bytesPerFrame;
00833 };
00834 
00835 
00844 class H323StreamedAudioCodec : public H323FramedAudioCodec
00845 {
00846   PCLASSINFO(H323StreamedAudioCodec, H323FramedAudioCodec);
00847 
00848   public:
00854     H323StreamedAudioCodec(
00855       const char * mediaFormat, 
00856       Direction direction,      
00857       unsigned samplesPerFrame, 
00858       unsigned bits             
00859     );
00860 
00866     virtual BOOL EncodeFrame(
00867       BYTE * buffer,    
00868       unsigned & length 
00869     );
00870 
00876     virtual BOOL DecodeFrame(
00877       const BYTE * buffer,  
00878       unsigned length,      
00879       unsigned & written,   
00880       unsigned & samples    
00881     );
00882 
00885     virtual int Encode(short sample) const = 0;
00886 
00889     virtual short Decode(int sample) const = 0;
00890 
00891   protected:
00892     unsigned bitsPerSample;
00893 };
00894 
00895 #endif // NO_H323_AUDIO_CODECS
00896 
00897 
00898 #ifndef NO_H323_VIDEO
00899 
00906 class H323VideoCodec : public H323Codec
00907 {
00908   PCLASSINFO(H323VideoCodec, H323Codec);
00909 
00910   public:
00916     H323VideoCodec(
00917       const char * mediaFormat, 
00918       Direction direction      
00919     );
00920 
00921     ~H323VideoCodec();
00922 
00931     virtual BOOL Open(
00932       H323Connection & connection 
00933     );
00934 
00942     virtual void Close();
00943 
00944 
00948     virtual void OnMiscellaneousCommand(
00949       const H245_MiscellaneousCommand_type & type  
00950     );
00951 
00955     virtual void OnMiscellaneousIndication(
00956       const H245_MiscellaneousIndication_type & type  
00957     );
00958 
00959     //    /**Attach the raw data device for use by codec.
00960     //   Note the device provided will be deleted on destruction of the codec.
00961     //   */
00962     // virtual BOOL AttachDevice(
00963     //  H323VideoDevice * device, ///< Device to read/write data
00964     //  BOOL autoDelete = TRUE    ///< Device is to be automatically deleted
00965     // );
00966 
00970     virtual void OnFreezePicture();
00971 
00975     virtual void OnFastUpdatePicture();
00976 
00980     virtual void OnFastUpdateGOB(unsigned firstGOB, unsigned numberOfGOBs);
00981 
00985     virtual void OnFastUpdateMB(int firstGOB, int firstMB, unsigned numberOfMBs);
00986 
00990     virtual void OnVideoIndicateReadyToActivate();
00991 
00995     virtual void OnVideoTemporalSpatialTradeOffCommand(int newQuality);
00996 
01000     virtual void OnVideoTemporalSpatialTradeOffIndication(int newQuality);
01001 
01005     virtual void OnVideoNotDecodedMBs(
01006       unsigned firstMB,
01007       unsigned numberOfMBs,
01008       unsigned temporalReference
01009     );
01010 
01014     virtual void OnLostPartialPicture();
01015 
01019     virtual void OnLostPicture();
01020 
01023     int GetWidth() const { return frameWidth; }
01024 
01027     int GetHeight() const { return frameHeight; }
01028 
01031     virtual void SetTxQualityLevel(int qlevel) {videoQuality = qlevel; }
01032 
01036     virtual void SetTxMinQuality(int qlevel) {videoQMin = qlevel; }
01037 
01041     virtual void SetTxMaxQuality(int qlevel) {videoQMax = qlevel; }
01042 
01045     virtual void SetBackgroundFill(int idle) {fillLevel= idle; }
01046  
01047     enum BitRateModeBits {
01048       None                = 0x00,
01049       DynamicVideoQuality = 0x01,
01050       AdaptivePacketDelay = 0x02
01051     };
01052 
01055     unsigned GetVideoMode(void) {return videoBitRateControlModes;}
01056 
01060     unsigned SetVideoMode(unsigned mode) {return videoBitRateControlModes = mode;}
01061 
01069     virtual BOOL SetMaxBitRate(
01070       unsigned bitRate 
01071     );
01072 
01077     virtual unsigned GetMaxBitRate() const { return bitRateHighLimit; }
01078 
01087     virtual BOOL SetTargetFrameTimeMs(
01088       unsigned ms 
01089     );
01090 
01095     void SendMiscCommand(unsigned command);
01096  
01100    virtual int GetFrameNum() { return frameNum; }
01101 
01102 
01103   protected:
01104 
01105     int frameWidth;
01106     int frameHeight;
01107     int fillLevel;
01108 
01109     // used in h261codec.cxx
01110     unsigned videoBitRateControlModes;
01111     // variables used for video bit rate control
01112     int bitRateHighLimit; // maximum instantaneous bit rate allowed
01113     unsigned oldLength;
01114     PTimeInterval oldTime;
01115     PTimeInterval newTime;
01116     // variables used for dynamic video quality control
01117     int targetFrameTimeMs; //targetFrameTimeMs = 1000 / videoSendFPS
01118     int frameBytes; // accumulate count of bytes per frame
01119     int sumFrameTimeMs, sumAdjFrameTimeMs, sumFrameBytes; // accumulate running average
01120     int videoQMax, videoQMin; // dynamic video quality min/max limits
01121     int videoQuality; // current video encode quality setting, 1..31
01122     PTimeInterval frameStartTime;
01123     PTimeInterval grabInterval;
01124     
01125     int frameNum, packetNum, oldPacketNum;
01126     int framesPerSec;
01127 
01128     PMutex  videoHandlerActive;    
01129 };
01130 
01131 #endif // NO_H323_VIDEO
01132 
01133 #ifndef NO_H323_AUDIO_CODECS
01134 
01136 // The simplest codec is the G.711 PCM codec.
01137 
01140 class H323_ALawCodec : public H323StreamedAudioCodec
01141 {
01142   PCLASSINFO(H323_ALawCodec, H323StreamedAudioCodec)
01143 
01144   public:
01149     H323_ALawCodec(
01150       Direction direction,  
01151       BOOL at56kbps,        
01152       unsigned frameSize    
01153     );
01155 
01156     virtual int   Encode(short sample) const { return EncodeSample(sample); }
01157     virtual short Decode(int   sample) const { return DecodeSample(sample); }
01158 
01159     static int   EncodeSample(short sample);
01160     static short DecodeSample(int   sample);
01161 
01162   protected:
01163     BOOL sevenBit;
01164 };
01165 
01166 
01169 class H323_muLawCodec : public H323StreamedAudioCodec
01170 {
01171   PCLASSINFO(H323_muLawCodec, H323StreamedAudioCodec)
01172 
01173   public:
01178     H323_muLawCodec(
01179       Direction direction,  
01180       BOOL at56kbps,        
01181       unsigned frameSize    
01182     );
01184 
01185     virtual int   Encode(short sample) const { return EncodeSample(sample); }
01186     virtual short Decode(int   sample) const { return DecodeSample(sample); }
01187 
01188     static int   EncodeSample(short sample);
01189     static short DecodeSample(int   sample);
01190 
01191   protected:
01192     BOOL sevenBit;
01193 };
01194 
01195 #endif // NO_H323_AUDIO_CODECS
01196 
01197 
01198 #endif // __CODECS_H
01199 
01200 

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