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
17ec4078
authored
2013-10-23 15:47:25 -0400
by
Tom Johnson
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
progress update
1 parent
ced9b85e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
121 additions
and
21 deletions
src/manifest-controller.js
src/segment-controller.js
test/video-js-hls.html
test/video-js-hls_test.js
src/manifest-controller.js
View file @
17ec407
(
function
(
window
)
{
var
M3U8
=
window
.
videojs
.
hls
.
M3U8
;
var
M3U8Parser
=
window
.
videojs
.
hls
.
M3U8Parser
;
var
M3U8TagTypes
=
window
.
videojs
.
hls
.
m3u8TagType
;
window
.
videojs
.
hls
.
ManifestController
=
function
(){
...
...
@@ -49,12 +48,4 @@
}
};
}
})(
this
);
/*
mc = new window.videojs.hls.ManifestController('myM3u8.m3u8', {
onData: function(){},
onError: function(){},
onUpdate: function(){}
});
*/
\ No newline at end of file
})(
this
);
\ No newline at end of file
...
...
src/segment-controller.js
0 → 100644
View file @
17ec407
(
function
(
window
)
{
var
SegmentParser
=
window
.
videojs
.
hls
.
SegmentParser
;
window
.
videojs
.
hls
.
SegmentController
=
function
(){
var
self
=
this
;
var
url
;
var
parser
;
var
requestTimestamp
;
var
responseTimestamp
;
var
data
;
var
onDataCallback
;
var
onErrorCallback
;
var
onUpdateCallback
;
self
.
loadSegment
=
function
(
segmentUrl
,
onDataCallback
,
onErrorCallback
,
onUpdateCallback
)
{
self
.
url
=
segmentUrl
;
self
.
onDataCallback
=
onDataCallback
;
self
.
onErrorCallback
=
onErrorCallback
;
self
.
onUpdateCallback
=
onUpdateCallback
;
self
.
requestTimestamp
=
new
Date
().
getTime
();
vjs
.
get
(
segmentUrl
,
self
.
onSegmentLoadComplete
,
self
.
onSegmentLoadError
);
};
self
.
parseSegment
=
function
(
incomingData
)
{
// Add David's code later //
self
.
data
=
{};
self
.
data
.
url
=
self
.
url
;
self
.
data
.
isCached
=
false
;
self
.
data
.
requestTimestamp
=
self
.
requestTimestamp
;
self
.
data
.
responseTimestamp
=
self
.
responseTimestamp
;
self
.
data
.
byteLength
=
incomingData
.
byteLength
;
self
.
data
.
isCached
=
(
parseInt
(
self
.
responseTimestamp
-
self
.
requestTimestamp
)
<
75
);
self
.
data
.
throughput
=
self
.
calculateThroughput
(
self
.
data
.
byteLength
,
self
.
requestTimestamp
,
self
.
responseTimestamp
)
return
self
.
data
;
};
self
.
calculateThroughput
=
function
(
dataAmount
,
startTime
,
endTime
)
{
return
Math
.
round
(
dataAmount
/
(
endTime
-
startTime
)
*
1000
)
*
8
;
}
self
.
onSegmentLoadComplete
=
function
(
response
)
{
self
.
responseTimestamp
=
new
Date
().
getTime
();
var
output
=
self
.
parseSegment
(
response
);
if
(
self
.
onDataCallback
!=
undefined
)
{
self
.
onDataCallback
(
output
);
}
};
self
.
onSegmentLoadError
=
function
(
err
)
{
if
(
err
)
{
console
.
log
(
err
.
message
);
}
if
(
self
.
onErrorCallback
!=
undefined
)
{
onErrorCallback
((
err
!=
undefined
)
?
err
:
null
);
}
};
}
})(
this
);
test/video-js-hls.html
View file @
17ec407
...
...
@@ -54,12 +54,9 @@
<script
src=
"manifest/playlistM3U8data.js"
></script>
<script
src=
"manifest/brightcove_playlist_m3u8.js"
></script>
<!-- M3U8 -->
<!-- an example MPEG2-TS segment -->
<!-- <script src="tsSegment.js"></script> -->
<!-- SEGMENT -->
<script
src=
"tsSegment-bc.js"
></script>
<script
src=
"../src/segment-controller.js"
></script>
<script
src=
"../src/bin-utils.js"
></script>
...
...
@@ -67,9 +64,9 @@
<script
src=
"exp-golomb_test.js"
></script>
<script
src=
"video-js-hls_test.js"
></script>
<script
src=
"exp-golomb_test.js"
></script>
</head>
<body>
<div
id=
"qunit"
></div>
...
...
test/video-js-hls_test.js
View file @
17ec407
...
...
@@ -21,6 +21,7 @@
*/
var
manifestController
,
segmentController
,
m3u8parser
,
parser
,
...
...
@@ -328,17 +329,58 @@
manifestController
.
loadManifest
(
hermesUrl
,
function
(
responseData
){
console
.
log
(
'got response data'
);
ok
(
true
);
},
function
(
errorData
){
console
.
log
(
'got error data'
)
console
.
log
(
'got error data'
)
;
},
function
(
updateData
){
console
.
log
(
'got update data'
)
console
.
log
(
'got update data'
)
;
}
)
});
module
(
'segment controller'
,
{
setup
:
function
()
{
segmentController
=
new
window
.
videojs
.
hls
.
SegmentController
();
this
.
vjsget
=
vjs
.
get
;
vjs
.
get
=
function
(
url
,
success
,
error
){
console
.
log
(
'load segment url'
,
url
);
success
(
window
.
bcSegment
);
};
},
teardown
:
function
()
{
vjs
.
get
=
this
.
vjsget
;
}
});
test
(
'should get a segment data'
,
function
()
{
ok
(
true
);
var
hermesUrl
=
"http://localhost:7070/test/ts-files/brightcove/s-1.ts"
;
segmentController
.
loadSegment
(
hermesUrl
,
function
(
responseData
){
console
.
log
(
'got response from segment controller'
);
ok
(
true
);
},
function
(
errorData
){
console
.
log
(
'got error data'
);
},
function
(
updateData
){
console
.
log
(
'got update data'
);
}
)
}
)
test
(
'bandwidth calulation test'
,
function
()
{
var
multiSecondData
=
segmentController
.
calculateThroughput
(
10000
,
1000
,
2000
);
var
subSecondData
=
segmentController
.
calculateThroughput
(
10000
,
1000
,
1500
);
equal
(
multiSecondData
,
80000
,
'MULTI-Second bits per second calculation'
);
equal
(
subSecondData
,
160000
,
'SUB-Second bits per second calculation'
);
})
})(
this
);
})(
this
);
\ No newline at end of file
...
...
Please
register
or
sign in
to post a comment