conference.cpp 4.62 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 * conference.cpp
 * Copyright (C) 2017  Belledonne Communications SARL
 *
 * 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 3 of the License, or
 * (at your option) any later version.
 *
 * 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
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

19
#include "participant-p.h"
20 21

#include "conference.h"
22
#include "logger/logger.h"
23

24 25
using namespace std;

26 27 28 29
LINPHONE_BEGIN_NAMESPACE

// =============================================================================

30 31 32 33 34 35 36 37 38 39 40 41 42
Conference::Conference (LinphoneCore *core, const Address &myAddress, CallListener *listener)
	: core(core), callListener(listener) {
	me = make_shared<Participant>(myAddress);
}

// -----------------------------------------------------------------------------

shared_ptr<Participant> Conference::getActiveParticipant () const {
	return activeParticipant;
}

// -----------------------------------------------------------------------------

43
shared_ptr<Participant> Conference::addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) {
44 45
	lError() << "Conference class does not handle addParticipant() generically";
	return nullptr;
46 47
}

48
void Conference::addParticipants (const list<Address> &addresses, const CallSessionParams *params, bool hasMedia) {
49 50
	for (const auto &addr : addresses)
		addParticipant(addr, params, hasMedia);
51 52
}

53 54 55 56
bool Conference::canHandleParticipants () const {
	return true;
}

57 58 59 60 61
const string& Conference::getId () const {
	return id;
}

int Conference::getNbParticipants () const {
62
	return participants.size();
63 64 65 66 67 68
}

list<shared_ptr<Participant>> Conference::getParticipants () const {
	return participants;
}

69
void Conference::removeParticipant (const shared_ptr<const Participant> &participant) {
70
	lError() << "Conference class does not handle removeParticipant() generically";
71 72
}

73
void Conference::removeParticipants (const list<shared_ptr<Participant>> &participants) {
74 75
	for (const auto &p : participants)
		removeParticipant(p);
76 77 78 79 80
}

// -----------------------------------------------------------------------------

void Conference::onAckBeingSent (const CallSession &session, LinphoneHeaders *headers) {
81
	if (callListener)
82
		callListener->onAckBeingSent(headers);
83 84
}

85
void Conference::onAckReceived (const CallSession &session, LinphoneHeaders *headers) {
86
	if (callListener)
87
		callListener->onAckReceived(headers);
88 89
}

90
void Conference::onCallSessionAccepted (const CallSession &session) {
91
	if (callListener)
92
		callListener->onIncomingCallToBeAdded();
93 94
}

95
void Conference::onCallSessionSetReleased (const CallSession &session) {
96
	if (callListener)
97
		callListener->onCallSetReleased();
98 99
}

100
void Conference::onCallSessionSetTerminated (const CallSession &session) {
101
	if (callListener)
102
		callListener->onCallSetTerminated();
103 104
}

105
void Conference::onCallSessionStateChanged (const CallSession &session, LinphoneCallState state, const string &message) {
106
	if (callListener)
107
		callListener->onCallStateChanged(state, message);
108 109
}

110
void Conference::onIncomingCallSessionStarted (const CallSession &session) {
111
	if (callListener)
112
		callListener->onIncomingCallStarted();
113 114
}

115
void Conference::onEncryptionChanged (const CallSession &session, bool activated, const string &authToken) {
116
	if (callListener)
117
		callListener->onEncryptionChanged(activated, authToken);
118 119
}

120
void Conference::onStatsUpdated (const LinphoneCallStats *stats) {
121
	if (callListener)
122
		callListener->onStatsUpdated(stats);
123 124
}

125
void Conference::onResetCurrentSession (const CallSession &session) {
126
	if (callListener)
127
		callListener->onResetCurrentCall();
128 129
}

130
void Conference::onSetCurrentSession (const CallSession &session) {
131
	if (callListener)
132
		callListener->onSetCurrentCall();
133 134
}

135
void Conference::onFirstVideoFrameDecoded (const CallSession &session) {
136
	if (callListener)
137
		callListener->onFirstVideoFrameDecoded();
138 139
}

140
void Conference::onResetFirstVideoFrameDecoded (const CallSession &session) {
141
	if (callListener)
142
		callListener->onResetFirstVideoFrameDecoded();
143 144
}

145 146 147 148 149 150 151 152 153 154
// -----------------------------------------------------------------------------

std::shared_ptr<Participant> Conference::findParticipant (const Address &addr) {
	for (const auto &participant : participants) {
		if (addr.equal(participant->getAddress()))
			return participant;
	}
	return nullptr;
}

155
LINPHONE_END_NAMESPACE