修复录像下载时 downLoadFilePath 为 null#2166
Open
liushuaiyu wants to merge 2 commits into
Open
Conversation
fix: 修复录像下载时 downLoadFilePath 为 null 的问题 当 ZLM 的 on_stream_changed 回调先于 on_record_mp4 到达时, WVP 会立即清理会话,导致 on_record_mp4 处理时无法设置下载文件路径。 解决方案: 1. InviteStreamServiceImpl: 对下载类型的会话延迟5秒清理 InviteInfo 2. PlayServiceImpl: 对下载类型的会话延迟5秒发送BYE请求 这样确保 on_record_mp4 有足够时间处理并设置 downLoadFilePath。
fix: 修复录像下载时 downLoadFilePath 为 null 的问题 当 ZLM 的 on_stream_changed 回调先于 on_record_mp4 到达时, WVP 会立即清理会话,导致 on_record_mp4 处理时无法设置下载文件路径。 解决方案: 1. InviteStreamServiceImpl: 对下载类型的会话延迟5秒清理 InviteInfo 2. PlayServiceImpl: 对下载类型的会话延迟5秒发送BYE请求 这样确保 on_record_mp4 有足够时间处理并设置 downLoadFilePath。
|
@liushuaiyu is attempting to deploy a commit to the 648540858's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题原因与解决方案详细说明
一、问题根本原因
1. ZLM 事件发送顺序(硬编码)
当 NVR 停止推流时,ZLM 内部会按固定顺序触发两个 WebHook 事件:
on_stream_changed(regist=false)on_record_mp4关键问题:
on_stream_changed总是先于on_record_mp4发送!2. WVP 原有处理逻辑的缺陷
WVP 中有两个服务都监听了
MediaDepartureEvent(由on_stream_changed触发):服务1:
PlayServiceImpl服务2:
InviteStreamServiceImpl3. 竞态条件导致的失败
二、解决方案
核心思路
对下载类型的会话延迟清理,确保
on_record_mp4有足够时间处理并设置downLoadFilePath。修改的文件
1.
PlayServiceImpl.java(第239-253行)2.
InviteStreamServiceImpl.java(第56-69行)三、修复后的执行流程
四、测试验证结果
从日志中可以看到修复后的正确流程:
最终结果:
{ "code": 0, "msg": "成功", "data": { "progress": 1.0, "downLoadFilePath": { "httpPath": "http://192.168.1.96:9092/index/api/downloadFile?file_path=..." } } }五、方案优势
六、为什么需要两处修改?
PlayServiceImpl.stop()方法内部也会调用inviteStreamService.removeInviteInfo():如果只改一处:
PlayServiceImpl:InviteStreamServiceImpl仍会立即清理InviteStreamServiceImpl:PlayServiceImpl.stop()仍会调用removeInviteInfo()因此必须两处都改才能真正实现延迟清理。