rtpconn.h

Go to the documentation of this file.
00001 /*
00002  * rtpconn.h
00003  *
00004  * Connection abstraction
00005  *
00006  * Open Phone Abstraction Library (OPAL)
00007  *
00008  * Copyright (C) 2007 Post Increment
00009  *
00010  * The contents of this file are subject to the Mozilla Public License
00011  * Version 1.0 (the "License"); you may not use this file except in
00012  * compliance with the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS"
00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00017  * the License for the specific language governing rights and limitations
00018  * under the License.
00019  *
00020  * The Original Code is Open Phone Abstraction Library.
00021  *
00022  * The Initial Developer of the Original Code is Post Increment
00023  *
00024  * Contributor(s): ______________________________________.
00025  *
00026  * $Revision: 20393 $
00027  * $Author: rjongbloed $
00028  * $Date: 2008-06-05 01:55:57 +0000 (Thu, 05 Jun 2008) $
00029  */
00030 
00031 #ifndef __OPAL_RTPCONN_H
00032 #define __OPAL_RTPCONN_H
00033 
00034 #include <opal/buildopts.h>
00035 
00036 #ifdef P_USE_PRAGMA
00037 #pragma interface
00038 #endif
00039 
00040 
00041 #include <opal/connection.h>
00042 #include <opal/mediatype.h>
00043 
00044 
00045 class OpalRTPEndPoint;
00046 
00047 //#ifdef HAS_LIBZRTP
00048 //#ifndef __ZRTP_TYPES_H__
00049 //struct zrtp_conn_ctx_t;
00050 //#endif
00051 //#endif
00052 
00055 class OpalMediaSession : public PObject
00056 {
00057   PCLASSINFO(OpalMediaSession, PObject);
00058   public:
00059     OpalMediaSession(const OpalMediaType & _mediaType);
00060     OpalMediaSession(const OpalMediaSession & _obj);
00061 
00062     PObject * Clone() const { return new OpalMediaSession(*this); }
00063 
00064     OpalMediaType mediaType;     // media type for session
00065     bool autoStartReceive;       // if true, this session should receive data when the call is started
00066     bool autoStartTransmit;      // if true, this session  should transmit data when the call is started
00067     unsigned sessionId;          // unique session ID
00068 
00069     RTP_Session * rtpSession;    // RTP session
00070 };
00071 
00074 class OpalRTPSessionManager : public PObject
00075 {
00076   PCLASSINFO(OpalRTPSessionManager , PObject);
00077 
00078   public:
00083     OpalRTPSessionManager();
00084     ~OpalRTPSessionManager();
00086 
00087     void CopyFromMaster(const OpalRTPSessionManager & sm);
00088     void CopyToMaster(OpalRTPSessionManager & sm);
00089 
00093     void Initialise(
00094       OpalRTPConnection & conn, 
00095       OpalConnection::StringOptions * stringOptions
00096     );
00097 
00101     unsigned AutoStartSession(
00102       unsigned sessionID,        
00103       const OpalMediaType & mediaType,
00104       bool autoStartReceive, 
00105       bool autoStartTransmit
00106     );
00107 
00116     void AddSession(
00117       RTP_Session * session,          
00118       const OpalMediaType & mediaType 
00119     );
00120 
00123     void ReleaseSession(
00124       unsigned sessionID,    
00125       PBoolean clearAll = PFalse  
00126     );
00127 
00130     RTP_Session * GetSession(
00131       unsigned sessionID    
00132     ) const;
00133 
00134     void SetCleanup(bool v) { m_cleanupOnDelete = v; }
00135 
00137     PMutex & GetMutex() { return m_mutex; }
00138 
00139   protected:
00140     void SetOldOptions(unsigned channelId, const OpalMediaType & mediaType, bool rx, bool tx);
00141 
00142     PMutex m_mutex;
00143     bool m_initialised;
00144     bool m_cleanupOnDelete;
00145     PDICTIONARY(SessionDict, POrdinalKey, OpalMediaSession);
00146     SessionDict sessions;
00147 
00148   private:
00149     OpalRTPSessionManager (const OpalRTPSessionManager & other): PObject (other) { }
00150     OpalRTPSessionManager & operator=(const OpalRTPSessionManager &) { return *this; }
00151 
00152 };
00153 
00154 typedef OpalRTPSessionManager RTP_SessionManager;
00155 
00159 class OpalRTPConnection : public OpalConnection
00160 {
00161   PCLASSINFO(OpalRTPConnection, OpalConnection);
00162   public:
00167     OpalRTPConnection(
00168       OpalCall & call,                         
00169       OpalRTPEndPoint & endpoint,              
00170       const PString & token,                   
00171       unsigned options = 0,                    
00172       OpalConnection::StringOptions * stringOptions = NULL     
00173     );  
00174 
00177     ~OpalRTPConnection();
00178 
00179 
00185     virtual RTP_Session * GetSession(
00186       unsigned sessionID    
00187     ) const;
00188 
00197     virtual RTP_Session * UseSession(
00198       const OpalTransport & transport,  
00199       unsigned sessionID,               
00200       const OpalMediaType & mediatype,  
00201       RTP_QOS * rtpqos = NULL           
00202     );
00203 
00206     virtual void ReleaseSession(
00207       unsigned sessionID,    
00208       PBoolean clearAll = PFalse  
00209     );
00210 
00215     virtual RTP_Session * CreateSession(
00216       const OpalTransport & transport,
00217       unsigned sessionID,
00218       RTP_QOS * rtpqos
00219     );
00220 
00222 
00224 
00226     virtual PBoolean RemoteIsNAT() const
00227     { return remoteIsNAT; }
00228 
00246     virtual PBoolean IsRTPNATEnabled(
00247       const PIPSocket::Address & localAddr,   
00248       const PIPSocket::Address & peerAddr,    
00249       const PIPSocket::Address & signalAddr,  
00250       PBoolean incoming                       
00251     );
00253 
00258     virtual void AttachRFC2833HandlerToPatch(PBoolean isSource, OpalMediaPatch & patch);
00259 
00260     virtual PBoolean SendUserInputTone(
00261       char tone,        
00262       unsigned duration = 0  
00263     );
00264 
00267     struct MediaInformation {
00268       MediaInformation() { 
00269         rfc2833  = RTP_DataFrame::IllegalPayloadType; 
00270         ciscoNSE = RTP_DataFrame::IllegalPayloadType; 
00271       }
00272 
00273       OpalTransportAddress data;           
00274       OpalTransportAddress control;        
00275       RTP_DataFrame::PayloadTypes rfc2833; 
00276       RTP_DataFrame::PayloadTypes ciscoNSE; 
00277     };
00278 
00287     virtual PBoolean GetMediaInformation(
00288       unsigned sessionID,     
00289       MediaInformation & info 
00290     ) const;
00291 
00296     virtual PBoolean IsMediaBypassPossible(
00297       unsigned sessionID                  
00298     ) const;
00299 
00312     virtual OpalMediaStream * CreateMediaStream(
00313       const OpalMediaFormat & mediaFormat, 
00314       unsigned sessionID,                  
00315       PBoolean isSource                        
00316     );
00317 
00320     virtual void OnPatchMediaStream(PBoolean isSource, OpalMediaPatch & patch);
00321 
00322     virtual void SetSecurityMode(const PString & v)
00323     { securityMode = v; }
00324 
00325     virtual PString GetSecurityMode() const 
00326     { return securityMode; }
00327 
00328     virtual void * GetSecurityData();         
00329     virtual void SetSecurityData(void *data); 
00330 
00331     void OnMediaCommand(OpalMediaCommand & command, INT extra);
00332 
00333     PDECLARE_NOTIFIER(OpalRFC2833Info, OpalRTPConnection, OnUserInputInlineRFC2833);
00334     PDECLARE_NOTIFIER(OpalRFC2833Info, OpalRTPConnection, OnUserInputInlineCiscoNSE);
00335 
00336   protected:
00337     PString securityMode;
00338     void * securityData;
00339     OpalRTPSessionManager m_rtpSessions;
00340     OpalRFC2833Proto * rfc2833Handler;
00341     OpalRFC2833Proto * ciscoNSEHandler;
00342 
00343     PBoolean remoteIsNAT;
00344     PBoolean useRTPAggregation;
00345 };
00346 
00347 
00348 class RTP_UDP;
00349 
00350 class OpalSecurityMode : public PObject
00351 {
00352   PCLASSINFO(OpalSecurityMode, PObject);
00353   public:
00354     virtual RTP_UDP * CreateRTPSession(
00355       OpalRTPConnection & connection,    
00356       const PString & encoding,          
00357 #if OPAL_RTP_AGGREGATE
00358       PHandleAggregator * _aggregator,   
00359 #endif
00360       unsigned id,                       
00361       PBoolean remoteIsNAT               
00362     ) = 0;
00363     virtual PBoolean Open() = 0;
00364 };
00365 
00366 #endif 
00367 

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