# 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: 21004 $
    00026  * $Author: rjongbloed $
    00027  * $Date: 2008-09-16 07:08:56 +0000 (Tue, 16 Sep 2008) $
    00028  */
    00029
    00030 #ifndef __OPAL_RFC2833_H
    00031 #define __OPAL_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 extern const char * OpalDefaultNTEString;
    00042
    00043 #if OPAL_T38_CAPABILITY
    00044 extern const char * OpalDefaultNSEString;
    00045 #endif
    00046
    00048
    00049 class OpalRFC2833Info : public PObject {
    00050     PCLASSINFO(OpalRFC2833Info, PObject);
    00051   public:
    00052     OpalRFC2833Info(
    00053       char tone,
    00054       unsigned duration = 0,
    00055       unsigned timestamp = 0
    00056     );
    00057
    00058     char GetTone() const { return tone; }
    00059     unsigned GetDuration() const { return duration; }
    00060     unsigned GetTimestamp() const { return timestamp; }
    00061     PBoolean IsToneStart() const { return duration == 0; }
    00062
    00063   protected:
    00064     char     tone;
    00065     unsigned duration;
    00066     unsigned timestamp;
    00067 };
    00068
    00069 class OpalRTPConnection;
    00070
    00071 class OpalRFC2833Proto : public PObject {
    00072     PCLASSINFO(OpalRFC2833Proto, PObject);
    00073   public:
    00074     OpalRFC2833Proto(
    00075       OpalRTPConnection & conn,
    00076       const PNotifier & receiveNotifier
    00077     );
    00078     ~OpalRFC2833Proto();
    00079
    00080     virtual PBoolean SendToneAsync(
    00081       char tone,
    00082       unsigned duration
    00083     );
    00084
    00085     virtual PBoolean BeginTransmit(
    00086       char tone
    00087     );
    00088
    00089     virtual void OnStartReceive(
    00090       char tone,
    00091       unsigned timestamp
    00092     );
    00093     virtual void OnStartReceive(
    00094       char tone
    00095     );
    00096     virtual void OnEndReceive(
    00097       char tone,
    00098       unsigned duration,
    00099       unsigned timestamp
    00100     );
    00101
    00102     RTP_DataFrame::PayloadTypes GetPayloadType() const { return payloadType; }
    00103
    00104     void SetPayloadType(
    00105       RTP_DataFrame::PayloadTypes type
    00106     ) { payloadType = type; }
    00107
    00108     const PNotifier & GetReceiveHandler() const { return receiveHandler; }
    00109
    00110     static PINDEX ASCIIToRFC2833(char tone);
    00111     static char RFC2833ToASCII(PINDEX rfc2833);
    00112
    00113   protected:
    00114     void SendAsyncFrame();
    00115
    00116     OpalRTPConnection & conn;
    00117
    00118     PDECLARE_NOTIFIER(RTP_DataFrame, OpalRFC2833Proto, ReceivedPacket);
    00119     PDECLARE_NOTIFIER(PTimer, OpalRFC2833Proto, ReceiveTimeout);
    00120     PDECLARE_NOTIFIER(PTimer, OpalRFC2833Proto, AsyncTimeout);
    00121
    00122     RTP_DataFrame::PayloadTypes payloadType;
    00123
    00124     PMutex mutex;
    00125
    00126     enum {
    00127       ReceiveIdle,
    00128       ReceiveActive,
    00129       ReceiveEnding
    00130     } receiveState;
    00131
    00132     BYTE      receivedTone;
    00133
    00134     //PBoolean  receiveComplete;
    00135     //unsigned  receivedDuration;
    00136     //unsigned  receiveTimestamp;
    00137
    00138     PNotifier receiveNotifier;
    00139     PTimer    receiveTimer;
    00140     PNotifier receiveHandler;
    00141
    00142     enum {
    00143       TransmitIdle,
    00144       TransmitActive,
    00145       TransmitEnding1,
    00146       TransmitEnding2,
    00147       TransmitEnding3,
    00148     } transmitState;
    00149     BYTE      transmitCode;
    00150
    00151     RTP_Session * rtpSession;
    00152     PTimer        asyncTransmitTimer;
    00153     PTimer        asyncDurationTimer;
    00154     DWORD         transmitTimestamp;
    00155     PBoolean      rewriteTransmitTimestamp;
    00156     PTimeInterval asyncStart;
    00157     unsigned      transmitDuration;
    00158     unsigned      tonesReceived;
    00159     DWORD         previousReceivedTimestamp;
    00160 };
    00161
    00162
    00163 #endif // __OPAL_RFC2833_H
    00164
    00165