reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
LibWebRTCRemoteParticipantDialogSet.cxx
Go to the documentation of this file.
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
4
5// sipX includes
6#if (_MSC_VER >= 1600)
7#include <stdint.h> // Use Visual Studio's stdint.h
8#define _MSC_STDINT_H_ // This define will ensure that stdint.h in sipXport tree is not used
9#endif
10
12#include "ReconSubsystem.hxx"
15#include "Conversation.hxx"
16#include "UserAgent.hxx"
17#include "MediaStreamEvent.hxx"
18
19#include "reTurn/StunTuple.hxx"
20
21#include <rutil/Log.hxx>
22#include <rutil/Logger.hxx>
23#include <rutil/Random.hxx>
24#include <rutil/DnsUtil.hxx>
28
30
31#include <utility>
32
33using namespace recon;
34using namespace reTurn;
35using namespace resip;
36using namespace std;
37
38#define RESIPROCATE_SUBSYSTEM ReconSubsystem::RECON
39
41 LibWebRTCMediaStackAdapter& libwebrtcMediaStackAdapter,
43 std::shared_ptr<ConversationProfile> conversationProfile) :
44 RemoteParticipantDialogSet(conversationManager, forkSelectMode, conversationProfile),
45 mLibWebRTCMediaStackAdapter(libwebrtcMediaStackAdapter),
46 mLocalRTPPort(0),
47 mAllocateLocalRTPPortFailed(false),
48 mPeerExpectsSAVPF(false),
49 //mNatTraversalMode(flowmanager::MediaStream::NoNatTraversal),
50 mMediaConnectionId(0),
51 mConnectionPortOnBridge(-1)
52{
53
54 InfoLog(<< "LibWebRTCRemoteParticipantDialogSet created.");
55}
56
58{
60 InfoLog(<< "LibWebRTCRemoteParticipantDialogSet destroyed. mActiveRemoteParticipantHandle=" << getActiveRemoteParticipantHandle());
61}
62
63void
64LibWebRTCRemoteParticipantDialogSet::processMediaStreamReadyEvent(std::shared_ptr<MediaStreamReadyEvent::StreamParams> streamParams)
65{
67 InfoLog( << "processMediaStreamReadyEvent: streamParams: " << *params);
68 mRtpTuple = params->getRtpTuple();
69 mRtcpTuple = params->getRtcpTuple(); // Check if we had operations pending on the media stream being ready
70
72}
73
74void
75LibWebRTCRemoteParticipantDialogSet::onMediaStreamReady(const StunTuple& rtpTuple, const StunTuple& rtcpTuple)
76{
77 // Get event into dum queue, so that callback is on dum thread
78 MediaStreamReadyEvent* event = new MediaStreamReadyEvent(&mConversationManager, mActiveRemoteParticipantHandle, std::make_shared<MediaStreamReadyEvent::ReTurnParams>(rtpTuple, rtcpTuple));
79 mDum.post(event);
80}
81
82void
83LibWebRTCRemoteParticipantDialogSet::onMediaStreamError(unsigned int errorCode)
84{
85 // Get event into dum queue, so that callback is on dum thread
87 mDum.post(event);
88}
89
90
91/* FIXME LibWebRTC std::shared_ptr<SipXMediaInterface>
92LibWebRTCRemoteParticipantDialogSet::getMediaInterface()
93{
94 if(!mMediaInterface)
95 {
96 // Get the media interface from the active participant
97 if(getUACOriginalRemoteParticipant())
98 {
99 mMediaInterface = dynamic_cast<SipXParticipant*>(getUACOriginalRemoteParticipant())->getMediaInterface();
100 }
101 else if(mDialogs.size() > 0)
102 {
103 // All participants in the set will have the same media interface - query from first
104 resip_assert(mDialogs.begin()->second);
105 mMediaInterface = dynamic_cast<SipXParticipant*>(mDialogs.begin()->second)->getMediaInterface();
106 }
107 }
108 resip_assert(mMediaInterface);
109 return mMediaInterface;
110} */
111
112int
114{
115 if(mConnectionPortOnBridge==-1)
116 {
117 // FIXME LibWebRTC getLocalRTPPort(); // This call will create a MediaConnection if not already created at this point
118 }
119 return mConnectionPortOnBridge;
120}
121
122void
124{
125 // FIXME LibWebRTC
126/* if(mMediaConnectionId)
127 {
128 getMediaInterface()->deleteConnection(mMediaConnectionId);
129 mMediaConnectionId = 0;
130 }*/
131
132
133}
134
135void
136LibWebRTCRemoteParticipantDialogSet::setActiveDestination(const char* address, unsigned short rtpPort, unsigned short rtcpPort)
137{
138// FIXME LibWebRTC
139}
140
141void
142LibWebRTCRemoteParticipantDialogSet::startDtlsClient(const char* address, unsigned short rtpPort, unsigned short rtcpPort)
143{
144// FIXME LibWebRTC
145}
146
147void
149{
150// FIXME LibWebRTC
151}
152
153bool
155{
156 // FIXME LibWebRTC
157 WarningLog(<<"createSRTPSession: FIXME");
158 return false;
159}
160
161AppDialog*
163{
164 /* FIXME LibWebRTC (HOMER) if(mFlowContext->getSipCallId().empty())
165 {
166 mFlowContext->setSipCallId(msg.header(h_CallId).value());
167 } */
168
170}
171
172void
174{
176 // Maintain MediaInterface mapping if connectionId is already allocated
177 if (mMediaConnectionId > 0)
178 {
179 // FIXME LibWebRTC getMediaInterface()->updateConnectionIdToPartipantHandleMapping(mMediaConnectionId, getActiveRemoteParticipantHandle());
180 }
181}
182
183void
184LibWebRTCRemoteParticipantDialogSet::onLibWebRTCEvent(const std::string& event_name, const json::Object& message)
185{
186 if(event_name == "IceGatheringDone")
187 {
188 dynamic_cast<LibWebRTCRemoteParticipant*>(mDialogs.begin()->second)->onIceGatheringDone();
189 }
190}
191
192bool
194{
195 //return mRtpTuple.getTransportType() == reTurn::StunTuple::None;
196 return false; // FIXME LibWebRTC
197}
198
199void
201{
202
203 if (sdp)
204 {
205 // FIXME LibWebRTC
206 sdp->session().origin().user() = "-";
207 // sdp->session().media().front().port() = mRtpTuple.getPort();
208 // sdp->session().connection() = SdpContents::Session::Connection(mRtpTuple.getAddress().is_v4() ? SdpContents::IP4 : SdpContents::IP6, mRtpTuple.getAddress().to_string().c_str()); // c=
209 }
210}
211
212
213/* ====================================================================
214
215 Copyright (c) 2022, Software Freedom Institute https://softwarefreedom.institute
216 Copyright (c) 2022, Daniel Pocock https://danielpocock.com
217 Copyright (c) 2021, SIP Spectrum, Inc.
218 Copyright (c) 2007-2008, Plantronics, Inc.
219 All rights reserved.
220
221 Redistribution and use in source and binary forms, with or without
222 modification, are permitted provided that the following conditions are
223 met:
224
225 1. Redistributions of source code must retain the above copyright
226 notice, this list of conditions and the following disclaimer.
227
228 2. Redistributions in binary form must reproduce the above copyright
229 notice, this list of conditions and the following disclaimer in the
230 documentation and/or other materials provided with the distribution.
231
232 3. Neither the name of Plantronics nor the names of its contributors
233 may be used to endorse or promote products derived from this
234 software without specific prior written permission.
235
236 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
237 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
238 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
239 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
240 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
241 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
242 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
243 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
244 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
245 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
246 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
247
248 ==================================================================== */
#define InfoLog(args_)
Definition Logger.hxx:131
#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 one of two main classes of concern to an application using the UserAgent library.
void setRemoteSDPFingerprint(const resip::Data &hashFunction, const resip::Data &fingerprint)
void startDtlsClient(const char *address, unsigned short rtpPort, unsigned short rtcpPort)
virtual void processMediaStreamReadyEvent(std::shared_ptr< MediaStreamReadyEvent::StreamParams > streamParams)
void setActiveDestination(const char *address, unsigned short rtpPort, unsigned short rtcpPort)
LibWebRTCRemoteParticipantDialogSet(ConversationManager &conversationManager, LibWebRTCMediaStackAdapter &libwebrtcMediaStackAdapter, ConversationManager::ParticipantForkSelectMode forkSelectMode=ConversationManager::ForkSelectAutomatic, std::shared_ptr< ConversationProfile > conversationProfile=nullptr)
virtual resip::AppDialog * createAppDialog(const resip::SipMessage &msg)
void onLibWebRTCEvent(const std::string &event_name, const json::Object &message)
bool createSRTPSession(resip::MediaConstants::SrtpCryptoSuite cryptoSuite, const char *remoteKey, size_t remoteKeyLen)
virtual void setActiveRemoteParticipantHandle(ParticipantHandle handle)
This class represent a remote participant.
This class represents events from the Media stream.
This class is used by Invite DialogSets.
virtual void setActiveRemoteParticipantHandle(ParticipantHandle handle)
virtual resip::AppDialog * createAppDialog(const resip::SipMessage &msg)
virtual ParticipantHandle getActiveRemoteParticipantHandle()
std::map< resip::DialogId, RemoteParticipant * > mDialogs
virtual void processMediaStreamReadyEvent(std::shared_ptr< MediaStreamReadyEvent::StreamParams > streamParams)
DialogUsageManager & mDum
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
const Data & user() const
returns the user string for the session
const Origin & origin() const
return session Origin line
Provides an interface to process and generate SDP bodies (MIME content-type application/sdp).
Session & session()
get the parsed SDP
Represents a SIP message.
void post(Message *msg)
Posts a Message to this TransactionUser's fifo.
unsigned int ParticipantHandle
dcm! – add UnusedChecking(_enum) below;