Skip to content

Parse role and accessibility descriptor values from adaptation sets#5578

Merged
ojw28 merged 5 commits intogoogle:dev-v2from
szaboa:dev-v2-5529
Mar 20, 2019
Merged

Parse role and accessibility descriptor values from adaptation sets#5578
ojw28 merged 5 commits intogoogle:dev-v2from
szaboa:dev-v2-5529

Conversation

@szaboa
Copy link
Contributor

@szaboa szaboa commented Feb 27, 2019

Pull request for Issue #5529 .

@ojw28 ojw28 self-assigned this Mar 3, 2019
return MimeTypes.AUDIO_E_AC3;
}

protected static String parseRole(List<Descriptor> roleDescriptors) {
Copy link
Contributor

@ojw28 ojw28 Mar 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making these non-static to allow overriding seems fine to me. And move them up to be grouped with the other protected non-static methods.

Note that after the suggestions I made on the corresponding issue, these methods will return @Role and @Accessibility integers respectively.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be tempted to make a parseSelectionFlags method too, that can parse selection flags from the role descriptors. The default implementation will contain the little piece of code that decides whether to set C.SELECTION_FLAG_DEFAULT that's currently further up in this class.

/**
* The Role descriptor value.
*/
public final String role;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that video formats can have role/accessibility as well. As can selection flags actually. So these three params shouldn't be under "// Audio and text specific.". They should probably be right up under the label param, or somewhere near there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I guess the parsing also needs to be moved up, right now it is called only in case of mimeTypeIsRawText(sampleMimeType) == true in DashManifestParser. Right?

@szaboa
Copy link
Contributor Author

szaboa commented Mar 3, 2019

Updated.

*/
@Documented
@Retention(RetentionPolicy.SOURCE)
@IntDef({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the issue thread, I'd suggest merging the two IntDefs and making it flag = true. You can then also remove the UNSET constants, since unset is just 0 for flags.

public final int selectionFlags;
/** Track role descriptor value, or {@link C#ROLE_UNSET} if unknown or not applicable. **/
@C.Role
public final int role;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And having a single roleFlags, rather than separate role and accessibility fields.

return C.ROLE_UNSET;
}

protected @C.Accessibility int parseAccessibility(List<Descriptor> accessibilityDescriptors) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If going with my suggested approach, this method will return C.RoleFlags, which is slightly strange. But then it's somewhat strange DASH-IF separated use of urn:mpeg:dash:role:2011 across Role and Accessibility elements to start with, in my opinion :)... They should then be OR'd with the parseRole result to get the final flags.

You could probably have a single method parse "urn:mpeg:dash:role:2011" that you call from both parseRole and parseAccessibility. I think we'd probably want to handle things like "description" appearing as Role elements as well.

Copy link
Contributor Author

@szaboa szaboa Mar 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could probably have a single method parse "urn:mpeg💨role:2011" that you call from both parseRole and parseAccessibility. I think we'd probably want to handle things like "description" appearing as Role elements as well.

This would mean that the roleFlags would have a common flag for role's "description" and accessibility's "description" values. In this case we couldn't decide if the "description" came from role or from accessibility.

Even if a couple of values could be the same for role and accessibility, I would store them as separate flags, as at the end we need to know where a value comes from (role or accessibility descriptor). Or am I missing something?

Copy link
Contributor Author

@szaboa szaboa Mar 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, probably we can merge these as you said under the correspondent issue.

@szaboa
Copy link
Contributor Author

szaboa commented Mar 5, 2019

Merged role and accessibility fields together as you've suggested.

public static final int NETWORK_TYPE_OTHER = 8;

/**
* Adaptation set's role and accessibility descriptor value.
Copy link
Contributor

@ojw28 ojw28 Mar 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit - Avoid DASH specific terms; there's no reason roles can't be used for other media formats. I would also avoid mentioning accessibility; since outside of the DASH specific parsing where they're merged, they're just "roles" and nothing else. Would suggest documenting like:

Track role flags. Possible values are {@link XXX}, ...

See how SelectionFlags is documented for an example.

Copy link
Contributor

@ojw28 ojw28 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. Just a bunch of nitty little things really, and then we'll get this merged. Thanks!

})
public @interface RoleFlags {}

public static final int ROLE_FLAGS_MAIN = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please add Javadoc on each of these constants?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I wanted but I didn't find the standard you were referred to (draft of third version of 23009-1) and I wanted to take the definition from there. In the second edition fo 23009-1 a couple of role values are missing (e.g. "sign"). But I will search for it again.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to leave them if you don't have the doc. I can add in some documentation when I merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't found it yet, please add these comments.

/** Track selection flags. **/
@C.SelectionFlags
public final int selectionFlags;
/** Track role and accessibility descriptor values. **/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Just "Track role flags."

@C.SelectionFlags int selectionFlags,
@Nullable String language) {
@Nullable String language,
@C.RoleFlags int roleFlags) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Seems nice to group selectionFlags and roleFlags together, as in the methods above? Ditto for methods below this one.

@C.SelectionFlags int selectionFlags,
@Nullable String language,
int accessibilityChannel,
@C.RoleFlags int roleFlags,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Put next to selectionFlags? Ditto x lots below.

} else if (XmlPullParserUtil.isStartTag(xpp, "Role")) {
selectionFlags |= parseRole(xpp);
Descriptor descriptor = parseDescriptor(xpp, "Role");
selectionFlags |= parseSelectionFlags(descriptor);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems cleaner to have a parseSelection(roleDescriptors) that you can call in buildFormat. This saves you from having to pass selectionFlags into that method separately.

language,
accessibilityChannel);
accessibilityChannel,
roleFlags);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you probably need to pass roleFlags into the Format.createContainerFormat on L647 (below) as well as the ones you've already done.

