fix:调整切换清晰度逻辑
This commit is contained in:
parent
de6d2628f6
commit
ce193a2195
@ -91,9 +91,6 @@ class TalkViewNativeDecodeLogic extends BaseGetXController {
|
||||
|
||||
int? lastDecodedIFrameSeq;
|
||||
|
||||
// 新增:只允许切换清晰度后一次回绕重置的标志
|
||||
bool _allowStreamResetOnce = false;
|
||||
|
||||
// 初始化视频解码器
|
||||
Future<void> _initVideoDecoder() async {
|
||||
try {
|
||||
@ -166,17 +163,16 @@ class TalkViewNativeDecodeLogic extends BaseGetXController {
|
||||
int frameSeqI,
|
||||
ScpMessage scpMessage,
|
||||
) {
|
||||
// 只允许切换清晰度后一次回绕重置
|
||||
if (_allowStreamResetOnce &&
|
||||
// 检测frameSeq回绕,且为I帧
|
||||
if (!_pendingStreamReset &&
|
||||
_lastFrameSeq != null &&
|
||||
frameType == TalkDataH264Frame_FrameTypeE.I &&
|
||||
frameSeq < _lastFrameSeq!) {
|
||||
// 检测到新流I帧,进入loading并重置所有本地状态
|
||||
AppLog.log(
|
||||
'检测到新流I帧(仅切换清晰度后允许),frameSeq回绕,进入loading并重置: frameSeq=$frameSeq, lastFrameSeq=$_lastFrameSeq');
|
||||
'检测到新流I帧,frameSeq回绕,进入loading并重置: frameSeq=$frameSeq, lastFrameSeq=$_lastFrameSeq');
|
||||
Future.microtask(() => state.isLoading.value = true);
|
||||
_pendingStreamReset = true;
|
||||
_allowStreamResetOnce = false; // 只允许一次
|
||||
// 先暂停帧处理定时器,防止竞态
|
||||
_stopFrameProcessTimer();
|
||||
// 先释放并重新初始化解码器
|
||||
@ -189,13 +185,6 @@ class TalkViewNativeDecodeLogic extends BaseGetXController {
|
||||
_startFrameProcessTimer();
|
||||
// 不return,直接用该I帧初始化解码器并解码
|
||||
// 继续往下执行
|
||||
} else if (!_allowStreamResetOnce &&
|
||||
_lastFrameSeq != null &&
|
||||
frameType == TalkDataH264Frame_FrameTypeE.I &&
|
||||
frameSeq < _lastFrameSeq!) {
|
||||
// 非切换清晰度场景下的回绕,直接丢弃
|
||||
AppLog.log('检测到I帧回绕,但未切换清晰度,不重置: frameSeq=$frameSeq, lastFrameSeq=$_lastFrameSeq');
|
||||
return;
|
||||
}
|
||||
// 如果处于pendingStreamReset,等待新I帧
|
||||
if (_pendingStreamReset) {
|
||||
@ -1344,8 +1333,6 @@ class TalkViewNativeDecodeLogic extends BaseGetXController {
|
||||
_pendingStreamReset = false;
|
||||
_pendingResetWidth = width;
|
||||
_pendingResetHeight = height;
|
||||
// 新增:切换清晰度后允许一次回绕重置
|
||||
_allowStreamResetOnce = true;
|
||||
}
|
||||
|
||||
void _initHdOptions() {
|
||||
@ -1393,9 +1380,6 @@ class TalkViewNativeDecodeLogic extends BaseGetXController {
|
||||
state.isLoading.value = false;
|
||||
});
|
||||
|
||||
// 防止极端情况下回调未触发导致loading卡住,手动关闭loading
|
||||
state.isLoading.value = false;
|
||||
|
||||
// 重新启动帧处理定时器
|
||||
_startFrameProcessTimer();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user