Commit 46fea3f2 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#1883] Fix mnagerimpl conference map insertion

parent aa5740f3
......@@ -41,14 +41,17 @@ Conference::~Conference()
void Conference::add(CallID participant_id)
{
_debug("Conference::add participant %s\n", participant_id.c_str());
_debug("---- Conference:: add participant %s\n", participant_id.c_str());
if(_nbParticipant >= 1)
{
ParticipantSet::iterator iter;
for(iter = _participants.begin(); iter != _participants.end(); iter++)
{
_debug("---- Conference:: bind callid %s with %s in conference add\n", participant_id.c_str(), (*iter).c_str());
Manager::instance().getAudioDriver()->getMainBuffer()->bindCallID(participant_id, *iter);
}
}
// Manager::instance().getAudioDriver()->getMainBuffer()->bindCallID(participant_id);
......@@ -62,12 +65,17 @@ void Conference::add(CallID participant_id)
void Conference::remove(CallID participant_id)
{
_debug("---- Conference:: remove participant %s\n", participant_id.c_str());
if(_nbParticipant >= 1)
{
ParticipantSet::iterator iter = _participants.begin();
for(iter = _participants.begin(); iter != _participants.end(); iter++)
Manager::instance().getAudioDriver()->getMainBuffer()->unBindCallID(participant_id, *iter);
{
_debug("---- Conference:: unbind callid %s from %s in conference add\n", participant_id.c_str(), (*iter).c_str());
Manager::instance().getAudioDriver()->getMainBuffer()->unBindCallID(participant_id, *iter);
}
}
_participants.erase(participant_id);
......
......@@ -317,7 +317,7 @@ ManagerImpl::answerCall (const CallID& id)
}
else
{
_debug("There is a conference!!!!!!!!!!!!!!!!!!!!!!\n");
_debug("There is a conference! Do not hold the current call\n");
}
}
......@@ -364,10 +364,14 @@ ManagerImpl::hangupCall (const CallID& id)
_debug ("hangupCall: callList is of size %i call(s)\n", nbCalls);
// stop stream
// stop streamx
if (! (nbCalls > 1))
audiolayer->stopStream();
if(participToConference(id))
removeParticipant(id);
/* Direct IP to IP call */
if (getConfigFromCall (id) == Call::IPtoIP) {
returnValue = SIPVoIPLink::instance (AccountNULL)->hangup (id);
......@@ -377,7 +381,8 @@ ManagerImpl::hangupCall (const CallID& id)
else {
accountid = getAccountFromCall (id);
if (accountid == AccountNULL) {
if (accountid == AccountNULL)
{
_debug ("! Manager Hangup Call: Call doesn't exists\n");
return false;
}
......@@ -449,6 +454,9 @@ ManagerImpl::onHoldCall (const CallID& id)
call_id = id;
if(participToConference(id))
removeParticipant(id);
/* Direct IP to IP call */
if (getConfigFromCall (id) == Call::IPtoIP) {
......@@ -635,7 +643,9 @@ ManagerImpl::createConference(const CallID& id)
_debug("ManagerImpl::createConference()\n");
Conference* conf = new Conference();
_conferencemap["conf"] = conf;
_conferencecall.insert(pair<CallID, Conference*>(id, conf));
_conferencemap.insert(pair<CallID, Conference*>("conf", conf));
conf->add(getCurrentCallId());
conf->add(id);
......@@ -645,30 +655,98 @@ ManagerImpl::createConference(const CallID& id)
}
void
ManagerImpl::addParticipant(const CallID& id)
ManagerImpl::removeConference(const CallID& conference_id)
{
_debug("ManagerImpl::addParticipant(%s)\n", id.c_str());
_debug("ManagerImpl::removeConference(%s)\n", conference_id.c_str());
Conference* conf;
ConferenceMap::iterator iter = _conferencemap.find(conference_id);
conf = iter->second;
ConferenceCallMap::iterator iter_p;
for(iter_p = _conferencecall.begin(); iter_p != _conferencecall.end(); iter_p++)
{
if(iter_p->second == conf)
{
_conferencecall.erase(iter_p);
}
}
_conferencemap.erase("conf");
}
bool
ManagerImpl::participToConference(const CallID& call_id)
{
ConferenceCallMap::iterator iter = _conferencecall.find(call_id);
if(iter == _conferencecall.end())
{
return false;
}
else
{
return true;
}
}
void
ManagerImpl::addParticipant(const CallID& call_id)
{
_debug("ManagerImpl::addParticipant(%s)\n", call_id.c_str());
_debug(" Current call ID %s\n", getCurrentCallId().c_str());
if(_conferencemap.empty())
// TODO: add conference_id as a second parameter
ConferenceMap::iterator iter = _conferencemap.find("conf");
if(iter == _conferencemap.end())
{
_debug("NO CONFERENCE YET, CREATE ONE\n");
createConference(id);
createConference(call_id);
}
else
{
_debug("ALREADY A CONFERENCE CREATED, ADD PARTICIPANT TO IT\n");
Conference* conf;
ConferenceMap::iterator iter = _conferencemap.find("conf");
conf = iter->second;
Conference* conf = iter->second;
conf->add(id);
conf->add(call_id);
_conferencecall.insert(pair<CallID, Conference*>(call_id, conf));
answerCall(id);
answerCall(call_id);
}
}
void
ManagerImpl::removeParticipant(const CallID& call_id)
{
_debug("ManagerImpl::removeParticipant(%s)\n", call_id.c_str());
// TODO: add conference_id as a second parameter
Conference* conf;
ConferenceMap::iterator iter = _conferencemap.find("conf");
if(iter == _conferencemap.end())
{
_debug("NO CONFERENCE CREATED, CANNOT REMOVE PARTICIPANT\n");
}
else
{
conf = iter->second;
_debug("REMOVE PARTICIPANT %s\n", call_id.c_str());
conf->remove(call_id);
_conferencecall.erase(iter);
if (conf->getNbParticipants() <= 1)
removeConference("conf");
}
}
//THREAD=Main
bool
ManagerImpl::saveConfig (void)
......@@ -976,6 +1054,9 @@ ManagerImpl::peerHungupCall (const CallID& id)
AccountID accountid;
bool returnValue;
if(participToConference(id))
removeParticipant(id);
/* Direct IP to IP call */
if (getConfigFromCall (id) == Call::IPtoIP) {
......@@ -993,6 +1074,8 @@ ManagerImpl::peerHungupCall (const CallID& id)
returnValue = getAccountLink (accountid)->peerHungup (id);
}
/* Broadcast a signal over DBus */
if (_dbus) _dbus->getCallManager()->callStateChanged (id, "HUNGUP");
......
......@@ -70,8 +70,11 @@ typedef std::set<CallID> CallIDSet;
/** To send multiple string */
typedef std::list<std::string> TokenList;
/** To store conference objects by ids */
typedef std::map<CallID, Conference*> ConferenceMap;
/** To store conference objects by call ids */
typedef std::map<CallID, Conference*> ConferenceCallMap;
/** To store conference objects by conference ids */
typedef std::map<CallID, Conference*> ConferenceMap;
/** Manager (controller) of sflphone daemon */
class ManagerImpl {
......@@ -182,7 +185,13 @@ class ManagerImpl {
void createConference(const CallID& id);
void addParticipant(const CallID& id);
void removeConference(const CallID& conference_id);
bool participToConference(const CallID& call_id);
void addParticipant(const CallID& call_id);
void removeParticipant(const CallID& call_id);
/**
* Save config to file
......@@ -1150,6 +1159,8 @@ class ManagerImpl {
int isStunEnabled (void);
void enableStun (void);
ConferenceCallMap _conferencecall;
ConferenceMap _conferencemap;
private:
......
......@@ -711,6 +711,7 @@ SIPVoIPLink::hangup (const CallID& id)
}
// User hangup current call. Notify peer
_debug("SIPVoIPLink::hangup Create inv session for call id: %s\n", call->getCallId().c_str());
status = pjsip_inv_end_session (call->getInvSession(), 404, NULL, &tdata);
if (status != PJ_SUCCESS)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment