Skip to content

Commit 9848864

Browse files
committed
Merge branch 'master' into null-safety
2 parents d1d6fb6 + becfd50 commit 9848864

38 files changed

+7234
-3857
lines changed

.github/workflows/dart.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
name: Flutter CI
1+
2+
name: Build
23

34
on:
45
push:
5-
branches:
6-
- dev
7-
- master
6+
branches: [ master ]
7+
pull_request:
8+
branches: [ master ]
89

910
jobs:
1011
test:
@@ -13,17 +14,16 @@ jobs:
1314
strategy:
1415
matrix:
1516
os: [ubuntu-latest]
16-
# os: [ubuntu-latest, windows-latest, macos-latest]
17+
1718
steps:
1819
- uses: actions/checkout@v2
1920
- uses: actions/setup-java@v1
2021
with:
2122
java-version: '12.x'
2223
- uses: subosito/flutter-action@v1
2324
with:
24-
flutter-version: '1.7.8+hotfix.4'
25+
flutter-version: '2.2.3'
2526
channel: 'stable'
26-
- run: cd example && ./scripts/project_tools.sh create
2727
- run: flutter packages get
28-
# - run: flutter test
29-
- run: cd example && flutter build apk
28+
- run: flutter format lib/ test/ --set-exit-if-changed
29+
- run: flutter pub run import_sorter:main --no-comments --exit-if-changed

.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/actions-flutter-pub-publisher@v1.3.1
17+
with:
18+
credential: ${{ secrets.CREDENTIAL_JSON }}
19+
flutter_package: true
20+
skip_test: true
21+
dry_run: false

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,36 @@
11
# Changelog
22

