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