OPAL  Version 3.10.10
rfc2833.h
Go to the documentation of this file.
1 /*
2  * rfc2833.h
3  *
4  * Open Phone Abstraction Library (OPAL)
5  * Formally known as the Open H323 project.
6  *
7  * Copyright (c) 2001 Equivalence Pty. Ltd.
8  *
9  * The contents of this file are subject to the Mozilla Public License
10  * Version 1.0 (the "License"); you may not use this file except in
11  * compliance with the License. You may obtain a copy of the License at
12  * http://www.mozilla.org/MPL/
13  *
14  * Software distributed under the License is distributed on an "AS IS"
15  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
16  * the License for the specific language governing rights and limitations
17  * under the License.
18  *
19  * The Original Code is Open Phone Abstraction Library.
20  *
21  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
22  *
23  * Contributor(s): ______________________________________.
24  *
25  * $Revision: 27191 $
26  * $Author: rjongbloed $
27  * $Date: 2012-03-14 02:20:26 -0500 (Wed, 14 Mar 2012) $
28  */
29 
30 #ifndef OPAL_CODEC_RFC2833_H
31 #define OPAL_CODEC_RFC2833_H
32 
33 #ifdef P_USE_PRAGMA
34 #pragma interface
35 #endif
36 
37 #include <opal/buildopts.h>
38 
39 #include <opal/mediafmt.h>
40 #include <rtp/rtp.h>
41 
42 
43 class OpalRTPConnection;
44 
45 
47 
48 class OpalRFC2833EventsMask : public std::vector<bool>
49 {
50  public:
51  enum { NumEvents = 256 };
52  OpalRFC2833EventsMask(bool defaultValue = false);
53  OpalRFC2833EventsMask(const char * defaultValues);
55  friend ostream & operator<<(ostream & strm, const OpalRFC2833EventsMask & mask);
56  friend istream & operator>>(istream & strm, OpalRFC2833EventsMask & mask);
57 };
58 
60 const PCaselessString & OpalRFC288EventsName();
61 
62 
64 
65 class OpalRFC2833Info : public PObject
66 {
67  PCLASSINFO(OpalRFC2833Info, PObject);
68  public:
69  // the following values are mandated by RFC 2833
70  enum NTEEvent {
71  Digit0 = 0,
72  Digit1 = 1,
73  Digit2 = 2,
74  Digit3 = 3,
75  Digit4 = 4,
76  Digit5 = 5,
77  Digit6 = 6,
78  Digit7 = 7,
79  Digit8 = 8,
80  Digit9 = 9,
81  Star = 10,
82  Hash = 11,
83  A = 12,
84  B = 13,
85  C = 14,
86  D = 15,
87  Flash = 16,
88  CED = 32,
89  CNG = 36
90  };
91 
93  char tone,
94  unsigned duration = 0,
95  unsigned timestamp = 0
96  );
97 
98  char GetTone() const { return tone; }
99  unsigned GetDuration() const { return duration; }
100  unsigned GetTimestamp() const { return timestamp; }
101  bool IsToneStart() const { return duration == 0; }
102 
103  protected:
104  char tone;
105  unsigned duration;
106  unsigned timestamp;
107 };
108 
109 
111 
112 class OpalRFC2833Proto : public PObject {
113  PCLASSINFO(OpalRFC2833Proto, PObject);
114  public:
116  OpalRTPConnection & conn,
117  const PNotifier & receiveNotifier,
118  const OpalMediaFormat & mediaFormat
119  );
120  ~OpalRFC2833Proto();
121 
122  virtual bool SendToneAsync(
123  char tone,
124  unsigned duration
125  );
126 
127  virtual void OnStartReceive(
128  char tone,
129  unsigned timestamp
130  );
131  virtual void OnStartReceive(
132  char tone
133  );
134  virtual void OnEndReceive(
135  char tone,
136  unsigned duration,
137  unsigned timestamp
138  );
139 
140  const RTP_Session::FilterNotifier & GetReceiveHandler() const { return m_receiveHandler; }
141 
142  OpalMediaFormat GetTxMediaFormat() const;
143  OpalMediaFormat GetRxMediaFormat() const;
144  void SetTxMediaFormat(const OpalMediaFormat & mediaFormat);
145  void SetRxMediaFormat(const OpalMediaFormat & mediaFormat);
146 
147  static PINDEX ASCIIToRFC2833(char tone, bool hasNSE);
148  static char RFC2833ToASCII(PINDEX rfc2833, bool hasNSE);
149 
150  protected:
151  void SendAsyncFrame();
152 
154  PDECLARE_NOTIFIER(PTimer, OpalRFC2833Proto, ReceiveTimeout);
155  PDECLARE_NOTIFIER(PTimer, OpalRFC2833Proto, AsyncTimeout);
156 
163  PNotifier m_receiveNotifier;
165 
166  enum {
169  ReceiveEnding
170  } m_receiveState;
171 
174  unsigned m_tonesReceived;
177 
178  enum {
184  } m_transmitState;
185 
186  PMutex m_sendMutex;
191  PTimeInterval m_asyncStart;
194 };
195 
196 
197 #endif // OPAL_CODEC_RFC2833_H
198 
199 
PMutex m_sendMutex
Definition: rfc2833.h:186
unsigned m_tonesReceived
Definition: rfc2833.h:174
Definition: rtpconn.h:247
char tone
Definition: rfc2833.h:104
RTP_DataFrame::PayloadTypes m_rxPayloadType
Definition: rfc2833.h:160
unsigned duration
Definition: rfc2833.h:105
Definition: mediafmt.h:368
const PCaselessString & OpalRFC288EventsName()
Definition: rfc2833.h:168
PTimer m_asyncDurationTimer
Definition: rfc2833.h:188
RTP_Session::FilterNotifier m_receiveHandler
Definition: rfc2833.h:164
bool m_rewriteTransmitTimestamp
Definition: rfc2833.h:190
friend ostream & operator<<(ostream &strm, const OpalRFC2833EventsMask &mask)
Definition: rfc2833.h:51
PTimer m_receiveTimer
Definition: rfc2833.h:175
NTEEvent
Definition: rfc2833.h:70
friend istream & operator>>(istream &strm, OpalRFC2833EventsMask &mask)
#define PDECLARE_RTPFilterNotifier(cls, fn)
Definition: rtp.h:980
PayloadTypes
Definition: rtp.h:86
unsigned timestamp
Definition: rfc2833.h:106
Definition: rfc2833.h:65
Definition: rfc2833.h:179
PNotifierTemplate< SendReceiveStatus & > FilterNotifier
Definition: rtp.h:979
Definition: mediafmt.h:724
char GetTone() const
Definition: rfc2833.h:98
PMutex m_receiveMutex
Definition: rfc2833.h:172
DWORD m_transmitTimestamp
Definition: rfc2833.h:189
OpalRFC2833EventsMask(bool defaultValue=false)
unsigned m_transmitDuration
Definition: rfc2833.h:193
DWORD m_previousReceivedTimestamp
Definition: rfc2833.h:176
BYTE m_transmitCode
Definition: rfc2833.h:192
Definition: rfc2833.h:112
PNotifier m_receiveNotifier
Definition: rfc2833.h:163
Definition: rfc2833.h:48
OpalRFC2833EventsMask & operator &=(const OpalRFC2833EventsMask &other)
Definition: rfc2833.h:181
Definition: rfc2833.h:180
RTP_DataFrame::PayloadTypes m_txPayloadType
Definition: rfc2833.h:159
unsigned GetTimestamp() const
Definition: rfc2833.h:100
OpalRFC2833EventsMask m_txEvents
Definition: rfc2833.h:161
bool IsToneStart() const
Definition: rfc2833.h:101
PTimeInterval m_asyncStart
Definition: rfc2833.h:191
Definition: rfc2833.h:183
unsigned GetDuration() const
Definition: rfc2833.h:99
PTimer m_asyncTransmitTimer
Definition: rfc2833.h:187
BYTE m_receivedTone
Definition: rfc2833.h:173
OpalMediaFormat m_baseMediaFormat
Definition: rfc2833.h:158
const RTP_Session::FilterNotifier & GetReceiveHandler() const
Definition: rfc2833.h:140
Definition: rfc2833.h:167
Definition: rfc2833.h:182
OpalRFC2833EventsMask m_rxEvents
Definition: rfc2833.h:162
OpalRTPConnection & m_connection
Definition: rfc2833.h:157
OpalMediaOptionValue< OpalRFC2833EventsMask > OpalRFC288EventsOption
Definition: rfc2833.h:59