33
--------------------------------------------
4+
[0.3.9] - 2021.09.27
5+
6+
* Upgrade flutter-webrtc to 0.6.8
7+
8+
[0.3.8] - 2021.09.26
9+
10+
* Fix ice delay.
11+
* Don't run ready if session has been terminated (#226)
12+
* Support IceRestart when IceStateDisconnected (#218)
13+
* Add options to the hangup (#224)
14+
* Adaptive when answering audio or video calls.
15+
16+
[0.3.7] - 2021.08.24
17+
18+
* Fix the issue that unified-plan's onTrack does not call back AudioTrack.
19+
* Export PeerConnection for call.
20+
21+
[0.3.6] - 2021.08.24
22+
23+
* Support custom MediaStream for call/answer.
24+
* Fix the exception caused by speaker operation in web mode.
25+
* bump dependencies (#216)
26+
* Fix the parameters with double quotes in the Authentication header,
27+
and the unknown parameters are saved to auth_params.
28+
* updated crypto and uuid versions (#188)
29+
* Update dependency sdp_transform to ^0.3.0
30+
* Fixed mute audio for unified-plan
31+
* Add remote_has_audio/video method for Call.
32+
* Configuring via_transport.
33+
434
[0.3.5] - 2021.02.03
535

636
* Upgrade flutter-webrtc to 0.5.8.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# dart-sip-ua
2+
3+
[![Financial Contributors on Open Collective](https://opencollective.com/flutter-webrtc/all/badge.svg?label=financial+contributors)](https://opencollective.com/flutter-webrtc) [![pub package](https://img.shields.io/pub/v/sip_ua.svg)](https://pub.dartlang.org/packages/sip_ua) [![slack](https://img.shields.io/badge/join-us%20on%20slack-gray.svg?longCache=true&logo=slack&colorB=brightgreen)](https://join.slack.com/t/flutterwebrtc/shared_invite/zt-q83o7y1s-FExGLWEvtkPKM8ku_F8cEQ)
4+
25
A dart-lang version of the SIP UA stack, ported from [JsSIP](https://github.com/versatica/JsSIP).
36

47
## Overview

example/lib/src/callscreen.dart

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import 'dart:async';
2+
3+
import 'package:flutter/foundation.dart';
24
import 'package:flutter/material.dart';
35
import 'package:flutter_webrtc/flutter_webrtc.dart';
46

@@ -151,11 +153,20 @@ class _MyCallScreenWidget extends State<CallScreenWidget>
151153
@override
152154
void registrationStateChanged(RegistrationState state) {}
153155

156+
void _cleanUp() {
157+
_localStream?.getTracks()?.forEach((track) {
158+
track.stop();
159+
});
160+
_localStream.dispose();
161+
_localStream = null;
162+
}
163+
154164
void _backToDialPad() {
155165
_timer.cancel();
156166
Timer(Duration(seconds: 2), () {
157167
Navigator.of(context).pop();
158168
});
169+
_cleanUp();
159170
}
160171

161172
void _handelStreams(CallState event) async {
@@ -164,7 +175,9 @@ class _MyCallScreenWidget extends State<CallScreenWidget>
164175
if (_localRenderer != null) {
165176
_localRenderer.srcObject = stream;
166177
}
167-
event.stream?.getAudioTracks()?.first?.enableSpeakerphone(false);
178+
if (!kIsWeb && !WebRTC.platformIsDesktop) {
179+
event.stream?.getAudioTracks()?.first?.enableSpeakerphone(false);
180+
}
168181
_localStream = stream;
169182
}
170183
if (event.originator == 'remote') {
@@ -196,8 +209,28 @@ class _MyCallScreenWidget extends State<CallScreenWidget>
196209
_timer.cancel();
197210
}
198211

199-
void _handleAccept() {
200-
call.answer(helper.buildCallOptions());
212+
void _handleAccept() async {
213+
bool remote_has_video = call.remote_has_video;
214+
final mediaConstraints = <String, dynamic>{
215+
'audio': true,
216+
'video': remote_has_video
217+
};
218+
MediaStream mediaStream;
219+
220+
if (kIsWeb && remote_has_video) {
221+
mediaStream =
222+
await navigator.mediaDevices.getDisplayMedia(mediaConstraints);
223+
mediaConstraints['video'] = false;
224+
MediaStream userStream =
225+
await navigator.mediaDevices.getUserMedia(mediaConstraints);
226+
mediaStream.addTrack(userStream.getAudioTracks()[0], addToNative: true);
227+
} else {
228+
mediaConstraints['video'] = remote_has_video;
229+
mediaStream = await navigator.mediaDevices.getUserMedia(mediaConstraints);
230+
}
231+
232+
call.answer(helper.buildCallOptions(!remote_has_video),
233+
mediaStream: mediaStream);
201234
}
202235

203236
void _switchCamera() {
@@ -283,7 +316,9 @@ class _MyCallScreenWidget extends State<CallScreenWidget>
283316
void _toggleSpeaker() {
284317
if (_localStream != null) {
285318
_speakerOn = !_speakerOn;
286-
_localStream.getAudioTracks()[0].enableSpeakerphone(_speakerOn);
319+
if (!kIsWeb) {
320+
_localStream.getAudioTracks()[0].enableSpeakerphone(_speakerOn);
321+
}
287322
}
288323
}
289324

example/lib/src/dialpad.dart

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import 'package:flutter/foundation.dart';
12
import 'package:flutter/material.dart';
23
import 'package:sip_ua/sip_ua.dart';
34
import 'package:shared_preferences/shared_preferences.dart';
5+
import 'package:flutter_webrtc/flutter_webrtc.dart';
46

57
import 'widgets/action_button.dart';
68

@@ -41,7 +43,8 @@ class _MyDialPadWidget extends State<DialPadWidget>
4143
helper.addSipUaHelperListener(this);
4244
}
4345

44-
Widget _handleCall(BuildContext context, [bool voiceonly = false]) {
46+
Future<Widget> _handleCall(BuildContext context,
47+
[bool voiceonly = false]) async {
4548
var dest = _textController.text;
4649
if (dest == null || dest.isEmpty) {
4750
showDialog<Null>(
@@ -64,7 +67,24 @@ class _MyDialPadWidget extends State<DialPadWidget>
6467
);
6568
return null;
6669
}
67-
helper.call(dest, voiceonly);
70+
71+
final mediaConstraints = <String, dynamic>{'audio': true, 'video': true};
72+
73+
MediaStream mediaStream;
74+
75+
if (kIsWeb && !voiceonly) {
76+
mediaStream =
77+
await navigator.mediaDevices.getDisplayMedia(mediaConstraints);
78+
mediaConstraints['video'] = false;
79+
MediaStream userStream =
80+
await navigator.mediaDevices.getUserMedia(mediaConstraints);
81+
mediaStream.addTrack(userStream.getAudioTracks()[0], addToNative: true);
82+
} else {
83+
mediaConstraints['video'] = !voiceonly;
84+
mediaStream = await navigator.mediaDevices.getUserMedia(mediaConstraints);
85+
}
86+
87+
helper.call(dest, voiceonly: voiceonly, mediaStream: mediaStream);
6888
_preferences.setString('dest', dest);
6989
return null;
7090
}

lib/src/config.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import 'package:sip_ua/sip_ua.dart';
2-
3-
import 'constants.dart';
42
import 'constants.dart' as DartSIP_C;
3+
import 'constants.dart';
54
import 'exceptions.dart' as Exceptions;
65
import 'grammar.dart';
76
import 'logger.dart';

lib/src/data.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ParsedData {
3333
List<String> qop = <String>[];
3434
String protocol;
3535
String realm;
36-
Map<String, dynamic> auth_params = <String, dynamic>{};
36+
Map<String, dynamic> auth_params = <String, dynamic>{};
3737
int cause;
3838
int expires;
3939
String refresher;

lib/src/grammar.peg

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -897,19 +897,20 @@ Proxy_Authenticate <- proxy_authenticate: challenge
897897
challenge <- (("Digest"i LWS digest_cln (COMMA digest_cln)*)
898898
/ other_challenge) {return data;}
899899

900-
other_challenge <- auth_scheme LWS auth_param (COMMA auth_param)*
900+
other_challenge <- auth_scheme LWS auth_param (COMMA auth_param)*
901+
{return data;}
901902

902903
auth_scheme <- token
903904

904-
auth_param <- key: auth_param_name EQUAL value: ( token / quoted_string ) {
905-
print(key + ' => ' + value);
906-
if(data.auth_params == null) data.auth_params = [];
905+
auth_param <- key: auth_param_name EQUAL value: ( token / quoted_string_clean ) {
906+
// print('other_auth_param: ' + key + ' => ' + value);
907+
if(data.auth_params == null) data.auth_params = {};
907908
data.auth_params[key] = value;
908909
}
909910

910911
auth_param_name <- token
911912

912-
digest_cln <- realm / domain / nonce / opaque / stale / algorithm / qop_options
913+
digest_cln <- realm / domain / nonce / opaque / stale / algorithm / qop_options / auth_param
913914

914915
realm <- "realm"i EQUAL realm_value
915916

@@ -931,7 +932,7 @@ stale <- "stale"i EQUAL stale: token {
931932
data.stale = stale.toLowerCase() == 'true';
932933
return stale;}
933934

934-
algorithm <- "algorithm"i EQUAL algorithm: ( "MD5"i / "MD5-sess"i / token ) {
935+
algorithm <- "algorithm"i EQUAL algorithm: ( "MD5"i / "MD5"i / "MD5-sess"i / token / quoted_string_clean) {
935936
data.algorithm=algorithm.toUpperCase(); return data.algorithm;}
936937

937938
qop_options <- "qop"i EQUAL LDQUOT (qop_value ("," qop_value)*) RDQUOT

0 commit comments

Comments
 (0)