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

feat: Add llhls preloadSegment, add parts to segments, and fix byterange for parts/preloadHints #137

Merged
merged 9 commits into from
Mar 4, 2021

Conversation

brandonocasey
Copy link
Contributor

@brandonocasey brandonocasey commented Jan 27, 2021

This does a few things:

  1. Adds preloadSegment. Which is the segment that is going to be added to the playlist, but we only have parts and preload hints for right now.
  2. Associates parts with segments
  3. Better byterange parsing for bytes

@@ -5,6 +5,21 @@ import Stream from '@videojs/vhs-utils/es/stream.js';

const TAB = String.fromCharCode(0x09);

const parseByterange = function(byterangeString) {
Copy link
Contributor Author

@brandonocasey brandonocasey Feb 5, 2021

Choose a reason for hiding this comment

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

Moved all byterange parsing into here as we do this for map, byterange, and part

@@ -535,6 +543,11 @@ export default class ParseStream extends Stream {
['BYTERANGE-START', 'BYTERANGE-LENGTH'].forEach(function(key) {
if (event.attributes.hasOwnProperty(key)) {
event.attributes[key] = parseInt(event.attributes[key], 10);

const subkey = key === 'BYTERANGE-LENGTH' ? 'length' : 'offset';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one is a bit different as we have attributes for both offest and length

@@ -92,6 +92,7 @@ export default class Parser extends Stream {
let currentMap;
// if specified, the active decryption key
let key;
let hasParts = false;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this to keep renditionReport warnings firing if we get a rendition report before any parts.

currentUri.timeline = currentTimeline;
}

this.manifest.preloadSegment = currentUri;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

build preload segment if we get end without getting an actual segment uri.

@@ -115,6 +116,29 @@ export default class Parser extends Stream {
// to provide the offset, in which case it defaults to the next byte after the
// previous segment
let lastByterangeEnd = 0;
// keep track of the last seen part's byte range end.
let lastPartByterangeEnd = 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

keep track of the current part byterange

@brandonocasey brandonocasey changed the title feat: add preloadSegment, associate parts with segments feat: Add llhls preloadSegment, add parts to segments, and fix byterange for parts/preloadHints Feb 5, 2021
src/parse-stream.js Show resolved Hide resolved
src/parser.js Show resolved Hide resolved
test/fixtures/integration/llhls-byte-range.js Outdated Show resolved Hide resolved
test/fixtures/integration/llhls-byte-range.js Show resolved Hide resolved
test/fixtures/integration/llhls-byte-range.js Show resolved Hide resolved
test/fixtures/integration/llhls-byte-range.m3u8 Outdated Show resolved Hide resolved
test/fixtures/integration/llhls-delta-byte-range.m3u8 Outdated Show resolved Hide resolved
@brandonocasey
Copy link
Contributor Author

  • Update preload-hints so that it warns on duplicate TYPE preloadHints. Added a test for it too.
  • Added a comment to byterange parsing regex
  • Fixed issues with the test data regarding preload-hints of the same type and out-of-order byteranges.

src/parse-stream.js Outdated Show resolved Hide resolved
src/parse-stream.js Outdated Show resolved Hide resolved
src/parse-stream.js Outdated Show resolved Hide resolved
@brandonocasey
Copy link
Contributor Author

brandonocasey commented Mar 2, 2021

good call on the byterange stuff @gkatsev I think I got locked in on making the code look similar to what it used to and didn't simplify enough.

src/parse-stream.js Outdated Show resolved Hide resolved
Co-authored-by: Garrett Singer <[email protected]>
@brandonocasey brandonocasey merged commit 2c2dffe into main Mar 4, 2021
@brandonocasey brandonocasey deleted the feat/preload-segment-parts branch March 4, 2021 18:06
miadabdi pushed a commit to miadabdi/m3u8-parser that referenced this pull request Jul 21, 2021
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.

3 participants