~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to daemon/src/sip/sipvoiplink.h

  • Committer: Package Import Robot
  • Author(s): Francois Marier, Francois Marier, Mark Purcell
  • Date: 2014-10-18 15:08:50 UTC
  • mfrom: (1.1.12)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20141018150850-2exfk34ckb15pcwi
Tags: 1.4.1-0.1
[ Francois Marier ]
* Non-maintainer upload
* New upstream release (closes: #759576, #741130)
  - debian/rules +PJPROJECT_VERSION := 2.2.1
  - add upstream patch to fix broken TLS support
  - add patch to fix pjproject regression

[ Mark Purcell ]
* Build-Depends:
  - sflphone-daemon + libavformat-dev, libavcodec-dev, libswscale-dev,
  libavdevice-dev, libavutil-dev
  - sflphone-gnome + libclutter-gtk-1.0-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
#include "config.h"
41
41
#endif
42
42
 
 
43
#include "voiplink.h"
 
44
#include "sipaccount.h"
 
45
#include "siptransport.h"
 
46
 
 
47
#include <pjsip.h>
 
48
#include <pjlib.h>
 
49
#include <pjsip_ua.h>
 
50
#include <pjlib-util.h>
 
51
#include <pjnath.h>
 
52
#include <pjnath/stun_config.h>
 
53
 
 
54
#ifdef SFL_VIDEO
 
55
#include <queue>
 
56
#endif
43
57
#include <map>
44
58
#include <mutex>
45
 
 
46
 
#include "pjsip.h"
47
 
#include "pjlib.h"
48
 
#include "pjsip_ua.h"
49
 
#include "pjlib-util.h"
50
 
#include "pjnath.h"
51
 
#include "pjnath/stun_config.h"
52
 
#ifdef SFL_VIDEO
53
 
#include <queue>
54
 
#endif
55
 
 
56
 
#include "sipaccount.h"
57
 
#include "voiplink.h"
58
 
#include "siptransport.h"
59
 
#include "eventthread.h"
 
59
#include <memory>
60
60
 
61
61
class SIPCall;
62
62
class SIPAccount;
63
63
 
64
 
typedef std::map<std::string, SIPCall*> SipCallMap;
 
64
typedef std::map<std::string, std::shared_ptr<SIPCall> > SipCallMap;
65
65
/**
66
66
 * @file sipvoiplink.h
67
67
 * @brief Specific VoIPLink for SIP (SIP core for incoming and outgoing events).
77
77
         * Singleton method. Enable to retrieve the unique static instance
78
78
         * @return SIPVoIPLink* A pointer on the object
79
79
         */
80
 
        static SIPVoIPLink* instance();
 
80
        static SIPVoIPLink& instance();
81
81
 
82
82
        /**
83
83
         * Destroy the singleton instance
98
98
        /**
99
99
         * Event listener. Each event send by the call manager is received and handled from here
100
100
         */
101
 
        virtual bool getEvent();
 
101
        virtual bool handleEvents();
102
102
 
103
103
        /* Returns a list of all callIDs */
104
104
        std::vector<std::string>
110
110
        AccountMap &
111
111
        getAccounts() { return sipAccountMap_; }
112
112
 
 
113
        virtual std::vector<std::shared_ptr<Call> > getCalls(const std::string &account_id) const;
 
114
 
113
115
        /**
114
116
         * Build and send SIP registration request
115
117
         */
116
 
        virtual void sendRegister(Account *a);
 
118
        virtual void sendRegister(Account& a);
117
119
 
118
120
        /**
119
121
         * Build and send SIP unregistration request
 
122
         * @param destroy_transport If true, attempt to destroy the transport.
120
123
         */
121
 
        virtual void sendUnregister(Account *a);
 
124
        virtual void sendUnregister(Account& a, std::function<void(bool)> cb = std::function<void(bool)>());
122
125
 
123
126
        /**
124
127
         * Register a new keepalive registration timer to this endpoint
136
139
         * @param toUrl  The Sip address of the recipient of the call
137
140
         * @return Call* The current call
138
141
         */
139
 
        virtual Call* newOutgoingCall(const std::string& id, const std::string& toUrl, const std::string &account_id);
 
142
        virtual std::shared_ptr<Call> newOutgoingCall(const std::string& id, const std::string& toUrl, const std::string &account_id);
140
143
 
141
144
        /**
142
145
         * Start a new SIP call using the IP2IP profile
143
146
         * @param The call id
144
147
         * @param The target sip uri
145
148
         */
146
 
        Call *SIPNewIpToIpCall(const std::string& id, const std::string& to);
 
149
        std::shared_ptr<Call> SIPNewIpToIpCall(const std::string& id, const std::string& to);
147
150
 
148
151
        /**
149
152
         * Place a call using the currently selected account
150
153
         * @param The call id
151
154
         * @param The target sip uri
152
155
         */
153
 
        Call *newRegisteredAccountCall(const std::string& id, const std::string& toUrl, const std::string &account_id);
 
156
        std::shared_ptr<Call> newRegisteredAccountCall(const std::string& id,
 
157
                                                       const std::string& toUrl,
 
158
                                                       const std::string &account_id);
154
159
 
155
160
        /**
156
161
         * Answer the call
241
246
        pj_caching_pool *getMemoryPoolFactory();
242
247
 
243
248
        /**
244
 
         * A non-blocking SIPCall accessor
245
 
         *
246
 
         * Will return NULL if the callMapMutex could not be locked
247
 
         *
248
 
         * @param id  The call identifier
249
 
         * @return SIPCall* A pointer to the SIPCall object
250
 
         */
251
 
        SIPCall* tryGetSIPCall(const std::string &id);
252
 
 
253
 
        /**
254
 
         * Return the codec protocol used for this call
255
 
         * @param c The call identifier
256
 
         */
257
 
        std::string getCurrentVideoCodecName(Call *c) const;
258
 
        std::string getCurrentAudioCodecNames(Call *c) const;
259
 
 
260
 
        /**
261
249
         * Retrive useragent name from account
262
250
         */
263
251
        std::string getUseragentName(SIPAccount *) const;
275
263
                             const std::string& from);
