rfc2833.h
Go to the documentation of this file.
/*
* rfc2833.h
*
* Open Phone Abstraction Library (OPAL)
* Formally known as the Open H323 project.
*
* Copyright (c) 2001 Equivalence Pty. Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Open Phone Abstraction Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Contributor(s): ______________________________________.
*
* $Revision: 27191 $
* $Author: rjongbloed $
* $Date: 2012-03-14 02:20:26 -0500 (Wed, 14 Mar 2012) $
*/
#ifndef OPAL_CODEC_RFC2833_H
#define OPAL_CODEC_RFC2833_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#include <opal/buildopts.h>
#include <opal/mediafmt.h>
#include <rtp/rtp.h>
class OpalRTPConnection;
class OpalRFC2833EventsMask : public std::vector<bool>
{
public:
enum { NumEvents = 256 };
OpalRFC2833EventsMask(bool defaultValue = false);
OpalRFC2833EventsMask(const char * defaultValues);
OpalRFC2833EventsMask & operator&=(const OpalRFC2833EventsMask & other);
friend ostream & operator<<(ostream & strm, const OpalRFC2833EventsMask & mask);
friend istream & operator>>(istream & strm, OpalRFC2833EventsMask & mask);
};
typedef OpalMediaOptionValue<OpalRFC2833EventsMask> OpalRFC288EventsOption;
const PCaselessString & OpalRFC288EventsName();
class OpalRFC2833Info : public PObject
{
PCLASSINFO(OpalRFC2833Info, PObject);
public:
// the following values are mandated by RFC 2833
enum NTEEvent {
Digit0 = 0,
Digit1 = 1,
Digit2 = 2,
Digit3 = 3,
Digit4 = 4,
Digit5 = 5,
Digit6 = 6,
Digit7 = 7,
Digit8 = 8,
Digit9 = 9,
Star = 10,
Hash = 11,
A = 12,
B = 13,
C = 14,
D = 15,
Flash = 16,
CED = 32,
CNG = 36
};
OpalRFC2833Info(
char tone,
unsigned duration = 0,
unsigned timestamp = 0
);
char GetTone() const { return tone; }
unsigned GetDuration() const { return duration; }
unsigned GetTimestamp() const { return timestamp; }
bool IsToneStart() const { return duration == 0; }
protected:
char tone;
unsigned duration;
unsigned timestamp;
};
class OpalRFC2833Proto : public PObject {
PCLASSINFO(OpalRFC2833Proto, PObject);
public:
OpalRFC2833Proto(
OpalRTPConnection & conn,
const PNotifier & receiveNotifier,
const OpalMediaFormat & mediaFormat
);
~OpalRFC2833Proto();
virtual bool SendToneAsync(
char tone,
unsigned duration
);
virtual void OnStartReceive(
char tone,
unsigned timestamp
);
virtual void OnStartReceive(
char tone
);
virtual void OnEndReceive(
char tone,
unsigned duration,
unsigned timestamp
);
const RTP_Session::FilterNotifier & GetReceiveHandler() const { return m_receiveHandler; }
OpalMediaFormat GetTxMediaFormat() const;
OpalMediaFormat GetRxMediaFormat() const;
void SetTxMediaFormat(const OpalMediaFormat & mediaFormat);
void SetRxMediaFormat(const OpalMediaFormat & mediaFormat);
static PINDEX ASCIIToRFC2833(char tone, bool hasNSE);
static char RFC2833ToASCII(PINDEX rfc2833, bool hasNSE);
protected:
void SendAsyncFrame();
PDECLARE_RTPFilterNotifier(OpalRFC2833Proto, ReceivedPacket);
PDECLARE_NOTIFIER(PTimer, OpalRFC2833Proto, ReceiveTimeout);
PDECLARE_NOTIFIER(PTimer, OpalRFC2833Proto, AsyncTimeout);
OpalRTPConnection & m_connection;
OpalMediaFormat m_baseMediaFormat;
RTP_DataFrame::PayloadTypes m_txPayloadType;
RTP_DataFrame::PayloadTypes m_rxPayloadType;
OpalRFC2833EventsMask m_txEvents;
OpalRFC2833EventsMask m_rxEvents;
PNotifier m_receiveNotifier;
RTP_Session::FilterNotifier m_receiveHandler;
enum {
ReceiveIdle,
ReceiveActive,
ReceiveEnding
} m_receiveState;
PMutex m_receiveMutex;
BYTE m_receivedTone;
unsigned m_tonesReceived;
PTimer m_receiveTimer;
DWORD m_previousReceivedTimestamp;
enum {
TransmitIdle,
TransmitActive,
TransmitEnding1,
TransmitEnding2,
TransmitEnding3,
} m_transmitState;
PMutex m_sendMutex;
PTimer m_asyncTransmitTimer;
PTimer m_asyncDurationTimer;
DWORD m_transmitTimestamp;
bool m_rewriteTransmitTimestamp;
PTimeInterval m_asyncStart;
BYTE m_transmitCode;
unsigned m_transmitDuration;
};
#endif // OPAL_CODEC_RFC2833_H
OpalRFC2833Proto::ASCIIToRFC2833
static PINDEX ASCIIToRFC2833(char tone, bool hasNSE)
OpalRFC2833Info::Digit9
Definition: rfc2833.h:80
OpalRFC2833Proto::m_sendMutex
PMutex m_sendMutex
Definition: rfc2833.h:186
OpalRFC2833Info::Digit0
Definition: rfc2833.h:71
OpalRFC2833Proto::m_transmitState
enum OpalRFC2833Proto::@7 m_transmitState
OpalRFC2833Proto::ReceiveEnding
Definition: rfc2833.h:169
OpalRFC2833Proto::m_tonesReceived
unsigned m_tonesReceived
Definition: rfc2833.h:174
OpalRTPConnection
Definition: rtpconn.h:247
OpalRFC2833Info::tone
char tone
Definition: rfc2833.h:104
OpalRFC2833Info::Digit7
Definition: rfc2833.h:78
OpalRFC2833Proto::GetReceiveHandler
const RTP_Session::FilterNotifier & GetReceiveHandler() const
Definition: rfc2833.h:140
OpalRFC2833Proto::m_rxPayloadType
RTP_DataFrame::PayloadTypes m_rxPayloadType
Definition: rfc2833.h:160
OpalRFC2833Info::D
Definition: rfc2833.h:86
buildopts.h
OpalRFC2833EventsMask::operator&=
OpalRFC2833EventsMask & operator&=(const OpalRFC2833EventsMask &other)
OpalRFC2833Info::duration
unsigned duration
Definition: rfc2833.h:105
OpalMediaOptionValue
Definition: mediafmt.h:368
OpalRFC2833Info::A
Definition: rfc2833.h:83
OpalRFC2833Info::Digit4
Definition: rfc2833.h:75
OpalRFC288EventsName
const PCaselessString & OpalRFC288EventsName()
OpalRFC2833Proto::ReceiveActive
Definition: rfc2833.h:168
OpalRFC2833Proto::m_asyncDurationTimer
PTimer m_asyncDurationTimer
Definition: rfc2833.h:188
OpalRFC2833Proto::m_receiveHandler
RTP_Session::FilterNotifier m_receiveHandler
Definition: rfc2833.h:164
OpalRFC2833Info::Hash
Definition: rfc2833.h:82
OpalRFC2833Info::Digit5
Definition: rfc2833.h:76
OpalRFC2833Proto::m_rewriteTransmitTimestamp
bool m_rewriteTransmitTimestamp
Definition: rfc2833.h:190
OpalRFC2833EventsMask::operator<<
friend ostream & operator<<(ostream &strm, const OpalRFC2833EventsMask &mask)
OpalRFC2833EventsMask::NumEvents
Definition: rfc2833.h:51
OpalRFC2833Proto::m_receiveTimer
PTimer m_receiveTimer
Definition: rfc2833.h:175
OpalRFC2833Proto::OnStartReceive
virtual void OnStartReceive(char tone, unsigned timestamp)
OpalRFC2833Info::NTEEvent
NTEEvent
Definition: rfc2833.h:70
OpalRFC2833Info::GetTone
char GetTone() const
Definition: rfc2833.h:98
OpalRFC2833EventsMask::operator>>
friend istream & operator>>(istream &strm, OpalRFC2833EventsMask &mask)
OpalRFC2833Proto::SetRxMediaFormat
void SetRxMediaFormat(const OpalMediaFormat &mediaFormat)
OpalRFC2833Info::CED
Definition: rfc2833.h:88
RTP_DataFrame::PayloadTypes
PayloadTypes
Definition: rtp.h:86
OpalRFC2833Info::timestamp
unsigned timestamp
Definition: rfc2833.h:106
OpalRFC2833Info
Definition: rfc2833.h:65
OpalRFC2833Proto::~OpalRFC2833Proto
~OpalRFC2833Proto()
OpalRFC2833Proto::GetTxMediaFormat
OpalMediaFormat GetTxMediaFormat() const
OpalRFC2833Info::Digit3
Definition: rfc2833.h:74
OpalRFC2833Info::Flash
Definition: rfc2833.h:87
OpalRFC2833Proto::TransmitIdle
Definition: rfc2833.h:179
OpalRFC2833Proto::SetTxMediaFormat
void SetTxMediaFormat(const OpalMediaFormat &mediaFormat)
OpalRFC2833Info::Digit1
Definition: rfc2833.h:72
RTP_Session::FilterNotifier
PNotifierTemplate< SendReceiveStatus & > FilterNotifier
Definition: rtp.h:979
OpalRFC2833Info::Digit8
Definition: rfc2833.h:79
OpalMediaFormat
Definition: mediafmt.h:724
OpalRFC2833Proto::m_receiveMutex
PMutex m_receiveMutex
Definition: rfc2833.h:172
OpalRFC2833Proto::m_transmitTimestamp
DWORD m_transmitTimestamp
Definition: rfc2833.h:189
OpalRFC2833Proto::PDECLARE_NOTIFIER
PDECLARE_NOTIFIER(PTimer, OpalRFC2833Proto, ReceiveTimeout)
OpalRFC2833Info::Digit6
Definition: rfc2833.h:77
OpalRFC2833EventsMask::OpalRFC2833EventsMask
OpalRFC2833EventsMask(bool defaultValue=false)
OpalRFC2833Proto::m_transmitDuration
unsigned m_transmitDuration
Definition: rfc2833.h:193
OpalRFC2833Proto::m_previousReceivedTimestamp
DWORD m_previousReceivedTimestamp
Definition: rfc2833.h:176
OpalRFC2833Proto::m_transmitCode
BYTE m_transmitCode
Definition: rfc2833.h:192
OpalRFC2833Proto
Definition: rfc2833.h:112
OpalRFC2833Proto::GetRxMediaFormat
OpalMediaFormat GetRxMediaFormat() const
OpalRFC2833Proto::PDECLARE_RTPFilterNotifier
PDECLARE_RTPFilterNotifier(OpalRFC2833Proto, ReceivedPacket)
OpalRFC2833Proto::m_receiveNotifier
PNotifier m_receiveNotifier
Definition: rfc2833.h:163
OpalRFC2833Proto::RFC2833ToASCII
static char RFC2833ToASCII(PINDEX rfc2833, bool hasNSE)
OpalRFC2833EventsMask
Definition: rfc2833.h:48
mediafmt.h
OpalRFC2833Proto::TransmitEnding1
Definition: rfc2833.h:181
OpalRFC2833Proto::TransmitActive
Definition: rfc2833.h:180
OpalRFC2833Info::B
Definition: rfc2833.h:84
OpalRFC2833Info::CNG
Definition: rfc2833.h:89
OpalRFC2833Proto::m_txPayloadType
RTP_DataFrame::PayloadTypes m_txPayloadType
Definition: rfc2833.h:159
OpalRFC2833Proto::m_txEvents
OpalRFC2833EventsMask m_txEvents
Definition: rfc2833.h:161
OpalRFC2833Proto::m_asyncStart
PTimeInterval m_asyncStart
Definition: rfc2833.h:191
OpalRFC2833Proto::TransmitEnding3
Definition: rfc2833.h:183
OpalRFC2833Info::OpalRFC2833Info
OpalRFC2833Info(char tone, unsigned duration=0, unsigned timestamp=0)
OpalRFC2833Info::Star
Definition: rfc2833.h:81
OpalRFC2833Info::GetTimestamp
unsigned GetTimestamp() const
Definition: rfc2833.h:100
OpalRFC2833Info::IsToneStart
bool IsToneStart() const
Definition: rfc2833.h:101
OpalRFC2833Info::C
Definition: rfc2833.h:85
OpalRFC2833Proto::OpalRFC2833Proto
OpalRFC2833Proto(OpalRTPConnection &conn, const PNotifier &receiveNotifier, const OpalMediaFormat &mediaFormat)
OpalRFC2833Info::GetDuration
unsigned GetDuration() const
Definition: rfc2833.h:99
OpalRFC2833Proto::m_asyncTransmitTimer
PTimer m_asyncTransmitTimer
Definition: rfc2833.h:187
rtp.h
OpalRFC2833Proto::m_receivedTone
BYTE m_receivedTone
Definition: rfc2833.h:173
OpalRFC2833Proto::m_baseMediaFormat
OpalMediaFormat m_baseMediaFormat
Definition: rfc2833.h:158
OpalRFC2833Proto::SendToneAsync
virtual bool SendToneAsync(char tone, unsigned duration)
OpalRFC2833Info::Digit2
Definition: rfc2833.h:73
OpalRFC2833Proto::ReceiveIdle
Definition: rfc2833.h:167
OpalRFC2833Proto::TransmitEnding2
Definition: rfc2833.h:182
OpalRFC2833Proto::OnEndReceive
virtual void OnEndReceive(char tone, unsigned duration, unsigned timestamp)
OpalRFC2833Proto::SendAsyncFrame
void SendAsyncFrame()
OpalRFC2833Proto::m_rxEvents
OpalRFC2833EventsMask m_rxEvents
Definition: rfc2833.h:162
OpalRFC2833Proto::m_connection
OpalRTPConnection & m_connection
Definition: rfc2833.h:157
OpalRFC288EventsOption
OpalMediaOptionValue< OpalRFC2833EventsMask > OpalRFC288EventsOption
Definition: rfc2833.h:59
OpalRFC2833Proto::m_receiveState
enum OpalRFC2833Proto::@6 m_receiveState