diff --git a/README.md b/README.md index 7bdb087..335c9cd 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,10 @@ A webrtc interface wrapped in dart language. - Use the [dart/js](https://pub.dev/packages/js) library to re-wrap the [webrtc](https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API) js interface of the browser, to adapted common browsers. This library will be used for [flutter-webrtc](https://github.com/flutter-webrtc/flutter-webrtc) for [flutter web](https://flutter.dev/web) plugin. - - ## How to develop * `git clone https://github.com/flutter-webrtc/dart-webrtc && cd dart-webrtc` diff --git a/lib/src/media_devices.dart b/lib/src/media_devices.dart index 661f56e..8d96508 100644 --- a/lib/src/media_devices.dart +++ b/lib/src/media_devices.dart @@ -1,6 +1,4 @@ -import 'package:webrtc_interface/webrtc_interface.dart'; import '../dart_webrtc.dart'; -import 'factory_impl.dart'; class MediaDevices { @Deprecated( diff --git a/lib/src/media_recorder.dart b/lib/src/media_recorder.dart index 0fc6f84..7d3412c 100644 --- a/lib/src/media_recorder.dart +++ b/lib/src/media_recorder.dart @@ -1,8 +1,6 @@ import 'package:webrtc_interface/src/media_recorder.dart' as _interface; -import 'package:webrtc_interface/webrtc_interface.dart'; import '../dart_webrtc.dart'; -import 'factory_impl.dart'; class MediaRecorder extends _interface.MediaRecorder { MediaRecorder() : _delegate = mediaRecorder(); diff --git a/lib/src/mediadevices_impl.dart b/lib/src/mediadevices_impl.dart index b4079ac..4b7fa4e 100644 --- a/lib/src/mediadevices_impl.dart +++ b/lib/src/mediadevices_impl.dart @@ -1,6 +1,5 @@ import 'dart:async'; import 'dart:html' as html; -import 'dart:html_common'; import 'dart:js' as js; import 'dart:js_util' as jsutil; import 'package:webrtc_interface/webrtc_interface.dart'; diff --git a/web/p2p/p2p.dart b/web/p2p/p2p.dart index 819337e..a3f5ec7 100644 --- a/web/p2p/p2p.dart +++ b/web/p2p/p2p.dart @@ -1,8 +1,8 @@ import 'dart:html' as html; -import 'package:test/test.dart'; import 'package:dart_webrtc/dart_webrtc.dart'; import 'package:js/js.dart'; +import 'package:test/test.dart'; import 'signaling.dart'; diff --git a/web/test_media_stream.dart b/web/test_media_stream.dart index ce531fd..cd82314 100644 --- a/web/test_media_stream.dart +++ b/web/test_media_stream.dart @@ -1,44 +1,44 @@ import 'package:dart_webrtc/dart_webrtc.dart'; import 'package:test/test.dart'; -late MediaStream mediaStream; +MediaStream? mediaStream; List testFunctions = [ - () => test('MediaStream.constructor()', () async { + () => test('mediaStream?.constructor()', () async { mediaStream = await navigator.mediaDevices .getUserMedia({'audio': true, 'video': true}); - expect(mediaStream.id != null, true); + expect(mediaStream?.id != null, true); }), - () => test('MediaStream.active()', () { - expect(mediaStream.active, true); + () => test('mediaStream?.active()', () { + expect(mediaStream?.active, true); }), - () => test('MediaStream.getTracks()', () { - expect(mediaStream.getTracks().length, 2); + () => test('mediaStream?.getTracks()', () { + expect(mediaStream?.getTracks().length, 2); }), - () => test('MediaStream.getAudioTracks()', () { - expect(mediaStream.getAudioTracks().length, 1); - var track = - mediaStream.getTrackById(mediaStream.getAudioTracks()[0].id!); - expect(track?.id, mediaStream.getAudioTracks()[0].id); + () => test('mediaStream?.getAudioTracks()', () { + expect(mediaStream?.getAudioTracks().length, 1); + var track = mediaStream + ?.getTrackById(mediaStream?.getAudioTracks()[0].id ?? ''); + expect(track?.id, mediaStream?.getAudioTracks()[0].id); }), - () => test('MediaStream.getVideoTracks()', () { - expect(mediaStream.getVideoTracks().length, 1); - var track = - mediaStream.getTrackById(mediaStream.getVideoTracks()[0].id!); - expect(track!.id, mediaStream.getVideoTracks()[0].id); + () => test('mediaStream?.getVideoTracks()', () { + expect(mediaStream?.getVideoTracks().length, 1); + var track = mediaStream + ?.getTrackById(mediaStream?.getVideoTracks()[0].id ?? ''); + expect(track!.id, mediaStream?.getVideoTracks()[0].id); }), - () => test('MediaStream.removeTrack()', () { - var track = - mediaStream.getTrackById(mediaStream.getVideoTracks()[0].id!); - mediaStream.removeTrack(track!); - expect(mediaStream.getVideoTracks().length, 0); + () => test('mediaStream?.removeTrack()', () { + var track = mediaStream + ?.getTrackById(mediaStream?.getVideoTracks()[0].id ?? ''); + mediaStream?.removeTrack(track!); + expect(mediaStream?.getVideoTracks().length, 0); }), - () => test('MediaStream.close()', () { - mediaStream.getTracks().forEach((element) { + () => test('mediaStream?.close()', () { + mediaStream?.getTracks().forEach((element) { element.stop(); - mediaStream.removeTrack(element); + mediaStream?.removeTrack(element); }); - expect(mediaStream.getTracks().isEmpty, true); + expect(mediaStream?.getTracks().isEmpty, true); }) ]; diff --git a/web/test_media_stream_track.dart b/web/test_media_stream_track.dart index 45dce25..98ff06d 100644 --- a/web/test_media_stream_track.dart +++ b/web/test_media_stream_track.dart @@ -1,9 +1,7 @@ -import 'dart:html'; - import 'package:dart_webrtc/dart_webrtc.dart'; import 'package:test/test.dart'; -late MediaStreamTrack audioTrack, videoTrack; +MediaStreamTrack? audioTrack, videoTrack; List testFunctions = [ () => test('MediaStreamTrack.constructor()', () async { @@ -13,43 +11,43 @@ List testFunctions = [ audioTrack = stream.getAudioTracks()[0]; expect(audioTrack != null, true); - expect(audioTrack.kind, 'audio'); + expect(audioTrack?.kind, 'audio'); videoTrack = stream.getVideoTracks()[0]; expect(videoTrack != null, true); - expect(videoTrack.kind, 'video'); + expect(videoTrack?.kind, 'video'); }), () => test('MediaStreamTrack.id()', () { - expect(audioTrack.id is String, true); - expect(audioTrack.id?.isNotEmpty, true); - expect(videoTrack.id is String, true); - expect(videoTrack.id?.isNotEmpty, true); + expect(audioTrack?.id is String, true); + expect(audioTrack?.id?.isNotEmpty, true); + expect(videoTrack?.id is String, true); + expect(videoTrack?.id?.isNotEmpty, true); }), () => test('MediaStreamTrack.label()', () { - expect(audioTrack.label is String, true); - expect(audioTrack.id?.isNotEmpty, true); - expect(videoTrack.id is String, true); - expect(videoTrack.id?.isNotEmpty, true); + expect(audioTrack?.label is String, true); + expect(audioTrack?.id?.isNotEmpty, true); + expect(videoTrack?.id is String, true); + expect(videoTrack?.id?.isNotEmpty, true); }), () => test('MediaStreamTrack.enabled()', () { - expect(audioTrack.enabled, true); - audioTrack.enabled = false; - expect(audioTrack.enabled, false); + expect(audioTrack?.enabled, true); + audioTrack?.enabled = false; + expect(audioTrack?.enabled, false); - expect(videoTrack.enabled, true); - videoTrack.enabled = false; - expect(videoTrack.enabled, false); + expect(videoTrack?.enabled, true); + videoTrack?.enabled = false; + expect(videoTrack?.enabled, false); }), () => test('MediaStreamTrack.readyState() | MediaStreamTrack.stop()', () { /* - expect(audioTrack.readyState, 'live'); - audioTrack.stop(); - expect(audioTrack.readyState, 'ended'); + expect(audioTrack?.readyState, 'live'); + audioTrack?.stop(); + expect(audioTrack?.readyState, 'ended'); - expect(videoTrack.readyState, 'live'); - videoTrack.stop(); - expect(videoTrack.readyState, 'ended'); + expect(videoTrack?.readyState, 'live'); + videoTrack?.stop(); + expect(videoTrack?.readyState, 'ended'); */ }) ]; diff --git a/web/test_video_element.dart b/web/test_video_element.dart index 52d0b21..918dd52 100644 --- a/web/test_video_element.dart +++ b/web/test_video_element.dart @@ -1,7 +1,7 @@ import 'package:dart_webrtc/dart_webrtc.dart'; import 'package:test/test.dart'; -late RTCVideoElement localVideo; +late RTCVideoElement? localVideo; List testFunctions = [ () => test('RTCVideoElement.constructor()', () { @@ -9,21 +9,21 @@ List testFunctions = [ expect(localVideo != null, true); }), () => test('RTCVideoElement.muted()', () { - localVideo.muted = true; - expect(localVideo.muted, true); - localVideo.muted = false; - expect(localVideo.muted, false); + localVideo?.muted = true; + expect(localVideo?.muted, true); + localVideo?.muted = false; + expect(localVideo?.muted, false); }), () => test('RTCVideoElement.controls()', () { - localVideo.controls = false; - expect(localVideo.controls, false); - localVideo.controls = true; - expect(localVideo.controls, true); + localVideo?.controls = false; + expect(localVideo?.controls, false); + localVideo?.controls = true; + expect(localVideo?.controls, true); }), () => test('RTCVideoElement.autoplay()', () { - localVideo.autoplay = false; - expect(localVideo.autoplay, false); - localVideo.autoplay = true; - expect(localVideo.autoplay, true); + localVideo?.autoplay = false; + expect(localVideo?.autoplay, false); + localVideo?.autoplay = true; + expect(localVideo?.autoplay, true); }) ];