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

Dev/fix pdt search #1601

Merged
merged 5 commits into from Mar 22, 2018
Merged

Dev/fix pdt search #1601

merged 5 commits into from Mar 22, 2018

Conversation

capagrisdesu
Copy link
Contributor

Description of the Changes

Testing some streams showed me that media seeking failed to perform properly when PDT is being used. I realized that the issue is that fragPrevious is not nullified. I also realized that a few more changes were actually needed.

Description of changes:

  • Use a for instead of binary search to ensure that PDT discontinuities still return the next segment.
  • Fixed an error with the unit tests that made me think that BufferEnd was milliseconds when it is actually seconds.
  • MediaSeek should set fragPrevious to null in order not to confuse the algorithm.
  • Added 3 new unit tests and changed some values that were milliseconds to seconds as they would be in real case scenario in order to properly test the feature.

I am very curious into why fragPrevious is not nullified when seeking is requested. Former segment is of no relevance or confusing as there is no connection between the jump and the current position. Please someone can explain? Maybe that is required for some obscure reason I can't see and this should not be committed as it is.

CheckLists

  • changes have been done against master branch, and PR does not conflict
  • no commits have been done in dist folder (we will take care of updating it)
  • new unit / functional tests have been added (whenever applicable)
  • Travis tests are passing (or test results are not worse than on master branch :))
  • API or design changes are documented in API.md

capagrisdesu and others added 4 commits March 5, 2018 14:15
…seconds as they would be in real case scenario in order to properly test the feature
… still return the next segment

Fixed an error with the unit tests that made me think that BufferEnd was milliseconds when it is actually seconds
MediaSeek should set fragPrevious to null in order not to confuse the algorithm
Copy link
Member

@mangui mangui left a comment

Choose a reason for hiding this comment

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

Hi @capagrisdesu thanks for you PR, IMHO there are a few items that would require clarification. please check

@@ -813,6 +818,8 @@ class StreamController extends TaskLoop {
if (!this.loadedmetadata)
this.nextLoadPosition = this.startPosition = currentTime;

this.fragPrevious = null;
Copy link
Member

Choose a reason for hiding this comment

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

there are several conditions in onMediaSeeking()that already nullify fragPrevious when needed.
for example if currentTime = 10s, media is buffered from 0 to 100s, and you seek to t=20s, there is no need to nullify fragPrevious, as this seek will be completely transparent (in the sense that there is no need to disturb frag loading/parsing/appending)
nullifying fragPrevious on seeking is only useful if we detect that we are seeking to a position that requires a change in frag loading (ie next frag loading will not be contiguous with the previous one)

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 see. When depending on PDT from the fragment to fetch the next one, then it is important than the next one is contiguous. That is why I thought of nullifying it. Then, I should change the implementation to depend on bufferEnd. That is another option that I believe it would work (in my tests seem to work).

return BinarySearch.search(fragments, function (frag) {
return PDTValue < frag.pdt ? -1 : PDTValue >= frag.endPdt ? 1 : 0;
});
for(let seg = 0; seg < fragments.length; ++seg)
Copy link
Member

Choose a reason for hiding this comment

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

if PDT is monotonic, then binary search should be equivalent and more efficient, I am not clear about the issue you are trying to address here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does have order but there are gaps. That is the main difference with a sequential one in which the start parameter is set contiguous independently of discontinuities. Not for PDT. If between two segments there is a discontinuity and you request a jump in between with a binary search is unable to find the segment. This is checked with a unit test.

@johnBartos johnBartos added this to the 0.8.10 milestone Mar 13, 2018
@johnBartos
Copy link
Collaborator

Since this fixes a regression introduced by a PR in master I'm tagging this for the next release

@mangui
Copy link
Member

mangui commented Mar 16, 2018

makes sense to target next release. i understand the fix for bufferEnd being in ms, but not the 2 others. it would be interesting to get more explanation / logs to understand what is going on

@capagrisdesu
Copy link
Contributor Author

I have submitted my last commit as an alternative. This way is not nullifying the previous segment at media seek which is consistent which your design. On the other hand, PDT will depend more on the bufferEnd which should be the same as if there is a vacuum due to a discontinuity the new for (instead of the binary search) will select the next one.

If you prefer the original solution, I can revert. Please ask any questions about it

assert.equal(foundFragment, fragments[2], 'Expected sn 2, found sn segment ' + resultSN);
});

it('PDT serch hitting empty discontinuity', function () {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you replace the former binary search, this unit test will fail. If a user selects a time that actually is a discontinuity, because the binary search only checks for if the PDT is within the segment. I could not figure out how to use the binary search taking into account next and former segment. I could also let the binary search stay as it is more efficient, and if null, then do the for. Is this preferable?

Copy link
Member

Choose a reason for hiding this comment

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

fair enough. as _findFragmentByPDT() is not expected to be triggered everytime, it should be fine

@jon-valliere
Copy link
Contributor

What is PDT? That acronym is not present in ISO/IEC 13818-1

@phloxic
Copy link
Contributor

phloxic commented Mar 24, 2018

@jon-valliere - program date time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants