Retain selectable audio languages and DVB subtitles through live continuity
This commit is contained in:
@@ -18,7 +18,7 @@ public sealed class ContinuityTimeline
|
||||
private long clock90k = 126000;
|
||||
private string previousEpoch;
|
||||
private DateTime lastAppend, lastLive;
|
||||
public ContinuityTimeline(DateTime now) { lastAppend = now; lastLive = DateTime.MinValue; Add(null, "waiting", "slate", SegmentSeconds, now); Add(null, "waiting", "slate", SegmentSeconds, now); }
|
||||
public ContinuityTimeline(DateTime now, bool withSlates = true) { lastAppend = now; lastLive = DateTime.MinValue; if (!withSlates) return; Add(null, "waiting", "slate", SegmentSeconds, now); Add(null, "waiting", "slate", SegmentSeconds, now); }
|
||||
private void Add(byte[] video, string slate, string epoch, double duration, DateTime now)
|
||||
{
|
||||
var discontinuity = next > 0 && (slate != null || previousEpoch != epoch);
|
||||
@@ -30,7 +30,7 @@ public sealed class ContinuityTimeline
|
||||
}
|
||||
public void Live(byte[] video, string epoch, double duration, DateTime now)
|
||||
{
|
||||
if (video == null || video.Length == 0 || video.Length > 32 * 1024 * 1024 || duration <= 0 || duration > 5) throw new ArgumentException("Invalid live segment");
|
||||
if (video == null || video.Length == 0 || video.Length > 32 * 1024 * 1024 || duration <= 0 || duration > 30) throw new ArgumentException("Invalid live segment");
|
||||
lock (gate) { lastLive = now; Add(video, null, epoch, duration, now); }
|
||||
}
|
||||
public void Tick(DateTime now, bool retrying)
|
||||
@@ -45,7 +45,8 @@ public sealed class ContinuityTimeline
|
||||
lock (gate)
|
||||
{
|
||||
var window = segments.TakeLast(4).ToArray();
|
||||
var text = new StringBuilder("#EXTM3U\n#EXT-X-VERSION:3\n#EXT-X-TARGETDURATION:5\n");
|
||||
var text = new StringBuilder($"#EXTM3U\n#EXT-X-VERSION:3\n#EXT-X-TARGETDURATION:{Math.Max(5, Math.Ceiling(window.Select(s => s.Duration).DefaultIfEmpty(5).Max()))}\n");
|
||||
if (window.Length == 0) return text.ToString();
|
||||
text.Append("#EXT-X-MEDIA-SEQUENCE:").Append(window[0].Sequence).Append('\n');
|
||||
text.Append("#EXT-X-DISCONTINUITY-SEQUENCE:").Append(window[0].DiscontinuitiesBefore).Append('\n');
|
||||
foreach (var segment in window)
|
||||
|
||||
Reference in New Issue
Block a user