reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
GstConversation.cxx
Go to the documentation of this file.
1
2#include <rutil/Log.hxx>
3
4#include "GstConversation.hxx"
5#include "Participant.hxx"
9#include "UserAgent.hxx"
11#include "ReconSubsystem.hxx"
13
14
15#include <rutil/Logger.hxx>
17
18using namespace recon;
19using namespace resip;
20
21#define RESIPROCATE_SUBSYSTEM ReconSubsystem::RECON
22
23// The Gst integration is currently only designed to
24// bridge two participants. Gst itself can support
25// rooms with more than two participants.
26// FIXME: adapt to support rooms with more than two participants
27#define MAX_PARTICIPANTS 2
28
30 ConversationManager& conversationManager,
31 GstMediaStackAdapter& gstreamerMediaStackAdapter,
32 RelatedConversationSet* relatedConversationSet,
33 ConversationHandle sharedMediaInterfaceConvHandle,
35: Conversation(handle, conversationManager, relatedConversationSet, sharedMediaInterfaceConvHandle, autoHoldMode, MAX_PARTICIPANTS),
36 mGstMediaStackAdapter(gstreamerMediaStackAdapter),
37 mGstReInviteOnParticipantsPresent(true)
38{
39 if(mGstMediaStackAdapter.supportsMultipleMediaInterfaces())
40 {
41
42 // FIXME Gst
44 {
45 //GstConversation* sharedFlowConversation = dynamic_cast<GstConversation*>(mGstMediaStackAdapter.getConversation(sharedMediaInterfaceConvHandle));
46 //mMediaInterface = sharedFlowConversation->getMediaInterface();
47 }
48 else
49 {
50 //std::shared_ptr<BridgeMixer> mixer;
51 //mGstMediaStackAdapter.createMediaInterfaceAndMixer(false /* giveFocus?*/, // Focus will be given when local participant is added
52 // mMediaInterface,
53 // mixer);
54 //setBridgeMixer(mixer);
55 }
56 }
57 //InfoLog(<< "mBridgeMixer " << getBridgeMixerShared().use_count() << " " << getBridgeMixer());
58
59 std::shared_ptr<ConfigParse> cfg = getConfig();
60 if(cfg)
61 {
62 mGstReInviteOnParticipantsPresent = cfg->getConfigBool("GstReInviteOnParticipantsPresent",
63 mGstReInviteOnParticipantsPresent);
64 }
65}
66
68{
69 getBridgeMixerShared().reset(); // Make sure the mixer is destroyed before the media interface
70 //mMediaInterface.reset();
71}
72
73void
77
78void
80{
81 DebugLog(<<"confirmParticipant handle: " << getHandle()
82 << " numRemote: " << getNumRemoteParticipants()
83 << " participant: " << participant->getParticipantHandle());
84 GstRemoteParticipant *_p = dynamic_cast<GstRemoteParticipant*>(participant);
85 //std::shared_ptr<gstreamer::BaseRtpEndpoint> answeredEndpoint = _p->getEndpoint();
87 {
88 DebugLog(<<"we are first in the conversation");
89 //_p->waitingMode(); // FIXME - loopback is setup in buildSdpOffer/buildSdpAnswer logic
90 return;
91 }
93 {
94 WarningLog(<<"participants already here, can't join, numRemoteParticipants = " << getNumRemoteParticipants());
95 return;
96 }
97 DebugLog(<<"joining a Conversation with an existing Participant");
98
99 /*if(!answeredEndpoint)
100 {
101 ErrLog(<<"our endpoint is not initialized"); // FIXME
102 return;
103 }
104 if(!_p->getWaitingModeElement()->valid())
105 {
106 DebugLog(<<"the local endpoint is not yet in a valid state");
107 return;
108 }
109 DebugLog(<<"attempting to join two RemoteParticipants");
110 _p->getWaitingModeElement()->disconnect([this, _p, answeredEndpoint]{
111 answeredEndpoint->disconnect([this, _p, answeredEndpoint]{
112 // Find the other Participant / endpoint
113
114 Conversation::ParticipantMap& m = getParticipants();
115 GstRemoteParticipant* krp = 0; // FIXME - better to use shared_ptr
116 Conversation::ParticipantMap::iterator _it = m.begin();
117 for(;_it != m.end() && krp == 0; _it++)
118 {
119 krp = dynamic_cast<GstRemoteParticipant*>(_it->second.getParticipant());
120 if(krp == _p)
121 {
122 krp = 0;
123 }
124 }
125 resip_assert(krp);
126 std::shared_ptr<gstreamer::BaseRtpEndpoint> otherEndpoint = krp->getEndpoint();
127
128 krp->getWaitingModeElement()->disconnect([this, _p, answeredEndpoint, otherEndpoint, krp]{
129 otherEndpoint->disconnect([this, _p, answeredEndpoint, otherEndpoint, krp]{
130 otherEndpoint->connect([this, _p, answeredEndpoint, otherEndpoint, krp]{
131 answeredEndpoint->connect([this, _p, answeredEndpoint, otherEndpoint, krp]{
132 InfoLog(<<"peers connected");
133 if(mGstReInviteOnParticipantsPresent)
134 {
135 krp->reInvite();
136 }
137
138 ParticipantHandle partHandle1 = _p->getParticipantHandle();
139 ParticipantHandle partHandle2 = krp->getParticipantHandle();
140 for(int i = 1000; i <= 5000; i+=1000)
141 {
142 std::chrono::milliseconds _i = std::chrono::milliseconds(i);
143 std::chrono::milliseconds __i = std::chrono::milliseconds(i + 500);
144 getConversationManager().requestKeyframe(partHandle1, _i);
145 getConversationManager().requestKeyframe(partHandle2, _i);
146 getConversationManager().requestKeyframeFromPeer(partHandle1, __i);
147 getConversationManager().requestKeyframeFromPeer(partHandle2, __i);
148 }
149
150 }, *otherEndpoint);
151 }, *answeredEndpoint);
152 }, *krp->getWaitingModeElement());
153 }, *otherEndpoint); // otherEndpoint->disconnect()
154 }, *_p->getWaitingModeElement());
155 }, *answeredEndpoint); // answeredEndpoint->disconnect()
156 */
157}
158
159void
161{
162 DebugLog(<<"onParticipantRemoved, checking for remaining participants");
163 GstRemoteParticipant *_p = dynamic_cast<GstRemoteParticipant*>(participant);
164 /*std::shared_ptr<gstreamer::BaseRtpEndpoint> myEndpoint = _p->getEndpoint();
165 Conversation::ParticipantMap& m = getParticipants();
166 GstRemoteParticipant* krp = 0; // FIXME - better to use shared_ptr
167 Conversation::ParticipantMap::iterator _it = m.begin();
168 for(;_it != m.end() && krp == 0; _it++)
169 {
170 krp = dynamic_cast<GstRemoteParticipant*>(_it->second.getParticipant());
171 if(krp == _p)
172 {
173 krp = 0;
174 }
175 }
176 if(krp)
177 {
178 DebugLog(<<"remaining participant found");
179 std::shared_ptr<gstreamer::BaseRtpEndpoint> otherEndpoint = krp->getEndpoint();
180 otherEndpoint->disconnect([this, krp, myEndpoint, otherEndpoint](){
181 myEndpoint->disconnect([this, krp](){
182 krp->waitingMode();
183 }, *otherEndpoint);
184 }, *myEndpoint);
185 }*/
186
187 return;
188}
189
190/* ====================================================================
191
192 Copyright (c) 2022, Software Freedom Institute https://softwarefreedom.institute
193 Copyright (c) 2022, Daniel Pocock https://danielpocock.com
194 Copyright (c) 2021, SIP Spectrum, Inc. www.sipspectrum.com
195 Copyright (c) 2007-2008, Plantronics, Inc.
196 All rights reserved.
197
198 Redistribution and use in source and binary forms, with or without
199 modification, are permitted provided that the following conditions are
200 met:
201
202 1. Redistributions of source code must retain the above copyright
203 notice, this list of conditions and the following disclaimer.
204
205 2. Redistributions in binary form must reproduce the above copyright
206 notice, this list of conditions and the following disclaimer in the
207 documentation and/or other materials provided with the distribution.
208
209 3. Neither the name of Plantronics nor the names of its contributors
210 may be used to endorse or promote products derived from this
211 software without specific prior written permission.
212
213 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
214 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
215 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
216 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
217 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
218 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
219 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
220 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
221 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
222 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
223 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
224
225 ==================================================================== */
#define MAX_PARTICIPANTS
#define DebugLog(args_)
Definition Logger.hxx:128
#define WarningLog(args_)
Definition Logger.hxx:134
This class is one of two main classes of concern to an application using the UserAgent library.
This class is used to manage membership of participants.
unsigned int getNumRemoteParticipants()
std::shared_ptr< resip::ConfigParse > getConfig()
std::shared_ptr< BridgeMixer > getBridgeMixerShared()
ConversationHandle getHandle()
virtual bool isSharingMediaInterfaceWithAnotherConversation()
virtual void onParticipantAdded(Participant *participant)
GstConversation(ConversationHandle handle, ConversationManager &conversationManager, GstMediaStackAdapter &gstreamerMediaStackAdapter, RelatedConversationSet *relatedConversationSet, ConversationHandle sharedMediaInterfaceConvHandle, ConversationManager::AutoHoldMode autoHoldMode)
virtual void confirmParticipant(Participant *participant)
virtual void onParticipantRemoved(Participant *participant)
This class is one of two main classes of concern to an application using the UserAgent library.
virtual bool supportsMultipleMediaInterfaces() override
This class represent a remote participant.
This is the base class for a RemoteParticipant, LocalParticipant and a MediaResourceParticipant.
virtual ParticipantHandle getParticipantHandle()
This is used to keep a mapping between all related conversations.
unsigned int ConversationHandle
dcm! – add UnusedChecking(_enum) below;