rfc2833.h

Go to the documentation of this file.
00001 /*
00002  * rfc2833.h
00003  *
00004  * Open Phone Abstraction Library (OPAL)
00005  * Formally known as the Open H323 project.
00006  *
00007  * Copyright (c) 2001 Equivalence Pty. Ltd.
00008  *
00009  * The contents of this file are subject to the Mozilla Public License
00010  * Version 1.0 (the "License"); you may not use this file except in
00011  * compliance with the License. You may obtain a copy of the License at
00012  * http://www.mozilla.org/MPL/
00013  *
00014  * Software distributed under the License is distributed on an "AS IS"
00015  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00016  * the License for the specific language governing rights and limitations
00017  * under the License.
00018  *
00019  * The Original Code is Open Phone Abstraction Library.
00020  *
00021  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00022  *
00023  * Contributor(s): ______________________________________.
00024  *
00025  * $Revision: 20188 $
00026  * $Author: rjongbloed $
00027  * $Date: 2008-05-06 12:48:17 +0000 (Tue, 06 May 2008) $
00028  */
00029 
00030 #ifndef __OPAL_RFC2833_H
00031 #define __OPAL_RFC2833_H
00032 
00033 #ifdef P_USE_PRAGMA
00034 #pragma interface
00035 #endif
00036 
00037 
00038 #include <rtp/rtp.h>
00039 
00040 extern const char * OpalDefaultNTEString;
00041 
00042 #if OPAL_T38_CAPABILITY
00043 extern const char * OpalDefaultNSEString;
00044 #endif
00045 
00047 
00048 class OpalRFC2833Info : public PObject {
00049     PCLASSINFO(OpalRFC2833Info, PObject);
00050   public:
00051     OpalRFC2833Info(
00052       char tone,
00053       unsigned duration = 0,
00054       unsigned timestamp = 0
00055     );
00056 
00057     char GetTone() const { return tone; }
00058     unsigned GetDuration() const { return duration; }
00059     unsigned GetTimestamp() const { return timestamp; }
00060     PBoolean IsToneStart() const { return duration == 0; }
00061 
00062   protected:
00063     char     tone;
00064     unsigned duration;
00065     unsigned timestamp;
00066 };
00067 
00068 class OpalRTPConnection;
00069 
00070 class OpalRFC2833Proto : public PObject {
00071     PCLASSINFO(OpalRFC2833Proto, PObject);
00072   public:
00073     OpalRFC2833Proto(
00074       OpalRTPConnection & conn,
00075       const PNotifier & receiveNotifier
00076     );
00077     ~OpalRFC2833Proto();
00078 
00079     virtual PBoolean SendToneAsync(
00080       char tone, 
00081       unsigned duration
00082     );
00083 
00084     virtual PBoolean BeginTransmit(
00085       char tone  
00086     );
00087 
00088     virtual void OnStartReceive(
00089       char tone,
00090       unsigned timestamp
00091     );
00092     virtual void OnStartReceive(
00093       char tone
00094     );
00095     virtual void OnEndReceive(
00096       char tone,
00097       unsigned duration,
00098       unsigned timestamp
00099     );
00100 
00101     RTP_DataFrame::PayloadTypes GetPayloadType() const { return payloadType; }
00102 
00103     void SetPayloadType(
00104       RTP_DataFrame::PayloadTypes type 
00105     ) { payloadType = type; }
00106 
00107     const PNotifier & GetReceiveHandler() const { return receiveHandler; }
00108 
00109     static PINDEX ASCIIToRFC2833(char tone);
00110     static char RFC2833ToASCII(PINDEX rfc2833);
00111 
00112   protected:
00113     void SendAsyncFrame();
00114 
00115     OpalRTPConnection & conn;
00116 
00117     PDECLARE_NOTIFIER(RTP_DataFrame, OpalRFC2833Proto, ReceivedPacket);
00118     PDECLARE_NOTIFIER(PTimer, OpalRFC2833Proto, ReceiveTimeout);
00119     PDECLARE_NOTIFIER(PTimer, OpalRFC2833Proto, AsyncTimeout);
00120 
00121     RTP_DataFrame::PayloadTypes payloadType;
00122 
00123     PMutex mutex;
00124 
00125     enum {
00126       ReceiveIdle,
00127       ReceiveActive,
00128       ReceiveEnding
00129     } receiveState;
00130 
00131     BYTE      receivedTone;
00132 
00133     //PBoolean  receiveComplete;
00134     //unsigned  receivedDuration;
00135     //unsigned  receiveTimestamp;
00136 
00137     PNotifier receiveNotifier;
00138     PTimer    receiveTimer;
00139     PNotifier receiveHandler;
00140 
00141     enum {
00142       TransmitIdle,
00143       TransmitActive,
00144       TransmitEnding1,
00145       TransmitEnding2,
00146       TransmitEnding3,
00147     } transmitState;
00148     BYTE      transmitCode;
00149 
00150     RTP_Session * rtpSession;
00151     PTimer        asyncTransmitTimer;
00152     PTimer        asyncDurationTimer;
00153     DWORD         transmitTimestamp;
00154     PBoolean      rewriteTransmitTimestamp;
00155     PTimeInterval asyncStart;
00156     unsigned      transmitDuration;
00157     unsigned      tonesReceived;
00158     DWORD         previousReceivedTimestamp;
00159 };
00160 
00161 
00162 #endif // __OPAL_RFC2833_H
00163 
00164 

Generated on Mon Sep 15 11:49:15 2008 for OPAL by  doxygen 1.5.1