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