276
264
#endif
277
265
        void clearSipCallMap();
278
 
        void addSipCall(SIPCall* call);
279
 
 
280
 
        SIPCall* getSipCall(const std::string& id);
281
 
        SIPCall* tryGetSipCall(const std::string& id);
 
266
        void addSipCall(std::shared_ptr<SIPCall>& call);
 
267
 
 
268
        std::shared_ptr<SIPCall> getSipCall(const std::string& id);
 
269
 
 
270
        /**
 
271
         * A non-blocking SIPCall accessor
 
272
         *
 
273
         * Will return NULL if the callMapMutex could not be locked
 
274
         *
 
275
         * @param id  The call identifier
 
276
         * @return SIPCall* A pointer to the SIPCall object
 
277
         */
 
278
        std::shared_ptr<SIPCall> tryGetSIPCall(const std::string &id);
 
279
 
282
280
        void removeSipCall(const std::string &id);
283
281
 
284
282
        /**
287
285
        void createDefaultSipUdpTransport();
288
286
 
289
287
    public:
 
288
        void loadIP2IPSettings();
 
289
 
290
290
        /**
291
291
         * Instance that maintain and manage transport (UDP, TLS)
292
292
         */
314
314
         */
315
315
        AccountMap sipAccountMap_;
316
316
 
317
 
        std::mutex sipCallMapMutex_;
 
317
        mutable std::mutex sipCallMapMutex_;
318
318
        SipCallMap sipCallMap_;
319
319
 
320
320
        /**
322
322
         * @param call  The current call
323
323
         * @return true if all is correct
324
324
         */
325
 
        bool SIPStartCall(SIPCall* call);
326
 
 
327
 
        /**
328
 
         * Threading object
329
 
         */
330
 
        EventThread evThread_;
 
325
        bool SIPStartCall(std::shared_ptr<SIPCall>& call);
331
326
 
332
327
#ifdef SFL_VIDEO
333
328
        void dequeKeyframeRequests();
336
331
        std::queue<std::string> keyframeRequests_;
337
332
#endif
338
333
 
339
 
        static SIPVoIPLink *instance_;
 
334
        static SIPVoIPLink * instance_;
340
335
 
341
336
        friend class SIPTest;
342
337
};