Skip to content

Commit d6d0eea

Browse files
authored
Merge pull request #5 from flutter-webrtc/refactor/use-webrtc-interface
refactor: use separate interface
2 parents d77e93e + f094389 commit d6d0eea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1574
-1371
lines changed

.github/workflows/build.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
test:
11+
name: Test on ${{ matrix.os }}
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest]
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
- uses: actions/setup-java@v1
20+
with:
21+
java-version: '12.x'
22+
- uses: subosito/flutter-action@v1
23+
with:
24+
flutter-version: '2.2.3'
25+
channel: 'stable'
26+
- run: dart pub get
27+
- run: dart format lib/ test/ --set-exit-if-changed
28+
- run: dart pub run import_sorter:main --no-comments --exit-if-changed
29+
- run: dart analyze

.github/workflows/publish.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Publish plugin
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish:
9+
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v1
15+
- name: Publish
16+
uses: sakebook/[email protected]
17+
with:
18+
credential: ${{ secrets.CREDENTIAL_JSON }}
19+
flutter_package: true
20+
skip_test: true
21+
dry_run: false

lib/dart_webrtc.dart

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
1-
export 'src/enums.dart';
2-
export 'src/event.dart';
1+
library dart_webrtc;
2+
3+
export 'package:webrtc_interface/webrtc_interface.dart'
4+
hide MediaDevices, MediaRecorder, Navigator;
5+
36
export 'src/media_devices.dart';
4-
export 'src/media_stream.dart';
5-
export 'src/media_stream_track.dart';
6-
export 'src/navigator.dart';
7-
export 'src/rtc_data_channel.dart';
8-
export 'src/rtc_dtmf_sender.dart';
9-
export 'src/rtc_ice_candidate.dart';
10-
export 'src/rtc_peerconnection.dart';
11-
export 'src/rtc_peerconnection.dart';
12-
export 'src/rtc_rtcp_parameters.dart';
13-
export 'src/rtc_rtp_parameters.dart';
14-
export 'src/rtc_rtp_receiver.dart';
15-
export 'src/rtc_rtp_sender.dart';
16-
export 'src/rtc_rtp_transceiver.dart';
17-
export 'src/rtc_session_description.dart';
18-
export 'src/rtc_stats_resport.dart';
19-
export 'src/rtc_track_event.dart';
7+
export 'src/media_recorder.dart';
8+
export 'src/rtc_peerconnection_factory.dart';
209
export 'src/video_element.dart';

lib/src/enums.dart

Lines changed: 0 additions & 174 deletions
This file was deleted.

lib/src/event.dart

Lines changed: 0 additions & 9 deletions
This file was deleted.

lib/src/factory_impl.dart

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import 'dart:async';
2+
import 'dart:convert';
3+
import 'dart:html' as html;
4+
import 'package:webrtc_interface/webrtc_interface.dart';
5+
6+
import 'media_recorder_impl.dart';
7+
import 'media_stream_impl.dart';
8+
import 'navigator_impl.dart';
9+
import 'rtc_peerconnection_impl.dart';
10+
11+
class RTCFactoryWeb extends RTCFactory {
12+
RTCFactoryWeb._internal();
13+
static final instance = RTCFactoryWeb._internal();
14+
15+
@override
16+
Future<RTCPeerConnection> createPeerConnection(
17+
Map<String, dynamic> configuration,
18+
[Map<String, dynamic>? constraints]) async {
19+
final constr = (constraints != null && constraints.isNotEmpty)
20+
? constraints
21+
: {
22+
'mandatory': {},
23+
'optional': [
24+
{'DtlsSrtpKeyAgreement': true},
25+
],
26+
};
27+
final jsRtcPc = html.RtcPeerConnection({...constr, ...configuration});
28+
final _peerConnectionId = base64Encode(jsRtcPc.toString().codeUnits);
29+
return RTCPeerConnectionWeb(_peerConnectionId, jsRtcPc);
30+
}
31+
32+
@override
33+
Future<MediaStream> createLocalMediaStream(String label) async {
34+
final jsMs = html.MediaStream();
35+
return MediaStreamWeb(jsMs, 'local');
36+
}
37+
38+
@override
39+
MediaRecorder mediaRecorder() {
40+
return MediaRecorderWeb();
41+
}
42+
43+
@override
44+
VideoRenderer videoRenderer() {
45+
throw UnimplementedError();
46+
}
47+
48+
@override
49+
Navigator get navigator => NavigatorWeb();
50+
}

0 commit comments

Comments
 (0)