Skip to content
Snippets Groups Projects
Commit f31b4e74 authored by Guillaume Roguez's avatar Guillaume Roguez Committed by Andreas Traczyk
Browse files

manager: refactor addParticipant method


As for joinParticipant, refactor addParticipant by using
the new bindCallToConference method.
Decrease code complexity, redundancy, CC, ...

Change-Id: I213bdc7d0caf597c388605df6d202907371ae19c
Reviewed-by: default avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent 733775d1
Branches
Tags
No related merge requests found
...@@ -948,9 +948,9 @@ Manager::addParticipant(const std::string& callId, ...@@ -948,9 +948,9 @@ Manager::addParticipant(const std::string& callId,
const std::string& conferenceId) const std::string& conferenceId)
{ {
RING_DBG("Add participant %s to %s", callId.c_str(), conferenceId.c_str()); RING_DBG("Add participant %s to %s", callId.c_str(), conferenceId.c_str());
ConferenceMap::iterator iter = conferenceMap_.find(conferenceId);
if (iter == conferenceMap_.end()) { auto iter = conferenceMap_.find(conferenceId);
if (iter == conferenceMap_.end() or iter->second == nullptr) {
RING_ERR("Conference id is not valid"); RING_ERR("Conference id is not valid");
return false; return false;
} }
...@@ -961,12 +961,8 @@ Manager::addParticipant(const std::string& callId, ...@@ -961,12 +961,8 @@ Manager::addParticipant(const std::string& callId,
return false; return false;
} }
// ensure that calls are only in one conference at a time
if (isConferenceParticipant(callId))
detachParticipant(callId);
// store the current call id (it will change in offHoldCall or in answerCall) // store the current call id (it will change in offHoldCall or in answerCall)
std::string current_call_id(getCurrentCallId()); auto current_call_id = getCurrentCallId();
// detach from prior communication and switch to this conference // detach from prior communication and switch to this conference
if (current_call_id != callId) { if (current_call_id != callId) {
...@@ -976,42 +972,17 @@ Manager::addParticipant(const std::string& callId, ...@@ -976,42 +972,17 @@ Manager::addParticipant(const std::string& callId,
onHoldCall(current_call_id); onHoldCall(current_call_id);
} }
bindCallToConference(*call, *iter->second);
// TODO: remove this ugly hack => There should be different calls when double clicking // TODO: remove this ugly hack => There should be different calls when double clicking
// a conference to add main participant to it, or (in this case) adding a participant // a conference to add main participant to it, or (in this case) adding a participant
// toconference // toconference
unsetCurrentCall(); unsetCurrentCall();
// Add main participant
addMainParticipant(conferenceId); addMainParticipant(conferenceId);
switchCall(conferenceId);
auto conf = iter->second;
switchCall(conf->getConfID());
// Add coresponding IDs in conf and call
call->setConfId(conf->getConfID());
conf->add(callId);
// Connect new audio streams together
getRingBufferPool().unBindAll(callId);
std::map<std::string, std::string> callDetails(getCallDetails(callId));
std::string callState(callDetails.find("CALL_STATE")->second);
if (callState == "HOLD") {
conf->bindParticipant(callId);
offHoldCall(callId);
} else if (callState == "INCOMING") {
conf->bindParticipant(callId);
answerCall(callId);
} else if (callState == "CURRENT")
conf->bindParticipant(callId);
ParticipantSet participants(conf->getParticipantList());
if (participants.empty())
RING_ERR("Participant list is empty for this conference");
addAudio(*call); addAudio(*call);
return true; return true;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment