local-conference.cpp 2.35 KB
Newer Older
1 2
/*
 * local-conference.cpp
3
 * Copyright (C) 2010-2018 Belledonne Communications SARL
4
 *
Ghislain MARY's avatar
Ghislain MARY committed
5 6 7 8
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
9 10 11 12 13 14 15
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
Ghislain MARY's avatar
Ghislain MARY committed
16 17
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 19
 */

20
#include "handlers/local-conference-event-handler.h"
21
#include "local-conference-p.h"
22
#include "logger/logger.h"
23
#include "participant-p.h"
24

25 26
// =============================================================================

27
using namespace std;
28 29

LINPHONE_BEGIN_NAMESPACE
30

31
LocalConference::LocalConference (const shared_ptr<Core> &core, const IdentityAddress &myAddress, CallSessionListener *listener)
32
	: Conference(*new LocalConferencePrivate, core, myAddress, listener) {
33
	L_D();
34
	d->eventHandler.reset(new LocalConferenceEventHandler(this));
35 36
}

Ghislain MARY's avatar
Ghislain MARY committed
37 38 39 40 41
LocalConference::~LocalConference () {
	L_D();
	d->eventHandler.reset();
}

42 43
// -----------------------------------------------------------------------------

44
bool LocalConference::addParticipant (const IdentityAddress &addr, const CallSessionParams *params, bool hasMedia) {
45
	L_D();
46
	shared_ptr<Participant> participant = findParticipant(addr);
47 48
	if (participant) {
		lInfo() << "Not adding participant '" << addr.asString() << "' because it is already a participant of the LocalConference";
49
		return false;
50
	}
51
	participant = make_shared<Participant>(this, addr);
52
	participant->getPrivate()->createSession(*this, params, hasMedia, d->listener);
53 54 55
	d->participants.push_back(participant);
	if (!d->activeParticipant)
		d->activeParticipant = participant;
56
	return true;
57 58
}

59
bool LocalConference::removeParticipant (const shared_ptr<Participant> &participant) {
60 61
	L_D();
	for (const auto &p : d->participants) {
62
		if (participant->getAddress() == p->getAddress()) {
63
			d->participants.remove(p);
64
			return true;
65 66
		}
	}
67
	return false;
68 69
}

70
LINPHONE_END_NAMESPACE