-
Notifications
You must be signed in to change notification settings - Fork 6k
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
feat(playlist): remove MediaSource range #4564
Conversation
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
CLA added for all commit authors |
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
I confirm I'm ok with that. |
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.
Looks good in general. Just a couple of formatting issues and minor changes.
@@ -50,6 +50,7 @@ | |||
private static final int MSG_ADD = 0; | |||
private static final int MSG_ADD_MULTIPLE = 1; | |||
private static final int MSG_REMOVE = 2; | |||
private static final int MSG_REMOVE_RANGE = 200; |
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.
Can you renumber this to be 3 and change the numbers below accordingly?
* @param fromIndex The initial range index, pointing to the first media source that will be | ||
* removed. This index must be in the range of 0 <= index < {@link #getSize()}. | ||
* @param toIndex The final range index, pointing to the first media source that will be left | ||
* untouched. The last media source to be removed is at index {@code toIndex} - 1. |
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.
"The last media source to be removed is at index {@code toIndex} - 1." - That seems redundant and can be removed.
* is thrown. | ||
* | ||
* @param fromIndex The initial range index, pointing to the first media source that will be | ||
* removed. This index must be in the range of 0 <= index < {@link #getSize()}. |
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.
Both ranges should be "in the range of 0 <= index <= {@link #getSize()}." That is, including the getSize index.
Otherwise you wouldn't be able to do removeMediaSourceRange(getSize(), getSize()) as an edge case.
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.
At a given time, "occupied" track indices are 0, 1, ... getSize() - 1
. fromIndex
should point to an occupied index, as the initial range index is included in the range. How can one remove the track at index getSize()
, if there's no track at that index? Just trying to understand
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.
As the end index is exclusive, the method must allow getSize() as end index.
And to support the example you gave in the issue, to keep an element at index N only, it would be nice to be able to call
removeMediaSourceRange(0, N) followed by removeMediaSourceRange(1,getSize()). If this is supposed to remove the last element, the second call will result in removeMediaSourceRange(1, 1) which should be a no-op.
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.
We've abandoned the "simplicity" implied by initial issue example when we "gave up" on API tolerance (so to say). Since then, the idea seemed: have a clear API with errors when arguments are not correct. And for fromIndex
to be equal to getSize()
seems not correct. Of course we noticed that you cannot call removeMediaSourceRange(getSize(), getSize())
anymore. And also you cannot call removeMediaSourceRange(1, getSize())
in issue second call, that would throw too.
Staying consistent with allowed param values in signature seems quite a thing. By allowing passing getIndex()
in fromIndex
, it seems to go back to the "tolerant" approach somehow, which is fine anyway. Don't know, your call.
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'd say it's best to follow the existing behaviour of List.subList and the like. That is, throwing if startIndex<0
, endIndex>size
or startIndex>endIndex
. This ensures the operation is valid, but is also tolerant enough to support common use cases like "remove everything behind element N" with removeRange(N, size) which will work even if N is the last element.
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.
Cool. Just to tease a little bit, in case like "remove everything behind element N" when N is the last element, then N = size - 1
, and removeMediaSourceRange(size - 1, size)
already works as is. What instead currently throws (and probably looks not tolerant) is removeMediaSourceRange(size, size)
. Right?
Anyway, changes are coming
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.
removeMediaSourceRange(size - 1, size)
would remove the element at N = size - 1
though, right?
And if I'm not mistaken removeMediaSourceRange(size, size)
won't throw too because List.subList doesn't throw for this case.
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.
Q1: correct, current implementation would remove element at size - 1
, i.e. "the last element"
Q2: removeMediaSourceRange(size, size)
throws in current (<=> initial version) of this PR. It will not throw after applying your proposed changes, as List.subList(size, size)
does not throw. I was referring to current implementation.
Cool
* @throws IndexOutOfBoundsException when either index is out of playlist bounds, i.e. {@code | ||
* fromIndex} < 0 or >= {@link #getSize()}, {@code toIndex} < 0 or > {@link | ||
* #getSize()} | ||
* @throws IndexOutOfBoundsException when range is malformed, i.e. {@code fromIndex} > |
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.
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.
Totally agree with grouping. Are you also suggesting to slim down the number of (broken) examples provided in JavaDoc?
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.
Yes. As we already require fromIndex>lastIndex, the other two examples are not needed.
|
||
/** | ||
* Removes a range of {@link MediaSource}s from the playlist, by specifying an initial index | ||
* (included) and a final index (excluded), and executes a custom action on completion.. |
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.
Remove second full stop.
* #getSize()} | ||
* @throws IndexOutOfBoundsException when range is malformed, i.e. {@code fromIndex} > | ||
* {@code toIndex} | ||
* @param actionOnCompletion A {@link Runnable} which is executed immediately after the media |
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.
This param should be together with the other params above.
* @param toIndex The final range index, pointing to the first media source that will be left | ||
* untouched. The last media source to be removed is at index {@code toIndex} - 1. | ||
* This index must be in the range of 0 <= index < {@link #getSize()}. | ||
* |
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.
} | ||
return; | ||
} | ||
mediaSourcesPublic.subList(fromIndex, toIndex).clear(); |
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.
Can you replace that with Util.removeRange(mediaSourcesPublic, fromIndex, toIndex)? That calls the same method but is slightly more readable.
Also move it above the if(fromIndex == toIndex) check to ensure the exceptions are thrown first.
*/ | ||
public final synchronized void removeMediaSourceRange( | ||
int fromIndex, int toIndex, @Nullable Runnable actionOnCompletion) { | ||
if (fromIndex < 0 || fromIndex >= mediaSourcesPublic.size()) { |
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.
No need to do the explicit bound checks here. As soon as you call the subList method, the IndexOutOfBoundsException will be thrown anyway.
mediaSourcesPublic.subList(fromIndex, toIndex).clear(); | ||
if (player != null) { | ||
player | ||
.createMessage(this) |
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.
These should be indented by 4 spaces (relative to "player")
No particular need to fix it for this contribution, but for future contributions it's preferable to configure git to use the same email as the one you specified when signing the CLA (setting user.email is described here). |
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) |
CLA status was manually verified for the committing username (GiuseppePiscopo), as the commits use a |
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) |
Thanks! Looks good now :) |
Not sure what's happening re. CLA. The other commit author account (GiuseppePiscopo) has registered google CLA with the same email address also associated to Github profile. Can that be related to the "keep my address private" option in github profile? |
I think it's because the email address the CLA is signed under doesn't match the email address on the commits (which is a For this commit we manually verified the username against our CLA records, so it's not a blocking issue. |
Thanks for feedback, yes we read that. Do you know if CLA can be signed under a |
Unsure. It seems a bit strange to do that :). We should probably just make the googlebot clever enough to look at the username as well. I'll try and get someone to do that internally! |
Turns out the issue with the CLA is that the account sending the pull request is different to the account whose commits are included within it. Hence we need to manually confirm that the commit author is OK with their changes being part of the pull request, under their signed CLA. If we didn't do this, it would be possible for someone to try and contribute commits by an author who has signed a CLA, but does not want the commits in question to be contributed. Please could you confirm with account @GiuseppePiscopo that you're OK with all commits that are part of this pull request being submitted (you'll need to do this again whenever a new commit is added). In future, using the same account for commits and pull requests, which is an account with a signed CLA, would help streamline this process. |
Hi there. Yes, we were aware of this distinction between pull request opener and commit authors, thanks for clarifying. Could not find more info on how to get a user confirmation, so we just added this comment here above. Does that count as a confirmation? Re. CLA, @GiuseppePiscopo also has a signed CLA in google, using the same email address associated with Github. Problem is (we think), email preference on Github is set to private, hence commits appear authored by a whatever-username@users.noreply.github.com, and it's not possible to sign a CLA under that "dummy" email address. If one wants to keep distinct commit authors, it seems there's no way to also keep Github email private. Anyway, for the next time we'll try to switch user so that all commits show up under same account as PR creator. |
It turned out this was not the problem. The CLA bot is clever enough to look at the username in this case. The problem is solely that the pull request opener is different to the commit author. In this case there is no automated way for the CLA bot to validate that the commit author is OK with their commit being included in the pull request, which is why manual validation is necessary. Them having signed the CLA is not sufficient (since they might have signed it to contribute some completely unrelated change to another Google project). We need the commit author to manually confirm they are OK with their commits being included in this case. Since additional commits were added after the comment you reference, we need the commit author to comment again on this thread, to cover the additional commits since that comment. Thanks! |
I confirm I'm ok with including those additional commits as well |
How can we track when this PR will be included in a public release? Thanks |
It will be in 2.9.0 (for which we don't yet have a solid eta). |
See #4542 for related discussion