Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2023-03-31 16:10:52 +08:00
parent 02561c3fff
commit 78748271ac
22 changed files with 470 additions and 441 deletions

View File

@@ -1349,29 +1349,30 @@ class _DisplayMenuState extends State<_DisplayMenu> {
codec() {
return futureBuilder(future: () async {
final supportedHwcodec =
await bind.sessionSupportedHwcodec(id: widget.id);
final alternativeCodecs =
await bind.sessionAlternativeCodecs(id: widget.id);
final codecPreference =
await bind.sessionGetOption(id: widget.id, arg: 'codec-preference') ??
'';
return {
'supportedHwcodec': supportedHwcodec,
'alternativeCodecs': alternativeCodecs,
'codecPreference': codecPreference
};
}(), hasData: (data) {
final List<bool> codecs = [];
try {
final Map codecsJson = jsonDecode(data['supportedHwcodec']);
final Map codecsJson = jsonDecode(data['alternativeCodecs']);
final vp8 = codecsJson['vp8'] ?? false;
final h264 = codecsJson['h264'] ?? false;
final h265 = codecsJson['h265'] ?? false;
codecs.add(vp8);
codecs.add(h264);
codecs.add(h265);
} catch (e) {
debugPrint("Show Codec Preference err=$e");
}
final visible = bind.mainHasHwcodec() &&
codecs.length == 2 &&
(codecs[0] || codecs[1]);
final visible =
codecs.length == 3 && (codecs[0] || codecs[1] || codecs[2]);
if (!visible) return Offstage();
final groupValue = data['codecPreference'] as String;
onChanged(String? value) async {
@@ -1392,6 +1393,13 @@ class _DisplayMenuState extends State<_DisplayMenu> {
onChanged: onChanged,
ffi: widget.ffi,
),
_RadioMenuButton<String>(
child: Text(translate('VP8')),
value: 'vp8',
groupValue: groupValue,
onChanged: codecs[0] ? onChanged : null,
ffi: widget.ffi,
),
_RadioMenuButton<String>(
child: Text(translate('VP9')),
value: 'vp9',
@@ -1403,14 +1411,14 @@ class _DisplayMenuState extends State<_DisplayMenu> {
child: Text(translate('H264')),
value: 'h264',
groupValue: groupValue,
onChanged: codecs[0] ? onChanged : null,
onChanged: codecs[1] ? onChanged : null,
ffi: widget.ffi,
),
_RadioMenuButton<String>(
child: Text(translate('H265')),
value: 'h265',
groupValue: groupValue,
onChanged: codecs[1] ? onChanged : null,
onChanged: codecs[2] ? onChanged : null,
ffi: widget.ffi,
),
]);