Skip to content

stream.dash: fix old timeline ID workaround #5199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 28, 2023

Conversation

bastimeyer
Copy link
Member

stream.dash: fix old timeline ID workaround

When building segment timelines, don't use the mimeType attribute of the SegmentTemplate's parent node as a fallback when the parent's id attribute is missing.

This doesn't work if the parent node is a Period, as it doesn't have the mimeType attribute, and it also generates timeline keys which are not unique if two streams of the same mimeType would get muxed (currently not supported).

Instead, build an ident tuple on the Representation instance consisting of the ids of the parent Period and AdaptationSet, and the Representation itself, with its required id attribute. This ensures a unique key for the timelines dict.

Then simply pass the ident tuple to the SegmentTemplate.segments() generator, similar to the BaseURL fixes of e684913.


stream.dash: refactor DASHStream{Reader,Worker}

Use the newly added Representation.ident for finding the same Representation after a manifest reload of a dynamic DASH stream.

Also use the worker's period attribute instead of the hardcoded zero index, even though only the first period is supported.


The missing parent ID workaround was initially implemented in #2096.

There's still a lot to do to fix some of the biggest issues with the DASH implementation. For example, manifest reloads are only attempted once without any retries, and failed manifest reloads or segment downloads can cause a deadlock. And much more...

When building segment timelines, don't use the `mimeType` attribute
of the `SegmentTemplate`'s parent node as a fallback when the parent's
`id` attribute is missing.

This doesn't work if the parent node is a `Period`, as it doesn't have
the `mimeType` attribute, and it also generates timeline keys which
are not unique if two streams of the same `mimeType` would get
muxed (currently not supported).

Instead, build an `ident` tuple on the `Representation` instance
consisting of the ids of the parent `Period` and `AdaptationSet`, and
the `Representation` itself, with its required `id` attribute. This
ensures a unique key for the `timelines` dict.

Then simply pass the `ident` tuple to the `SegmentTemplate.segments()`
generator, similar to the `BaseURL` fixes of e684913.
Use the newly added `Representation.ident` for finding the same
`Representation` after a manifest reload of a dynamic DASH stream.

Also use the worker's `period` attribute instead of the hardcoded
zero index, even though only the first period is supported.
@bastimeyer bastimeyer force-pushed the stream/dash/timeline-ids branch from 4b5d36c to 5f42563 Compare February 28, 2023 05:30
@gravyboat gravyboat merged commit 9d853b3 into streamlink:master Feb 28, 2023
@bastimeyer bastimeyer deleted the stream/dash/timeline-ids branch February 28, 2023 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants