Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
videojs-contrib-hls
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
866d581d
authored
2013-10-23 16:37:16 -0400
by
Tom Johnson
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
merge commit
2 parents
17ec4078
1541a1dc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
18 deletions
example.html
src/flv-tag.js
src/h264-stream.js
test/flv-tag_test.js
test/video-js-hls.html
example.html
View file @
866d581
...
...
@@ -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
);
...
...
src/flv-tag.js
View file @
866d581
...
...
@@ -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
;
}
...
...
src/h264-stream.js
View file @
866d581
...
...
@@ -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
;
...
...
test/flv-tag_test.js
0 → 100644
View file @
866d581
(
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
);
test/video-js-hls.html
View file @
866d581
...
...
@@ -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>
...
...
Please
register
or
sign in
to post a comment