00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
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
00038 #include <rtp/rtp.h>
00039
00040 extern const char * OpalDefaultNTEString;
00041
00042 #if OPAL_T38_CAPABILITY
00043 extern const char * OpalDefaultNSEString;
00044 #endif
00045
00047
00048 class OpalRFC2833Info : public PObject {
00049 PCLASSINFO(OpalRFC2833Info, PObject);
00050 public:
00051 OpalRFC2833Info(
00052 char tone,
00053 unsigned duration = 0,
00054 unsigned timestamp = 0
00055 );
00056
00057 char GetTone() const { return tone; }
00058 unsigned GetDuration() const { return duration; }
00059 unsigned GetTimestamp() const { return timestamp; }
00060 PBoolean IsToneStart() const { return duration == 0; }
00061
00062 protected:
00063 char tone;
00064 unsigned duration;
00065 unsigned timestamp;
00066 };
00067
00068 class OpalRTPConnection;
00069
00070 class OpalRFC2833Proto : public PObject {
00071 PCLASSINFO(OpalRFC2833Proto, PObject);
00072 public:
00073 OpalRFC2833Proto(
00074 OpalRTPConnection & conn,
00075 const PNotifier & receiveNotifier
00076 );
00077 ~OpalRFC2833Proto();
00078
00079 virtual PBoolean SendToneAsync(
00080 char tone,
00081 unsigned duration
00082 );
00083
00084 virtual PBoolean BeginTransmit(
00085 char tone
00086 );
00087
00088 virtual void OnStartReceive(
00089 char tone,
00090 unsigned timestamp
00091 );
00092 virtual void OnStartReceive(
00093 char tone
00094 );
00095 virtual void OnEndReceive(
00096 char tone,
00097 unsigned duration,
00098 unsigned timestamp
00099 );
00100
00101 RTP_DataFrame::PayloadTypes GetPayloadType() const { return payloadType; }
00102
00103 void SetPayloadType(
00104 RTP_DataFrame::PayloadTypes type
00105 ) { payloadType = type; }
00106
00107 const PNotifier & GetReceiveHandler() const { return receiveHandler; }
00108
00109 static PINDEX ASCIIToRFC2833(char tone);
00110 static char RFC2833ToASCII(PINDEX rfc2833);
00111
00112 protected:
00113 void SendAsyncFrame();
00114
00115 OpalRTPConnection & conn;
00116
00117 PDECLARE_NOTIFIER(RTP_DataFrame, OpalRFC2833Proto, ReceivedPacket);
00118 PDECLARE_NOTIFIER(PTimer, OpalRFC2833Proto, ReceiveTimeout);
00119 PDECLARE_NOTIFIER(PTimer, OpalRFC2833Proto, AsyncTimeout);
00120
00121 RTP_DataFrame::PayloadTypes payloadType;
00122
00123 PMutex mutex;
00124
00125 enum {
00126 ReceiveIdle,
00127 ReceiveActive,
00128 ReceiveEnding
00129 } receiveState;
00130
00131 BYTE receivedTone;
00132
00133
00134
00135
00136
00137 PNotifier receiveNotifier;
00138 PTimer receiveTimer;
00139 PNotifier receiveHandler;
00140
00141 enum {
00142 TransmitIdle,
00143 TransmitActive,
00144 TransmitEnding1,
00145 TransmitEnding2,
00146 TransmitEnding3,
00147 } transmitState;
00148 BYTE transmitCode;
00149
00150 RTP_Session * rtpSession;
00151 PTimer asyncTransmitTimer;
00152 PTimer asyncDurationTimer;
00153 DWORD transmitTimestamp;
00154 PBoolean rewriteTransmitTimestamp;
00155 PTimeInterval asyncStart;
00156 unsigned transmitDuration;
00157 unsigned tonesReceived;
00158 DWORD previousReceivedTimestamp;
00159 };
00160
00161
00162 #endif // __OPAL_RFC2833_H
00163
00164