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

« back to all changes in this revision

Viewing changes to daemon/src/sip/sipcall.cpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (1.1.11)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: package-import@ubuntu.com-20140128182336-3xenud1kbnwmf3mz
* 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: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
4
4
 *  Author: Alexandre Bourget <alexandre.bourget@savoirfairelinux.com>
5
5
 *  Author: Yan Morin <yan.morin@savoirfairelinux.com>
32
32
 */
33
33
 
34
34
#include "sipcall.h"
 
35
#include "sip_utils.h"
35
36
#include "logger.h" // for _debug
36
37
#include "sdp.h"
37
38
#include "manager.h"
38
39
#ifdef SFL_VIDEO
39
 
#include "dbus/video_controls.h"
 
40
#include "client/video_controls.h"
40
41
#endif
41
42
 
42
43
namespace {
51
52
    , audiortp_(this)
52
53
#ifdef SFL_VIDEO
53
54
    // The ID is used to associate video streams to calls
54
 
    , videortp_(id, Manager::instance().getDbusManager()->getVideoControls()->getSettings())
 
55
    , videortp_(id, Manager::instance().getClient()->getVideoControls()->getSettings())
55
56
#endif
56
57
    , pool_(pj_pool_create(&caching_pool->factory, id.c_str(), INITIAL_SIZE, INCREMENT_SIZE, NULL))
57
58
    , local_sdp_(new Sdp(pool_))
 
59
    , contactBuffer_()
 
60
    , contactHeader_{contactBuffer_, 0}
58
61
{}
59
62
 
60
63
SIPCall::~SIPCall()
63
66
    pj_pool_release(pool_);
64
67
}
65
68
 
 
69
void SIPCall::setContactHeader(pj_str_t *contact)
 
70
{
 
71
    pj_strcpy(&contactHeader_, contact);
 
72
}
 
73
 
66
74
void SIPCall::answer()
67
75
{
68
76
    pjsip_tx_data *tdata;
73
81
    if (pjsip_inv_answer(inv, PJSIP_SC_OK, NULL, !inv->neg ? local_sdp_->getLocalSdpSession() : NULL, &tdata) != PJ_SUCCESS)
74
82
        throw std::runtime_error("Could not init invite request answer (200 OK)");
75
83
 
 
84
    // contactStr must stay in scope as long as tdata
 
85
    if (contactHeader_.slen) {
 
86
        DEBUG("Answering with contact header: %.*s", contactHeader_.slen, contactHeader_.ptr);
 
87
        sip_utils::addContactHeader(&contactHeader_, tdata);
 
88
    }
 
89
 
76
90
    if (pjsip_inv_send_msg(inv, tdata) != PJ_SUCCESS)
77
91
        throw std::runtime_error("Could not send invite request answer (200 OK)");
78
92
 
96
110
    using sfl::HistoryItem;
97
111
 
98
112
    std::map<std::string, std::string> entry(Call::createHistoryEntry());
99
 
    // FIXME: we need a better a way of getting this info, or maybe just
100
 
    // get rid of it since it's only good for debugging
101
 
    try {
102
 
        entry[HistoryItem::AUDIO_CODEC_KEY] = audiortp_.getCurrentAudioCodecNames();
103
 
    } catch (const sfl::AudioRtpFactoryException &e) {
104
 
        ERROR("%s", e.what());
105
 
    }
106
 
#ifdef SFL_VIDEO
107
 
    entry[HistoryItem::VIDEO_CODEC_KEY] = local_sdp_->getSessionVideoCodec();
108
 
#endif
109
113
    return entry;
110
114
}