Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7332b7f

Browse files
fix: fix errors for flutter analyze.
1 parent a1146d1 commit 7332b7f

File tree

5 files changed

+141
-8
lines changed

5 files changed

+141
-8
lines changed

‎example/pubspec.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies:
1111
flutter:
1212
sdk: flutter
1313
flutter_icons: ^1.0.0
14-
flutter_whip_meeting:
14+
flutter_whip:
1515
path: ../
1616

1717
dev_dependencies:

‎lib/src/transports/http.dart‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,21 @@ void httpInit() {
1414
ioClient = IOClient(httpClient);
1515
}
1616

17-
Future<http.Response> httpGet(Uri url, {Map<String, String>? headers}) =>
18-
ioClient.get(url, headers: headers);
19-
17+
// POST/PATCH/DELETE
2018
Future<http.Response> httpPost(Uri url,
2119
{Map<String, String>? headers, Object? body, Encoding? encoding}) =>
2220
ioClient.post(url, headers: headers, body: body, encoding: encoding);
21+
22+
Future<http.Response> httpPatch(Uri url, {Map<String, String>? headers, Object? body}) async {
23+
final response = await ioClient.patch(url, headers: headers, body: body);
24+
print('Status code: ${response.statusCode}');
25+
print('Body: ${response.body}');
26+
return response;
27+
}
28+
29+
Future<http.Response> httpDelete(Uri url) async {
30+
final response = await ioClient.delete(url);
31+
print('Status code: ${response.statusCode}');
32+
print('Body: ${response.body}');
33+
return response;
34+
}

‎lib/src/transports/http_web.dart‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,21 @@ import 'package:http/http.dart' as http;
44

55
void httpInit() {}
66

7-
Future<http.Response> httpGet(Uri url, {Map<String, String>? headers}) =>
8-
http.get(url, headers: headers);
9-
107
Future<http.Response> httpPost(Uri url,
118
{Map<String, String>? headers, Object? body, Encoding? encoding}) =>
129
http.post(url, headers: headers, body: body, encoding: encoding);
10+
11+
12+
Future<http.Response> httpPatch(Uri url, {Map<String, String>? headers, Object? body}) async {
13+
final response = await http.patch(url, headers: headers, body: body);
14+
print('Status code: ${response.statusCode}');
15+
print('Body: ${response.body}');
16+
return response;
17+
}
18+
19+
Future<http.Response> httpDelete(Uri url) async {
20+
final response = await http.delete(url);
21+
print('Status code: ${response.statusCode}');
22+
print('Body: ${response.body}');
23+
return response;
24+
}

‎lib/src/utils.dart‎

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import 'package:sdp_transform/sdp_transform.dart' as sdp_transform;
2+
3+
class CodecCapability {
4+
CodecCapability(
5+
this.kind, this.payloads, this.codecs, this.fmtp, this.rtcpFb) {
6+
codecs.forEach((element) {
7+
element['orign_payload'] = element['payload'];
8+
});
9+
}
10+
String kind;
11+
List<dynamic> rtcpFb;
12+
List<dynamic> fmtp;
13+
List<String> payloads;
14+
List<dynamic> codecs;
15+
bool setCodecPreferences(String kind, List<dynamic>? newCodecs) {
16+
if (newCodecs == null) {
17+
return false;
18+
}
19+
var newRtcpFb = <dynamic>[];
20+
var newFmtp = <dynamic>[];
21+
var newPayloads = <String>[];
22+
newCodecs.forEach((element) {
23+
var orign_payload = element['orign_payload'] as int;
24+
var payload = element['payload'] as int;
25+
// change payload type
26+
if (payload != orign_payload) {
27+
newRtcpFb.addAll(rtcpFb.where((e) {
28+
if (e['payload'] == orign_payload) {
29+
e['payload'] = payload;
30+
return true;
31+
}
32+
return false;
33+
}).toList());
34+
newFmtp.addAll(fmtp.where((e) {
35+
if (e['payload'] == orign_payload) {
36+
e['payload'] = payload;
37+
return true;
38+
}
39+
return false;
40+
}).toList());
41+
if (payloads.contains('$orign_payload')) {
42+
newPayloads.add('$payload');
43+
}
44+
} else {
45+
newRtcpFb.addAll(rtcpFb.where((e) => e['payload'] == payload).toList());
46+
newFmtp.addAll(fmtp.where((e) => e['payload'] == payload).toList());
47+
newPayloads.addAll(payloads.where((e) => e == '$payload').toList());
48+
}
49+
});
50+
rtcpFb = newRtcpFb;
51+
fmtp = newFmtp;
52+
payloads = newPayloads;
53+
codecs = newCodecs;
54+
return true;
55+
}
56+
}
57+
58+
class CodecCapabilitySelector {
59+
CodecCapabilitySelector(String sdp) {
60+
_sdp = sdp;
61+
_session = sdp_transform.parse(_sdp);
62+
}
63+
late String _sdp;
64+
late Map<String, dynamic> _session;
65+
Map<String, dynamic> get session => _session;
66+
String sdp() => sdp_transform.write(_session, null);
67+
68+
CodecCapability? getCapabilities(String kind) {
69+
var mline = _mline(kind);
70+
if (mline == null) {
71+
return null;
72+
}
73+
var rtcpFb = mline['rtcpFb'] as List<dynamic>;
74+
var fmtp = mline['fmtp'] as List<dynamic>;
75+
var payloads = (mline['payloads'] as String).split(' ');
76+
var codecs = mline['rtp'] as List<dynamic>;
77+
return CodecCapability(kind, payloads, codecs, fmtp, rtcpFb);
78+
}
79+
80+
bool setCapabilities(CodecCapability? caps) {
81+
if (caps == null) {
82+
return false;
83+
}
84+
var mline = _mline(caps.kind);
85+
if (mline == null) {
86+
return false;
87+
}
88+
mline['payloads'] = caps.payloads.join(' ');
89+
mline['rtp'] = caps.codecs;
90+
mline['fmtp'] = caps.fmtp;
91+
mline['rtcpFb'] = caps.rtcpFb;
92+
93+
var mlines = _session['media'] as List<dynamic>;
94+
mlines.forEach((m) {
95+
m.remove('ssrcGroups');
96+
var ssrcs = m['ssrcs'];
97+
if (ssrcs != null && ssrcs.length >= 4) {
98+
m['ssrcs'] = ssrcs.sublist(0, 3);
99+
}
100+
});
101+
return true;
102+
}
103+
104+
Map<String, dynamic>? _mline(String kind) {
105+
var mlist = _session['media'] as List<dynamic>;
106+
return mlist.firstWhere((element) => element['type'] == kind,
107+
orElse: () => null);
108+
}
109+
}

‎test/sdp_test.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'dart:convert';
22
import 'dart:io';
33

4-
import 'package:flutter_cisco_meeting/src/utils.dart';
4+
import 'package:flutter_whip/src/utils.dart';
55
import 'package:test/test.dart';
66

77
void main() async {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /