fbb6a663 by David LaPalomento

Use 4-byte ecmascriptarray terminator to match acstionscript. Fix writeBytes.

The actionscript segment parser uses a 4-byte terminator for "ecmascriptarray" objects in script tags. This doesn't match my reading of the spec but we'll go with it for now to get these things binary-compatible. The writeBytes method on FlvTag defaults the length argument to zero but in that case, the entire bytes argument should be written out instead of nothing.
1 parent 5351582b
......@@ -42,7 +42,7 @@ hls.FlvTag = function(type, extraData) {
// ByteArray#writeBytes(bytes:ByteArray, offset:uint = 0, length:uint = 0)
this.writeBytes = function(bytes, offset, length) {
offset = offset || 0;
length = length || 0;
length = length || bytes.byteLength;
try {
this.bytes.set(bytes.subarray(offset, offset + length), this.position);
......@@ -198,10 +198,10 @@ hls.FlvTag = function(type, extraData) {
this.position++;
this.view.setUint32(this.position, adHoc);
this.position = this.length;
this.bytes.set([0, 0, 9], this.position);
this.position += 3;
// this.view.setUint32(this.position, 0x09); // End Data Tag
// this.position += 4;
// this.bytes.set([0, 0, 9], this.position);
// this.position += 3;
this.view.setUint32(this.position, 0x09); // End Data Tag
this.position += 4;
this.length = this.position;
break;
}
......
......@@ -146,9 +146,14 @@
tag.pts = pts;
expGolomb = new ExpGolomb(this.getSps0Rbsp());
profile_idc = expGolomb.readUnsignedByte(); // :int = expGolomb.readUnsignedByte(); // profile_idc u(8)
expGolomb.skipBits(16);// constraint_set[0-5]_flag, u(1), reserved_zero_2bits u(2), level_idc u(8)
expGolomb.skipUnsignedExpGolomb(); // seq_parameter_set_id
// :int = expGolomb.readUnsignedByte(); // profile_idc u(8)
profile_idc = expGolomb.readUnsignedByte();
// constraint_set[0-5]_flag, u(1), reserved_zero_2bits u(2), level_idc u(8)
expGolomb.skipBits(16);
// seq_parameter_set_id
expGolomb.skipUnsignedExpGolomb();
if (profile_idc === 100 ||
profile_idc === 110 ||
......@@ -230,7 +235,7 @@
this.extraDataTag = function(pts) {
var
i,
tag = new FlvTag(FlvTag.VIDEO_TAG,true);
tag = new FlvTag(FlvTag.VIDEO_TAG, true);
tag.dts = pts;
tag.pts = pts;
......
(function(window) {
/*
======== A Handy Little QUnit Reference ========
http://api.qunitjs.com/
Test methods:
module(name, {[setup][ ,teardown]})
test(name, callback)
expect(numberOfAssertions)
stop(increment)
start(decrement)
Test assertions:
ok(value, [message])
equal(actual, expected, [message])
notEqual(actual, expected, [message])
deepEqual(actual, expected, [message])
notDeepEqual(actual, expected, [message])
strictEqual(actual, expected, [message])
notStrictEqual(actual, expected, [message])
throws(block, [expected], [message])
*/
var FlvTag = window.videojs.hls.FlvTag;
module('FLV tag');
test('writeBytes with zero length writes the entire array', function() {
var
tag = new FlvTag(FlvTag.VIDEO_TAG),
headerLength = tag.length;
tag.writeBytes(new Uint8Array([0x1, 0x2, 0x3]));
equal(3 + headerLength, tag.length, '3 payload bytes are written');
});
})(this);
......@@ -52,6 +52,7 @@
<script src="video-js-hls_test.js"></script>
<script src="exp-golomb_test.js"></script>
<script src="flv-tag_test.js"></script>
</head>
<body>
<div id="qunit"></div>
......