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 #ifndef __OPAL_RFC2833_H
00045 #define __OPAL_RFC2833_H
00046
00047 #ifdef P_USE_PRAGMA
00048 #pragma interface
00049 #endif
00050
00051
00052 #include <rtp/rtp.h>
00053
00054
00056
00057 class OpalRFC2833Info : public PObject {
00058 PCLASSINFO(OpalRFC2833Info, PObject);
00059 public:
00060 OpalRFC2833Info(
00061 char tone,
00062 unsigned duration = 0,
00063 unsigned timestamp = 0
00064 );
00065
00066 char GetTone() const { return tone; }
00067 unsigned GetDuration() const { return duration; }
00068 unsigned GetTimestamp() const { return timestamp; }
00069 BOOL IsToneStart() const { return duration == 0; }
00070
00071 protected:
00072 char tone;
00073 unsigned duration;
00074 unsigned timestamp;
00075 };
00076
00077
00078 class OpalRFC2833Proto : public PObject {
00079 PCLASSINFO(OpalRFC2833Proto, PObject);
00080 public:
00081 OpalRFC2833Proto(
00082 const PNotifier & receiveNotifier
00083 );
00084
00085 virtual BOOL SendTone(
00086 char tone,
00087 unsigned duration
00088 );
00089
00090 virtual BOOL BeginTransmit(
00091 char tone
00092 );
00093 virtual BOOL EndTransmit();
00094
00095 virtual void OnStartReceive(
00096 char tone
00097 );
00098 virtual void OnEndReceive(
00099 char tone,
00100 unsigned duration,
00101 unsigned timestamp
00102 );
00103
00104 RTP_DataFrame::PayloadTypes GetPayloadType() const { return payloadType; }
00105
00106 void SetPayloadType(
00107 RTP_DataFrame::PayloadTypes type
00108 ) { payloadType = type; }
00109
00110 const PNotifier & GetReceiveHandler() const { return receiveHandler; }
00111 const PNotifier & GetTransmitHandler() const { return transmitHandler; }
00112
00113 protected:
00114 PDECLARE_NOTIFIER(RTP_DataFrame, OpalRFC2833Proto, ReceivedPacket);
00115 PDECLARE_NOTIFIER(RTP_DataFrame, OpalRFC2833Proto, TransmitPacket);
00116 PDECLARE_NOTIFIER(PTimer, OpalRFC2833Proto, ReceiveTimeout);
00117 PDECLARE_NOTIFIER(PTimer, OpalRFC2833Proto, TransmitEnded);
00118
00119 RTP_DataFrame::PayloadTypes payloadType;
00120
00121 PMutex mutex;
00122
00123 PNotifier receiveNotifier;
00124 BOOL receiveComplete;
00125 BYTE receivedTone;
00126 unsigned receivedDuration;
00127 unsigned receiveTimestamp;
00128 PTimer receiveTimer;
00129 PNotifier receiveHandler;
00130
00131 enum {
00132 TransmitIdle,
00133 TransmitActive,
00134 TransmitEnding
00135 } transmitState;
00136 BYTE transmitCode;
00137 unsigned transmitTimestamp;
00138 PTimer transmitTimer;
00139 PNotifier transmitHandler;
00140 };
00141
00142
00143 #endif // __OPAL_RFC2833_H
00144
00145