|
1 | 1 | import 'dart:async';
|
2 | 2 | import 'dart:js_interop';
|
| 3 | +import 'dart:js_interop_unsafe'; |
| 4 | +import 'dart:js_util' as js; |
3 | 5 | import 'dart:typed_data';
|
4 | 6 |
|
5 | 7 | import 'package:web/web.dart' as web;
|
@@ -77,25 +79,49 @@ class MediaStreamTrackWeb extends MediaStreamTrack {
|
77 | 79 | var settings = jsTrack.getSettings();
|
78 | 80 | var _converted = <String, dynamic>{};
|
79 | 81 | if (kind == 'audio') {
|
80 |
| - _converted['sampleRate'] = settings.sampleRate; |
81 |
| - _converted['sampleSize'] = settings.sampleSize; |
82 |
| - _converted['echoCancellation'] = settings.echoCancellation; |
83 |
| - _converted['autoGainControl'] = settings.autoGainControl; |
84 |
| - _converted['noiseSuppression'] = settings.noiseSuppression; |
85 |
| - _converted['latency'] = settings.latency; |
86 |
| - _converted['channelCount'] = settings.channelCount; |
| 82 | + if (settings.has('sampleRate')) { |
| 83 | + _converted['sampleRate'] = settings.sampleRate; |
| 84 | + } |
| 85 | + if (settings.has('sampleSize')) { |
| 86 | + _converted['sampleSize'] = settings.sampleSize; |
| 87 | + } |
| 88 | + if (settings.has('echoCancellation')) { |
| 89 | + _converted['echoCancellation'] = settings.echoCancellation; |
| 90 | + } |
| 91 | + if (settings.has('autoGainControl')) { |
| 92 | + _converted['autoGainControl'] = settings.autoGainControl; |
| 93 | + } |
| 94 | + if (settings.has('noiseSuppression')) { |
| 95 | + _converted['noiseSuppression'] = settings.noiseSuppression; |
| 96 | + } |
| 97 | + if (settings.has('latency')) _converted['latency'] = settings.latency; |
| 98 | + if (settings.has('channelCount')) { |
| 99 | + _converted['channelCount'] = settings.channelCount; |
| 100 | + } |
87 | 101 | } else {
|
88 |
| - _converted['width'] = settings.width; |
89 |
| - _converted['height'] = settings.height; |
90 |
| - _converted['aspectRatio'] = settings.aspectRatio; |
91 |
| - _converted['frameRate'] = settings.frameRate; |
92 |
| - if (isMobile) { |
| 102 | + if (settings.has('width')) { |
| 103 | + _converted['width'] = settings.width; |
| 104 | + } |
| 105 | + if (settings.has('height')) { |
| 106 | + _converted['height'] = settings.height; |
| 107 | + } |
| 108 | + if (settings.has('aspectRatio')) { |
| 109 | + _converted['aspectRatio'] = settings.aspectRatio; |
| 110 | + } |
| 111 | + if (settings.has('frameRate')) { |
| 112 | + _converted['frameRate'] = settings.frameRate; |
| 113 | + } |
| 114 | + if (isMobile && settings.has('facingMode')) { |
93 | 115 | _converted['facingMode'] = settings.facingMode;
|
94 | 116 | }
|
95 |
| - _converted['resizeMode'] = settings.resizeMode; |
| 117 | + if (settings.has('resizeMode')) { |
| 118 | + _converted['resizeMode'] = settings.resizeMode; |
| 119 | + } |
| 120 | + } |
| 121 | + if (settings.has('deviceId')) _converted['deviceId'] = settings.deviceId; |
| 122 | + if (settings.has('groupId')) { |
| 123 | + _converted['groupId'] = settings.groupId; |
96 | 124 | }
|
97 |
| - _converted['deviceId'] = settings.deviceId; |
98 |
| - _converted['groupId'] = settings.groupId; |
99 | 125 | return _converted;
|
100 | 126 | }
|
101 | 127 |
|
|
0 commit comments