@@ -41,6 +41,7 @@ Napi::Object PeerConnectionWrapper::Init(Napi::Env env, Napi::Object exports)
41
41
InstanceMethod (" setRemoteDescription" , &PeerConnectionWrapper::setRemoteDescription),
42
42
InstanceMethod (" localDescription" , &PeerConnectionWrapper::localDescription),
43
43
InstanceMethod (" remoteDescription" , &PeerConnectionWrapper::remoteDescription),
44
+ InstanceMethod (" remoteFingerprint" , &PeerConnectionWrapper::remoteFingerprint),
44
45
InstanceMethod (" addRemoteCandidate" , &PeerConnectionWrapper::addRemoteCandidate),
45
46
InstanceMethod (" createDataChannel" , &PeerConnectionWrapper::createDataChannel),
46
47
InstanceMethod (" addTrack" , &PeerConnectionWrapper::addTrack),
@@ -214,6 +215,10 @@ PeerConnectionWrapper::PeerConnectionWrapper(const Napi::CallbackInfo &info) : N
214
215
if (config.Get (" disableAutoNegotiation" ).IsBoolean ())
215
216
rtcConfig.disableAutoNegotiation = config.Get (" disableAutoNegotiation" ).As <Napi::Boolean >();
216
217
218
+ // disableAutoGathering option
219
+ if (config.Get (" disableAutoGathering" ).IsBoolean ())
220
+ rtcConfig.disableAutoGathering = config.Get (" disableAutoGathering" ).As <Napi::Boolean >();
221
+
217
222
// forceMediaTransport option
218
223
if (config.Get (" forceMediaTransport" ).IsBoolean ())
219
224
rtcConfig.forceMediaTransport = config.Get (" forceMediaTransport" ).As <Napi::Boolean >();
@@ -331,6 +336,7 @@ void PeerConnectionWrapper::setLocalDescription(const Napi::CallbackInfo &info)
331
336
}
332
337
333
338
rtc::Description::Type type = rtc::Description::Type::Unspec;
339
+ rtc::LocalDescriptionInit init;
334
340
335
341
// optional
336
342
if (length > 0 )
@@ -356,7 +362,29 @@ void PeerConnectionWrapper::setLocalDescription(const Napi::CallbackInfo &info)
356
362
type = rtc::Description::Type::Rollback;
357
363
}
358
364
359
- mRtcPeerConnPtr ->setLocalDescription (type);
365
+ // optional
366
+ if (length > 1 )
367
+ {
368
+ PLOG_DEBUG << " setLocalDescription() called with LocalDescriptionInit" ;
369
+
370
+ if (info[1 ].IsObject ())
371
+ {
372
+ PLOG_DEBUG << " setLocalDescription() called with LocalDescriptionInit as object" ;
373
+ Napi::Object obj = info[1 ].As <Napi::Object>();
374
+
375
+ if (obj.Get (" iceUfrag" ).IsString ()) {
376
+ PLOG_DEBUG << " setLocalDescription() has ufrag" ;
377
+ init.iceUfrag = obj.Get (" iceUfrag" ).As <Napi::String>();
378
+ }
379
+
380
+ if (obj.Get (" icePwd" ).IsString ()) {
381
+ PLOG_DEBUG << " setLocalDescription() has password" ;
382
+ init.icePwd = obj.Get (" icePwd" ).As <Napi::String>();
383
+ }
384
+ }
385
+ }
386
+
387
+ mRtcPeerConnPtr ->setLocalDescription (type, init);
360
388
}
361
389
362
390
void PeerConnectionWrapper::setRemoteDescription (const Napi::CallbackInfo &info)
@@ -1002,7 +1030,34 @@ Napi::Value PeerConnectionWrapper::maxMessageSize(const Napi::CallbackInfo &info
1002
1030
1003
1031
try
1004
1032
{
1005
- return Napi::Number::New (env, mRtcPeerConnPtr ->remoteMaxMessageSize ());
1033
+ return Napi::Array::New (env, mRtcPeerConnPtr ->remoteMaxMessageSize ());
1034
+ }
1035
+ catch (std::exception &ex)
1036
+ {
1037
+ Napi::Error::New (env, std::string (" libdatachannel error: " ) + ex.what ()).ThrowAsJavaScriptException ();
1038
+ return Napi::Number::New (info.Env (), 0 );
1039
+ }
1040
+ }
1041
+
1042
+ Napi::Value PeerConnectionWrapper::remoteFingerprint (const Napi::CallbackInfo &info)
1043
+ {
1044
+ PLOG_DEBUG << " remoteFingerprints() called" ;
1045
+ Napi::Env env = info.Env ();
1046
+
1047
+ if (!mRtcPeerConnPtr )
1048
+ {
1049
+ return Napi::Number::New (info.Env (), 0 );
1050
+ }
1051
+
1052
+ try
1053
+ {
1054
+ auto fingerprint = mRtcPeerConnPtr ->remoteFingerprint ();
1055
+
1056
+ Napi::Object fingerprintObject = Napi::Object::New (env);
1057
+ fingerprintObject.Set (" value" , fingerprint.value );
1058
+ fingerprintObject.Set (" algorithm" , rtc::CertificateFingerprint::AlgorithmIdentifier (fingerprint.algorithm ));
1059
+
1060
+ return fingerprintObject;
1006
1061
}
1007
1062
catch (std::exception &ex)
1008
1063
{
0 commit comments