使用`timeShiftBufferDepth`替代`minimumUpdatePeriod`

This commit is contained in:
nilaoda 2022-07-10 11:57:54 +08:00
parent 4172a69819
commit 1795d3920e
1 changed files with 5 additions and 5 deletions

View File

@ -73,10 +73,10 @@ namespace N_m3u8DL_RE.Parser.Extractor
//分片最大时长 //分片最大时长
var maxSegmentDuration = mpdElement.Attribute("maxSegmentDuration")?.Value; var maxSegmentDuration = mpdElement.Attribute("maxSegmentDuration")?.Value;
//MPD更新间隔
var minimumUpdatePeriod = mpdElement.Attribute("minimumUpdatePeriod")?.Value;
//分片从该时间起可用 //分片从该时间起可用
var availabilityStartTime = mpdElement.Attribute("availabilityStartTime")?.Value; var availabilityStartTime = mpdElement.Attribute("availabilityStartTime")?.Value;
//在availabilityStartTime的前XX段时间分片有效
var timeShiftBufferDepth = mpdElement.Attribute("timeShiftBufferDepth")?.Value;
//MPD发布时间 //MPD发布时间
var publishTime = mpdElement.Attribute("publishTime")?.Value; var publishTime = mpdElement.Attribute("publishTime")?.Value;
//MPD总时长 //MPD总时长
@ -147,9 +147,9 @@ namespace N_m3u8DL_RE.Parser.Extractor
}; };
streamSpec.Playlist.IsLive = isLive; streamSpec.Playlist.IsLive = isLive;
//设置刷新间隔 //设置刷新间隔
if (minimumUpdatePeriod != null) if (timeShiftBufferDepth != null)
{ {
streamSpec.Playlist.RefreshIntervalMs = XmlConvert.ToTimeSpan(minimumUpdatePeriod).TotalMilliseconds; streamSpec.Playlist.RefreshIntervalMs = XmlConvert.ToTimeSpan(timeShiftBufferDepth).TotalMilliseconds;
} }
//读取声道数量 //读取声道数量
@ -327,7 +327,7 @@ namespace N_m3u8DL_RE.Parser.Extractor
var now = publishTime == null ? DateTime.Now : DateTime.Parse(publishTime); var now = publishTime == null ? DateTime.Now : DateTime.Parse(publishTime);
var availableTime = DateTime.Parse(availabilityStartTime); var availableTime = DateTime.Parse(availabilityStartTime);
var ts = now - availableTime; var ts = now - availableTime;
var updateTs = XmlConvert.ToTimeSpan(minimumUpdatePeriod); var updateTs = XmlConvert.ToTimeSpan(timeShiftBufferDepth);
//(当前时间到发布时间的时间差 - 最小刷新间隔) / 分片时长 //(当前时间到发布时间的时间差 - 最小刷新间隔) / 分片时长
startNumber = (long)((ts.TotalSeconds - updateTs.TotalSeconds) * timescale / duration); startNumber = (long)((ts.TotalSeconds - updateTs.TotalSeconds) * timescale / duration);
totalNumber = (long)(updateTs.TotalSeconds * timescale / duration); totalNumber = (long)(updateTs.TotalSeconds * timescale / duration);