8000 Update. · lineCode/flutter-webrtc@168dca5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 168dca5

Browse files
committed
Update.
1 parent cc2a122 commit 168dca5

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class _MyAppState extends State<MyApp> {
5151
}
5252

5353
List<RouteItem> items;
54-
String _ip = '192.168.2.168';
54+
String _ip = '192.168.31.152';
5555

5656
_initItems(){
5757

example/lib/src/call_sample/call_sample.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
22
import 'dart:core';
33
import 'dart:async';
44
import 'signaling.dart';
5-
import 'calling_screen.dart';
65
import 'package:webrtc/webrtc.dart';
76

87
class CallSample extends StatefulWidget {
@@ -96,7 +95,7 @@ class _CallSampleState extends State<CallSample> {
9695
_inCalling = false;
9796
});
9897
if (_signaling != null) {
99-
_signaling.leave();
98+
_signaling.bye();
10099
}
101100
}
102101

example/lib/src/call_sample/signaling.dart

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,13 @@ String randomNumeric(int length) =>
2929
randomString(length, from: NUMERIC_START, to: NUMERIC_END);
3030

3131
class Signaling {
32-
String _self_id = randomNumeric(6);
32+
String _self_id = randomString(6, from: NUMERIC_START, to: NUMERIC_END);
3333
var _socket;
34+
var _session_id;
3435
var _peerConnections = new Map<String, RTCPeerConnection>();
35-
var _data = new Map<int, RTCDataChannel>();
36+
var _daChannels = new Map<int, RTCDataChannel>();
3637
var _messageController = new StreamController();
3738
Stream _messageStream;
38-
var _session_id;
39-
4039
MediaStream _localStream;
4140

4241
Map<String, dynamic> _iceServers = {
@@ -79,7 +78,7 @@ class Signaling {
7978
this._session_id = sessionId;
8079
}
8180

82-
void leave() {
81+
void bye() {
8382
_send('bye', {
8483
'session_id': this._session_id,
8584
'from': this._self_id,
@@ -172,7 +171,7 @@ class Signaling {
172171
Map<String, dynamic> data = message;
173172
var id = data['data'];
174173
_peerConnections.remove(id);
175-
_data.remove(id);
174+
_daChannels.remove(id);
176175
});
177176

178177
onOffer.listen((message) async {
@@ -250,12 +249,6 @@ class Signaling {
250249
return stream;
251250
}
252251

253-
send(data) {
254-
_data.forEach((k, d) {
255-
d.send('text', data);
256-
});
257-
}
258-
259252
_createPeerConnection(id, media) async {
260253
_localStream = await createStream();
261254
RTCPeerConnection pc = await createPeerConnection(_iceServers, _config);
@@ -292,7 +285,7 @@ class Signaling {
292285
channel.onMessage = (data) {
293286
_messageController.add({'type': 'data', 'id': id, 'data': data});
294287
};
295-
_data[id] = channel;
288+
_daChannels[id] = channel;
296289
}
297290

298291
_createDataChannel(id, RTCPeerConnection pc, {label: 'fileTransfer'}) async {
@@ -334,4 +327,22 @@ class Signaling {
334327
if (_socket != null) _socket.add(JSON.encode(data));
335328
print('send: ' + JSON.encode(data));
336329
}
330+
331+
_handleStatsReport(Timer timer, pc) async {
332+
if (pc != null) {
333+
List<StatsReport> reports = await pc.getStats(null);
334+
reports.forEach((report) {
335+
print("report => { ");
336+
print(" id: " + report.id + ",");
337+
print(" type: " + report.type + ",");
338+
print(" timestamp: ${report.timestamp},");
339+
print(" values => {");
340+
report.values.forEach((key, value) {
341+
print(" " + key + " : " + value + ", ");
342+
});
343+
print(" }");
344+
print("}");
345+
});
346+
}
347+
}
337348
}

0 commit comments

Comments
 (0)
0