rfc2833.h

Go to the documentation of this file.
00001 /*
00002  * rfc2833.h
00003  *
00004  * Open Phone Abstraction Library (OPAL)
00005  * Formally known as the Open H323 project.
00006  *
00007  * Copyright (c) 2001 Equivalence Pty. Ltd.
00008  *
00009  * The contents of this file are subject to the Mozilla Public License
00010  * Version 1.0 (the "License"); you may not use this file except in
00011  * compliance with the License. You may obtain a copy of the License at
00012  * http://www.mozilla.org/MPL/
00013  *
00014  * Software distributed under the License is distributed on an "AS IS"
00015  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00016  * the License for the specific language governing rights and limitations
00017  * under the License.
00018  *
00019  * The Original Code is Open Phone Abstraction Library.
00020  *
00021  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00022  *
00023  * Contributor(s): ______________________________________.
00024  *
00025  * $Revision: 21860 $
00026  * $Author: rjongbloed $
00027  * $Date: 2008-12-23 02:24:22 +0000 (Tue, 23 Dec 2008) $
00028  */
00029 
00030 #ifndef OPAL_CODEC_RFC2833_H
00031 #define OPAL_CODEC_RFC2833_H
00032 
00033 #ifdef P_USE_PRAGMA
00034 #pragma interface
00035 #endif
00036 
00037 #include <opal/buildopts.h>
00038 
00039 #include <rtp/rtp.h>
00040 
00041 
00042 class OpalMediaFormat;
00043 
00044 
00046 
00047 class OpalRFC2833Info : public PObject {
00048     PCLASSINFO(OpalRFC2833Info, PObject);
00049   public:
00050     // the following values are mandated by RFC 2833
00051     enum NTEEvent {
00052       Digit0 = 0,
00053       Digit1 = 1,
00054       Digit2 = 2,
00055       Digit3 = 3,
00056       Digit4 = 4,
00057       Digit5 = 5,
00058       Digit6 = 6,
00059       Digit7 = 7,
00060       Digit8 = 8,
00061       Digit9 = 9,
00062       Star   = 10,
00063       Hash   = 11,
00064       A      = 12,
00065       B      = 13,
00066       C      = 14,
00067       D      = 15,
00068       Flash  = 16,
00069       CED    = 32,
00070       CNG    = 36
00071     };
00072 
00073     OpalRFC2833Info(
00074       char tone,
00075       unsigned duration = 0,
00076       unsigned timestamp = 0
00077     );
00078 
00079     char GetTone() const { return tone; }
00080     unsigned GetDuration() const { return duration; }
00081     unsigned GetTimestamp() const { return timestamp; }
00082     bool IsToneStart() const { return duration == 0; }
00083 
00084   protected:
00085     char     tone;
00086     unsigned duration;
00087     unsigned timestamp;
00088 };
00089 
00090 class OpalRTPConnection;
00091 
00092 class OpalRFC2833Proto : public PObject {
00093     PCLASSINFO(OpalRFC2833Proto, PObject);
00094   public:
00095     OpalRFC2833Proto(
00096       OpalRTPConnection & conn,
00097       const PNotifier & receiveNotifier,
00098       const OpalMediaFormat & mediaFormat
00099     );
00100     ~OpalRFC2833Proto();
00101 
00102     virtual bool SendToneAsync(
00103       char tone, 
00104       unsigned duration
00105     );
00106 
00107     virtual void OnStartReceive(
00108       char tone,
00109       unsigned timestamp
00110     );
00111     virtual void OnStartReceive(
00112       char tone
00113     );
00114     virtual void OnEndReceive(
00115       char tone,
00116       unsigned duration,
00117       unsigned timestamp
00118     );
00119 
00120     RTP_DataFrame::PayloadTypes GetPayloadType() const { return m_payloadType; }
00121 
00122     void SetPayloadType(
00123       RTP_DataFrame::PayloadTypes type 
00124     ) { m_payloadType = type; }
00125 
00126     const PNotifier & GetReceiveHandler() const { return m_receiveHandler; }
00127 
00128     PString GetTxCapability() const;
00129     PString GetRxCapability() const;
00130     void SetTxCapability(const PString & codes);
00131     void SetRxCapability(const PString & codes);
00132 
00133     static PINDEX ASCIIToRFC2833(char tone, bool hasNSE);
00134     static char RFC2833ToASCII(PINDEX rfc2833, bool hasNSE);
00135 
00136   protected:
00137     void SendAsyncFrame();
00138 
00139     PDECLARE_NOTIFIER(RTP_DataFrame, OpalRFC2833Proto, ReceivedPacket);
00140     PDECLARE_NOTIFIER(PTimer, OpalRFC2833Proto, ReceiveTimeout);
00141     PDECLARE_NOTIFIER(PTimer, OpalRFC2833Proto, AsyncTimeout);
00142 
00143     OpalRTPConnection         & m_connection;
00144     RTP_DataFrame::PayloadTypes m_payloadType;
00145     std::vector<bool>           m_txCapabilitySet;
00146     std::vector<bool>           m_rxCapabilitySet;
00147     PNotifier                   m_receiveNotifier;
00148     PNotifier                   m_receiveHandler;
00149 
00150     enum {
00151       ReceiveIdle,
00152       ReceiveActive,
00153       ReceiveEnding
00154     } m_receiveState;
00155 
00156     BYTE     m_receivedTone;
00157     unsigned m_tonesReceived;
00158     PTimer   m_receiveTimer;
00159     DWORD    m_previousReceivedTimestamp;
00160 
00161     enum {
00162       TransmitIdle,
00163       TransmitActive,
00164       TransmitEnding1,
00165       TransmitEnding2,
00166       TransmitEnding3,
00167     } m_transmitState;
00168 
00169     RTP_Session * m_rtpSession;
00170     PTimer        m_asyncTransmitTimer;
00171     PTimer        m_asyncDurationTimer;
00172     DWORD         m_transmitTimestamp;
00173     bool          m_rewriteTransmitTimestamp;
00174     PTimeInterval m_asyncStart;
00175     BYTE          m_transmitCode;
00176     unsigned      m_transmitDuration;
00177 
00178     PMutex m_mutex;
00179 };
00180 
00181 
00182 #endif // OPAL_CODEC_RFC2833_H
00183 
00184 

Generated on Mon Feb 1 00:25:53 2010 for OPAL by  doxygen 1.5.1