Skip to content

Commit a2e6413

Browse files
committed
update.
1 parent 57c5868 commit a2e6413

File tree

4 files changed

+42
-296
lines changed

4 files changed

+42
-296
lines changed

lib/src/call_sample/call_sample.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ class _CallSampleState extends State<CallSample> {
110110
_signaling.switchCamera();
111111
}
112112

113-
_muteMic() {}
113+
_muteMic() {
114+
_signaling.muteMic();
115+
}
114116

115117
_buildRow(context, peer) {
116118
var self = (peer['id'] == _selfId);

lib/src/call_sample/signaling.dart

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,24 @@ class Signaling {
110110
}
111111
}
112112

113-
void invite(String peer_id, String media, use_screen) {
114-
this._sessionId = this._selfId + '-' + peer_id;
113+
void muteMic() {
114+
if (_localStream != null) {
115+
bool enabled = _localStream.getAudioTracks()[0].enabled;
116+
_localStream.getAudioTracks()[0].enabled = !enabled;
117+
}
118+
}
119+
120+
void invite(String peerId, String media, bool useScreen) {
121+
this._sessionId = this._selfId + '-' + peerId;
115122

116123
this.onStateChange?.call(SignalingState.CallStateNew);
117124

118-
_createPeerConnection(peer_id, media, use_screen).then((pc) {
119-
_peerConnections[peer_id] = pc;
125+
_createPeerConnection(peerId, media, useScreen).then((pc) {
126+
_peerConnections[peerId] = pc;
120127
if (media == 'data') {
121-
_createDataChannel(peer_id, pc);
128+
_createDataChannel(peerId, pc);
122129
}
123-
_createOffer(peer_id, pc, media);
130+
_createOffer(peerId, pc, media);
124131
});
125132
}
126133

@@ -339,7 +346,8 @@ class Signaling {
339346
.getTracks()
340347
.forEach((track) => pc.addTrack(track, _localStream));
341348

342-
/* Unified-Plan: Simuclast
349+
// Unified-Plan: Simuclast
350+
/*
343351
await pc.addTransceiver(
344352
track: _localStream.getAudioTracks()[0],
345353
init: RTCRtpTransceiverInit(
@@ -354,19 +362,32 @@ class Signaling {
354362
_localStream
355363
],
356364
sendEncodings: [
357-
RTCRtpEncoding(rid: 'f'),
365+
RTCRtpEncoding(rid: 'f', active: true),
358366
RTCRtpEncoding(
359367
rid: 'h',
368+
active: true,
360369
scaleResolutionDownBy: 2.0,
361-
maxBitrateBps: 150000,
370+
maxBitrate: 150000,
362371
),
363372
RTCRtpEncoding(
364373
rid: 'q',
374+
active: true,
365375
scaleResolutionDownBy: 4.0,
366-
maxBitrateBps: 100000,
376+
maxBitrate: 100000,
367377
),
368378
]),
369-
);
379+
);*/
380+
/*
381+
var sender = pc.getSenders().find(s => s.track.kind == "video");
382+
var parameters = sender.getParameters();
383+
if(!parameters)
384+
parameters = {};
385+
parameters.encodings = [
386+
{ rid: "h", active: true, maxBitrate: 900000 },
387+
{ rid: "m", active: true, maxBitrate: 300000, scaleResolutionDownBy: 2 },
388+
{ rid: "l", active: true, maxBitrate: 100000, scaleResolutionDownBy: 4 }
389+
];
390+
sender.setParameters(parameters);
370391
*/
371392
}
372393
pc.onIceCandidate = (candidate) {
@@ -423,15 +444,16 @@ class Signaling {
423444
}
424445

425446
_createDataChannel(id, RTCPeerConnection pc, {label: 'fileTransfer'}) async {
426-
RTCDataChannelInit dataChannelDict = new RTCDataChannelInit();
447+
RTCDataChannelInit dataChannelDict = new RTCDataChannelInit()
448+
..maxRetransmits = 30;
427449
RTCDataChannel channel = await pc.createDataChannel(label, dataChannelDict);
428450
_addDataChannel(id, channel);
429451
}
430452

431453
_createOffer(String id, RTCPeerConnection pc, String media) async {
432454
try {
433-
RTCSessionDescription s = await pc
434-
.createOffer(media == 'data' ? _dc_constraints : _constraints);
455+
RTCSessionDescription s =
456+
await pc.createOffer(media == 'data' ? _dc_constraints : {});
435457
pc.setLocalDescription(s);
436458
_send('offer', {
437459
'to': id,
@@ -447,8 +469,8 @@ class Signaling {
447469

448470
_createAnswer(String id, RTCPeerConnection pc, media) async {
449471
try {
450-
RTCSessionDescription s = await pc
451-
.createAnswer(media == 'data' ? _dc_constraints : _constraints);
472+
RTCSessionDescription s =
473+
await pc.createAnswer(media == 'data' ? _dc_constraints : {});
452474
pc.setLocalDescription(s);
453475
_send('answer', {
454476
'to': id,

pubspec.lock

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

0 commit comments

Comments
 (0)