-
-
Notifications
You must be signed in to change notification settings - Fork 199
Expand file tree
/
Copy pathPeerConnection.cpp
More file actions
783 lines (620 loc) · 21.9 KB
/
Copy pathPeerConnection.cpp
File metadata and controls
783 lines (620 loc) · 21.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
#include "api/jsep.h"
#include "api/peer_connection_interface.h"
#define MSC_CLASS "PeerConnection"
#include "Logger.hpp"
#include "MediaSoupClientErrors.hpp"
#include "PeerConnection.hpp"
#include "api/video_codecs/video_decoder_factory_template.h"
#include "api/video_codecs/video_decoder_factory_template_dav1d_adapter.h"
#include "api/video_codecs/video_decoder_factory_template_libvpx_vp8_adapter.h"
#include "api/video_codecs/video_decoder_factory_template_libvpx_vp9_adapter.h"
#include "api/video_codecs/video_decoder_factory_template_open_h264_adapter.h"
#include "api/video_codecs/video_encoder_factory_template.h"
#include "api/video_codecs/video_encoder_factory_template_libaom_av1_adapter.h"
#include "api/video_codecs/video_encoder_factory_template_libvpx_vp8_adapter.h"
#include "api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter.h"
#include "api/video_codecs/video_encoder_factory_template_open_h264_adapter.h"
#include <api/audio_codecs/builtin_audio_decoder_factory.h>
#include <api/audio_codecs/builtin_audio_encoder_factory.h>
#include <api/create_peerconnection_factory.h>
#include <api/video_codecs/builtin_video_decoder_factory.h>
#include <api/video_codecs/builtin_video_encoder_factory.h>
#include <rtc_base/ssl_adapter.h>
using json = nlohmann::json;
/**
* Waits for a future while pumping the current WebRTC thread's message queue
* if we are running on one.
*
* Without this, calling PeerConnection methods from the signaling thread
* deadlocks: future.get() blocks the thread, preventing it from processing
* the observer callback task that would resolve the future.
*/
template<typename T>
static T waitForFuture(std::future<T>& future)
{
auto* thread = webrtc::Thread::Current();
if (thread)
{
// We are on a WebRTC thread. Pump its message queue so observer
// callbacks (posted as tasks) can fire while we wait.
while (future.wait_for(std::chrono::milliseconds(0)) != std::future_status::ready)
{
thread->ProcessMessages(10);
}
}
return future.get();
}
namespace mediasoupclient
{
/* Static. */
// clang-format off
std::map<webrtc::PeerConnectionInterface::IceConnectionState, const std::string>
PeerConnection::iceConnectionState2String =
{
{ webrtc::PeerConnectionInterface::IceConnectionState::kIceConnectionNew, "new" },
{ webrtc::PeerConnectionInterface::IceConnectionState::kIceConnectionChecking, "checking" },
{ webrtc::PeerConnectionInterface::IceConnectionState::kIceConnectionConnected, "connected" },
{ webrtc::PeerConnectionInterface::IceConnectionState::kIceConnectionCompleted, "completed" },
{ webrtc::PeerConnectionInterface::IceConnectionState::kIceConnectionFailed, "failed" },
{ webrtc::PeerConnectionInterface::IceConnectionState::kIceConnectionDisconnected, "disconnected" },
{ webrtc::PeerConnectionInterface::IceConnectionState::kIceConnectionClosed, "closed" }
};
std::map<webrtc::PeerConnectionInterface::IceGatheringState, const std::string>
PeerConnection::iceGatheringState2String =
{
{ webrtc::PeerConnectionInterface::IceGatheringState::kIceGatheringNew, "new" },
{ webrtc::PeerConnectionInterface::IceGatheringState::kIceGatheringGathering, "gathering" },
{ webrtc::PeerConnectionInterface::IceGatheringState::kIceGatheringComplete, "complete" }
};
std::map<webrtc::PeerConnectionInterface::SignalingState, const std::string>
PeerConnection::signalingState2String =
{
{ webrtc::PeerConnectionInterface::SignalingState::kStable, "stable" },
{ webrtc::PeerConnectionInterface::SignalingState::kHaveLocalOffer, "have-local-offer" },
{ webrtc::PeerConnectionInterface::SignalingState::kHaveLocalPrAnswer, "have-local-pranswer" },
{ webrtc::PeerConnectionInterface::SignalingState::kHaveRemoteOffer, "have-remote-offer" },
{ webrtc::PeerConnectionInterface::SignalingState::kHaveRemotePrAnswer, "have-remote-pranswer" },
{ webrtc::PeerConnectionInterface::SignalingState::kClosed, "closed" }
};
// clang-format on
/* Instance methods. */
PeerConnection::PeerConnection(
PeerConnection::PrivateListener* privateListener, const PeerConnection::Options* options)
{
MSC_TRACE();
webrtc::PeerConnectionInterface::RTCConfiguration config;
if (options != nullptr)
{
config = options->config;
}
// PeerConnection factory provided.
if ((options != nullptr) && (options->factory != nullptr))
{
this->peerConnectionFactory =
webrtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface>(options->factory);
}
else
{
this->networkThread = webrtc::Thread::CreateWithSocketServer();
this->signalingThread = webrtc::Thread::Create();
this->workerThread = webrtc::Thread::Create();
this->networkThread->SetName("network_thread", nullptr);
this->signalingThread->SetName("signaling_thread", nullptr);
this->workerThread->SetName("worker_thread", nullptr);
if (!this->networkThread->Start() || !this->signalingThread->Start() || !this->workerThread->Start())
{
MSC_THROW_INVALID_STATE_ERROR("thread start errored");
}
this->peerConnectionFactory = webrtc::CreatePeerConnectionFactory(
this->networkThread.get(),
this->workerThread.get(),
this->signalingThread.get(),
nullptr /*default_adm*/,
webrtc::CreateBuiltinAudioEncoderFactory(),
webrtc::CreateBuiltinAudioDecoderFactory(),
std::make_unique<webrtc::VideoEncoderFactoryTemplate<
webrtc::LibvpxVp8EncoderTemplateAdapter,
webrtc::LibvpxVp9EncoderTemplateAdapter,
webrtc::OpenH264EncoderTemplateAdapter,
webrtc::LibaomAv1EncoderTemplateAdapter>>(),
std::make_unique<webrtc::VideoDecoderFactoryTemplate<
webrtc::LibvpxVp8DecoderTemplateAdapter,
webrtc::LibvpxVp9DecoderTemplateAdapter,
webrtc::OpenH264DecoderTemplateAdapter,
webrtc::Dav1dDecoderTemplateAdapter>>(),
nullptr /*audio_mixer*/,
nullptr /*audio_processing*/,
nullptr /*audio_frame_processor*/,
nullptr /*field_trials*/);
}
// Set SDP semantics to Unified Plan.
config.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan;
// Create the webrtc::Peerconnection.
auto pcOrError = this->peerConnectionFactory->CreatePeerConnectionOrError(
config, webrtc::PeerConnectionDependencies{ privateListener });
if (!pcOrError.ok())
{
MSC_THROW_INVALID_STATE_ERROR(
"failed to create peer connection: %s", pcOrError.error().message());
}
this->pc = pcOrError.value();
}
void PeerConnection::Close()
{
MSC_TRACE();
this->pc->Close();
}
webrtc::PeerConnectionInterface::RTCConfiguration PeerConnection::GetConfiguration() const
{
MSC_TRACE();
return this->pc->GetConfiguration();
}
bool PeerConnection::SetConfiguration(const webrtc::PeerConnectionInterface::RTCConfiguration& config)
{
MSC_TRACE();
webrtc::RTCError error = this->pc->SetConfiguration(config);
if (error.ok())
{
return true;
}
MSC_WARN(
"webrtc::PeerConnection::SetConfiguration failed [%s:%s]",
std::string(webrtc::ToString(error.type())).c_str(),
error.message());
return false;
}
std::string PeerConnection::CreateOffer(
const webrtc::PeerConnectionInterface::RTCOfferAnswerOptions& options)
{
MSC_TRACE();
CreateSessionDescriptionObserver* sessionDescriptionObserver =
new webrtc::RefCountedObject<CreateSessionDescriptionObserver>();
auto future = sessionDescriptionObserver->GetFuture();
this->pc->CreateOffer(sessionDescriptionObserver, options);
return waitForFuture(future);
}
std::string PeerConnection::CreateAnswer(
const webrtc::PeerConnectionInterface::RTCOfferAnswerOptions& options)
{
MSC_TRACE();
CreateSessionDescriptionObserver* sessionDescriptionObserver =
new webrtc::RefCountedObject<CreateSessionDescriptionObserver>();
auto future = sessionDescriptionObserver->GetFuture();
this->pc->CreateAnswer(sessionDescriptionObserver, options);
return waitForFuture(future);
}
void PeerConnection::SetLocalDescription(webrtc::SdpType type, const std::string& sdp)
{
MSC_TRACE();
webrtc::SdpParseError error;
std::unique_ptr<webrtc::SessionDescriptionInterface> sessionDescription;
webrtc::scoped_refptr<SetLocalDescriptionObserver> observer(
new webrtc::RefCountedObject<SetLocalDescriptionObserver>());
auto future = observer->GetFuture();
sessionDescription = webrtc::CreateSessionDescription(type, sdp, &error);
if (sessionDescription == nullptr)
{
MSC_WARN(
"webrtc::CreateSessionDescription failed [%s]: %s",
error.line.c_str(),
error.description.c_str());
observer->Reject(error.description);
waitForFuture(future);
return;
}
this->pc->SetLocalDescription(std::move(sessionDescription), observer);
waitForFuture(future);
}
void PeerConnection::SetRemoteDescription(webrtc::SdpType type, const std::string& sdp)
{
MSC_TRACE();
webrtc::SdpParseError error;
std::unique_ptr<webrtc::SessionDescriptionInterface> sessionDescription;
webrtc::scoped_refptr<SetRemoteDescriptionObserver> observer(
new webrtc::RefCountedObject<SetRemoteDescriptionObserver>());
auto future = observer->GetFuture();
sessionDescription = webrtc::CreateSessionDescription(type, sdp, &error);
if (sessionDescription == nullptr)
{
MSC_WARN(
"webrtc::CreateSessionDescription failed [%s]: %s",
error.line.c_str(),
error.description.c_str());
observer->Reject(error.description);
waitForFuture(future);
return;
}
this->pc->SetRemoteDescription(std::move(sessionDescription), observer);
waitForFuture(future);
}
std::string PeerConnection::GetLocalDescription()
{
MSC_TRACE();
const auto* desc = this->pc->local_description();
std::string sdp;
desc->ToString(&sdp);
return sdp;
}
std::string PeerConnection::GetRemoteDescription()
{
MSC_TRACE();
const auto* desc = this->pc->remote_description();
std::string sdp;
desc->ToString(&sdp);
return sdp;
}
std::vector<webrtc::scoped_refptr<webrtc::RtpTransceiverInterface>> PeerConnection::GetTransceivers() const
{
MSC_TRACE();
return this->pc->GetTransceivers();
}
webrtc::scoped_refptr<webrtc::RtpTransceiverInterface> PeerConnection::AddTransceiver(
webrtc::MediaType mediaType)
{
MSC_TRACE();
auto result = this->pc->AddTransceiver(mediaType);
if (!result.ok())
{
webrtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver = nullptr;
return transceiver;
}
return result.value();
}
webrtc::scoped_refptr<webrtc::RtpTransceiverInterface> PeerConnection::AddTransceiver(
webrtc::scoped_refptr<webrtc::MediaStreamTrackInterface> track,
webrtc::RtpTransceiverInit rtpTransceiverInit)
{
MSC_TRACE();
/*
* Define a stream id so the generated local description is correct.
* - with a stream id: "a=ssrc:<ssrc-id> mslabel:<value>"
* - without a stream id: "a=ssrc:<ssrc-id> mslabel:"
*
* The second is incorrect (https://tools.ietf.org/html/rfc5576#section-4.1)
*/
rtpTransceiverInit.stream_ids.emplace_back("0");
auto result = this->pc->AddTransceiver(
track, rtpTransceiverInit); // NOLINT(performance-unnecessary-value-param)
if (!result.ok())
{
webrtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver = nullptr;
return transceiver;
}
return result.value();
}
std::vector<webrtc::scoped_refptr<webrtc::RtpSenderInterface>> PeerConnection::GetSenders()
{
MSC_TRACE();
return this->pc->GetSenders();
}
bool PeerConnection::RemoveTrack(webrtc::scoped_refptr<webrtc::RtpSenderInterface> sender)
{
MSC_TRACE();
const auto result = this->pc->RemoveTrackOrError(std::move(sender));
return result.ok();
}
json PeerConnection::GetStats()
{
MSC_TRACE();
webrtc::scoped_refptr<RTCStatsCollectorCallback> callback(
new webrtc::RefCountedObject<RTCStatsCollectorCallback>());
auto future = callback->GetFuture();
this->pc->GetStats(callback.get());
return waitForFuture(future);
}
json PeerConnection::GetStats(webrtc::scoped_refptr<webrtc::RtpSenderInterface> selector)
{
MSC_TRACE();
webrtc::scoped_refptr<RTCStatsCollectorCallback> callback(
new webrtc::RefCountedObject<RTCStatsCollectorCallback>());
auto future = callback->GetFuture();
this->pc->GetStats(std::move(selector), callback);
return waitForFuture(future);
}
json PeerConnection::GetStats(webrtc::scoped_refptr<webrtc::RtpReceiverInterface> selector)
{
MSC_TRACE();
webrtc::scoped_refptr<RTCStatsCollectorCallback> callback(
new webrtc::RefCountedObject<RTCStatsCollectorCallback>());
auto future = callback->GetFuture();
this->pc->GetStats(std::move(selector), callback);
return waitForFuture(future);
}
webrtc::scoped_refptr<webrtc::DataChannelInterface> PeerConnection::CreateDataChannel(
const std::string& label, const webrtc::DataChannelInit* config)
{
MSC_TRACE();
const auto result = this->pc->CreateDataChannelOrError(label, config);
if (result.ok())
{
MSC_DEBUG("Success creating data channel");
}
else
{
MSC_THROW_ERROR("Failed creating data channel");
}
return result.value();
}
/* SetLocalDescriptionObserver */
std::future<void> PeerConnection::SetLocalDescriptionObserver::GetFuture()
{
MSC_TRACE();
return this->promise.get_future();
}
void PeerConnection::SetLocalDescriptionObserver::Reject(const std::string& error)
{
MSC_TRACE();
this->promise.set_exception(std::make_exception_ptr(MediaSoupClientError(error.c_str())));
}
void PeerConnection::SetLocalDescriptionObserver::OnSetLocalDescriptionComplete(webrtc::RTCError error)
{
MSC_TRACE();
if (!error.ok())
{
MSC_WARN(
"webrtc::SetLocalDescriptionObserverWrapper failure [%s:%s]",
std::string(webrtc::ToString(error.type())).c_str(),
error.message());
auto message = std::string(error.message());
this->Reject(message);
}
else
{
this->promise.set_value();
}
};
/* SetRemoteDescriptionObserver */
std::future<void> PeerConnection::SetRemoteDescriptionObserver::GetFuture()
{
MSC_TRACE();
return this->promise.get_future();
}
void PeerConnection::SetRemoteDescriptionObserver::Reject(const std::string& error)
{
MSC_TRACE();
this->promise.set_exception(std::make_exception_ptr(MediaSoupClientError(error.c_str())));
}
void PeerConnection::SetRemoteDescriptionObserver::OnSetRemoteDescriptionComplete(webrtc::RTCError error)
{
MSC_TRACE();
if (!error.ok())
{
MSC_WARN(
"webrtc::SetRemoteDescriptionObserverWrapper failure [%s:%s]",
std::string(webrtc::ToString(error.type())).c_str(),
error.message());
auto message = std::string(error.message());
this->Reject(message);
}
else
{
this->promise.set_value();
}
};
/* SetSessionDescriptionObserver */
std::future<void> PeerConnection::SetSessionDescriptionObserver::GetFuture()
{
MSC_TRACE();
return this->promise.get_future();
}
void PeerConnection::SetSessionDescriptionObserver::Reject(const std::string& error)
{
MSC_TRACE();
this->promise.set_exception(std::make_exception_ptr(MediaSoupClientError(error.c_str())));
}
void PeerConnection::SetSessionDescriptionObserver::OnSuccess()
{
MSC_TRACE();
this->promise.set_value();
};
void PeerConnection::SetSessionDescriptionObserver::OnFailure(webrtc::RTCError error)
{
MSC_TRACE();
MSC_WARN(
"webrtc::SetSessionDescriptionObserver failure [%s:%s]",
std::string(webrtc::ToString(error.type())).c_str(),
error.message());
auto message = std::string(error.message());
this->Reject(message);
};
/* CreateSessionDescriptionObserver */
std::future<std::string> PeerConnection::CreateSessionDescriptionObserver::GetFuture()
{
MSC_TRACE();
return this->promise.get_future();
}
void PeerConnection::CreateSessionDescriptionObserver::Reject(const std::string& error)
{
MSC_TRACE();
this->promise.set_exception(std::make_exception_ptr(MediaSoupClientError(error.c_str())));
}
void PeerConnection::CreateSessionDescriptionObserver::OnSuccess(
webrtc::SessionDescriptionInterface* desc)
{
MSC_TRACE();
// This callback should take the ownership of |desc|.
std::unique_ptr<webrtc::SessionDescriptionInterface> ownedDesc(desc);
std::string sdp;
ownedDesc->ToString(&sdp);
this->promise.set_value(sdp);
};
void PeerConnection::CreateSessionDescriptionObserver::OnFailure(webrtc::RTCError error)
{
MSC_TRACE();
MSC_WARN(
"webtc::CreateSessionDescriptionObserver failure [%s:%s]",
std::string(webrtc::ToString(error.type())).c_str(),
error.message());
auto message = std::string(error.message());
this->Reject(message);
}
/* RTCStatsCollectorCallback */
std::future<json> PeerConnection::RTCStatsCollectorCallback::GetFuture()
{
MSC_TRACE();
return this->promise.get_future();
}
void PeerConnection::RTCStatsCollectorCallback::OnStatsDelivered(
const webrtc::scoped_refptr<const webrtc::RTCStatsReport>& report)
{
MSC_TRACE();
std::string s = report->ToJson();
// RtpReceiver stats JSON string is sometimes empty.
if (s.empty())
{
this->promise.set_value(json::array());
}
else
{
this->promise.set_value(json::parse(s));
}
};
/* PeerConnection::PrivateListener */
/**
* Triggered when the SignalingState changed.
*/
void PeerConnection::PrivateListener::OnSignalingChange(
webrtc::PeerConnectionInterface::SignalingState newState)
{
MSC_TRACE();
MSC_DEBUG("[newState:%s]", PeerConnection::signalingState2String[newState].c_str());
}
/**
* Triggered when media is received on a new stream from remote peer.
*/
void PeerConnection::PrivateListener::OnAddStream(
webrtc::scoped_refptr<webrtc::MediaStreamInterface> /*stream*/)
{
MSC_TRACE();
}
/**
* Triggered when a remote peer closes a stream.
*/
void PeerConnection::PrivateListener::OnRemoveStream(
webrtc::scoped_refptr<webrtc::MediaStreamInterface> /*stream*/)
{
MSC_TRACE();
}
/**
* Triggered when a remote peer opens a data channel.
*/
void PeerConnection::PrivateListener::OnDataChannel(
webrtc::scoped_refptr<webrtc::DataChannelInterface> /*dataChannel*/)
{
MSC_TRACE();
}
/**
* Triggered when renegotiation is needed. For example, an ICE restart has begun.
*/
void PeerConnection::PrivateListener::OnRenegotiationNeeded()
{
MSC_TRACE();
}
/**
* Triggered any time the IceConnectionState changes.
*
* Note that our ICE states lag behind the standard slightly. The most
* notable differences include the fact that "failed" occurs after 15
* seconds, not 30, and this actually represents a combination ICE + DTLS
* state, so it may be "failed" if DTLS fails while ICE succeeds.
*/
void PeerConnection::PrivateListener::OnIceConnectionChange(
webrtc::PeerConnectionInterface::IceConnectionState newState)
{
MSC_TRACE();
MSC_DEBUG("[newState:%s]", PeerConnection::iceConnectionState2String[newState].c_str());
}
/**
* Triggered any time the IceGatheringState changes.
*/
void PeerConnection::PrivateListener::OnIceGatheringChange(
webrtc::PeerConnectionInterface::IceGatheringState newState)
{
MSC_TRACE();
MSC_DEBUG("[newState:%s]", PeerConnection::iceGatheringState2String[newState].c_str());
}
/**
* Triggered when a new ICE candidate has been gathered.
*/
void PeerConnection::PrivateListener::OnIceCandidate(const webrtc::IceCandidateInterface* candidate)
{
MSC_TRACE();
std::string candidateStr;
candidate->ToString(&candidateStr);
MSC_DEBUG("[candidate:%s]", candidateStr.c_str());
}
/**
* Triggered when the ICE candidates have been removed.
*/
void PeerConnection::PrivateListener::OnIceCandidatesRemoved(
const std::vector<webrtc::Candidate>& /*candidates*/)
{
MSC_TRACE();
}
/**
* Triggered when the ICE connection receiving status changes.
*/
void PeerConnection::PrivateListener::OnIceConnectionReceivingChange(bool /*receiving*/)
{
MSC_TRACE();
}
/**
* Triggered when a receiver and its track are created.
*
* Note: This is called with both Plan B and Unified Plan semantics. Unified
* Plan users should prefer OnTrack, OnAddTrack is only called as backwards
* compatibility (and is called in the exact same situations as OnTrack).
*/
void PeerConnection::PrivateListener::OnAddTrack(
webrtc::scoped_refptr<webrtc::RtpReceiverInterface> /*receiver*/,
const std::vector<webrtc::scoped_refptr<webrtc::MediaStreamInterface>>& /*streams*/)
{
MSC_TRACE();
}
/**
* Triggered when signaling indicates a transceiver will be receiving
*
* media from the remote endpoint. This is fired during a call to
* SetRemoteDescription. The receiving track can be accessed by:
* transceiver->receiver()->track() and its associated streams by
* transceiver->receiver()->streams().
*
* NOTE: This will only be called if Unified Plan semantics are specified.
* This behavior is specified in section 2.2.8.2.5 of the "Set the
* RTCSessionDescription" algorithm:
* https://w3c.github.io/webrtc-pc/#set-description
*/
void PeerConnection::PrivateListener::OnTrack(
webrtc::scoped_refptr<webrtc::RtpTransceiverInterface> /*transceiver*/)
{
MSC_TRACE();
}
/**
* Triggered when signaling indicates that media will no longer be received on a
* track.
*
* With Plan B semantics, the given receiver will have been removed from the
* PeerConnection and the track muted.
* With Unified Plan semantics, the receiver will remain but the transceiver
* will have changed direction to either sendonly or inactive.
* https://w3c.github.io/webrtc-pc/#process-remote-track-removal
*/
void PeerConnection::PrivateListener::OnRemoveTrack(
webrtc::scoped_refptr<webrtc::RtpReceiverInterface> /*receiver*/)
{
MSC_TRACE();
}
/**
* Triggered when an interesting usage is detected by WebRTC.
*
* An appropriate action is to add information about the context of the
* PeerConnection and write the event to some kind of "interesting events"
* log function.
* The heuristics for defining what constitutes "interesting" are
* implementation-defined.
*/
void PeerConnection::PrivateListener::OnInterestingUsage(int /*usagePattern*/)
{
MSC_TRACE();
}
} // namespace mediasoupclient