~ubuntu-branches/ubuntu/trusty/sflphone/trusty

« back to all changes in this revision

Viewing changes to daemon/src/call.cpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (4.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20140128182336-jrsv0k9u6cawc068
Tags: 1.3.0-1
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *  Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
 
2
 *  Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
3
3
 *  Author: Yan Morin <yan.morin@savoirfairelinux.com>
4
4
 *  Author : Laurielle Lea <laurielle.lea@savoirfairelinux.com>
5
5
 *
32
32
#include "manager.h"
33
33
#include "audio/mainbuffer.h"
34
34
#include "history/historyitem.h"
35
 
#include "scoped_lock.h"
36
35
 
37
36
Call::Call(const std::string& id, Call::CallType type, const std::string &accountID)
38
37
    : callMutex_()
51
50
    , timestamp_start_(0)
52
51
    , timestamp_stop_(0)
53
52
{
54
 
    pthread_mutex_init(&callMutex_, NULL);
55
53
    time(&timestamp_start_);
56
54
}
57
55
 
58
56
Call::~Call()
59
 
{
60
 
    pthread_mutex_destroy(&callMutex_);
61
 
}
 
57
{}
62
58
 
63
59
void
64
60
Call::setConnectionState(ConnectionState state)
65
61
{
66
 
    sfl::ScopedLock m(callMutex_);
 
62
    std::lock_guard<std::mutex> lock(callMutex_);
67
63
    connectionState_ = state;
68
64
}
69
65
 
70
66
Call::ConnectionState
71
67
Call::getConnectionState()
72
68
{
73
 
    sfl::ScopedLock m(callMutex_);
 
69
    std::lock_guard<std::mutex> lock(callMutex_);
74
70
    return connectionState_;
75
71
}
76
72
 
77
73
void
78
74
Call::setState(CallState state)
79
75
{
80
 
    sfl::ScopedLock m(callMutex_);
 
76
    std::lock_guard<std::mutex> lock(callMutex_);
81
77
    callState_ = state;
82
78
}
83
79
 
84
80
Call::CallState
85
81
Call::getState()
86
82
{
87
 
    sfl::ScopedLock m(callMutex_);
 
83
    std::lock_guard<std::mutex> lock(callMutex_);
88
84
    return callState_;
89
85
}
90
86
 
129
125
std::string
130
126
Call::getLocalIp()
131
127
{
132
 
    sfl::ScopedLock m(callMutex_);
 
128
    std::lock_guard<std::mutex> lock(callMutex_);
133
129
    return localIPAddress_;
134
130
}
135
131
 
136
132
unsigned int
137
133
Call::getLocalAudioPort()
138
134
{
139
 
    sfl::ScopedLock m(callMutex_);
 
135
    std::lock_guard<std::mutex> lock(callMutex_);
140
136
    return localAudioPort_;
141
137
}
142
138
 
143
139
unsigned int
144
140
Call::getLocalVideoPort()
145
141
{
146
 
    sfl::ScopedLock m(callMutex_);
 
142
    std::lock_guard<std::mutex> lock(callMutex_);
147
143
    return localVideoPort_;
148
144
}
149
145
 
150
146
bool
151
 
Call::setRecording()
 
147
Call::toggleRecording()
152
148
{
153
 
    bool recordStatus = Recordable::recAudio_.isRecording();
154
 
 
155
 
    Recordable::recAudio_.setRecording();
 
149
    const bool startRecording = Recordable::recAudio_.toggleRecording();
156
150
    MainBuffer &mbuffer = Manager::instance().getMainBuffer();
157
151
    std::string process_id = Recordable::recorder_.getRecorderID();
158
152
 
159
 
    if (!recordStatus) {
 
153
    if (startRecording) {
160
154
        mbuffer.bindHalfDuplexOut(process_id, id_);
161
155
        mbuffer.bindHalfDuplexOut(process_id, MainBuffer::DEFAULT_ID);
162
156
 
166
160
        mbuffer.unBindHalfDuplexOut(process_id, MainBuffer::DEFAULT_ID);
167
161
    }
168
162
 
169
 
    Manager::instance().getMainBuffer().dumpInfo();
170
 
 
171
 
    return recordStatus;
 
163
    return startRecording;
172
164
}
173
165
 
174
166
void Call::time_stop()
212
204
    result[HistoryItem::RECORDING_PATH_KEY] = recAudio_.fileExists() ? getFilename() : "";
213
205
    result[HistoryItem::TIMESTAMP_START_KEY] = timestamp_to_string(timestamp_start_);
214
206
    result[HistoryItem::TIMESTAMP_STOP_KEY] = timestamp_to_string(timestamp_stop_);
215
 
    if (connectionState_ == RINGING)
 
207
 
 
208
    // FIXME: state will no longer exist, it will be split into
 
209
    // a boolean field called "missed" and a direction field "incoming" or "outgoing"
 
210
    if (connectionState_ == RINGING) {
216
211
        result[HistoryItem::STATE_KEY] = HistoryItem::MISSED_STRING;
217
 
    else
 
212
        result[HistoryItem::MISSED_KEY] = "true";
 
213
    } else {
218
214
        result[HistoryItem::STATE_KEY] = getTypeStr();
 
215
        result[HistoryItem::MISSED_KEY] = "false";
 
216
    }
 
217
 
 
218
    // now "missed" and direction are independent
 
219
    result[HistoryItem::DIRECTION_KEY] = getTypeStr();
 
220
 
219
221
    return result;
220
222
}
221
223
 
239
241
Call::getNullDetails()
240
242
{
241
243
    std::map<std::string, std::string> details;
242
 
    details["ACCOUNTID"] = "";
 
244
    details["CALL_TYPE"] = "0";
243
245
    details["PEER_NUMBER"] = "Unknown";
244
 
    details["PEER_NAME"] = "Unknown";
245
246
    details["DISPLAY_NAME"] = "Unknown";
246
247
    details["CALL_STATE"] = "UNKNOWN";
247
 
    details["CALL_TYPE"] = "0";
 
248
    details["CONF_ID"] = "";
 
249
    details["TIMESTAMP_START"] = "";
 
250
    details["ACCOUNTID"] = "";
248
251
    return details;
249
252
}