WIP: Refactor object model #30
Loading…
Reference in New Issue
No description provided.
Delete Branch "model"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The PRV object model (
Program
,Rendition
,Variant
) implementation is a bit annoying:For some aesthetic reasons, the intermediate URLs (or sources) are not embedded in the objects themselves because those are consumed along the way: the URL pointing to the file containing rendition information is "replaced" by that rendition information once we got it. The downside is that we end up dealing with
(objects, sources)
tuples and/or parameters making the code less readable.The three structures are inherently interconnected, they actually form a tree structure (programs have renditions, renditions have variants), except they are not (in the code). Again, we end up using
(Program[, Rendition [, Variant]])
tuples and/or parameters making the code less readable.By definition renditions is supposed to be a chosen audio/subtitles languages/type combination. Except that, in our implementation, they are not. Mainly because the rendition information we get from API does not actually tell us, it implies it (through the code: VOF-STF, VO-ST[ITA], ...). Conversely, a variant should be a chosen quality for the tracks, and that is not obvious in the model definition (actually, our
Variant
looks a bit too much like what a rendition should be and ourRendition
does not carry a lot of information).Addressing those points one by one:
This could be addressed with a bunch more of named tuples, but then we would have to find clever naming and at the end it just adds a lot of code. As the amount of data we are dealing with is ridiculous, we could just grow our data structures, including
sources
.Same as above, including tree structure.
Limit the scope of the model to only top-level API functions and having each module (
www
,api
,hls
...) having their "own model" based on the actual data they handle.About the tree structure (point 2), I see two approaches:
Program
has a list ofRendition
,Rendition
a list ofVariant
.Variant
has aRendition
,Rendition
has aProgram
.Although the second option makes bigger objects and duplicate of the parents for each child, it is the one I favor:
Program
, we do not have rendition information yet and therefore would initialize an empty list ofRendition
and only then populate it. This makes the intermediateProgram
a false representation: it does have someRendition
but we just don't know about them yet.Rendition
perProgram
and exactly oneVariant
perRendition
. So, again, the benefit of actually dealing with list of children is kind of null.About the semantics of the model (Point 3):
Variant
should carry the information about audio/subtitles languages and types (audio description, hearing impaired, etc...) these can be inferred from the rendition codes (VOF-STF, VO-ST[ITA], ...). Then we do not need to carry the code itself (which, by the way have horrific format) and leave it to the human interface to reconstruct an identifier based on theVariant
data.The main problem is that the code don't always inform about audio languages. But we can temporarily use the
und
language code that actually mean undefined. We can then set it to the proper language when building theVariant
object from the HLS program index.Rendition
should then carry the quality information (only applicable to video track for now). Also, we should drop thecode
field and likewise, leave it the the human interface to construct it as needed.About the codes (renditions and variants): I think it make sense to leave that responsibility to the human interface. We may need different types of codes for example:
Okay, the more I think about it, the more I think point 1 and 2 are secondary and may be addressed by a better splitting between our 3 "zones":
www
,api
andhls
modules (their data)__init__
top level module API (our data)__main__
So I'll first address that splitting and point 3 (semantics) and then see if 1 and 2 are still relevant.
Step 1:
From your project repository, check out a new branch and test the changes.Step 2:
Merge the changes and update on Gitea.