@@ -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 >();
@@ -251,6 +256,17 @@ PeerConnectionWrapper::PeerConnectionWrapper(const Napi::CallbackInfo &info) : N
251
256
rtcConfig.disableFingerprintVerification = config.Get (" disableFingerprintVerification" ).As <Napi::Boolean >();
252
257
}
253
258
259
+ // Specify certificate to use if set
260
+ if (config.Get (" certificatePemFile" ).IsString ()) {
261
+ rtcConfig.certificatePemFile = config.Get (" certificatePemFile" ).As <Napi::String>().ToString ();
262
+ }
263
+ if (config.Get (" keyPemFile" ).IsString ()) {
264
+ rtcConfig.keyPemFile = config.Get (" keyPemFile" ).As <Napi::String>().ToString ();
265
+ }
266
+ if (config.Get (" keyPemPass" ).IsString ()) {
267
+ rtcConfig.keyPemPass = config.Get (" keyPemPass" ).As <Napi::String>().ToString ();
268
+ }
269
+
254
270
// Create peer-connection
255
271
try
256
272
{
@@ -331,6 +347,7 @@ void PeerConnectionWrapper::setLocalDescription(const Napi::CallbackInfo &info)
331
347
}
332
348
333
349
rtc::Description::Type type = rtc::Description::Type::Unspec;
350
+ rtc::LocalDescriptionInit init;
334
351
335
352
// optional
336
353
if (length > 0 )
@@ -356,7 +373,29 @@ void PeerConnectionWrapper::setLocalDescription(const Napi::CallbackInfo &info)
356
373
type = rtc::Description::Type::Rollback;
357
374
}
358
375
359
- mRtcPeerConnPtr ->setLocalDescription (type);
376
+ // optional
377
+ if (length > 1 )
378
+ {
379
+ PLOG_DEBUG << " setLocalDescription() called with LocalDescriptionInit" ;
380
+
381
+ if (info[1 ].IsObject ())
382
+ {
383
+ PLOG_DEBUG << " setLocalDescription() called with LocalDescriptionInit as object" ;
384
+ Napi::Object obj = info[1 ].As <Napi::Object>();
385
+
386
+ if (obj.Get (" iceUfrag" ).IsString ()) {
387
+ PLOG_DEBUG << " setLocalDescription() has ufrag" ;
388
+ init.iceUfrag = obj.Get (" iceUfrag" ).As <Napi::String>();
389
+ }
390
+
391
+ if (obj.Get (" icePwd" ).IsString ()) {
392
+ PLOG_DEBUG << " setLocalDescription() has password" ;
393
+ init.icePwd = obj.Get (" icePwd" ).As <Napi::String>();
394
+ }
395
+ }
396
+ }
397
+
398
+ mRtcPeerConnPtr ->setLocalDescription (type, init);
360
399
}
361
400
362
401
void PeerConnectionWrapper::setRemoteDescription (const Napi::CallbackInfo &info)
@@ -1002,7 +1041,34 @@ Napi::Value PeerConnectionWrapper::maxMessageSize(const Napi::CallbackInfo &info
1002
1041
1003
1042
try
1004
1043
{
1005
- return Napi::Number::New (env, mRtcPeerConnPtr ->remoteMaxMessageSize ());
1044
+ return Napi::Array::New (env, mRtcPeerConnPtr ->remoteMaxMessageSize ());
1045
+ }
1046
+ catch (std::exception &ex)
1047
+ {
1048
+ Napi::Error::New (env, std::string (" libdatachannel error: " ) + ex.what ()).ThrowAsJavaScriptException ();
1049
+ return Napi::Number::New (info.Env (), 0 );
1050
+ }
1051
+ }
1052
+
1053
+ Napi::Value PeerConnectionWrapper::remoteFingerprint (const Napi::CallbackInfo &info)
1054
+ {
1055
+ PLOG_DEBUG << " remoteFingerprints() called" ;
1056
+ Napi::Env env = info.Env ();
1057
+
1058
+ if (!mRtcPeerConnPtr )
1059
+ {
1060
+ return Napi::Number::New (info.Env (), 0 );
1061
+ }
1062
+
1063
+ try
1064
+ {
1065
+ auto fingerprint = mRtcPeerConnPtr ->remoteFingerprint ();
1066
+
1067
+ Napi::Object fingerprintObject = Napi::Object::New (env);
1068
+ fingerprintObject.Set (" value" , fingerprint.value );
1069
+ fingerprintObject.Set (" algorithm" , rtc::CertificateFingerprint::AlgorithmIdentifier (fingerprint.algorithm ));
1070
+
1071
+ return fingerprintObject;
1006
1072
}
1007
1073
catch (std::exception &ex)
1008
1074
{
0 commit comments