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

fix: make byteRange.length inclusive #43

Merged
merged 1 commit into from
Nov 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/segment/urlType.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import resolveUrl from '../utils/resolveUrl';
*
* @param {string} baseUrl - baseUrl provided by <BaseUrl> nodes
* @param {string} source - source url for segment
* @param {string} range - optional range used for range calls, follows
* @param {string} range - optional range used for range calls,
* follows RFC 2616, Clause 14.35.1
* @return {SingleUri} full segment information transformed into a format similar
* to m3u8-parser
*/
Expand All @@ -35,8 +36,10 @@ export const urlTypeToSegment = ({ baseUrl = '', source = '', range = '' }) => {
const startRange = parseInt(ranges[0], 10);
const endRange = parseInt(ranges[1], 10);

// byterange should be inclusive according to
// RFC 2616, Clause 14.35.1
init.byterange = {
length: endRange - startRange,
length: endRange - startRange + 1,
offset: startRange
};
}
Expand Down
2 changes: 1 addition & 1 deletion test/segment/segmentBase.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ QUnit.test('translates ranges in <Initialization> node', function(assert) {
resolvedUri: 'http://www.example.com/init.fmp4',
uri: 'http://www.example.com/init.fmp4',
byterange: {
length: 4,
length: 5,
offset: 121
}
},
Expand Down
8 changes: 4 additions & 4 deletions test/segment/segmentList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ QUnit.test('segmentUrl translates ranges correctly', function(assert) {
uri: 'init.fmp4'
},
byterange: {
length: 200,
length: 201,
offset: 0
},
resolvedUri: 'http://example.com/1.fmp4',
Expand All @@ -435,7 +435,7 @@ QUnit.test('segmentUrl translates ranges correctly', function(assert) {
}, {
duration: 10,
byterange: {
length: 199,
length: 200,
offset: 201
},
map: {
Expand Down Expand Up @@ -517,7 +517,7 @@ QUnit.test('translates ranges in <Initialization> node', function(assert) {
resolvedUri: 'http://example.com/init.fmp4',
uri: 'init.fmp4',
byterange: {
length: 4,
length: 5,
offset: 121
}
},
Expand All @@ -531,7 +531,7 @@ QUnit.test('translates ranges in <Initialization> node', function(assert) {
resolvedUri: 'http://example.com/init.fmp4',
uri: 'init.fmp4',
byterange: {
length: 4,
length: 5,
offset: 121
}
},
Expand Down
6 changes: 3 additions & 3 deletions test/segment/segmentTemplate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ QUnit.test('constructs simple segment list and with <Initialization> node', func
resolvedUri: 'https://example.com/init.mp4',
uri: 'init.mp4',
byterange: {
length: 4,
length: 5,
offset: 121
}
},
Expand All @@ -1327,7 +1327,7 @@ QUnit.test('constructs simple segment list and with <Initialization> node', func
resolvedUri: 'https://example.com/init.mp4',
uri: 'init.mp4',
byterange: {
length: 4,
length: 5,
offset: 121
}
},
Expand All @@ -1342,7 +1342,7 @@ QUnit.test('constructs simple segment list and with <Initialization> node', func
resolvedUri: 'https://example.com/init.mp4',
uri: 'init.mp4',
byterange: {
length: 4,
length: 5,
offset: 121
}
},
Expand Down
4 changes: 2 additions & 2 deletions test/segment/urlType.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ QUnit.test('returns correct object if given baseUrl, source and range', function
uri: 'init.fmp4',
byterange: {
offset: 101,
length: 4
length: 5
}
});
});
Expand All @@ -44,7 +44,7 @@ QUnit.test('returns correct object if given baseUrl and range', function(assert)
uri: '',
byterange: {
offset: 101,
length: 4
length: 5
}
});
});