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
00042 class OpalMediaFormat;
00043
00044
00046
00047 class OpalRFC2833Info : public PObject {
00048 PCLASSINFO(OpalRFC2833Info, PObject);
00049 public:
00050
00051 enum NTEEvent {
00052 Digit0 = 0,
00053 Digit1 = 1,
00054 Digit2 = 2,
00055 Digit3 = 3,
00056 Digit4 = 4,
00057 Digit5 = 5,
00058 Digit6 = 6,
00059 Digit7 = 7,
00060 Digit8 = 8,
00061 Digit9 = 9,
00062 Star = 10,
00063 Hash = 11,
00064 A = 12,
00065 B = 13,
00066 C = 14,
00067 D = 15,
00068 Flash = 16,
00069 CED = 32,
00070 CNG = 36
00071 };
00072
00073 OpalRFC2833Info(
00074 char tone,
00075 unsigned duration = 0,
00076 unsigned timestamp = 0
00077 );
00078
00079 char GetTone() const { return tone; }
00080 unsigned GetDuration() const { return duration; }
00081 unsigned GetTimestamp() const { return timestamp; }
00082 bool IsToneStart() const { return duration == 0; }
00083
00084 protected:
00085 char tone;
00086 unsigned duration;
00087 unsigned timestamp;
00088 };
00089
00090 class OpalRTPConnection;
00091
00092 class OpalRFC2833Proto : public PObject {
00093 PCLASSINFO(OpalRFC2833Proto, PObject);
00094 public:
00095 OpalRFC2833Proto(
00096 OpalRTPConnection & conn,
00097 const PNotifier & receiveNotifier,
00098 const OpalMediaFormat & mediaFormat
00099 );
00100 ~OpalRFC2833Proto();
00101
00102 virtual bool SendToneAsync(
00103 char tone,
00104 unsigned duration
00105 );
00106
00107 virtual void OnStartReceive(
00108 char tone,
00109 unsigned timestamp
00110 );
00111 virtual void OnStartReceive(
00112 char tone
00113 );
00114 virtual void OnEndReceive(
00115 char tone,
00116 unsigned duration,
00117 unsigned timestamp
00118 );
00119
00120 RTP_DataFrame::PayloadTypes GetPayloadType() const { return m_payloadType; }
00121
00122 void SetPayloadType(
00123 RTP_DataFrame::PayloadTypes type
00124 ) { m_payloadType = type; }
00125
00126 const PNotifier & GetReceiveHandler() const { return m_receiveHandler; }
00127
00128 PString GetTxCapability() const;
00129 PString GetRxCapability() const;
00130 void SetTxCapability(const PString & codes);
00131 void SetRxCapability(const PString & codes);
00132
00133 static PINDEX ASCIIToRFC2833(char tone, bool hasNSE);
00134 static char RFC2833ToASCII(PINDEX rfc2833, bool hasNSE);
00135
00136 protected:
00137 void SendAsyncFrame();
00138
00139 PDECLARE_NOTIFIER(RTP_DataFrame, OpalRFC2833Proto, ReceivedPacket);
00140 PDECLARE_NOTIFIER(PTimer, OpalRFC2833Proto, ReceiveTimeout);
00141 PDECLARE_NOTIFIER(PTimer, OpalRFC2833Proto, AsyncTimeout);
00142
00143 OpalRTPConnection & m_connection;
00144 RTP_DataFrame::PayloadTypes m_payloadType;
00145 std::vector<bool> m_txCapabilitySet;
00146 std::vector<bool> m_rxCapabilitySet;
00147 PNotifier m_receiveNotifier;
00148 PNotifier m_receiveHandler;
00149
00150 enum {
00151 ReceiveIdle,
00152 ReceiveActive,
00153 ReceiveEnding
00154 } m_receiveState;
00155
00156 BYTE m_receivedTone;
00157 unsigned m_tonesReceived;
00158 PTimer m_receiveTimer;
00159 DWORD m_previousReceivedTimestamp;
00160
00161 enum {
00162 TransmitIdle,
00163 TransmitActive,
00164 TransmitEnding1,
00165 TransmitEnding2,
00166 TransmitEnding3,
00167 } m_transmitState;
00168
00169 RTP_Session * m_rtpSession;
00170 PTimer m_asyncTransmitTimer;
00171 PTimer m_asyncDurationTimer;
00172 DWORD m_transmitTimestamp;
00173 bool m_rewriteTransmitTimestamp;
00174 PTimeInterval m_asyncStart;
00175 BYTE m_transmitCode;
00176 unsigned m_transmitDuration;
00177
00178 PMutex m_mutex;
00179 };
00180
00181
00182 #endif // OPAL_CODEC_RFC2833_H
00183
00184