mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-03 20:46:28 +00:00
added participant's device added/removed listener
This commit is contained in:
parent
5350cadf47
commit
26cc84140d
12 changed files with 181 additions and 9 deletions
|
|
@ -62,6 +62,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
|
|||
conference/params/call-session-params.h
|
||||
conference/params/media-session-params-p.h
|
||||
conference/params/media-session-params.h
|
||||
conference/participant-device.h
|
||||
conference/participant-p.h
|
||||
conference/participant.h
|
||||
conference/remote-conference-event-handler-p.h
|
||||
|
|
@ -144,6 +145,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
|
|||
conference/local-conference.cpp
|
||||
conference/params/call-session-params.cpp
|
||||
conference/params/media-session-params.cpp
|
||||
conference/participant-device.cpp
|
||||
conference/participant.cpp
|
||||
conference/remote-conference-event-handler.cpp
|
||||
conference/remote-conference.cpp
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ void ClientGroupChatRoom::onParticipantAdded (const Address &addr) {
|
|||
void ClientGroupChatRoom::onParticipantRemoved (const Address &addr) {
|
||||
shared_ptr<Participant> participant = findParticipant(addr);
|
||||
if (!participant) {
|
||||
lWarning() << "Participant " << participant << " removed but not in the list of participants!";
|
||||
lWarning() << "Participant " << participant << " removed but is not in the list of participants!";
|
||||
return;
|
||||
}
|
||||
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(this);
|
||||
|
|
@ -269,6 +269,32 @@ void ClientGroupChatRoom::onSubjectChanged (const std::string &subject) {
|
|||
cb(cr, subject.c_str());
|
||||
}
|
||||
|
||||
void ClientGroupChatRoom::onParticipantDeviceAdded (const Address &addr, const Address &gruu) {
|
||||
shared_ptr<Participant> participant = nullptr;
|
||||
if (isMe(addr))
|
||||
participant = me;
|
||||
else
|
||||
participant = findParticipant(addr);
|
||||
if (!participant) {
|
||||
lWarning() << "Participant " << participant << " added a device but is not in the list of participants!";
|
||||
return;
|
||||
}
|
||||
participant->getPrivate()->addDevice(gruu);
|
||||
}
|
||||
|
||||
void ClientGroupChatRoom::onParticipantDeviceRemoved (const Address &addr, const Address &gruu) {
|
||||
shared_ptr<Participant> participant = nullptr;
|
||||
if (isMe(addr))
|
||||
participant = me;
|
||||
else
|
||||
participant = findParticipant(addr);
|
||||
if (!participant) {
|
||||
lWarning() << "Participant " << participant << " removed a device but is not in the list of participants!";
|
||||
return;
|
||||
}
|
||||
participant->getPrivate()->removeDevice(gruu);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void ClientGroupChatRoom::onCallSessionSetReleased (const std::shared_ptr<const CallSession> &session) {
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ private:
|
|||
void onParticipantRemoved (const Address &addr) override;
|
||||
void onParticipantSetAdmin (const Address &addr, bool isAdmin) override;
|
||||
void onSubjectChanged (const std::string &subject) override;
|
||||
void onParticipantDeviceAdded (const Address &addr, const Address &gruu) override;
|
||||
void onParticipantDeviceRemoved (const Address &addr, const Address &gruu) override;
|
||||
|
||||
private:
|
||||
/* CallSessionListener */
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ public:
|
|||
virtual void onParticipantRemoved (const Address &addr) = 0;
|
||||
virtual void onParticipantSetAdmin (const Address &addr, bool isAdmin) = 0;
|
||||
virtual void onSubjectChanged (const std::string &subject) = 0;
|
||||
virtual void onParticipantDeviceAdded (const Address &addr, const Address &gruu) = 0;
|
||||
virtual void onParticipantDeviceRemoved (const Address &addr, const Address &gruu) = 0;
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
36
src/conference/participant-device.cpp
Normal file
36
src/conference/participant-device.cpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* participant-device.cpp
|
||||
* Copyright (C) 2010-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 2
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "participant-device.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
ParticipantDevice::ParticipantDevice (const Address &gruu) {
|
||||
mGruu = gruu;
|
||||
}
|
||||
|
||||
bool ParticipantDevice::operator== (const ParticipantDevice &device) const {
|
||||
return (mGruu == device.getGruu());
|
||||
}
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
48
src/conference/participant-device.h
Normal file
48
src/conference/participant-device.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* participant-device.h
|
||||
* Copyright (C) 2010-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 2
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _PARTICIPANT_DEVICE_H_
|
||||
#define _PARTICIPANT_DEVICE_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "address/address.h"
|
||||
#include "linphone/utils/general.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
class ParticipantDevice {
|
||||
public:
|
||||
explicit ParticipantDevice (const Address &gruu);
|
||||
|
||||
bool operator== (const ParticipantDevice &device) const;
|
||||
|
||||
inline const Address &getGruu () const {
|
||||
return mGruu;
|
||||
};
|
||||
|
||||
private:
|
||||
Address mGruu;
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
||||
#endif // ifndef _PARTICIPANT_DEVICE_H_
|
||||
|
|
@ -40,18 +40,23 @@ public:
|
|||
virtual ~ParticipantPrivate () = default;
|
||||
|
||||
std::shared_ptr<CallSession> createSession (const Conference &conference, const CallSessionParams *params, bool hasMedia, CallSessionListener *listener);
|
||||
std::shared_ptr<CallSession> getSession () const { return session; }
|
||||
bool isSubscribedToConferenceEventPackage () const { return _isSubscribedToConferenceEventPackage; }
|
||||
void subscribeToConferenceEventPackage (bool value) { _isSubscribedToConferenceEventPackage = value; }
|
||||
void removeSession () { session = nullptr; }
|
||||
void setAddress (const Address &newAddr) { addr = newAddr; }
|
||||
void setAdmin (bool isAdmin) { this->isAdmin = isAdmin; }
|
||||
inline std::shared_ptr<CallSession> getSession () const { return session; }
|
||||
inline bool isSubscribedToConferenceEventPackage () const { return _isSubscribedToConferenceEventPackage; }
|
||||
inline void subscribeToConferenceEventPackage (bool value) { _isSubscribedToConferenceEventPackage = value; }
|
||||
inline void removeSession () { session.reset(); }
|
||||
inline void setAddress (const Address &newAddr) { addr = newAddr; }
|
||||
inline void setAdmin (bool isAdmin) { this->isAdmin = isAdmin; }
|
||||
const std::list<ParticipantDevice>::const_iterator findDevice (const Address &gruu) const;
|
||||
const std::list<ParticipantDevice> &getDevices () const;
|
||||
void addDevice (const Address &gruu);
|
||||
void removeDevice (const Address &gruu);
|
||||
|
||||
private:
|
||||
Address addr;
|
||||
bool isAdmin = false;
|
||||
bool _isSubscribedToConferenceEventPackage = false;
|
||||
std::shared_ptr<CallSession> session;
|
||||
std::list<ParticipantDevice> devices;
|
||||
|
||||
L_DECLARE_PUBLIC(Participant);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "object/object-p.h"
|
||||
#include "participant-p.h"
|
||||
|
||||
|
|
@ -41,6 +43,29 @@ shared_ptr<CallSession> ParticipantPrivate::createSession (
|
|||
return session;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
const list<ParticipantDevice>::const_iterator ParticipantPrivate::findDevice (const Address &gruu) const {
|
||||
ParticipantDevice device(gruu);
|
||||
return find(devices.cbegin(), devices.cend(), device);
|
||||
}
|
||||
|
||||
const list<ParticipantDevice> &ParticipantPrivate::getDevices () const {
|
||||
return devices;
|
||||
}
|
||||
|
||||
void ParticipantPrivate::addDevice (const Address &gruu) {
|
||||
ParticipantDevice device(gruu);
|
||||
if(findDevice(gruu) == devices.cend())
|
||||
devices.push_back(device);
|
||||
}
|
||||
|
||||
void ParticipantPrivate::removeDevice (const Address &gruu) {
|
||||
ParticipantDevice device(gruu);
|
||||
if(findDevice(gruu) != devices.cend())
|
||||
devices.remove(device);
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
|
||||
Participant::Participant (const Address &address) : Object(*new ParticipantPrivate) {
|
||||
|
|
|
|||
|
|
@ -20,10 +20,12 @@
|
|||
#ifndef _PARTICIPANT_H_
|
||||
#define _PARTICIPANT_H_
|
||||
|
||||
#include "address/address.h"
|
||||
#include <list>
|
||||
|
||||
#include "address/address.h"
|
||||
#include "object/object.h"
|
||||
#include "conference/params/call-session-params.h"
|
||||
#include "conference/participant-device.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
|
|
|
|||
|
|
@ -94,4 +94,8 @@ void RemoteConference::onParticipantSetAdmin (const Address &addr, bool isAdmin)
|
|||
|
||||
void RemoteConference::onSubjectChanged (const std::string &subject) {}
|
||||
|
||||
void RemoteConference::onParticipantDeviceAdded (const Address &addr, const Address &gruu) {}
|
||||
|
||||
void RemoteConference::onParticipantDeviceRemoved (const Address &addr, const Address &gruu) {}
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ protected:
|
|||
void onParticipantRemoved (const Address &addr) override;
|
||||
void onParticipantSetAdmin (const Address &addr, bool isAdmin) override;
|
||||
void onSubjectChanged (const std::string &subject) override;
|
||||
void onParticipantDeviceAdded (const Address &addr, const Address &gruu) override;
|
||||
void onParticipantDeviceRemoved (const Address &addr, const Address &gruu) override;
|
||||
|
||||
protected:
|
||||
RemoteConferenceEventHandler *eventHandler = nullptr;
|
||||
|
|
|
|||
|
|
@ -434,9 +434,12 @@ private:
|
|||
void onParticipantRemoved (const Address &addr) override;
|
||||
void onParticipantSetAdmin (const Address &addr, bool isAdmin) override;
|
||||
void onSubjectChanged(const string &subject) override;
|
||||
void onParticipantDeviceAdded(const Address &addr, const Address &gruu) override;
|
||||
void onParticipantDeviceRemoved(const Address &addr, const Address &gruu) override;
|
||||
public:
|
||||
RemoteConferenceEventHandler *handler;
|
||||
map<string, bool> participants;
|
||||
map<string, int> participantDevices;
|
||||
string confSubject;
|
||||
};
|
||||
|
||||
|
|
@ -453,10 +456,12 @@ void ConferenceEventTester::onConferenceCreated (const Address &addr) {}
|
|||
void ConferenceEventTester::onConferenceTerminated (const Address &addr) {}
|
||||
|
||||
void ConferenceEventTester::onParticipantAdded (const Address &addr) {
|
||||
participants.insert(pair<string, int>(addr.asString(), false));
|
||||
participants.insert(pair<string, bool>(addr.asString(), FALSE));
|
||||
participantDevices.insert(pair<string, int>(addr.asString(), 0));
|
||||
}
|
||||
void ConferenceEventTester::onParticipantRemoved (const Address &addr) {
|
||||
participants.erase(addr.asString());
|
||||
participantDevices.erase(addr.asString());
|
||||
}
|
||||
|
||||
void ConferenceEventTester::onParticipantSetAdmin (const Address &addr, bool isAdmin) {
|
||||
|
|
@ -469,6 +474,19 @@ void ConferenceEventTester::onSubjectChanged(const string &subject) {
|
|||
confSubject = subject;
|
||||
}
|
||||
|
||||
void ConferenceEventTester::onParticipantDeviceAdded (const Address &addr, const Address &gruu) {
|
||||
auto it = participantDevices.find(addr.asString());
|
||||
if (it != participantDevices.end())
|
||||
it->second++;
|
||||
|
||||
}
|
||||
|
||||
void ConferenceEventTester::onParticipantDeviceRemoved (const Address &addr, const Address &gruu) {
|
||||
auto it = participantDevices.find(addr.asString());
|
||||
if (it != participantDevices.end() && it->second > 0)
|
||||
it->second--;
|
||||
}
|
||||
|
||||
void first_notify_parsing() {
|
||||
LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
|
||||
LinphoneAddress *confAddress = linphone_core_interpret_url(marie->lc, confUri);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue