866d581d by Tom Johnson

merge commit

2 parents 17ec4078 1541a1dc
...@@ -71,14 +71,14 @@ ...@@ -71,14 +71,14 @@
71 mediaSource = new videojs.MediaSource(); 71 mediaSource = new videojs.MediaSource();
72 72
73 mediaSource.addEventListener('sourceopen', function(event){ 73 mediaSource.addEventListener('sourceopen', function(event){
74 var tag, bytes, parser, i, feedBytes, everything, old; 74 var tag, bytes, parser, i, everything, old;
75 75
76 // feed parsed bytes into the player 76 // feed parsed bytes into the player
77 var sourceBuffer = mediaSource.addSourceBuffer('video/flv; codecs="vp6,aac"'); 77 var sourceBuffer = mediaSource.addSourceBuffer('video/flv; codecs="vp6,aac"');
78 parser = new videojs.hls.SegmentParser(); 78 parser = new videojs.hls.SegmentParser();
79 // var header = parser.getFlvHeader(); 79 // var header = parser.getFlvHeader();
80 everything = parser.getFlvHeader(); 80 everything = parser.getFlvHeader();
81 // sourceBuffer.appendBuffer(header); 81 // sourceBuffer.appendBuffer(header, video);
82 82
83 parser.parseSegmentBinaryData(window.bcSegment); 83 parser.parseSegmentBinaryData(window.bcSegment);
84 84
...@@ -90,12 +90,12 @@ ...@@ -90,12 +90,12 @@
90 everything.set(tag.bytes, old.byteLength); 90 everything.set(tag.bytes, old.byteLength);
91 } 91 }
92 console.log('sending ' + everything.byteLength + 'B'); 92 console.log('sending ' + everything.byteLength + 'B');
93 var iframe = document.createElement('iframe'); 93 // var iframe = document.createElement('iframe');
94 iframe.src = 'data:video/x-flv;base64,' + window.btoa((Array.prototype.map.call(everything, function(byte) { 94 // iframe.src = 'data:video/x-flv;base64,' + window.btoa((Array.prototype.map.call(everything, function(byte) {
95 return String.fromCharCode(byte); 95 // return String.fromCharCode(byte);
96 })).join('')); 96 // })).join(''));
97 document.body.appendChild(iframe); 97 //document.body.appendChild(iframe);
98 // sourceBuffer.appendBuffer(everything, video); 98 sourceBuffer.appendBuffer(everything, video);
99 }, false); 99 }, false);
100 100
101 url = videojs.URL.createObjectURL(mediaSource); 101 url = videojs.URL.createObjectURL(mediaSource);
......
...@@ -42,7 +42,7 @@ hls.FlvTag = function(type, extraData) { ...@@ -42,7 +42,7 @@ hls.FlvTag = function(type, extraData) {
42 // ByteArray#writeBytes(bytes:ByteArray, offset:uint = 0, length:uint = 0) 42 // ByteArray#writeBytes(bytes:ByteArray, offset:uint = 0, length:uint = 0)
43 this.writeBytes = function(bytes, offset, length) { 43 this.writeBytes = function(bytes, offset, length) {
44 offset = offset || 0; 44 offset = offset || 0;
45 length = length || 0; 45 length = length || bytes.byteLength;
46 46
47 try { 47 try {
48 this.bytes.set(bytes.subarray(offset, offset + length), this.position); 48 this.bytes.set(bytes.subarray(offset, offset + length), this.position);
...@@ -198,10 +198,10 @@ hls.FlvTag = function(type, extraData) { ...@@ -198,10 +198,10 @@ hls.FlvTag = function(type, extraData) {
198 this.position++; 198 this.position++;
199 this.view.setUint32(this.position, adHoc); 199 this.view.setUint32(this.position, adHoc);
200 this.position = this.length; 200 this.position = this.length;
201 this.bytes.set([0, 0, 9], this.position); 201 // this.bytes.set([0, 0, 9], this.position);
202 this.position += 3; 202 // this.position += 3;
203 // this.view.setUint32(this.position, 0x09); // End Data Tag 203 this.view.setUint32(this.position, 0x09); // End Data Tag
204 // this.position += 4; 204 this.position += 4;
205 this.length = this.position; 205 this.length = this.position;
206 break; 206 break;
207 } 207 }
......
...@@ -146,9 +146,14 @@ ...@@ -146,9 +146,14 @@
146 tag.pts = pts; 146 tag.pts = pts;
147 expGolomb = new ExpGolomb(this.getSps0Rbsp()); 147 expGolomb = new ExpGolomb(this.getSps0Rbsp());
148 148
149 profile_idc = expGolomb.readUnsignedByte(); // :int = expGolomb.readUnsignedByte(); // profile_idc u(8) 149 // :int = expGolomb.readUnsignedByte(); // profile_idc u(8)
150 expGolomb.skipBits(16);// constraint_set[0-5]_flag, u(1), reserved_zero_2bits u(2), level_idc u(8) 150 profile_idc = expGolomb.readUnsignedByte();
151 expGolomb.skipUnsignedExpGolomb(); // seq_parameter_set_id 151
152 // constraint_set[0-5]_flag, u(1), reserved_zero_2bits u(2), level_idc u(8)
153 expGolomb.skipBits(16);
154
155 // seq_parameter_set_id
156 expGolomb.skipUnsignedExpGolomb();
152 157
153 if (profile_idc === 100 || 158 if (profile_idc === 100 ||
154 profile_idc === 110 || 159 profile_idc === 110 ||
...@@ -230,7 +235,7 @@ ...@@ -230,7 +235,7 @@
230 this.extraDataTag = function(pts) { 235 this.extraDataTag = function(pts) {
231 var 236 var
232 i, 237 i,
233 tag = new FlvTag(FlvTag.VIDEO_TAG,true); 238 tag = new FlvTag(FlvTag.VIDEO_TAG, true);
234 239
235 tag.dts = pts; 240 tag.dts = pts;
236 tag.pts = pts; 241 tag.pts = pts;
......
1 (function(window) {
2 /*
3 ======== A Handy Little QUnit Reference ========
4 http://api.qunitjs.com/
5
6 Test methods:
7 module(name, {[setup][ ,teardown]})
8 test(name, callback)
9 expect(numberOfAssertions)
10 stop(increment)
11 start(decrement)
12 Test assertions:
13 ok(value, [message])
14 equal(actual, expected, [message])
15 notEqual(actual, expected, [message])
16 deepEqual(actual, expected, [message])
17 notDeepEqual(actual, expected, [message])
18 strictEqual(actual, expected, [message])
19 notStrictEqual(actual, expected, [message])
20 throws(block, [expected], [message])
21 */
22 var FlvTag = window.videojs.hls.FlvTag;
23
24 module('FLV tag');
25
26 test('writeBytes with zero length writes the entire array', function() {
27 var
28 tag = new FlvTag(FlvTag.VIDEO_TAG),
29 headerLength = tag.length;
30
31 tag.writeBytes(new Uint8Array([0x1, 0x2, 0x3]));
32
33 equal(3 + headerLength, tag.length, '3 payload bytes are written');
34 });
35
36 })(this);
...@@ -66,7 +66,8 @@ ...@@ -66,7 +66,8 @@
66 66
67 <script src="exp-golomb_test.js"></script> 67 <script src="exp-golomb_test.js"></script>
68 <script src="video-js-hls_test.js"></script> 68 <script src="video-js-hls_test.js"></script>
69 69 <script src="exp-golomb_test.js"></script>
70 <script src="flv-tag_test.js"></script>
70 </head> 71 </head>
71 <body> 72 <body>
72 <div id="qunit"></div> 73 <div id="qunit"></div>
......