Skip to content
Snippets Groups Projects
Commit f7d93108 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#2006] Fix detachParticipant/removeParticipant switchCall ids

parent 4af0e7f7
No related branches found
No related tags found
No related merge requests found
...@@ -56,20 +56,6 @@ void Conference::add(CallID participant_id) ...@@ -56,20 +56,6 @@ 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);
*/
_participants.insert(participant_id); _participants.insert(participant_id);
_nbParticipant++; _nbParticipant++;
...@@ -81,19 +67,6 @@ void Conference::remove(CallID participant_id) ...@@ -81,19 +67,6 @@ void Conference::remove(CallID participant_id)
_debug("---- Conference:: remove participant %s\n", participant_id.c_str()); _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++)
{
_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); _participants.erase(participant_id);
_nbParticipant--; _nbParticipant--;
...@@ -146,3 +119,16 @@ std::string Conference::getStateStr() ...@@ -146,3 +119,16 @@ std::string Conference::getStateStr()
return state_str; return state_str;
} }
CallID Conference::getLastParticipant()
{
CallID call_id = "";
ParticipantSet::iterator iter = _participants.begin();
if (iter != _participants.end())
{
call_id = *iter;
return call_id;
}
}
...@@ -54,6 +54,8 @@ class Conference{ ...@@ -54,6 +54,8 @@ class Conference{
void bindParticipant(CallID participant_id); void bindParticipant(CallID participant_id);
CallID getLastParticipant();
private: private:
/** Unique ID of the call */ /** Unique ID of the call */
......
...@@ -246,7 +246,7 @@ ManagerImpl::outgoingCall (const std::string& accountid, const CallID& id, const ...@@ -246,7 +246,7 @@ ManagerImpl::outgoingCall (const std::string& accountid, const CallID& id, const
else else
{ {
_debug ("ManagerImpl::outgoingCall() Put the current conference (ID=%s) on hold\n", getCurrentCallId().c_str()); _debug ("ManagerImpl::outgoingCall() Put the current conference (ID=%s) on hold\n", getCurrentCallId().c_str());
detachParticipant(); // detachParticipant();
} }
} }
...@@ -569,7 +569,7 @@ ManagerImpl::offHoldCall (const CallID& id) ...@@ -569,7 +569,7 @@ ManagerImpl::offHoldCall (const CallID& id)
else else
{ {
_debug ("Put the current conference (ID=%s) on hold\n", getCurrentCallId().c_str()); _debug ("Put the current conference (ID=%s) on hold\n", getCurrentCallId().c_str());
detachParticipant(); // detachParticipant();
} }
} }
...@@ -708,7 +708,7 @@ ManagerImpl::refuseCall (const CallID& id) ...@@ -708,7 +708,7 @@ ManagerImpl::refuseCall (const CallID& id)
} }
void Conference*
ManagerImpl::createConference(const CallID& id1, const CallID& id2) ManagerImpl::createConference(const CallID& id1, const CallID& id2)
{ {
_debug("ManagerImpl::createConference()\n"); _debug("ManagerImpl::createConference()\n");
...@@ -725,6 +725,7 @@ ManagerImpl::createConference(const CallID& id1, const CallID& id2) ...@@ -725,6 +725,7 @@ ManagerImpl::createConference(const CallID& id1, const CallID& id2)
// broadcast a signal over dbus // broadcast a signal over dbus
_dbus->getCallManager()->conferenceCreated(default_conf); _dbus->getCallManager()->conferenceCreated(default_conf);
return conf;
} }
void void
...@@ -981,8 +982,10 @@ ManagerImpl::joinParticipant(const CallID& call_id1, const CallID& call_id2) ...@@ -981,8 +982,10 @@ ManagerImpl::joinParticipant(const CallID& call_id1, const CallID& call_id2)
if(iter == _conferencemap.end()){ if(iter == _conferencemap.end()){
_debug("NO CONFERENCE YET, CREATE ONE\n"); _debug("ManagerImpl::joinParticipant create a conference\n");
createConference(call_id1, call_id2); Conference *conf = createConference(call_id1, call_id2);
iter_details = call1_details.find("CALL_STATE"); iter_details = call1_details.find("CALL_STATE");
_debug(" call %s state: %s\n", call_id1.c_str(), iter_details->second.c_str()); _debug(" call %s state: %s\n", call_id1.c_str(), iter_details->second.c_str());
...@@ -996,6 +999,11 @@ ManagerImpl::joinParticipant(const CallID& call_id1, const CallID& call_id2) ...@@ -996,6 +999,11 @@ ManagerImpl::joinParticipant(const CallID& call_id1, const CallID& call_id2)
_debug(" ANSWER %s\n", call_id1.c_str()); _debug(" ANSWER %s\n", call_id1.c_str());
answerCall(call_id1); answerCall(call_id1);
} }
else if(iter_details->second == "CURRENT")
{
_debug(" CURRENT %s\n", call_id1.c_str());
conf->bindParticipant(call_id1);
}
iter_details = call2_details.find("CALL_STATE"); iter_details = call2_details.find("CALL_STATE");
_debug(" call %s state: %s\n", call_id2.c_str(), iter_details->second.c_str()); _debug(" call %s state: %s\n", call_id2.c_str(), iter_details->second.c_str());
...@@ -1009,6 +1017,11 @@ ManagerImpl::joinParticipant(const CallID& call_id1, const CallID& call_id2) ...@@ -1009,6 +1017,11 @@ ManagerImpl::joinParticipant(const CallID& call_id1, const CallID& call_id2)
_debug(" ANSWER %s\n", call_id2.c_str()); _debug(" ANSWER %s\n", call_id2.c_str());
answerCall(call_id2); answerCall(call_id2);
} }
else if(iter_details->second == "CURRENT")
{
_debug(" CURRENT %s\n", call_id2.c_str());
conf->bindParticipant(call_id2);
}
AccountID currentAccountId; AccountID currentAccountId;
...@@ -1022,42 +1035,14 @@ ManagerImpl::joinParticipant(const CallID& call_id1, const CallID& call_id2) ...@@ -1022,42 +1035,14 @@ ManagerImpl::joinParticipant(const CallID& call_id1, const CallID& call_id2)
call = getAccountLink (currentAccountId)->getCall (call_id2); call = getAccountLink (currentAccountId)->getCall (call_id2);
call->setConfId (default_conf); call->setConfId (default_conf);
switchCall(default_conf);
} }
else { else {
_debug("ALREADY A CONFERENCE CREATED\n"); _debug("ManagerImpl::joinParticipant already a conference created with this ID\n");
/*
Conference* conf = iter->second;
conf->add(call_id1);
_conferencecall.insert(pair<CallID, Conference*>(call_id1, conf));
iter_details = call1_details.find("CALL_STATE");
if(iter_details->second == "HOLD")
{
_debug(" Add INCOMING call to conference\n");
offHoldCall (call_id1);
} }
else if(iter_details->second == "INCOMING")
{
_debug(" Add INCOMING call to conference\n");
answerCall(call_id1);
}
*/
/*
iter_details = call2_details.find("CALL_STATE");
if(iter_details->second == "HOLD")
{
}
else if(iter_details->second == "INCOMING")
{
}
*/
}
switchCall(default_conf);
} }
...@@ -1072,11 +1057,8 @@ ManagerImpl::detachParticipant(const CallID& call_id) ...@@ -1072,11 +1057,8 @@ ManagerImpl::detachParticipant(const CallID& call_id)
if(iter == _conferencemap.end()) { if(iter != _conferencemap.end()) {
_debug("Error there is no conference, call is not conferencing\n");
}
else {
_debug("ManagerImpl::detachParticipant detach participant %s\n", call_id.c_str()); _debug("ManagerImpl::detachParticipant detach participant %s\n", call_id.c_str());
if(call_id != default_id) if(call_id != default_id)
...@@ -1094,6 +1076,13 @@ ManagerImpl::detachParticipant(const CallID& call_id) ...@@ -1094,6 +1076,13 @@ ManagerImpl::detachParticipant(const CallID& call_id)
} }
// _dbus->getCallManager()->conferenceChanged(conference_id); // _dbus->getCallManager()->conferenceChanged(conference_id);
}
else {
_debug("Error there is no conference, call is not conferencing\n");
} }
} }
...@@ -1111,19 +1100,39 @@ ManagerImpl::removeParticipant(const CallID& call_id) ...@@ -1111,19 +1100,39 @@ ManagerImpl::removeParticipant(const CallID& call_id)
ConferenceMap::iterator iter = conf_map.find(default_conf); ConferenceMap::iterator iter = conf_map.find(default_conf);
if(iter == _conferencemap.end()) { if(iter == _conferencemap.end()) {
_debug("NO CONFERENCE CREATED, CANNOT REMOVE PARTICIPANT\n"); _debug("ManagerImpl::removeParticipant no conference created, cannot remove participant \n");
} }
else { else {
conf = iter->second; conf = iter->second;
_debug("REMOVE PARTICIPANT %s\n", call_id.c_str()); _debug("ManagerImpl::removeParticipant %s\n", call_id.c_str());
conf->remove(call_id); conf->remove(call_id);
_conferencecall.erase(iter->first); _conferencecall.erase(iter->first);
if (conf->getNbParticipants() <= 1) if(conf->getNbParticipants() > 1)
{
switchCall(default_conf);
}
else if (conf->getNbParticipants() == 1)
{
CallID last_participant = conf->getLastParticipant();
_debug("ManagerImpl::removeParticipant only one participant remaining %s\n", last_participant.c_str());
removeConference(default_conf);
switchCall(last_participant);
}
else
{
removeConference(default_conf); removeConference(default_conf);
switchCall("");
}
} }
} }
......
...@@ -195,7 +195,7 @@ class ManagerImpl { ...@@ -195,7 +195,7 @@ class ManagerImpl {
*/ */
bool refuseCall(const CallID& id); bool refuseCall(const CallID& id);
void createConference(const CallID& id1, const CallID& id2); Conference* createConference(const CallID& id1, const CallID& id2);
void removeConference(const CallID& conference_id); void removeConference(const CallID& conference_id);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment