866d581d by Tom Johnson

merge commit

2 parents 17ec4078 1541a1dc
......@@ -71,14 +71,14 @@
mediaSource = new videojs.MediaSource();
mediaSource.addEventListener('sourceopen', function(event){
var tag, bytes, parser, i, feedBytes, everything, old;
var tag, bytes, parser, i, everything, old;
// feed parsed bytes into the player
var sourceBuffer = mediaSource.addSourceBuffer('video/flv; codecs="vp6,aac"');
parser = new videojs.hls.SegmentParser();
// var header = parser.getFlvHeader();
everything = parser.getFlvHeader();
// sourceBuffer.appendBuffer(header);
// sourceBuffer.appendBuffer(header, video);
parser.parseSegmentBinaryData(window.bcSegment);
......@@ -90,12 +90,12 @@
everything.set(tag.bytes, old.byteLength);
}
console.log('sending ' + everything.byteLength + 'B');
var iframe = document.createElement('iframe');
iframe.src = 'data:video/x-flv;base64,' + window.btoa((Array.prototype.map.call(everything, function(byte) {
return String.fromCharCode(byte);
})).join(''));
document.body.appendChild(iframe);
// sourceBuffer.appendBuffer(everything, video);
// var iframe = document.createElement('iframe');
// iframe.src = 'data:video/x-flv;base64,' + window.btoa((Array.prototype.map.call(everything, function(byte) {
// return String.fromCharCode(byte);
// })).join(''));
//document.body.appendChild(iframe);
sourceBuffer.appendBuffer(everything, video);
}, false);
url = videojs.URL.createObjectURL(mediaSource);
......
......@@ -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);
......@@ -66,7 +66,8 @@
<script src="exp-golomb_test.js"></script>
<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>
......