Skip to content

Commit

Permalink
Merge pull request #39 from td-famedly/td/logs
Browse files Browse the repository at this point in the history
missing fault tolerance, better worker reports and a increased timeout for worker tasks
  • Loading branch information
cloudwebrtc authored Jun 3, 2024
2 parents ab0438d + 6571ab3 commit ea029c2
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 23 deletions.
2 changes: 1 addition & 1 deletion lib/src/e2ee.worker/e2ee.cryptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import 'dart:js_util' as jsutil;
import 'dart:math';
import 'dart:typed_data';

import 'package:dart_webrtc/src/rtc_transform_stream.dart';
import 'package:web/web.dart' as web;

import 'package:dart_webrtc/src/rtc_transform_stream.dart';
import 'crypto.dart' as crypto;
import 'e2ee.keyhandler.dart';
import 'e2ee.logger.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/e2ee.worker/e2ee.worker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import 'dart:js_util' as js_util;
import 'dart:typed_data';

import 'package:collection/collection.dart';
import 'package:dart_webrtc/src/rtc_transform_stream.dart';
import 'package:logging/logging.dart';
import 'package:web/web.dart' as web;

import 'package:dart_webrtc/src/rtc_transform_stream.dart';
import 'e2ee.cryptor.dart';
import 'e2ee.keyhandler.dart';
import 'e2ee.logger.dart';
Expand Down
1 change: 1 addition & 0 deletions lib/src/factory_impl.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';
import 'dart:convert';

import 'package:js/js.dart';
import 'package:js/js_util.dart';
import 'package:web/web.dart' as web;
Expand Down
68 changes: 49 additions & 19 deletions lib/src/frame_cryptor_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import 'dart:js_util' as jsutil;
import 'dart:typed_data';

import 'package:collection/collection.dart';
import 'package:dart_webrtc/src/event.dart';
import 'package:js/js_util.dart';
import 'package:web/web.dart' as web;
import 'package:webrtc_interface/webrtc_interface.dart';

import 'package:dart_webrtc/src/e2ee.worker/e2ee.logger.dart';
import 'package:dart_webrtc/src/event.dart';
import 'rtc_rtp_receiver_impl.dart';
import 'rtc_rtp_sender_impl.dart';
import 'rtc_transform_stream.dart';
Expand Down Expand Up @@ -191,6 +192,7 @@ class KeyProviderImpl implements KeyProvider {
'sharedKey': options.sharedKey,
'ratchetSalt': base64Encode(options.ratchetSalt),
'ratchetWindowSize': options.ratchetWindowSize,
'failureTolerance': options.failureTolerance,
if (options.uncryptedMagicBytes != null)
'uncryptedMagicBytes': base64Encode(options.uncryptedMagicBytes!),
'keyRingSize': options.keyRingSize,
Expand All @@ -201,8 +203,11 @@ class KeyProviderImpl implements KeyProvider {
]);

await events.waitFor<WorkerResponse>(
filter: (event) => event.msgId == msgId,
duration: Duration(seconds: 5));
filter: (event) {
logger.fine('waiting for init on msg: $msgId');
return event.msgId == msgId;
},
duration: Duration(seconds: 15));
}

@override
Expand All @@ -217,8 +222,11 @@ class KeyProviderImpl implements KeyProvider {
]);

await events.waitFor<WorkerResponse>(
filter: (event) => event.msgId == msgId,
duration: Duration(seconds: 5));
filter: (event) {
logger.fine('waiting for dispose on msg: $msgId');
return event.msgId == msgId;
},
duration: Duration(seconds: 15));

_keys.clear();
}
Expand All @@ -241,8 +249,12 @@ class KeyProviderImpl implements KeyProvider {
]);

await events.waitFor<WorkerResponse>(
filter: (event) => event.msgId == msgId,
duration: Duration(seconds: 5));
filter: (event) {
logger.fine('waiting for setKey on msg: $msgId');
return event.msgId == msgId;
},
duration: Duration(minutes: 15),
);

_keys[participantId] ??= [];
if (_keys[participantId]!.length <= index) {
Expand All @@ -268,8 +280,11 @@ class KeyProviderImpl implements KeyProvider {
]);

var res = await events.waitFor<WorkerResponse>(
filter: (event) => event.msgId == msgId,
duration: Duration(seconds: 5));
filter: (event) {
logger.fine('waiting for ratchetKey on msg: $msgId');
return event.msgId == msgId;
},
duration: Duration(seconds: 15));

return base64Decode(res.data['newKey']);
}
Expand All @@ -289,8 +304,11 @@ class KeyProviderImpl implements KeyProvider {
]);

var res = await events.waitFor<WorkerResponse>(
filter: (event) => event.msgId == msgId,
duration: Duration(seconds: 5));
filter: (event) {
logger.fine('waiting for exportKey on msg: $msgId');
return event.msgId == msgId;
},
duration: Duration(seconds: 15));

return base64Decode(res.data['exportedKey']);
}
Expand All @@ -308,8 +326,11 @@ class KeyProviderImpl implements KeyProvider {
]);

