Skip to content

Commit

Permalink
fix starting offset, remove comments
Browse files Browse the repository at this point in the history
  • Loading branch information
adrums86 committed Jan 23, 2023
1 parent f202a4a commit ae07a32
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/mp4/emsg.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ var uint8ToCString = require('../utils/string.js').uint8ToCString;
* @returns A parsed emsg box object
*/
var parseEmsgBox = function(boxData) {
var offset = 1;
// version + flags
var offset = 4;
var version = boxData[0];
var scheme_id_uri,
value, timescale,
Expand Down
5 changes: 2 additions & 3 deletions test/mp4-emsg.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ QUnit.module('EMSG Parsing');
QUnit.test('Can parse a v0 emsg box', function(assert) {
var boxData = generateEmsgBoxData(0, messageData);
var parsedBox = emsg.parseEmsgBox(boxData);
// we're getting wrong version for some reason

assert.equal(parsedBox.scheme_id_uri, 'urn:foo:bar:2023\0', 'v0 box has expected scheme_id_uri');
assert.equal(parsedBox.value, 'foo.bar.value\0', 'v0 box has expected value');
assert.equal(parsedBox.timescale, 100, 'v0 box has expected timescale');
Expand All @@ -25,7 +25,7 @@ QUnit.test('Can parse a v0 emsg box', function(assert) {
QUnit.test('Can parse a v1 emsg box', function(assert) {
var boxData = generateEmsgBoxData(1, messageData);
var parsedBox = emsg.parseEmsgBox(boxData);
// we're getting wrong version for some reason

assert.equal(parsedBox.scheme_id_uri, 'urn:foo:bar:2023\0', 'v1 box has expected scheme_id_uri');
assert.equal(parsedBox.value, 'foo.bar.value\0', 'v1 box has expected value');
assert.equal(parsedBox.timescale, 100, 'v1 box has expected timescale');
Expand All @@ -34,5 +34,4 @@ QUnit.test('Can parse a v1 emsg box', function(assert) {
assert.equal(parsedBox.event_duration, 1, 'v1 box has expected event_duration');
assert.equal(parsedBox.id, 2, 'v1 box has expected id');
assert.deepEqual(parsedBox.message_data, messageData, 'v1 box has expected data');

});
2 changes: 2 additions & 0 deletions test/utils/mp4-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ var generateEmsgBoxData = function(version, messageData) {
if (version === 0) {
emsgProps = new Uint8Array([
0x00, // version
0x00, 0x00, 0x00, //flags
0x75, 0x72, 0x6E, 0x3A, 0x66, 0x6F, 0x6F, 0x3A, 0x62, 0x61, 0x72, 0x3A, 0x32, 0x30, 0x32, 0x33, 0x00, // urn:foo:bar:2023\0
0x66, 0x6F, 0x6F, 0x2E, 0x62, 0x61, 0x72, 0x2E, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x00, // foo.bar.value\0
0x00, 0x00, 0x00, 0x64, // timescale = 100
Expand All @@ -329,6 +330,7 @@ var generateEmsgBoxData = function(version, messageData) {
} else if (version === 1) {
emsgProps = new Uint8Array([
0x01, // version
0x00, 0x00, 0x00, //flags
0x00, 0x00, 0x00, 0x64, // timescale = 100
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x27, 0x10, // presentation_time = 10000
0x00, 0x00, 0x00, 0x01, // event_duration = 1
Expand Down

0 comments on commit ae07a32

Please sign in to comment.