if ("urn:mpeg:dash:role:2011".equalsIgnoreCase(descriptor.schemeIdUri) && descriptor.value != null) {
result |= parseRoleSchemeValue(descriptor.value);
}
if ("urn:tva:metadata:cs:AudioPurposeCS:2007".equalsIgnoreCase(descriptor.schemeIdUri) &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Use else if

}
if ("urn:tva:metadata:cs:AudioPurposeCS:2007".equalsIgnoreCase(descriptor.schemeIdUri) &&
descriptor.value != null) {
switch (descriptor.value){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it's only used here, it might be nice to split this into a parseAudioPurposeValue method, for consistency with parseRoleSchemeValue.

@C.RoleFlags int result = 0;
switch (value) {
case "main":
result |= C.ROLE_FLAGS_MAIN;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just return C.ROLE_FLAGS_X; for each case, and add a default case that returns 0. Ditto for parseAudioPurposeValue if you make that a method too.

@C.RoleFlags int result = 0;
for (int i = 0; i < roleDescriptors.size(); i++) {
Descriptor descriptor = roleDescriptors.get(i);
if ("urn:mpeg:dash:role:2011".equalsIgnoreCase(descriptor.schemeIdUri) && descriptor.value != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would IMO be neater for the null check to happen at the start of parseRoleSchemeValue (ditto parseAudioPurposeValue if you make that).

@szaboa
Copy link
Contributor Author

szaboa commented Mar 6, 2019

I will do these minor changes later today. You would like to have some test cases for this whole role flags, or do you think isn't so important right now?

@ojw28
Copy link
Contributor

ojw28 commented Mar 6, 2019

Thanks! Feel free to add some test cases if you think they'd be helpful, but I don't think it's hugely important in this case. The non-parser parts are trivial, and parsing code tends to be write-once-never-touch-again.

@szaboa
Copy link
Contributor Author

szaboa commented Mar 6, 2019

Updated. I hope I've covered everything, please say so if not. I decided to not to add tests for now :)

@ojw28
Copy link
Contributor

ojw28 commented Mar 6, 2019

Thanks!

@ojw28 ojw28 merged commit d7c2519 into google:dev-v2 Mar 20, 2019
ojw28 added a commit that referenced this pull request Mar 20, 2019
This is a precursor to merging #5578

PiperOrigin-RevId: 239371046
ojw28 added a commit that referenced this pull request Mar 20, 2019
PiperOrigin-RevId: 239398940
@google google locked and limited conversation to collaborators Aug 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants