00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
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
00042 #if OPAL_SIP
00043 #include <sip/sdp.h>
00044 #endif
00045
00046 #if OPAL_HAS_SIPIM
00047
00048 class OpalSIPIMMediaType : public OpalIMMediaType
00049 {
00050 public:
00051 OpalSIPIMMediaType();
00052 virtual OpalMediaSession * CreateMediaSession(OpalConnection & conn, unsigned sessionID) const;
00053
00054 #if OPAL_SIP
00055 SDPMediaDescription * CreateSDPMediaDescription(const OpalTransportAddress & localAddress);
00056 #endif
00057 };
00058
00060
00063 class OpalSIPIMMediaSession : public OpalMediaSession
00064 {
00065 PCLASSINFO(OpalSIPIMMediaSession, OpalMediaSession);
00066 public:
00067 OpalSIPIMMediaSession(OpalConnection & connection, unsigned sessionId);
00068 OpalSIPIMMediaSession(const OpalSIPIMMediaSession & _obj);
00069
00070 virtual bool Open() { return true; }
00071
00072 virtual void Close() { }
00073
00074 virtual PObject * Clone() const { return new OpalSIPIMMediaSession(*this); }
00075
00076 virtual bool IsActive() const { return true; }
00077
00078 virtual bool IsRTP() const { return false; }
00079
00080 virtual bool HasFailed() const { return false; }
00081
00082 virtual OpalTransportAddress GetLocalMediaAddress() const;
00083
00084 virtual void SetRemoteMediaAddress(const OpalTransportAddress &, const OpalMediaFormatList & );
00085
00086 #if OPAL_SIP
00087 virtual SDPMediaDescription * CreateSDPMediaDescription(
00088 const OpalTransportAddress & localAddress
00089 );
00090 #endif
00091
00092 virtual OpalMediaStream * CreateMediaStream(
00093 const OpalMediaFormat & mediaFormat,
00094 unsigned sessionID,
00095 PBoolean isSource
00096 );
00097
00098 virtual bool SendMessage(const PString & contentType, const PString & body);
00099
00100 virtual bool SendIM(const PString & contentType, const PString & body);
00101
00102 virtual PString GetCallID() const { return callId; }
00103
00104 protected:
00105 OpalTransportAddress transportAddress;
00106 PString localURL;
00107 PString remoteURL;
00108 PString callId;
00109 };
00110
00112
00113 class OpalSIPIMMediaStream : public OpalIMMediaStream
00114 {
00115 public:
00116 OpalSIPIMMediaStream(
00117 OpalConnection & conn,
00118 const OpalMediaFormat & mediaFormat,
00119 unsigned sessionID,
00120 bool isSource,
00121 OpalSIPIMMediaSession & imSession
00122 );
00123
00124 ~OpalSIPIMMediaStream();
00125
00126 virtual bool Open();
00127
00131 virtual PBoolean ReadData(
00132 BYTE * data,
00133 PINDEX size,
00134 PINDEX & length
00135 );
00136
00140 virtual PBoolean WriteData(
00141 const BYTE * data,
00142 PINDEX length,
00143 PINDEX & written
00144 );
00145
00150 virtual PBoolean Close();
00152
00153 protected:
00154 OpalSIPIMMediaSession & m_imSession;
00155 };
00156
00158
00159 class SIPEndPoint;
00160 class SIP_PDU;
00161 class SIPConnection;
00162
00163 class OpalSIPIMManager : public PObject
00164 {
00165 public:
00166 OpalSIPIMManager(SIPEndPoint & endpoint);
00167 void OnReceivedMessage(const SIP_PDU & pdu);
00168
00169 bool StartSession(OpalSIPIMMediaSession * mediaSession);
00170
00171 bool EndSession(OpalSIPIMMediaSession * mediaSession);
00172
00173 protected:
00174 SIPEndPoint & m_endpoint;
00175 PMutex m_mutex;
00176
00177 typedef std::map<std::string, OpalSIPIMMediaSession *> IMSessionMapType;
00178 IMSessionMapType m_imSessionMap;
00179 };
00180
00181
00182
00184
00185 #endif // OPAL_HAS_SIPIM
00186
00187 #endif // OPAL_IM_SIPIM_H