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_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 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
00135
00136
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_CODEC_RFC2833_H
00164
00165