e03bfc26 by David LaPalomento

Fix writeShort

Swap the order of arguments when writing a short to an FLV tag so the correct value is actually written.
1 parent 8478511a
...@@ -63,7 +63,7 @@ hls.FlvTag = function(type, extraData) { ...@@ -63,7 +63,7 @@ hls.FlvTag = function(type, extraData) {
63 63
64 // ByteArray#writeShort(value:int):void 64 // ByteArray#writeShort(value:int):void
65 this.writeShort = function(short) { 65 this.writeShort = function(short) {
66 this.view.setUint16(short, this.position); 66 this.view.setUint16(this.position, short);
67 this.position += 2; 67 this.position += 2;
68 this.length = Math.max(this.length, this.position); 68 this.length = Math.max(this.length, this.position);
69 }; 69 };
......
...@@ -27,10 +27,21 @@ test('writeBytes with zero length writes the entire array', function() { ...@@ -27,10 +27,21 @@ test('writeBytes with zero length writes the entire array', function() {
27 var 27 var
28 tag = new FlvTag(FlvTag.VIDEO_TAG), 28 tag = new FlvTag(FlvTag.VIDEO_TAG),
29 headerLength = tag.length; 29 headerLength = tag.length;
30
31 tag.writeBytes(new Uint8Array([0x1, 0x2, 0x3])); 30 tag.writeBytes(new Uint8Array([0x1, 0x2, 0x3]));
32 31
33 equal(3 + headerLength, tag.length, '3 payload bytes are written'); 32 equal(3 + headerLength, tag.length, '3 payload bytes are written');
34 }); 33 });
35 34
35 test('writeShort writes a two byte sequence', function() {
36 var
37 tag = new FlvTag(FlvTag.VIDEO_TAG),
38 headerLength = tag.length;
39 tag.writeShort(0x0102);
40
41 equal(2 + headerLength, tag.length, '2 bytes are written');
42 equal(0x0102,
43 new DataView(tag.bytes.buffer).getUint16(tag.length - 2),
44 'the value is written');
45 });
46
36 })(this); 47 })(this);
......