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

« back to all changes in this revision

Viewing changes to daemon/src/call.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2015-01-07 14:51:16 UTC
  • mfrom: (4.3.5 sid)
  • Revision ID: package-import@ubuntu.com-20150107145116-yxnafinf4lrdvrmx
Tags: 1.4.1-0.1ubuntu1
* Merge with Debian, remaining changes:
 - Drop soprano, nepomuk build-dep
* Drop ubuntu patches, now upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#ifndef __CALL_H__
33
33
#define __CALL_H__
34
34
 
 
35
#include "logger.h"
 
36
 
 
37
#include "audio/recordable.h"
 
38
#include "ip_utils.h"
 
39
 
 
40
#include <mutex>
 
41
#include <map>
35
42
#include <sstream>
36
 
#include <map>
37
 
#include <mutex>
38
 
#include "audio/recordable.h"
39
43
 
40
44
/*
41
45
 * @file call.h
55
59
        /**
56
60
         * Tell where we're at with the call. The call gets Connected when we know
57
61
         * from the other end what happened with out call. A call can be 'Connected'
58
 
         * even if the call state is Busy, Refused, or Error.
 
62
         * even if the call state is Busy, or Error.
59
63
         *
60
64
         * Audio should be transmitted when ConnectionState = Connected AND
61
65
         * CallState = Active.
65
69
        /**
66
70
         * The Call State.
67
71
         */
68
 
        enum CallState {INACTIVE, ACTIVE, HOLD, BUSY, CONFERENCING, REFUSED, ERROR};
 
72
        enum CallState {INACTIVE, ACTIVE, HOLD, BUSY, ERROR};
69
73
 
70
74
        /**
71
75
         * Constructor of a call
162
166
        /**
163
167
         * Set the state of the call (protected by mutex)
164
168
         * @param state The call state
 
169
         * @return true if the requested state change was valid, false otherwise
165
170
         */
166
 
        void setState(CallState state);
 
171
        bool setState(CallState state);
167
172
 
168
173
        /**
169
174
         * Get the call state of the call (protected by mutex)
183
188
         * Set my IP [not protected]
184
189
         * @param ip  The local IP address
185
190
         */
186
 
        void setLocalIp(const std::string& ip) {
187
 
            localIPAddress_ = ip;
 
191
        void setLocalIp(const IpAddr& ip) {
 
192
            localAddr_ = ip;
188
193
        }
189
194
 
190
195
        /**
207
212
         * Return my IP [mutex protected]
208
213
         * @return std::string The local IP
209
214
         */
210
 
        std::string getLocalIp();
 
215
        IpAddr getLocalIp() const;
211
216
 
212
217
        /**
213
218
         * Return port used locally (for my machine) [mutex protected]
214
219
         * @return unsigned int  The local audio port
215
220
         */
216
 
        unsigned int getLocalAudioPort();
 
221
        unsigned int getLocalAudioPort() const;
217
222
 
218
223
        /**
219
224
         * Return port used locally (for my machine) [mutex protected]
220
225
         * @return unsigned int  The local video port
221
226
         */
222
 
        unsigned int getLocalVideoPort();
 
227
        unsigned int getLocalVideoPort() const;
223
228
 
224
229
        void time_stop();
225
230
        virtual std::map<std::string, std::string> getDetails();
231
236
        virtual bool toggleRecording();
232
237
 
233
238
    private:
 
239
        bool validTransition(CallState newState);
 
240
 
234
241
        std::string getTypeStr() const;
235
242
        /** Protect every attribute that can be changed by two threads */
236
 
        std::mutex callMutex_;
 
243
        mutable std::mutex callMutex_;
237
244
 
238
245
        // Informations about call socket / audio
239
246
 
240
247
        /** My IP address */
241
 
        std::string localIPAddress_;
 
248
        IpAddr localAddr_;
242
249
 
243
250
        /** Local audio port, as seen by me. */
244
251
        unsigned int localAudioPort_;
261
268
        /** Disconnected/Progressing/Trying/Ringing/Connected */
262
269
        ConnectionState connectionState_;
263
270
 
264
 
        /** Inactive/Active/Hold/Busy/Refused/Error */
 
271
        /** Inactive/Active/Hold/Busy/Error */
265
272
        CallState callState_;
266
273
 
267
274
        /** Direct IP-to-IP or classic call */