@@ -46,24 +46,22 @@ static LogCounter
46
46
47
47
const string PemBeginCertificateTag = " -----BEGIN CERTIFICATE-----" ;
48
48
49
- PeerConnection::PeerConnection (Configuration config_)
50
- : config(std::move(config_)) {
49
+ PeerConnection::PeerConnection (Configuration config_) : config(std::move(config_)) {
51
50
PLOG_VERBOSE << " Creating PeerConnection" ;
52
51
53
-
54
52
if (config.certificatePemFile && config.keyPemFile ) {
55
53
std::promise<certificate_ptr> cert;
56
54
cert.set_value (std::make_shared<Certificate>(
57
- config.certificatePemFile ->find (PemBeginCertificateTag) != string::npos
58
- ? Certificate::FromString (*config.certificatePemFile , *config.keyPemFile )
59
- : Certificate::FromFile (*config.certificatePemFile , *config.keyPemFile ,
60
- config.keyPemPass .value_or (" " ))));
55
+ config.certificatePemFile ->find (PemBeginCertificateTag) != string::npos
56
+ ? Certificate::FromString (*config.certificatePemFile , *config.keyPemFile )
57
+ : Certificate::FromFile (*config.certificatePemFile , *config.keyPemFile ,
58
+ config.keyPemPass .value_or (" " ))));
61
59
mCertificate = cert.get_future ();
62
60
} else if (!config.certificatePemFile && !config.keyPemFile ) {
63
61
mCertificate = make_certificate (config.certificateType );
64
62
} else {
65
63
throw std::invalid_argument (
66
- " Either none or both certificate and key PEM files must be specified" );
64
+ " Either none or both certificate and key PEM files must be specified" );
67
65
}
68
66
69
67
if (config.portRangeEnd && config.portRangeBegin > config.portRangeEnd )
@@ -443,23 +441,24 @@ void PeerConnection::rollbackLocalDescription() {
443
441
444
442
bool PeerConnection::checkFingerprint (const std::string &fingerprint) {
445
443
std::lock_guard lock (mRemoteDescriptionMutex );
444
+ mRemoteFingerprint = fingerprint;
445
+
446
446
if (!mRemoteDescription || !mRemoteDescription ->fingerprint ())
447
447
return false ;
448
448
449
- if (config.disableFingerprintVerification ) {
449
+ if (config.disableFingerprintVerification ) {
450
450
PLOG_VERBOSE << " Skipping fingerprint validation" ;
451
- mRemoteFingerprint = fingerprint;
452
451
return true ;
453
452
}
454
453
455
454
auto expectedFingerprint = mRemoteDescription ->fingerprint ()->value ;
456
455
if (expectedFingerprint == fingerprint) {
457
456
PLOG_VERBOSE << " Valid fingerprint \" " << fingerprint << " \" " ;
458
- mRemoteFingerprint = fingerprint;
459
457
return true ;
460
458
}
461
459
462
- PLOG_ERROR << " Invalid fingerprint \" " << fingerprint << " \" , expected \" " << expectedFingerprint << " \" " ;
460
+ PLOG_ERROR << " Invalid fingerprint \" " << fingerprint << " \" , expected \" "
461
+ << expectedFingerprint << " \" " ;
463
462
return false ;
464
463
}
465
464
@@ -555,7 +554,7 @@ void PeerConnection::forwardMedia([[maybe_unused]] message_ptr message) {
555
554
void PeerConnection::dispatchMedia ([[maybe_unused]] message_ptr message) {
556
555
#if RTC_ENABLE_MEDIA
557
556
std::shared_lock lock (mTracksMutex ); // read-only
558
- if (mTrackLines .size ()== 1 ) {
557
+ if (mTrackLines .size () == 1 ) {
559
558
if (auto track = mTrackLines .front ().lock ())
560
559
track->incoming (message);
561
560
return ;
@@ -742,7 +741,7 @@ void PeerConnection::iterateDataChannels(
742
741
{
743
742
std::shared_lock lock (mDataChannelsMutex ); // read-only
744
743
locked.reserve (mDataChannels .size ());
745
- for (auto it = mDataChannels .begin (); it != mDataChannels .end (); ++it) {
744
+ for (auto it = mDataChannels .begin (); it != mDataChannels .end (); ++it) {
746
745
auto channel = it->second .lock ();
747
746
if (channel && !channel->isClosed ())
748
747
locked.push_back (std::move (channel));
@@ -811,7 +810,7 @@ void PeerConnection::iterateTracks(std::function<void(shared_ptr<Track> track)>
811
810
{
812
811
std::shared_lock lock (mTracksMutex ); // read-only
813
812
locked.reserve (mTrackLines .size ());
814
- for (auto it = mTrackLines .begin (); it != mTrackLines .end (); ++it) {
813
+ for (auto it = mTrackLines .begin (); it != mTrackLines .end (); ++it) {
815
814
auto track = it->lock ();
816
815
if (track && !track->isClosed ())
817
816
locked.push_back (std::move (track));
@@ -1308,6 +1307,7 @@ void PeerConnection::resetCallbacks() {
1308
1307
}
1309
1308
1310
1309
CertificateFingerprint PeerConnection::remoteFingerprint () {
1310
+ std::lock_guard lock (mRemoteDescriptionMutex );
1311
1311
if (mRemoteFingerprint )
1312
1312
return {CertificateFingerprint{mRemoteFingerprintAlgorithm , *mRemoteFingerprint }};
1313
1313
else
0 commit comments