var res = await events.waitFor<WorkerResponse>(
filter: (event) => event.msgId == msgId,
duration: Duration(seconds: 5));
filter: (event) {
logger.fine('waiting for exportSharedKey on msg: $msgId');
return event.msgId == msgId;
},
duration: Duration(seconds: 15));

return base64Decode(res.data['exportedKey']);
}
Expand All @@ -326,8 +347,11 @@ class KeyProviderImpl implements KeyProvider {
})
]);
var res = await events.waitFor<WorkerResponse>(
filter: (event) => event.msgId == msgId,
duration: Duration(seconds: 5));
filter: (event) {
logger.fine('waiting for ratchetSharedKey on msg: $msgId');
return event.msgId == msgId;
},
duration: Duration(seconds: 15));

return base64Decode(res.data['newKey']);
}
Expand All @@ -346,8 +370,11 @@ class KeyProviderImpl implements KeyProvider {
]);

await events.waitFor<WorkerResponse>(
filter: (event) => event.msgId == msgId,
duration: Duration(seconds: 5));
filter: (event) {
logger.fine('waiting for setSharedKey on msg: $msgId');
return event.msgId == msgId;
},
duration: Duration(seconds: 15));
}

@override
Expand All @@ -363,8 +390,11 @@ class KeyProviderImpl implements KeyProvider {
]);

await events.waitFor<WorkerResponse>(
filter: (event) => event.msgId == msgId,
duration: Duration(seconds: 5));
filter: (event) {
logger.fine('waiting for setSifTrailer on msg: $msgId');
return event.msgId == msgId;
},
duration: Duration(seconds: 15));
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/src/media_recorder_impl.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:js' as js;
import 'dart:js_interop';

import 'package:web/web.dart' as web;
import 'package:webrtc_interface/webrtc_interface.dart';

Expand Down
1 change: 1 addition & 0 deletions lib/src/media_stream_impl.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';
import 'dart:js_interop';

import 'package:web/web.dart' as web;
import 'package:webrtc_interface/webrtc_interface.dart';

Expand Down
1 change: 1 addition & 0 deletions lib/src/mediadevices_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:js' as js;
import 'dart:js_interop';
import 'dart:js_util' as jsutil;

import 'package:web/web.dart' as web;
import 'package:webrtc_interface/webrtc_interface.dart';

Expand Down
1 change: 1 addition & 0 deletions lib/src/rtc_data_channel_impl.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';
import 'dart:js_interop';

import 'package:js/js_util.dart' as jsutil;
import 'package:web/web.dart' as web;
import 'package:webrtc_interface/webrtc_interface.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/rtc_peerconnection_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import 'dart:js_interop';
import 'dart:js_interop_unsafe';
import 'dart:js_util' as jsutil;

import 'package:dart_webrtc/dart_webrtc.dart';
import 'package:js/js_util.dart';
import 'package:platform_detect/platform_detect.dart';
import 'package:web/web.dart' as web;

import 'package:dart_webrtc/dart_webrtc.dart';
import 'media_stream_track_impl.dart';
import 'rtc_data_channel_impl.dart';
import 'rtc_dtmf_sender_impl.dart';
Expand Down
1 change: 1 addition & 0 deletions lib/src/rtc_rtp_capailities_imp.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:js_util' as jsutil;

import 'package:webrtc_interface/webrtc_interface.dart';

class RTCRtpCapabilitiesWeb {
Expand Down
1 change: 1 addition & 0 deletions lib/src/rtc_rtp_parameters_impl.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:js_util' as jsutil;

import 'package:webrtc_interface/webrtc_interface.dart';

class RTCRtpParametersWeb {
Expand Down
1 change: 1 addition & 0 deletions lib/src/rtc_rtp_receiver_impl.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:js_util' as jsutil;

import 'package:web/web.dart' as web;
import 'package:webrtc_interface/webrtc_interface.dart';

Expand Down
2 changes: 1 addition & 1 deletion lib/src/rtc_rtp_sender_impl.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'dart:async';
import 'dart:js_util' as jsutil;

import 'package:dart_webrtc/src/media_stream_impl.dart';
import 'package:web/web.dart' as web;
import 'package:webrtc_interface/webrtc_interface.dart';

import 'package:dart_webrtc/src/media_stream_impl.dart';
import 'media_stream_track_impl.dart';
import 'rtc_dtmf_sender_impl.dart';
import 'rtc_rtp_parameters_impl.dart';
Expand Down
1 change: 1 addition & 0 deletions lib/src/rtc_transform_stream.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:js_util' as js_util;
import 'dart:typed_data';

import 'package:js/js.dart';
import 'package:web/web.dart';

Expand Down
2 changes: 2 additions & 0 deletions lib/src/rtc_video_element.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'dart:js_interop';

import 'package:web/web.dart' as web;

import '../dart_webrtc.dart';

class RTCVideoElement {
Expand Down

0 comments on commit ea029c2

Please sign in to comment.