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 出画面排查表与实测截图
This commit is contained in:
1 parent
adaa23f895
commit
df2affa9e2
30 files changed
+2814
-134
No files matched your search
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import '../../core/bridge.dart';
|
||||
import '../../core/models.dart';
|
||||
import '../../core/service_check.dart';
|
||||
|
||||
class SettingsPage extends StatefulWidget {
|
||||
const SettingsPage({
|
||||
@@ -28,6 +29,10 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
late bool _clipboardSync;
|
||||
late bool _fileTransfer;
|
||||
late int _bitrateMbps;
|
||||
DeviceInfo? _localListener;
|
||||
ServiceCheckResult? _serviceResult;
|
||||
bool _checkingServices = false;
|
||||
bool _listenerRunning = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -42,6 +47,8 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
_clipboardSync = widget.settings.clipboardSync;
|
||||
_fileTransfer = widget.settings.fileTransfer;
|
||||
_bitrateMbps = widget.settings.bitrateMbps;
|
||||
_loadLocalListener();
|
||||
_refreshListenerState();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -62,6 +69,102 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _loadLocalListener() async {
|
||||
final listener = await widget.bridge.localListener();
|
||||
if (!mounted) return;
|
||||
setState(() => _localListener = listener);
|
||||
}
|
||||
|
||||
void _refreshListenerState() {
|
||||
try {
|
||||
final status = widget.bridge.demoStatus();
|
||||
_listenerRunning = status['running'] == true;
|
||||
} on Object catch (_) {
|
||||
_listenerRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _runServiceCheck() async {
|
||||
setState(() => _checkingServices = true);
|
||||
final url = _useLocalSignaling
|
||||
? widget.bridge.localSignalingUrl(_port)
|
||||
: _signalingUrl.text.trim();
|
||||
final listener = _localListener ?? await widget.bridge.localListener();
|
||||
final host = listener?.ip ?? '127.0.0.1';
|
||||
final results = await Future.wait<bool>([
|
||||
ServiceChecker.checkSignaling(url),
|
||||
ServiceChecker.checkTcp(host, 41001),
|
||||
]);
|
||||
Map<String, dynamic> status = const <String, dynamic>{'running': false};
|
||||
try {
|
||||
status = widget.bridge.demoStatus();
|
||||
} on Object catch (_) {}
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_localListener = listener;
|
||||
_listenerRunning = status['running'] == true;
|
||||
_serviceResult = ServiceCheckResult(
|
||||
nativeCoreLoaded: widget.bridge.nativeCore != null,
|
||||
localSignalingRunning: widget.bridge.isLocalSignalingRunning,
|
||||
signalingReachable: results[0],
|
||||
listenerRunning: _listenerRunning,
|
||||
listenerReachable: results[1],
|
||||
signalingUrl: url,
|
||||
listenerHost: host,
|
||||
listenerPort: 41001,
|
||||
);
|
||||
_checkingServices = false;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _toggleListener() async {
|
||||
if (_listenerRunning) {
|
||||
widget.bridge.stopDemoServer();
|
||||
if (!mounted) return;
|
||||
setState(() => _listenerRunning = false);
|
||||
} else {
|
||||
final started = widget.bridge.startDemoServer();
|
||||
var running = started;
|
||||
if (!running) {
|
||||
try {
|
||||
running = widget.bridge.demoStatus()['running'] == true;
|
||||
} on Object catch (_) {}
|
||||
}
|
||||
if (!mounted) return;
|
||||
setState(() => _listenerRunning = running);
|
||||
if (!running) _snack('本机监听启动失败');
|
||||
}
|
||||
await _runServiceCheck();
|
||||
}
|
||||
|
||||
Widget _serviceRow(String label, bool? ok) {
|
||||
final theme = Theme.of(context);
|
||||
final icon = ok == null
|
||||
? Icons.help_outline
|
||||
: ok
|
||||
? Icons.check_circle
|
||||
: Icons.cancel;
|
||||
final color = ok == null
|
||||
? theme.colorScheme.outline
|
||||
: ok
|
||||
? theme.colorScheme.primary
|
||||
: theme.colorScheme.error;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 3),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(icon, size: 18, color: color),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(child: Text(label, style: theme.textTheme.bodySmall)),
|
||||
Text(
|
||||
ok == null ? '未检测' : ok ? '正常' : '异常',
|
||||
style: theme.textTheme.bodySmall?.copyWith(color: color),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _setLocalServer(bool enabled) {
|
||||
setState(() => _localSignalingEnabled = enabled);
|
||||
}
|
||||
@@ -203,6 +306,77 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.health_and_safety, color: theme.colorScheme.primary),
|
||||
const SizedBox(width: 8),
|
||||
Text('服务检测', style: theme.textTheme.titleMedium),
|
||||
const Spacer(),
|
||||
TextButton.icon(
|
||||
onPressed: _checkingServices ? null : _runServiceCheck,
|
||||
icon: _checkingServices
|
||||
? const SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
)
|
||||
: const Icon(Icons.refresh),
|
||||
label: Text(_checkingServices ? '检测中' : '检测'),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_serviceRow('Rust Core 动态库', _serviceResult?.nativeCoreLoaded),
|
||||
_serviceRow('本机信令进程', _serviceResult?.localSignalingRunning),
|
||||
_serviceRow('信令 /healthz', _serviceResult?.signalingReachable),
|
||||
_serviceRow('本机监听服务', _serviceResult?.listenerRunning),
|
||||
_serviceRow('主控监听端口 41001', _serviceResult?.listenerReachable),
|
||||
const Divider(height: 24),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text('本机监听端点', style: theme.textTheme.titleSmall),
|
||||
),
|
||||
TextButton.icon(
|
||||
onPressed: _toggleListener,
|
||||
icon: Icon(
|
||||
_listenerRunning ? Icons.stop : Icons.play_arrow,
|
||||
size: 18,
|
||||
),
|
||||
label: Text(_listenerRunning ? '停止' : '启动'),
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
_localListener == null
|
||||
? '未获取到本机 IPv4 地址'
|
||||
: '${_localListener!.ip}:${_localListener!.controlPort} · 媒体 ${_localListener!.mediaPort}',
|
||||
style: theme.textTheme.bodySmall,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'该端点仅用于被控端接入,不再显示在主页设备列表。',
|
||||
style: theme.textTheme.bodySmall,
|
||||
),
|
||||
if (_serviceResult != null && _serviceResult!.signalingUrl.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: Text(
|
||||
'检测地址:${_serviceResult!.signalingUrl}',
|
||||
style: theme.textTheme.labelSmall,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const Divider(height: 32),
|
||||
SwitchListTile(
|
||||
title: const Text('优先使用 H.265'),
|
||||
|
||||
Reference in new issue
Block a user