# 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: 25063 $
    00027  * $Author: csoutheren $
    00028  * $Date: 2011-01-13 22:54:22 -0600 (Thu, 13 Jan 2011) $
    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 <opal/mediatype.h>
    00041 #include <im/im.h>
    00042 #include <sip/sdp.h>
    00043 #include <sip/sippdu.h>
    00044
    00045 #if OPAL_HAS_SIPIM
    00046
    00047 class OpalSIPIMMediaType : public OpalIMMediaType
    00048 {
    00049   public:
    00050     OpalSIPIMMediaType();
    00051     virtual OpalMediaSession * CreateMediaSession(OpalConnection & conn, unsigned sessionID) const;
    00052
    00053     SDPMediaDescription * CreateSDPMediaDescription(const OpalTransportAddress & localAddress);
    00054 };
    00055
    00057
    00060 class OpalSIPIMMediaSession : public OpalMediaSession
    00061 {
    00062   PCLASSINFO(OpalSIPIMMediaSession, OpalMediaSession);
    00063   public:
    00064     OpalSIPIMMediaSession(OpalConnection & connection, unsigned sessionId);
    00065     OpalSIPIMMediaSession(const OpalSIPIMMediaSession & _obj);
    00066
    00067     virtual bool Open() { return true; }
    00068
    00069     virtual void Close() { }
    00070
    00071     virtual PObject * Clone() const { return new OpalSIPIMMediaSession(*this); }
    00072
    00073     virtual bool IsActive() const { return true; }
    00074
    00075     virtual bool IsRTP() const { return false; }
    00076
    00077     virtual bool HasFailed() const { return false; }
    00078
    00079     virtual OpalTransportAddress GetLocalMediaAddress() const;
    00080
    00081     virtual void SetRemoteMediaAddress(const OpalTransportAddress &, const OpalMediaFormatList & );
    00082
    00083     virtual SDPMediaDescription * CreateSDPMediaDescription(
    00084       const OpalTransportAddress & localAddress
    00085     );
    00086
    00087     virtual OpalMediaStream * CreateMediaStream(
    00088       const OpalMediaFormat & mediaFormat,
    00089       unsigned sessionID,
    00090       PBoolean isSource
    00091     );
    00092
    00093     virtual PString GetCallID() const { return callId; }
    00094
    00095   protected:
    00096     OpalTransportAddress transportAddress;
    00097     PString localURL;
    00098     PString remoteURL;
    00099     PString callId;
    00100 };
    00101
    00103
    00104 class OpalSIPIMContext : public OpalConnectionIMContext
    00105 {
    00106   public:
    00107     OpalSIPIMContext();
    00108
    00109     virtual SentStatus SendCompositionIndication(bool active = true);
    00110
    00111     static void PopulateParams(SIPMessage::Params & params, OpalIM & message);
    00112
    00113   protected:
    00114     virtual SentStatus InternalSendOutsideCall(OpalIM * message);
    00115     virtual SentStatus InternalSendInsideCall(OpalIM * message);
    00116
    00117     virtual SentStatus OnIncomingIM(OpalIM & message);
    00118     void OnCompositionIndicationTimeout();
    00119
    00120     void ResetTimers(OpalIM & message);
    00121
    00122     PDECLARE_NOTIFIER(PTimer, OpalSIPIMContext, OnRxCompositionTimerExpire);
    00123     PDECLARE_NOTIFIER(PTimer, OpalSIPIMContext, OnTxCompositionTimerExpire);
    00124     PDECLARE_NOTIFIER(PTimer, OpalSIPIMContext, OnTxIdleTimerExpire);
    00125
    00126     PTimer m_rxCompositionTimeout;
    00127     PTimer m_txCompositionTimeout;
    00128     PTimer m_txIdleTimeout;
    00129
    00130     RFC4103Context m_rfc4103Context;
    00131 };
    00132
    00133
    00135
    00136 #endif // OPAL_HAS_SIPIM
    00137
    00138 #endif // OPAL_IM_SIPIM_H