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