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
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #ifndef __OPAL_RFC2833_H
00054 #define __OPAL_RFC2833_H
00055
00056 #ifdef P_USE_PRAGMA
00057 #pragma interface
00058 #endif
00059
00060
00061 #include <rtp/rtp.h>
00062
00063 extern const char * OpalDefaultNTEString;
00064
00065 #if OPAL_T38FAX
00066 extern const char * OpalDefaultNSEString;
00067 #endif
00068
00070
00071 class OpalRFC2833Info : public PObject {
00072 PCLASSINFO(OpalRFC2833Info, PObject);
00073 public:
00074 OpalRFC2833Info(
00075 char tone,
00076 unsigned duration = 0,
00077 unsigned timestamp = 0
00078 );
00079
00080 char GetTone() const { return tone; }
00081 unsigned GetDuration() const { return duration; }
00082 unsigned GetTimestamp() const { return timestamp; }
00083 BOOL IsToneStart() const { return duration == 0; }
00084
00085 protected:
00086 char tone;
00087 unsigned duration;
00088 unsigned timestamp;
00089 };
00090
00091 class OpalConnection;
00092
00093 class OpalRFC2833Proto : public PObject {
00094 PCLASSINFO(OpalRFC2833Proto, PObject);
00095 public:
00096 OpalRFC2833Proto(
00097 OpalConnection & conn,
00098 const PNotifier & receiveNotifier
00099 );
00100 ~OpalRFC2833Proto();
00101
00102 virtual BOOL SendToneAsync(
00103 char tone,
00104 unsigned duration
00105 );
00106
00107 virtual BOOL BeginTransmit(
00108 char tone
00109 );
00110 virtual BOOL EndTransmit();
00111
00112 virtual void OnStartReceive(
00113 char tone
00114 );
00115 virtual void OnEndReceive(
00116 char tone,
00117 unsigned duration,
00118 unsigned timestamp
00119 );
00120
00121 RTP_DataFrame::PayloadTypes GetPayloadType() const { return payloadType; }
00122
00123 void SetPayloadType(
00124 RTP_DataFrame::PayloadTypes type
00125 ) { payloadType = type; }
00126
00127 const PNotifier & GetReceiveHandler() const { return receiveHandler; }
00128
00129 protected:
00130 void SendAsyncFrame();
00131 void TransmitPacket(RTP_DataFrame & frame);
00132
00133 OpalConnection & conn;
00134
00135 PDECLARE_NOTIFIER(RTP_DataFrame, OpalRFC2833Proto, ReceivedPacket);
00136 PDECLARE_NOTIFIER(PTimer, OpalRFC2833Proto, ReceiveTimeout);
00137 PDECLARE_NOTIFIER(PTimer, OpalRFC2833Proto, AsyncTimeout);
00138
00139 RTP_DataFrame::PayloadTypes payloadType;
00140
00141 PMutex mutex;
00142
00143 PNotifier receiveNotifier;
00144 BOOL receiveComplete;
00145 BYTE receivedTone;
00146 unsigned receivedDuration;
00147 unsigned receiveTimestamp;
00148 PTimer receiveTimer;
00149 PNotifier receiveHandler;
00150
00151 enum {
00152 TransmitIdle,
00153 TransmitActive,
00154 TransmitEnding
00155 } transmitState;
00156 BYTE transmitCode;
00157
00158 RTP_Session * rtpSession;
00159 PTimer asyncTransmitTimer;
00160 PTimer asyncDurationTimer;
00161 DWORD transmitTimestamp;
00162 BOOL transmitTimestampSet;
00163 PTimeInterval asyncStart;
00164 };
00165
00166
00167 #endif // __OPAL_RFC2833_H
00168
00169