sipim.h

Go to the documentation of this file.
00001 /*
00002  * sipim.h
00003  *
00004  * Support for SIP session mode IM
00005  *
00006  * Open Phone Abstraction Library (OPAL)
00007  *
00008  * Copyright (c) 2008 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: 22675 $
00027  * $Author: rjongbloed $
00028  * $Date: 2009-05-20 04:23:29 +0000 (Wed, 20 May 2009) $
00029  */
00030 
00031 #ifndef OPAL_IM_SIPIM_H
00032 #define OPAL_IM_SIPIM_H
00033 
00034 #include <ptlib.h>
00035 #include <opal/buildopts.h>
00036 #include <opal/rtpconn.h>
00037 #include <opal/manager.h>
00038 #include <opal/mediastrm.h>
00039 #include <opal/mediatype.h>
00040 #include <im/im.h>
00041 #include <sip/sdp.h>
00042 
00043 
00044 #if OPAL_HAS_SIPIM
00045 
00046 class OpalSIPIMMediaType : public OpalIMMediaType 
00047 {
00048   public:
00049     OpalSIPIMMediaType();
00050     virtual OpalMediaSession * CreateMediaSession(OpalConnection & conn, unsigned sessionID) const;
00051 
00052     SDPMediaDescription * CreateSDPMediaDescription(const OpalTransportAddress & localAddress);
00053 };
00054 
00056 
00059 class OpalSIPIMMediaSession : public OpalMediaSession
00060 {
00061   PCLASSINFO(OpalSIPIMMediaSession, OpalMediaSession);
00062   public:
00063     OpalSIPIMMediaSession(OpalConnection & connection, unsigned sessionId);
00064     OpalSIPIMMediaSession(const OpalSIPIMMediaSession & _obj);
00065 
00066     virtual bool Open() { return true; }
00067 
00068     virtual void Close() { }
00069 
00070     virtual PObject * Clone() const { return new OpalSIPIMMediaSession(*this); }
00071 
00072     virtual bool IsActive() const { return true; }
00073 
00074     virtual bool IsRTP() const { return false; }
00075 
00076     virtual bool HasFailed() const { return false; }
00077 
00078     virtual OpalTransportAddress GetLocalMediaAddress() const;
00079 
00080     virtual void SetRemoteMediaAddress(const OpalTransportAddress &, const OpalMediaFormatList & );
00081 
00082     virtual SDPMediaDescription * CreateSDPMediaDescription(
00083       const OpalTransportAddress & localAddress
00084     );
00085 
00086     virtual OpalMediaStream * CreateMediaStream(
00087       const OpalMediaFormat & mediaFormat, 
00088       unsigned sessionID, 
00089       PBoolean isSource
00090     );
00091 
00092     virtual bool SendMessage(const PString & contentType, const PString & body);
00093 
00094     virtual bool SendIM(const PString & contentType, const PString & body);
00095 
00096     virtual PString GetCallID() const { return callId; }
00097 
00098   protected:
00099     OpalTransportAddress transportAddress;
00100     PString localURL;
00101     PString remoteURL;
00102     PString callId;
00103 };
00104 
00106 
00107 class OpalSIPIMMediaStream : public OpalIMMediaStream
00108 {
00109   public:
00110     OpalSIPIMMediaStream(
00111       OpalConnection & conn,
00112       const OpalMediaFormat & mediaFormat, 
00113       unsigned sessionID,                  
00114       bool isSource,                       
00115       OpalSIPIMMediaSession & imSession
00116     );
00117 
00118     ~OpalSIPIMMediaStream();
00119 
00120     virtual bool Open();
00121 
00125     virtual PBoolean ReadData(
00126       BYTE * data,      
00127       PINDEX size,      
00128       PINDEX & length   
00129     );
00130 
00134     virtual PBoolean WriteData(
00135       const BYTE * data,   
00136       PINDEX length,       
00137       PINDEX & written     
00138     );
00139 
00144     virtual PBoolean Close();
00146 
00147   protected:
00148     OpalSIPIMMediaSession & m_imSession;
00149 };
00150 
00152 
00153 class SIPEndPoint;
00154 class SIP_PDU;
00155 class SIPConnection;
00156 
00157 class OpalSIPIMManager : public PObject
00158 {
00159   public:
00160     OpalSIPIMManager(SIPEndPoint & endpoint);
00161     void OnReceivedMessage(const SIP_PDU & pdu);
00162 
00163     bool StartSession(OpalSIPIMMediaSession * mediaSession);
00164 
00165     bool EndSession(OpalSIPIMMediaSession * mediaSession);
00166 
00167   protected:
00168     SIPEndPoint & m_endpoint;
00169     PMutex m_mutex;
00170 
00171     typedef std::map<std::string, OpalSIPIMMediaSession *> IMSessionMapType;
00172     IMSessionMapType m_imSessionMap;
00173 };
00174 
00175 
00176 
00178 
00179 #endif // OPAL_HAS_SIPIM
00180 
00181 #endif // OPAL_IM_SIPIM_H

Generated on Mon Feb 1 00:25:54 2010 for OPAL by  doxygen 1.5.1