-
Notifications
You must be signed in to change notification settings - Fork 405
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
Replacing label with a list of Label elements in Format. #1054
Conversation
Hi @jekopena, Thank you for this high-quality PR, your input is very appreciated. Without delving much further into it, the immediate problem I see is that this looks like a breaking change. We tend to deprecate methods/fields first and remove them after a couple of releases to give people a chance to migrate. And |
Good point, let me keep label as deprecated and add labels. |
Could you describe in a bit more detail what you are trying to achieve? As @oceanjules noted above, this is quite a drastic change given how widely used this |
@oceanjules I have updated the PR to keep @tonihei concatenating all labels in the current label field wouldn't work because that would break what current users are expecting from What I'm trying to achieve is that a track with Director's commentary in English, for example, should contain a list of Labels with a description of the content in different languages. For example:
So the client can show a track description in the track selector depending on the language used by the client. If the client is using English, it can describe the track as "Director's commentary", or "Comentarios del Director" if it's using Spanish. |
@oceanjules @tonihei Hi! Do you have any more feedback about this PR? |
If you're only adding a |
I created a model called |
Ah right, sorry - read it too quickly and missed that. |
Sorry for the delay. It wasn't super clear to us yet how we think this should look like, but your change is definitely a sensible start. One of the issues is that it should not be too DASH specific, but rather represent a generic concept every streaming format could fill in if needed. I was wondering if we really need the Is your goal to support the language tags or do you actually care about the group ids as well? If the main goal of your PR is the translation of the labels, then we could make this more explicit by adding for example a |
Hi @tonihei, yeah, I'm not interested in Your suggested |
@tonihei by the way, |
Thanks for all these useful comments! We discussed this a bit more and ended up with something similar to what you have already:
Overall, that should be pretty close to your existing pull request. Not deprecating the old field and having this default consistency update in |
This sounds good to me, I'll start working in the changes! |
@tonihei working on this, I don't understand very well the I pushed a commit with all the changes so you can take a look except the |
I was under the assumption that all labels are signalled via |
@tonihei Correct, following the DASH manifest ISO, But I guess you want to keep So anyway, maybe I'm overthinking it, if you still want me to throw the |
A singular label also makes sense for other formats, e.g. Matroska, see The exception is nice because it means we can document |
@icbaker cool, I've added the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making all these updates! I left a few comments in the code, nothing major, mostly adjusting to existing style and reusing utilities where they exist.
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you revert this?
* @return Whether the {@link #labels} belonging to this format and {@code other} are equal. | ||
*/ | ||
@UnstableApi | ||
public boolean labelsEquals(Format other) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think labels.equals(other.labels)
should work just fine. The List
implementations override the equals method to do what this helper method is doing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, I'll delete it, I just created this one following the initializationDataEquals
method.
@@ -1111,7 +1161,8 @@ public int hashCode() { | |||
// Some fields for which hashing is expensive are deliberately omitted. | |||
int result = 17; | |||
result = 31 * result + (id == null ? 0 : id.hashCode()); | |||
result = 31 * result + (label != null ? label.hashCode() : 0); | |||
result = 31 * result + (label == null ? 0 : label.hashCode()); | |||
// [Omitted] labels. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think labels.hashCode()
should work and there is no need to omit them.
if (labels.isEmpty() && !TextUtils.isEmpty(tmpLabel)) { | ||
labels.add(new Label(language, tmpLabel)); | ||
} | ||
label = makeLabelIfNeeded(tmpLabel, labels); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make the logic flow easier to read, could it add an else if (!labels.isEmpty() && tmpLabel == null)
to call this method and rename the method to getDefaultLabel
?
@@ -1284,6 +1362,11 @@ public static String toLogString(@Nullable Format format) { | |||
if (format.label != null) { | |||
builder.append(", label=").append(format.label); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the new guarantees that label
and labels
always match, we can now remove this part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which part? This code is just printing all the fields of the Format
for logging, how is this affected by if label
and labels
match?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will always print the default label twice now, which seems unnecessary for someone reading a log line to understand which Format
is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I just removed the label
from toLogString.
@@ -1301,36 +1384,37 @@ public static String toLogString(@Nullable Format format) { | |||
|
|||
private static final String FIELD_ID = Util.intToStringMaxRadix(0); | |||
private static final String FIELD_LABEL = Util.intToStringMaxRadix(1); | |||
private static final String FIELD_LANGUAGE = Util.intToStringMaxRadix(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you leave all these numbers as they were and instead use the next available number? The reason is that these constants are used for serialization across processes and versions and they have to stay the same forever.
@@ -1347,6 +1431,11 @@ public Bundle toBundle(boolean excludeMetadata) { | |||
Bundle bundle = new Bundle(); | |||
bundle.putString(FIELD_ID, id); | |||
bundle.putString(FIELD_LABEL, label); | |||
if (labels != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid this manual loop here, you can use putParcelableArrayList
with toBundleArrayList
, similar to
bundle.putParcelableArrayList( |
This will require toBundle
/fromBundle
methods in Label
I believe.
@tonihei I addressed your PR feedback except one I didn't understand. Feel free to resolve the conversations when you review the changes if you are ok with them! |
Thanks a lot! We'll work on merging the PR internally (you may see some additional commits for formatting fixes etc). |
cebd57e
to
e239ca4
Compare
PiperOrigin-RevId: 619573181 (cherry picked from commit 8fe7033)
PiperOrigin-RevId: 619573181 (cherry picked from commit 8fe7033)
According to ISO/IEC 23009-1 [4], clause 5.3.7.2 Table 13, an AdaptationSet could include several Label elements (0..N), not only one. But right now Exoplayer only fetches the first Label and ignores the rest.
This PR fetches all the Labels and stores them in Format.labels that is a List of labels instead of only one label String. Also, instead of just storing a String, it creates the class Label that stores the three possible fields that can be related to the Label: id, lang and the value of the Label.