Various Live stream improvements, streamed directly without local proxy, attempt to reduce errors and stutters.
This commit is contained in:
1 parent
2dbd5840c0
commit
2bdcd0007d
27 files changed
+1360
-946
No files matched your search
@@ -32,6 +32,13 @@ namespace PlaybackTelemetry
|
||||
return "unknown"
|
||||
end function
|
||||
|
||||
function ContentVideoLoadId(content as object) as string
|
||||
if content = invalid
|
||||
return ""
|
||||
end if
|
||||
return ValidString(content.videoLoadId)
|
||||
end function
|
||||
|
||||
' The summary's wire rule: false, 0, "", [] and invalid are omitted, at every depth; a reader takes an absent
|
||||
' field as that default.
|
||||
function OmitDefaults(value as dynamic) as dynamic
|
||||
@@ -254,6 +261,7 @@ namespace PlaybackTelemetry
|
||||
`logged_in: ${loggedIn}`
|
||||
`backend: ${backend}`
|
||||
`is_live: ${isLive}`
|
||||
`video_load_id: ${PlaybackTelemetry.ContentVideoLoadId(content)}`
|
||||
].Join(Chr(10))
|
||||
fingerprint = [
|
||||
Locale.VideoPlayer.ErrorPlayingVideo
|
||||
@@ -300,6 +308,7 @@ namespace PlaybackTelemetry
|
||||
summary = {
|
||||
"live": m.transport.isLive
|
||||
"backend": PlaybackTelemetry.ContentBackend(content)
|
||||
"video_load_id": PlaybackTelemetry.ContentVideoLoadId(content)
|
||||
"outcome": m.outcome
|
||||
"metadata_done_at_ms": m.metadataDoneAtMs
|
||||
"first_playing_at_ms": m.firstPlayingAtMs
|
||||
|
||||
@@ -94,9 +94,6 @@ namespace TransportController
|
||||
' not a seek into the last instants (which just re-buffers and fights the device's EOF auto-resume).
|
||||
' Matches the SponsorBlock finish rule (SkipTargetForSegment).
|
||||
const FINISH_EPSILON_MS = 2000
|
||||
' Live streams whose DVR window is under this are treated as NOT rewindable (a ~30s window is just the
|
||||
' buffer): the rewind/scan/replay commands are ignored and the bar drops the "Rewind live TV" label.
|
||||
const LIVE_REWIND_MIN_WINDOW_MS = 60000
|
||||
const REPLAY_TOAST_MS = 700 ' how long the transient InstantReplay icon stays before it self-clears
|
||||
' "● LIVE" shows while the offset is within this jitter band of the inherent latency; beyond it the bar
|
||||
' shows the time-behind. The clock-anchored edge advances smoothly, so this only needs to absorb position
|
||||
@@ -130,8 +127,7 @@ namespace TransportController
|
||||
isLive as boolean = false
|
||||
private hasStoryboards as boolean = false
|
||||
storyboardStepMs as integer = 2000 ' VOD per-tap step + scan base (storyboard L2 interval)
|
||||
' Live DVR window length (0 = unknown). The generated DASH anchors t=0 to the window start, so the
|
||||
' rewind floor is edge - window once the session outlives the window (content below it has expired).
|
||||
' Live DVR window length (0 = unknown); see LiveFloorMs.
|
||||
private dvrWindowMs as integer = 0
|
||||
|
||||
' ---- inputs pushed by the coordinator (OnPosition / OnDuration / OnReady) ----
|
||||
@@ -211,22 +207,9 @@ namespace TransportController
|
||||
end if
|
||||
end function
|
||||
|
||||
' Whether this live stream is rewindable at all. The DVR window we receive is the same value the
|
||||
' generated DASH advertises as timeShiftBufferDepth, so this IS the manifest's signal: a tiny window
|
||||
' (~30s) is just the buffer, not a rewind feature. Unknown (0) assumes rewindable.
|
||||
function CanRewindLive() as boolean
|
||||
if not m.isLive
|
||||
return false
|
||||
end if
|
||||
if m.dvrWindowMs <= 0
|
||||
return true
|
||||
end if
|
||||
return m.dvrWindowMs >= TransportController.LIVE_REWIND_MIN_WINDOW_MS
|
||||
end function
|
||||
|
||||
' The rewind FLOOR: the oldest still-available position. t=0 is the window start at manifest build
|
||||
' time, so as the session outlives the window the floor advances (edge - window); 0 while unknown or
|
||||
' while the stream is younger than its window.
|
||||
' The rewind FLOOR: the oldest still-available position. t=0 is the oldest segment at manifest build
|
||||
' time (the stream's start on a stream younger than the window), so as the session outlives the window
|
||||
' the floor advances (edge - window); 0 while unknown or until then.
|
||||
function LiveFloorMs() as integer
|
||||
if m.dvrWindowMs <= 0
|
||||
return 0
|
||||
@@ -404,10 +387,6 @@ namespace TransportController
|
||||
return
|
||||
end if
|
||||
if m.isLive
|
||||
' a non-rewindable live stream (DVR window is just the buffer) takes no transport input.
|
||||
if not m.CanRewindLive()
|
||||
return
|
||||
end if
|
||||
if command = TransportController.Command.Left
|
||||
m.LiveStep(-1)
|
||||
else if command = TransportController.Command.Right
|
||||
@@ -714,10 +693,7 @@ namespace TransportController
|
||||
function Replay() as void
|
||||
' InstantReplay works from ANY state. From a transport (frozen) it cancels it and RESUMES from
|
||||
' cursor-20s; from idle it just seeks -20s and keeps the play state. Reference is the cursor (= position
|
||||
' while idle). A non-rewindable live stream takes no replay either.
|
||||
if m.isLive and not m.CanRewindLive()
|
||||
return
|
||||
end if
|
||||
' while idle).
|
||||
wasTransport = (m.transportMode <> TransportController.Mode.Idle)
|
||||
' spamming InstantReplay must ACCUMULATE: while a prior replay seek is still in flight, base off the
|
||||
' LAST target so each press goes another -20s, not off the stale position (all presses landing together).
|
||||
|
||||
@@ -26,7 +26,7 @@ function Init()
|
||||
' language — "EN DIRECT" is far wider than "LIVE"); measured lazily, once.
|
||||
m.liveBadgeLaidOut = false
|
||||
|
||||
for each field in ["transportMode", "positionMs", "durationMs", "cursorMs", "isLive", "canRewind", "liveOffsetMs", "atLiveEdge", "forceLiveBadge"]
|
||||
for each field in ["transportMode", "positionMs", "durationMs", "cursorMs", "isLive", "liveOffsetMs", "liveFloorMs", "atLiveEdge", "forceLiveBadge"]
|
||||
m.top.ObserveField(field, FuncName(Repaint))
|
||||
end for
|
||||
m.top.ObserveField("focused", FuncName(OnFocusChange))
|
||||
@@ -84,12 +84,13 @@ function RenderLiveBar() as void
|
||||
' moved yet at entry, so atLiveEdge alone would keep the badge up.
|
||||
showBadge = (m.top.atLiveEdge or m.top.forceLiveBadge) and not transportActive
|
||||
|
||||
' Fill + playhead are proportional to the cursor's place in the DVR window [0, effEdge], where
|
||||
' Fill + playhead are proportional to the cursor's place in the reachable range [floor, effEdge], where
|
||||
' effEdge = cursor + offset; at the edge the playhead sits at the right end and the fill clips rightward.
|
||||
effEdge = m.top.cursorMs + m.top.liveOffsetMs
|
||||
floor = m.top.liveFloorMs
|
||||
span = m.top.cursorMs + m.top.liveOffsetMs - floor
|
||||
frac = 1.0
|
||||
if effEdge > 0
|
||||
frac = m.top.cursorMs / (effEdge * 1.0)
|
||||
if span > 0
|
||||
frac = (m.top.cursorMs - floor) / (span * 1.0)
|
||||
end if
|
||||
if frac < 0
|
||||
frac = 0
|
||||
@@ -106,12 +107,7 @@ function RenderLiveBar() as void
|
||||
' Handle raised for the bif while rewinding, resting at the edge otherwise.
|
||||
PositionHandle(transportActive)
|
||||
|
||||
' the rewind hint only when the stream actually rewinds (a buffer-sized DVR window doesn't count).
|
||||
if m.top.canRewind
|
||||
m.currentLabel.text = m.rewindLiveText
|
||||
else
|
||||
m.currentLabel.text = ""
|
||||
end if
|
||||
m.currentLabel.text = m.rewindLiveText
|
||||
|
||||
if showBadge
|
||||
m.remainingLabel.text = ""
|
||||
|
||||
@@ -150,17 +150,6 @@ namespace Tests
|
||||
m.assertFalse(m.top.findNode("liveLabel").visible)
|
||||
end function
|
||||
|
||||
@it("a NON-rewindable live stream (buffer-sized DVR window) drops the rewind label")
|
||||
function _()
|
||||
m.top.isLive = true
|
||||
m.top.transportMode = TransportController.Mode.Idle
|
||||
m.top.canRewind = false
|
||||
m.assertEqual(m.top.findNode("currentLabel").text, "")
|
||||
' rewindable again (e.g. next content) -> the label returns
|
||||
m.top.canRewind = true
|
||||
m.assertEqual(m.top.findNode("currentLabel").text, Tr(Locale.VideoPlayer.RewindLiveTv))
|
||||
end function
|
||||
|
||||
@it("AT the edge: frac=1 -> playhead at 1130.87 (the exact at-edge stock pin) + ● LIVE")
|
||||
function _()
|
||||
m.top.isLive = true
|
||||
@@ -189,6 +178,21 @@ namespace Tests
|
||||
m.assertTrue(moved > 85 and moved < 105) ' ~1136.87/12 ≈ 95px
|
||||
end function
|
||||
|
||||
@it("starts the bar at the floor once the session outlives the window")
|
||||
function _()
|
||||
m.top.isLive = true
|
||||
m.top.transportMode = TransportController.Mode.LiveDvr
|
||||
m.top.atLiveEdge = false
|
||||
m.top.liveFloorMs = 3600000 ' 1h into the session: the first hour has expired
|
||||
m.top.cursorMs = 25200000 ' 7h
|
||||
m.top.liveOffsetMs = 21600000 ' 6h behind -> edge 13h, halfway through [1h, 13h]
|
||||
fill = m.top.findNode("trackFill")
|
||||
m.assertTrue(Abs(fill.clippingRect.x - 0.5 * 1136.8679) < 0.5)
|
||||
m.top.cursorMs = 3600000 ' at the floor
|
||||
m.top.liveOffsetMs = 43200000
|
||||
m.assertEqual(fill.clippingRect.x, 0.0)
|
||||
end function
|
||||
|
||||
@it("shows the ● LIVE badge only at the edge")
|
||||
function _()
|
||||
m.top.isLive = true
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
<component name="TrickPlayBar" extends="Group">
|
||||
<!-- A projection of the shared scalar input fields; no outputs. Every input field is observed in code
|
||||
(not onChange) and a change repaints. The scanGlyph is a child of the handle so it paints in front of
|
||||
the bif. Left label = "Rewind live TV" while the stream is rewindable (canRewind); right label =
|
||||
offset M:SS when behind, or "● LIVE" at the edge. -->
|
||||
the bif. Left label = "Rewind live TV" on live; right label = offset M:SS when behind, or "● LIVE"
|
||||
at the edge. -->
|
||||
<interface>
|
||||
<field id="transportMode" type="integer" value="0" /> <!-- selects cursor vs position + raises the handle -->
|
||||
<field id="positionMs" type="integer" value="0" /> <!-- real Video position (used when idle) -->
|
||||
<field id="durationMs" type="integer" value="0" />
|
||||
<field id="cursorMs" type="integer" value="0" /> <!-- transport cursor (used when active) -->
|
||||
<field id="isLive" type="boolean" value="false" />
|
||||
<field id="canRewind" type="boolean" value="true" /> <!-- live only: false (buffer-sized DVR window) drops the rewind label -->
|
||||
<field id="liveOffsetMs" type="integer" value="0" /> <!-- edge - cursor; the right-label M:SS -->
|
||||
<field id="liveFloorMs" type="integer" value="0" /> <!-- oldest reachable position: the live bar's left end -->
|
||||
<field id="atLiveEdge" type="boolean" value="true" /> <!-- swaps "● LIVE" <-> offset -->
|
||||
|
||||
<field id="glyph" type="integer" value="0" />
|
||||
|
||||
@@ -289,6 +289,7 @@ function PushTransportToRenderers() as void
|
||||
m.trickPlayBar.durationMs = m.transport.durationMs
|
||||
|
||||
if mode <> TransportController.Mode.Idle or isLive
|
||||
m.trickPlayBar.liveFloorMs = m.transport.LiveFloorMs()
|
||||
m.trickPlayBar.cursorMs = m.transport.cursorMs
|
||||
m.trickPlayBar.liveOffsetMs = m.transport.liveOffsetMs
|
||||
m.trickPlayBar.atLiveEdge = m.transport.atLiveEdge
|
||||
@@ -1151,13 +1152,9 @@ function OnVideoContentJobDone(event as object) as void
|
||||
' fill them in for VOD.
|
||||
isLive = content <> invalid and content.Live = true
|
||||
m.transport.SetContent(isLive, 2000, false)
|
||||
' live floor: how far back the DVR window reaches (0 = unknown -> the brain keeps the [0, edge] clamp).
|
||||
' The generated DASH anchors t=0 to the window start, so floor = edge - window as the session outlives it.
|
||||
' The same window decides rewindability: a buffer-sized window means no live trickplay at all.
|
||||
' Use the seekable depth (window - cushion) to match the manifest's timeShiftBufferDepth.
|
||||
' The seekable depth keeps the rewind floor on the manifest's listed segments (see Innertube.GetLiveTimeline).
|
||||
m.transport.SetLiveDvrWindow(ValidInt(metadata.liveSeekableWindowSec) * 1000)
|
||||
m.trickPlayBar.isLive = isLive
|
||||
m.trickPlayBar.canRewind = m.transport.CanRewindLive()
|
||||
m.bifDisplay.tileSet = invalid
|
||||
|
||||
' anchor the live edge clock at the cushioned availabilityStartTime and start the 1s heartbeat: the brain
|
||||
@@ -1167,7 +1164,7 @@ function OnVideoContentJobDone(event as object) as void
|
||||
m.liveFallbackEdgeMs = -1
|
||||
m.liveFallbackAtSeconds = 0
|
||||
if isLive
|
||||
ast = ValidString(metadata.liveCushionedAvailabilityStartUtc)
|
||||
ast = ValidString(metadata.liveAvailabilityStartUtc)
|
||||
if ast <> ""
|
||||
astDate = CreateObject("roDateTime")
|
||||
astDate.FromISO8601String(ast)
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Tests
|
||||
content.addField("playletStreamUrls", "array", false)
|
||||
content.addField("playletStreamUrlIndex", "integer", false)
|
||||
content.addField("playletStreamSource", "string", false)
|
||||
content.addField("videoLoadId", "string", false)
|
||||
content.setFields({
|
||||
videoId: "vid1"
|
||||
backend: "playlet"
|
||||
@@ -31,6 +32,7 @@ namespace Tests
|
||||
playletStreamUrls: urls
|
||||
playletStreamUrlIndex: 0
|
||||
playletStreamSource: "adaptiveFormats"
|
||||
videoLoadId: "load1"
|
||||
})
|
||||
m.top.content = content
|
||||
end function
|
||||
@@ -107,7 +109,7 @@ namespace Tests
|
||||
m.State(VideoState.Error)
|
||||
report = m.global.telemetry.LogEvent
|
||||
m.assertEqual(report.level, "warning", "retried: not shown to the viewer")
|
||||
m.assertTrue(report.message.InStr("Url: http://a") > 0 and report.message.InStr("Url index: 0") > 0, "got: " + report.message)
|
||||
m.assertTrue(report.message.InStr("Url: http://a") > 0 and report.message.InStr("Url index: 0") > 0, `got: ${report.message}`)
|
||||
m.State(VideoState.Playing)
|
||||
summary = m.Close()
|
||||
m.assertEqual(summary.error_count, 1)
|
||||
@@ -115,6 +117,17 @@ namespace Tests
|
||||
m.assertEqual(summary.outcome, "closed")
|
||||
end function
|
||||
|
||||
@it("the video load id joins the error report to the summary")
|
||||
function _()
|
||||
m.SetContent(["http://stream"])
|
||||
m.HttpError()
|
||||
m.State(VideoState.Error)
|
||||
report = m.global.telemetry.LogEvent
|
||||
m.assertTrue(report.message.InStr("video_load_id: load1") > 0, `got: ${report.message}`)
|
||||
summary = m.Close()
|
||||
m.assertEqual(summary.video_load_id, "load1")
|
||||
end function
|
||||
|
||||
@it("an error with no retry left ends in error")
|
||||
function _()
|
||||
m.SetContent(["http://stream"])
|
||||
|
||||
@@ -115,13 +115,12 @@ function TestSetControl(value as string) as void
|
||||
m.top.control = value
|
||||
end function
|
||||
|
||||
' TestSetLive — flip the loaded content to a rewindable live stream with a known edge: what
|
||||
' TestSetLive — flip the loaded content to a live stream with a known edge: what
|
||||
' OnVideoContentJobDone does for real live content (SetContent + DVR window + bar fields), minus the job.
|
||||
function TestSetLive(edgeMs as integer) as void
|
||||
m.transport.SetContent(true, 2000, false)
|
||||
m.transport.SetLiveDvrWindow(4 * 3600 * 1000) ' 4h window -> rewindable
|
||||
m.transport.SetLiveDvrWindow(4 * 3600 * 1000)
|
||||
m.trickPlayBar.isLive = true
|
||||
m.trickPlayBar.canRewind = m.transport.CanRewindLive()
|
||||
m.transport.OnLiveEdge(edgeMs)
|
||||
m.transport.OnPosition(edgeMs)
|
||||
end function
|
||||
|
||||
Reference in new issue
Block a user