- Invite participants first to avoid removing conference if empty

- Put in pause and remove all calls that are not in the conference list
- Show only calls that are in conference
This commit is contained in:
Julien Wadel 2020-06-01 17:00:21 +02:00
parent bd6055227f
commit e94296019c
5 changed files with 35 additions and 28 deletions

View file

@ -187,7 +187,6 @@ void CallModel::acceptWithVideo () {
void CallModel::terminate () {
CoreManager *core = CoreManager::getInstance();
core->lockVideoRender();
mCall->terminate();
core->unlockVideoRender();
@ -365,10 +364,10 @@ void CallModel::accept (bool withVideo) {
// -----------------------------------------------------------------------------
void CallModel::updateIsInConference () {
if (mIsInConference != mCall->getParams()->getLocalConferenceMode()) {
if (mIsInConference != mCall->getCurrentParams()->getLocalConferenceMode()) {
mIsInConference = !mIsInConference;
emit isInConferenceChanged(mIsInConference);
}
emit isInConferenceChanged(mIsInConference);
}
// -----------------------------------------------------------------------------

View file

@ -239,7 +239,7 @@ void CallsListModel::addCall (const shared_ptr<linphone::Call> &call) {
}
CallModel *callModel = new CallModel(call);
qInfo() << QStringLiteral("Add call:") << callModel;
qInfo() << QStringLiteral("Add call:") << callModel->getFullLocalAddress() << callModel->getFullPeerAddress();
App::getInstance()->getEngine()->setObjectOwnership(callModel, QQmlEngine::CppOwnership);
// This connection is (only) useful for `CallsListProxyModel`.

View file

@ -42,7 +42,7 @@ ConferenceHelperModel::ConferenceAddModel::ConferenceAddModel (QObject *parent)
);
for (const auto &call : coreManager->getCore()->getCalls()) {
if (call->getParams()->getLocalConferenceMode())
if (call->getCurrentParams()->getLocalConferenceMode())
addToConference(call->getRemoteAddress());
}
}
@ -134,33 +134,41 @@ bool ConferenceHelperModel::ConferenceAddModel::removeFromConference (const QStr
// -----------------------------------------------------------------------------
void ConferenceHelperModel::ConferenceAddModel::update () {
list<shared_ptr<linphone::Address>> linphoneAddresses;
shared_ptr<linphone::Conference> conference = mConferenceHelperModel->mCore->getConference();
if(!conference){
conference = mConferenceHelperModel->mCore->createConferenceWithParams(mConferenceHelperModel->mCore->createConferenceParams());
}
auto currentCalls = CoreManager::getInstance()->getCore()->getCalls();
list<shared_ptr<linphone::Address>> allLinphoneAddresses;
//1) Invite participants first to avoid removing conference if empty
for (const auto &map : mRefs) {
shared_ptr<linphone::Address> linphoneAddress = map->value("__linphoneAddress").value<shared_ptr<linphone::Address>>();
Q_CHECK_PTR(linphoneAddress);
linphoneAddresses.push_back(linphoneAddress);
allLinphoneAddresses.push_back(linphoneAddress);
}
if( allLinphoneAddresses.size() > 0)
conference->inviteParticipants(
allLinphoneAddresses,
CoreManager::getInstance()->getCore()->createCallParams(nullptr)
);
shared_ptr<linphone::Conference> conference = mConferenceHelperModel->mCore->getConference();
if(!conference)
conference = mConferenceHelperModel->mCore->createConferenceWithParams(mConferenceHelperModel->mCore->createConferenceParams());
// Remove sip addresses if necessary.
for (const auto &call : CoreManager::getInstance()->getCore()->getCalls()) {
if (!call->getParams()->getLocalConferenceMode())
continue;
const QString sipAddress = Utils::coreStringToAppString(call->getRemoteAddress()->asStringUriOnly());
if (!mSipAddresses.contains(sipAddress))
call->terminate();
}
conference->inviteParticipants(
linphoneAddresses,
CoreManager::getInstance()->getCore()->createCallParams(nullptr)
);
// 2) Put in pause and remove all calls that are not in the conference list
for(const auto &call : CoreManager::getInstance()->getCore()->getCalls()){
const std::string callAddress = call->getRemoteAddress()->asStringUriOnly();
auto address = allLinphoneAddresses.begin();
while(address != allLinphoneAddresses.end() && (*address)->asStringUriOnly() != callAddress)
++address;
if(address == allLinphoneAddresses.end()){// Not in conference list : put in pause and remove it from conference if it's the case
call->pause();
if( call->getParams()->getLocalConferenceMode() ){// Remove conference if it is not yet requested
CoreManager::getInstance()->getCore()->removeFromConference(call);
}
}
}
}
// -----------------------------------------------------------------------------
void ConferenceHelperModel::ConferenceAddModel::addToConferencePrivate (const shared_ptr<linphone::Address> &linphoneAddress) {

View file

@ -50,7 +50,7 @@ ConferenceModel::ConferenceModel (QObject *parent) : QSortFilterProxyModel(paren
CoreManager::getInstance()->getHandlers().get(), &CoreHandlers::callStateChanged,
this, [this] { emit conferenceChanged(); });
}
// Show all paraticpants thar should be, will be or are still in conference
bool ConferenceModel::filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const {
const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
const CallModel *callModel = index.data().value<CallModel *>();
@ -63,7 +63,7 @@ void ConferenceModel::terminate () {
core->terminateConference();
for (const auto &call : core->getCalls()) {
if (call->getParams()->getLocalConferenceMode())
if (call->getParams()->getLocalConferenceMode())// Terminate all call where participants are or will be in conference
call->terminate();
}
}

@ -1 +1 @@
Subproject commit 75277202452c3af9b61f3c1e238e9d7c1bb72473
Subproject commit 5fae77a2f789c4e61972b5b706359b9cc2404acd