Files
TTSTDConnect/flutter_sender/lib/features/discovery/device_list.dart
T
tongtong df2affa9e2 feat(video): 打通桌面端真实视频画面链路
- Rust: 新增 media::stream 访问单元队列与分片重组,FFI 增加 ttstd_video_next/pending/stats(ABI 2)

- Windows: runner 内嵌 Media Foundation 解码纹理插件(NV12/RGB32→BGRA),开启 CODECAPI_AVLowLatencyMode 消除约 36 帧积压,按显示区域裁掉 16 对齐补齐行

- Android: 大帧按 1200 字节分片发送;csd(SPS/PPS) 随每个关键帧重发,修复先投屏后连接时只收到 P 帧导致的黑屏

- Flutter: 独立 ttstd/video 通道获取 textureId 与统计,VideoView 渲染 Texture 并显示分辨率/PTS/失败原因

- 诊断: stats 增加 format/auBytes/keyframes/submitHr;缺插件、缺 SPS/PPS 显式提示;TTSTD_DUMP_VIDEO 可抓码流配合 ffprobe 定位

- 发现与服务检查: mDNS 发现客户端、服务地址探测、设置页与连接状态卡片(启动本机监听/停止)

- 工具与文档: video_feed 推流示例、一键打包脚本、DEMO 出画面排查表与实测截图
2026-11-27 04:29:40 +08:00

177 lines
5.7 KiB
Dart

import 'package:flutter/material.dart';
import '../../core/models.dart';
class DeviceList extends StatelessWidget {
const DeviceList({
super.key,
required this.devices,
required this.selectedId,
required this.onSelected,
required this.onRefresh,
this.refreshing = false,
this.shrinkWrap = false,
});
final List<DeviceInfo> devices;
final String? selectedId;
final ValueChanged<DeviceInfo> onSelected;
final VoidCallback onRefresh;
final bool refreshing;
final bool shrinkWrap;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(16, 16, 16, 8),
child: Row(
children: [
Icon(Icons.devices_other, size: 20, color: theme.colorScheme.primary),
const SizedBox(width: 8),
Text('可连接设备', style: theme.textTheme.titleMedium),
const Spacer(),
Text('${devices.length} 台', style: theme.textTheme.bodySmall),
IconButton(
tooltip: '重新发现',
onPressed: onRefresh,
icon: refreshing
? const SizedBox(
width: 16,
height: 16,
child: CircularProgressIndicator(strokeWidth: 2),
)
: const Icon(Icons.refresh),
),
],
),
),
if (shrinkWrap)
_buildList()
else
Expanded(child: _buildList()),
],
);
}
Widget _buildList() {
if (devices.isEmpty) return _EmptyState(onRefresh: onRefresh);
return ListView.separated(
shrinkWrap: shrinkWrap,
physics: shrinkWrap ? const NeverScrollableScrollPhysics() : null,
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
itemCount: devices.length,
separatorBuilder: (_, __) => const SizedBox(height: 8),
itemBuilder: (context, index) => _DeviceCard(
device: devices[index],
selected: devices[index].id == selectedId,
onTap: () => onSelected(devices[index]),
),
);
}
}
class _DeviceCard extends StatelessWidget {
const _DeviceCard({required this.device, required this.selected, required this.onTap});
final DeviceInfo device;
final bool selected;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Card(
clipBehavior: Clip.antiAlias,
color: selected ? theme.colorScheme.primaryContainer : null,
child: InkWell(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.all(12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
CircleAvatar(
backgroundColor: selected ? theme.colorScheme.primary : theme.colorScheme.surfaceContainerHighest,
foregroundColor: selected ? theme.colorScheme.onPrimary : theme.colorScheme.onSurface,
child: const Icon(Icons.android),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(device.name, style: theme.textTheme.titleSmall),
const SizedBox(height: 2),
Text('${device.ip}:${device.controlPort} · ${device.model}',
style: theme.textTheme.bodySmall,
maxLines: 1,
overflow: TextOverflow.ellipsis),
],
),
),
if (selected) Icon(Icons.check_circle, color: theme.colorScheme.primary),
],
),
const SizedBox(height: 10),
Wrap(
spacing: 6,
runSpacing: 4,
children: [
for (final capability in device.capabilities.take(4))
Chip(
visualDensity: VisualDensity.compact,
label: Text(capability, style: theme.textTheme.labelSmall),
padding: EdgeInsets.zero,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
],
),
const SizedBox(height: 6),
Text('指纹 ${device.shortFingerprint} · ${device.resolution}',
style: theme.textTheme.labelSmall?.copyWith(color: theme.colorScheme.outline)),
],
),
),
),
);
}
}
class _EmptyState extends StatelessWidget {
const _EmptyState({required this.onRefresh});
final VoidCallback onRefresh;
@override
Widget build(BuildContext context) {
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.wifi_find, size: 48),
const SizedBox(height: 12),
const Text('未发现设备'),
const SizedBox(height: 4),
Text(
'本机监听端点已移至设置;请确认被控端与主控端处于同一网段',
style: Theme.of(context).textTheme.bodySmall,
textAlign: TextAlign.center,
),
const SizedBox(height: 12),
OutlinedButton.icon(
onPressed: onRefresh,
icon: const Icon(Icons.refresh),
label: const Text('重新扫描'),
),
],
),
);
}
}