[go: nahoru, domu]

Skip to content
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

Consider making MediaItem.Builder fail more loudly on invalid configurations #8957

Closed
icbaker opened this issue May 18, 2021 · 1 comment
Closed
Assignees

Comments

@icbaker
Copy link
Collaborator
icbaker commented May 18, 2021

The motivating example for this issue is that MediaItem.Builder#setDrmSessionForClearPeriods() is silently ignored if MediaItem.Builder#setDrmUuid() is not set (#8842 (comment)).

From an implementation details perspective it's understandable that the UUID is required for any of the other DRM fields to be useful, but the silent dropping of the value (rather than failing during build()) leads to confusing behaviour for users of the API who believe they're calling a method and have no indication it's having no effect.

This issue tracks changing MediaItem.Builder to more aggressively fail during build() if some setters have been called that are going to be ignored.

This isn't limited to the DRM fields, there are many other examples (the javadoc has lots of text like "If setUri(java.lang.String) is passed a non-null uri, the MIME type is used to create a MediaItem.PlaybackProperties object. Otherwise it will be ignored.").

Some apps may be (intentionally or unintentionally) depending on the existing silently-drop behaviour, so we may need to consider making this change gradually, e.g. by introducing a buildStrict() method which fails loudly and deprecating the silently-ignoring build() method. (this specific example is a shame because we'd really like to end up in a final state where the method is called build() (since that seems like obviously the correct name) - so it might be enough to instead change the behaviour of build() and introduce a temporary buildLenient() method with the 'old' behaviour that apps can switch to if they observe problems with the strict behaviour).

@icbaker icbaker self-assigned this May 18, 2021
ojw28 pushed a commit that referenced this issue May 27, 2021
Many of the setters are ignored unless others are set - this change:
* Lists these conditions exhaustively.
* Uses more concise language to avoid overshadowing the main details
  of what the setter sets.
* Tweaks the language from 'is ignored' to 'shouldn't be called', to
  open up the future possibility of throwing an error if these are
  called without the 'required' setter also being present (see
  Issue: #8957).

#minor-release

PiperOrigin-RevId: 376162385
ojw28 pushed a commit that referenced this issue Jun 10, 2021
Many of the setters are ignored unless others are set - this change:
* Lists these conditions exhaustively.
* Uses more concise language to avoid overshadowing the main details
  of what the setter sets.
* Tweaks the language from 'is ignored' to 'shouldn't be called', to
  open up the future possibility of throwing an error if these are
  called without the 'required' setter also being present (see
  Issue: #8957).

#minor-release

PiperOrigin-RevId: 376162385
@icbaker
Copy link
Collaborator Author
icbaker commented Aug 30, 2022

The MediaItem.Builder class structure has now been changed to make it harder/impossible to create 'impossible' configurations - because most required fields are now passed into the constructor of the relevant sub-builder. I don't think there's any additional work to do here.

@icbaker icbaker closed this as completed Aug 30, 2022
@google google locked and limited conversation to collaborators Oct 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant