df9faa3f by David LaPalomento

Whitespace and formatting cleanup

Remove a remaining tabs. Standardize whitespace usage around declarations and keywords. Lift and unify `var` declarations.
1 parent e95cfe5a
1 (function (window) { 1 (function(window) {
2 window.videojs.hls.HLSPlaybackController = function (vjsPlayerReference) { 2 var
3 var ManifestController = window.videojs.hls.ManifestController; 3 ManifestController = window.videojs.hls.ManifestController,
4 var SegmentController = window.videojs.hls.SegmentController; 4 SegmentController = window.videojs.hls.SegmentController,
5 var MediaSource = window.videojs.MediaSource; 5 MediaSource = window.videojs.MediaSource,
6 var SegmentParser = window.videojs.hls.SegmentParser; 6 SegmentParser = window.videojs.hls.SegmentParser,
7 var M3U8 = window.videojs.hls.M3U8; 7 M3U8 = window.videojs.hls.M3U8;
8
9 window.videojs.hls.HLSPlaybackController = function(player) {
8 10
9 var self = this; 11 var self = this;
10 12
11 self.player = vjsPlayerReference; 13 self.player = player;
12 self.mediaSource = new MediaSource(); 14 self.mediaSource = new MediaSource();
13 self.parser = new SegmentParser(); 15 self.parser = new SegmentParser();
14 16
15 self.manifestController = null;
16 self.segmentController = null;
17 self.manifestLoaded = false; 17 self.manifestLoaded = false;
18 self.currentSegment = 0; 18 self.currentSegment = 0;
19 self.currentManifest = null;
20 self.currentPlaylist = null;
21 self.currentRendition = null;
22
23 // Register Externall Callbacks
24 self.manifestLoadCompleteCallback;
25 19
26 self.player.on('timeupdate', function () { 20 // register external callbacks
27 console.log(self.player.currentTime()); 21 self.rendition = function(rendition) {
28 });
29
30 self.player.on('onsrcchange', function () {
31 console.log('src change', self.player.currentSrc());
32 //if src.url.m3u8 -- loadManifest.url
33 });
34
35 self.rendition = function (rendition) {
36 self.currentRendition = rendition; 22 self.currentRendition = rendition;
37 self.loadManifest(self.currentRendition.url, self.onM3U8LoadComplete, self.onM3U8LoadError, self.onM3U8Update); 23 self.loadManifest(self.currentRendition.url, self.onM3U8LoadComplete, self.onM3U8LoadError, self.onM3U8Update);
38 }; 24 };
39 25
40 self.loadManifest = function (manifestUrl, onDataCallback, onErrorCallback, onUpdateCallback) { 26 self.loadManifest = function(manifestUrl, onDataCallback, onErrorCallback, onUpdateCallback) {
41 self.mediaSource.addEventListener('sourceopen', function (event) { 27 self.mediaSource.addEventListener('sourceopen', function(event) {
42 console.log('source open here');
43 // feed parsed bytes into the player 28 // feed parsed bytes into the player
44 self.sourceBuffer = self.mediaSource.addSourceBuffer('video/flv; codecs="vp6,aac"'); 29 self.sourceBuffer = self.mediaSource.addSourceBuffer('video/flv; codecs="vp6,aac"');
45 30
...@@ -47,8 +32,7 @@ ...@@ -47,8 +32,7 @@
47 32
48 self.sourceBuffer.appendBuffer(self.parser.getFlvHeader(), video); 33 self.sourceBuffer.appendBuffer(self.parser.getFlvHeader(), video);
49 34
50 if( onDataCallback ) 35 if (onDataCallback) {
51 {
52 self.manifestLoadCompleteCallback = onDataCallback; 36 self.manifestLoadCompleteCallback = onDataCallback;
53 } 37 }
54 38
...@@ -63,10 +47,9 @@ ...@@ -63,10 +47,9 @@
63 }); 47 });
64 }; 48 };
65 49
66 self.onM3U8LoadComplete = function (m3u8) { 50 self.onM3U8LoadComplete = function(m3u8) {
67 if (m3u8.invalidReasons.length == 0) { 51 if (m3u8.invalidReasons.length === 0) {
68 if(m3u8.isPlaylist) 52 if (m3u8.isPlaylist) {
69 {
70 self.currentPlaylist = m3u8; 53 self.currentPlaylist = m3u8;
71 self.rendition(self.currentPlaylist.playlistItems[0]); 54 self.rendition(self.currentPlaylist.playlistItems[0]);
72 } else { 55 } else {
...@@ -75,52 +58,39 @@ ...@@ -75,52 +58,39 @@
75 58
76 self.loadSegment(self.currentManifest.mediaItems[0]); 59 self.loadSegment(self.currentManifest.mediaItems[0]);
77 60
78 if(self.manifestLoadCompleteCallback) 61 if (self.manifestLoadCompleteCallback) {
79 {
80 self.manifestLoadCompleteCallback(m3u8); 62 self.manifestLoadCompleteCallback(m3u8);
81 } 63 }
82 } 64 }
83 } 65 }
84 }; 66 };
85 67
86 self.onM3U8LoadError = function (error) { 68 self.onM3U8LoadError = function(error) {};
87 69 self.onM3U8Update = function(m3u8) {};
88 };
89
90 self.onM3U8Update = function (m3u8) {
91
92 };
93 70
94 self.loadSegment = function(segment) { 71 self.loadSegment = function(segment) {
95 self.segmentController = new SegmentController(); 72 self.segmentController = new SegmentController();
96 self.segmentController.loadSegment(segment.url, self.onSegmentLoadComplete, self.onSegmentLoadError); 73 self.segmentController.loadSegment(segment.url, self.onSegmentLoadComplete, self.onSegmentLoadError);
97
98 }; 74 };
99 75
100 self.onSegmentLoadComplete = function (segment) { 76 self.onSegmentLoadComplete = function(segment) {
101 self.parser.parseSegmentBinaryData(segment.binaryData); 77 self.parser.parseSegmentBinaryData(segment.binaryData);
102 78
103 while (self.parser.tagsAvailable()) { 79 while (self.parser.tagsAvailable()) {
104 self.sourceBuffer.appendBuffer(self.parser.getNextTag().bytes, self.player); 80 self.sourceBuffer.appendBuffer(self.parser.getNextTag().bytes, self.player);
105 }; 81 }
106
107 console.log('load another',self.currentSegment,self.currentManifest.mediaItems.length);
108 82
109 if(self.currentSegment < self.currentManifest.mediaItems.length-1) 83 if (self.currentSegment < self.currentManifest.mediaItems.length-1) {
110 {
111 console.log('load another');
112 self.loadNextSegment(); 84 self.loadNextSegment();
113 } 85 }
114 }; 86 };
115 87
116 self.loadNextSegment = function () { 88 self.loadNextSegment = function() {
117 self.currentSegment++; 89 self.currentSegment++;
118 self.loadSegment(self.currentManifest.mediaItems[self.currentSegment]); 90 self.loadSegment(self.currentManifest.mediaItems[self.currentSegment]);
119 } 91 }
120 92
121 self.onSegmentLoadError = function (error) { 93 self.onSegmentLoadError = function(error) {};
122
123 };
124 94
125 }; 95 };
126 })(this); 96 })(this);
......
...@@ -2,54 +2,48 @@ ...@@ -2,54 +2,48 @@
2 var M3U8 = window.videojs.hls.M3U8; 2 var M3U8 = window.videojs.hls.M3U8;
3 3
4 window.videojs.hls.M3U8Parser = function() { 4 window.videojs.hls.M3U8Parser = function() {
5 5 var
6 var self = this; 6 self = this,
7 self.directory; 7 tagTypes = window.videojs.hls.m3u8TagType,
8 8 lines = [],
9 var tagTypes = window.videojs.hls.m3u8TagType; 9 data;
10 var lines = []; 10
11 var data; 11 self.getTagType = function(lineData) {
12 12 for (var s in tagTypes) {
13 self.getTagType = function( lineData ) { 13 if (lineData.indexOf(tagTypes[s]) === 0) {
14 for ( var s in tagTypes )
15 {
16 if (lineData.indexOf(tagTypes[s]) == 0)
17 {
18 return tagTypes[s]; 14 return tagTypes[s];
19 } 15 }
20 } 16 }
21 } 17 };
22 18
23 self.getTagValue = function ( lineData ) { 19 self.getTagValue = function(lineData) {
24 for ( var s in tagTypes ) 20 for (var s in tagTypes) {
25 { 21 if (lineData.indexOf(tagTypes[s]) === 0) {
26 if (lineData.indexOf(tagTypes[s]) == 0)
27 {
28 return lineData.substr(tagTypes[s].length); 22 return lineData.substr(tagTypes[s].length);
29 } 23 }
30 } 24 }
31 } 25 };
32 26
33 self.parse = function( rawDataString ) { 27 self.parse = function(rawDataString) {
34 data = new M3U8(); 28 data = new M3U8();
35 29
36 if(self.directory) 30 if (self.directory) {
37 {
38 data.directory = self.directory; 31 data.directory = self.directory;
39 } 32 }
40 33
41 if( rawDataString != undefined && rawDataString.toString().length > 0 ) 34 if (rawDataString === undefined || rawDataString.length <= 0) {
42 { 35 data.invalidReasons.push("Empty Manifest");
36 return;
37 }
43 lines = rawDataString.split('\n'); 38 lines = rawDataString.split('\n');
44 39
45 lines.forEach( 40 lines.forEach(function(value,index) {
46 function(value,index) { 41 var segment, rendition, attribute;
47 switch( self.getTagType(value) ) 42
48 { 43 switch (self.getTagType(value)) {
49 case tagTypes.EXTM3U: 44 case tagTypes.EXTM3U:
50 data.hasValidM3UTag = (index == 0); 45 data.hasValidM3UTag = (index == 0);
51 if(!data.hasValidM3UTag) 46 if (!data.hasValidM3UTag) {
52 {
53 data.invalidReasons.push("Invalid EXTM3U Tag"); 47 data.invalidReasons.push("Invalid EXTM3U Tag");
54 } 48 }
55 break; 49 break;
...@@ -58,8 +52,8 @@ ...@@ -58,8 +52,8 @@
58 break; 52 break;
59 53
60 case tagTypes.PLAYLIST_TYPE: 54 case tagTypes.PLAYLIST_TYPE:
61 if(self.getTagValue(value) == "VOD" || self.getTagValue(value) == "EVENT") 55 if (self.getTagValue(value) === "VOD" ||
62 { 56 self.getTagValue(value) === "EVENT") {
63 data.playlistType = self.getTagValue(value); 57 data.playlistType = self.getTagValue(value);
64 data.isPlaylist = true; 58 data.isPlaylist = true;
65 } else { 59 } else {
...@@ -68,59 +62,53 @@ ...@@ -68,59 +62,53 @@
68 break; 62 break;
69 63
70 case tagTypes.EXTINF: 64 case tagTypes.EXTINF:
71 var segment = {url: "unknown", byterange: -1, targetDuration: data.targetDuration }; 65 segment = {
66 url: "unknown",
67 byterange: -1,
68 targetDuration: data.targetDuration
69 };
72 70
73 if( self.getTagType(lines[index+1]) == tagTypes.BYTERANGE ) 71 if (self.getTagType(lines[index + 1]) === tagTypes.BYTERANGE) {
74 { 72 segment.byterange = self.getTagValue(lines[index + 1]).split('@');
75 segment.byterange = self.getTagValue(lines[index+1]).split('@'); 73 segment.url = lines[index + 2];
76 segment.url = lines[index+2]; 74 } else {
77 } else 75 segment.url = lines[index + 1];
78 {
79 segment.url = lines[index+1];
80 } 76 }
81 77
82 if(segment.url.indexOf("http")===-1 && self.directory) 78 if (segment.url.indexOf("http") === -1 && self.directory) {
83 { 79 if (data.directory[data.directory.length-1] === segment.url[0] &&
84 if(data.directory[data.directory.length-1] === segment.url[0] && segment.url[0] === "/") 80 segment.url[0] === "/") {
85 {
86 segment.url = segment.url.substr(1); 81 segment.url = segment.url.substr(1);
87 } 82 }
88 segment.url = self.directory + segment.url; 83 segment.url = self.directory + segment.url;
89 } 84 }
90
91 data.mediaItems.push(segment); 85 data.mediaItems.push(segment);
92
93 break; 86 break;
94 87
95 case tagTypes.STREAM_INF: 88 case tagTypes.STREAM_INF:
96 var rendition = {}; 89 rendition = {};
97 var attributes = value.substr(tagTypes.STREAM_INF.length).split(','); 90 attributes = value.substr(tagTypes.STREAM_INF.length).split(',');
98 91
99 attributes.forEach(function(attr_value,attr_index) { 92 attributes.forEach(function(attrValue) {
100 if(isNaN(attr_value.split('=')[1])){ 93 if (isNaN(attrValue.split('=')[1])) {
101 rendition[attr_value.split('=')[0].toLowerCase()] = attr_value.split('=')[1]; 94 rendition[attrValue.split('=')[0].toLowerCase()] = attrValue.split('=')[1];
102 95
103 if(rendition[attr_value.split('=')[0].toLowerCase()].split('x').length = 2) 96 if (rendition[attrValue.split('=')[0].toLowerCase()].split('x').length === 2) {
104 {
105 rendition.resolution = { 97 rendition.resolution = {
106 width: Number(rendition[attr_value.split('=')[0].toLowerCase()].split('x')[0]), 98 width: parseInt(rendition[attrValue.split('=')[0].toLowerCase()].split('x')[0]),
107 height: Number(rendition[attr_value.split('=')[0].toLowerCase()].split('x')[1]) 99 height: parseInt(rendition[attrValue.split('=')[0].toLowerCase()].split('x')[1])
108 } 100 }
109 } 101 }
110
111 } else { 102 } else {
112 rendition[attr_value.split('=')[0].toLowerCase()] = Number(attr_value.split('=')[1]); 103 rendition[attrValue.split('=')[0].toLowerCase()] = parseInt(attrValue.split('=')[1]);
113 } 104 }
114 }); 105 });
115 106
116 107 if (self.getTagType(lines[index + 1]) === tagTypes.BYTERANGE) {
117 if( self.getTagType(lines[index+1]) == tagTypes.BYTERANGE ) 108 rendition.byterange = self.getTagValue(lines[index + 1]).split('@');
118 { 109 rendition.url = lines[index + 2];
119 rendition.byterange = self.getTagValue(lines[index+1]).split('@'); 110 } else {
120 rendition.url = lines[index+2]; 111 rendition.url = lines[index + 1];
121 } else
122 {
123 rendition.url = lines[index+1];
124 } 112 }
125 113
126 data.isPlaylist = true; 114 data.isPlaylist = true;
...@@ -128,15 +116,15 @@ ...@@ -128,15 +116,15 @@
128 break; 116 break;
129 117
130 case tagTypes.TARGETDURATION: 118 case tagTypes.TARGETDURATION:
131 data.targetDuration = Number(self.getTagValue(value).split(',')[0]); 119 data.targetDuration = parseFloat(self.getTagValue(value).split(',')[0]);
132 break; 120 break;
133 121
134 case tagTypes.ZEN_TOTAL_DURATION: 122 case tagTypes.ZEN_TOTAL_DURATION:
135 data.totalDuration = Number(self.getTagValue(value)); 123 data.totalDuration = parseFloat(self.getTagValue(value));
136 break; 124 break;
137 125
138 case tagTypes.VERSION: 126 case tagTypes.VERSION:
139 data.version = Number(self.getTagValue(value)); 127 data.version = parseFloat(self.getTagValue(value));
140 break; 128 break;
141 129
142 case tagTypes.MEDIA_SEQUENCE: 130 case tagTypes.MEDIA_SEQUENCE:
...@@ -144,8 +132,7 @@ ...@@ -144,8 +132,7 @@
144 break; 132 break;
145 133
146 case tagTypes.ALLOW_CACHE: 134 case tagTypes.ALLOW_CACHE:
147 if(self.getTagValue(value) == "YES" || self.getTagValue(value) == "NO") 135 if (self.getTagValue(value) === "YES" || self.getTagValue(value) === "NO") {
148 {
149 data.allowCache = self.getTagValue(value); 136 data.allowCache = self.getTagValue(value);
150 } else { 137 } else {
151 data.invalidReasons.push("Invalid ALLOW_CACHE Value"); 138 data.invalidReasons.push("Invalid ALLOW_CACHE Value");
...@@ -156,15 +143,9 @@ ...@@ -156,15 +143,9 @@
156 data.hasEndTag = true; 143 data.hasEndTag = true;
157 break; 144 break;
158 } 145 }
159 } 146 });
160 )
161 } else {
162 data.invalidReasons.push("Empty Manifest");
163 }
164 147
165 return data; 148 return data;
166
167 }; 149 };
168 }; 150 };
169
170 })(this); 151 })(this);
......
1 (function(window) { 1 (function(window) {
2 window.videojs.hls.m3u8TagType = { 2 window.videojs.hls.m3u8TagType = {
3 /* 3 /*
4 * Derived from V8: http://tools.ietf.org/html/draft-pantos-http-live-streaming-08 4 * Derived from the HTTP Live Streaming Spec V8
5 * http://tools.ietf.org/html/draft-pantos-http-live-streaming-08
5 */ 6 */
6 7
7 /** 8 /**
......
...@@ -14,5 +14,5 @@ ...@@ -14,5 +14,5 @@
14 this.playlistType = ""; 14 this.playlistType = "";
15 this.mediaSequence = -1; 15 this.mediaSequence = -1;
16 this.version = -1; 16 this.version = -1;
17 } 17 };
18 })(this); 18 })(this);
......
1 (function (window) { 1 (function (window) {
2 var M3U8 = window.videojs.hls.M3U8; 2 var
3 var M3U8Parser = window.videojs.hls.M3U8Parser; 3 M3U8 = window.videojs.hls.M3U8,
4 M3U8Parser = window.videojs.hls.M3U8Parser;
4 5
5 window.videojs.hls.ManifestController = function () { 6 window.videojs.hls.ManifestController = function() {
6 var self = this; 7 var self = this;
7 8
8 self.parser; 9 self.parser;
...@@ -13,7 +14,7 @@ ...@@ -13,7 +14,7 @@
13 self.onErrorCallback; 14 self.onErrorCallback;
14 self.onUpdateCallback; 15 self.onUpdateCallback;
15 16
16 self.loadManifest = function (manifestUrl, onDataCallback, onErrorCallback, onUpdateCallback) { 17 self.loadManifest = function(manifestUrl, onDataCallback, onErrorCallback, onUpdateCallback) {
17 self.url = manifestUrl; 18 self.url = manifestUrl;
18 19
19 if (onDataCallback) { 20 if (onDataCallback) {
...@@ -30,7 +31,7 @@ ...@@ -30,7 +31,7 @@
30 vjs.get(manifestUrl, self.onManifestLoadComplete, self.onManifestLoadError); 31 vjs.get(manifestUrl, self.onManifestLoadComplete, self.onManifestLoadError);
31 }; 32 };
32 33
33 self.parseManifest = function (dataAsString) { 34 self.parseManifest = function(dataAsString) {
34 self.parser = new M3U8Parser(); 35 self.parser = new M3U8Parser();
35 self.parser.directory = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(self.url).slice(1)[1]; 36 self.parser.directory = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(self.url).slice(1)[1];
36 self.data = self.parser.parse(dataAsString); 37 self.data = self.parser.parse(dataAsString);
...@@ -38,7 +39,7 @@ ...@@ -38,7 +39,7 @@
38 return self.data; 39 return self.data;
39 }; 40 };
40 41
41 self.onManifestLoadComplete = function (response) { 42 self.onManifestLoadComplete = function(response) {
42 var output = self.parseManifest(response); 43 var output = self.parseManifest(response);
43 44
44 if (self.onDataCallback != undefined) { 45 if (self.onDataCallback != undefined) {
...@@ -46,7 +47,7 @@ ...@@ -46,7 +47,7 @@
46 } 47 }
47 }; 48 };
48 49
49 self.onManifestLoadError = function (err) { 50 self.onManifestLoadError = function(err) {
50 if (self.onErrorCallback != undefined) { 51 if (self.onErrorCallback != undefined) {
51 self.onErrorCallback((err != undefined) ? err : null); 52 self.onErrorCallback((err != undefined) ? err : null);
52 } 53 }
......
1 (function(window) { 1 (function(window) {
2 2
3 window.videojs.hls.SegmentController = function(){ 3 window.videojs.hls.SegmentController = function() {
4
5 var self = this; 4 var self = this;
6 5
7 self.url; 6 self.loadSegment = function(segmentUrl, onDataCallback, onErrorCallback, onUpdateCallback) {
8 7 var request = new XMLHttpRequest();
9 self.requestTimestamp;
10 self.responseTimestamp;
11 self.data;
12
13 self.onDataCallback;
14 self.onErrorCallback;
15 self.onUpdateCallback;
16 8
17 self.loadSegment = function ( segmentUrl, onDataCallback, onErrorCallback, onUpdateCallback ) {
18 self.url = segmentUrl; 9 self.url = segmentUrl;
19 self.onDataCallback = onDataCallback; 10 self.onDataCallback = onDataCallback;
20 self.onErrorCallback = onErrorCallback; 11 self.onErrorCallback = onErrorCallback;
21 self.onUpdateCallback = onUpdateCallback; 12 self.onUpdateCallback = onUpdateCallback;
22 self.requestTimestamp = new Date().getTime(); 13 self.requestTimestamp = +new Date();
23 14
24 var req = new XMLHttpRequest(); 15 request.open('GET', segmentUrl, true);
25 req.open('GET', segmentUrl, true); 16 request.responseType = 'arraybuffer';
26 req.responseType = 'arraybuffer'; 17 request.onload = function(response) {
27 req.onload = function(response) { 18 self.onSegmentLoadComplete(new Uint8Array(request.response));
28 self.onSegmentLoadComplete(new Uint8Array(req.response));
29 }; 19 };
30 20
31 req.send(null); 21 request.send(null);
32
33 //vjs.get(segmentUrl, self.onSegmentLoadComplete, self.onSegmentLoadError);
34 }; 22 };
35 23
36 self.parseSegment = function ( incomingData ) { 24 self.parseSegment = function(incomingData) {
37 // Add David's code later //
38 console.log('got segment data', incomingData.byteLength);
39
40 self.data = {}; 25 self.data = {};
41 self.data.binaryData = incomingData; 26 self.data.binaryData = incomingData;
42 self.data.url = self.url; 27 self.data.url = self.url;
...@@ -44,36 +29,35 @@ ...@@ -44,36 +29,35 @@
44 self.data.requestTimestamp = self.requestTimestamp; 29 self.data.requestTimestamp = self.requestTimestamp;
45 self.data.responseTimestamp = self.responseTimestamp; 30 self.data.responseTimestamp = self.responseTimestamp;
46 self.data.byteLength = incomingData.byteLength; 31 self.data.byteLength = incomingData.byteLength;
47 self.data.isCached = ( parseInt(self.responseTimestamp - self.requestTimestamp) < 75 ); 32 self.data.isCached = parseInt(self.responseTimestamp - self.requestTimestamp) < 75;
48 self.data.throughput = self.calculateThroughput(self.data.byteLength, self.requestTimestamp ,self.responseTimestamp); 33 self.data.throughput = self.calculateThroughput(self.data.byteLength, self.requestTimestamp ,self.responseTimestamp);
49 34
50 return self.data; 35 return self.data;
51 }; 36 };
52 37
53 self.calculateThroughput = function(dataAmount, startTime, endTime) { 38 self.calculateThroughput = function(dataAmount, startTime, endTime) {
54 return Math.round(dataAmount/(endTime-startTime)*1000)*8; 39 return Math.round(dataAmount / (endTime - startTime) * 1000) * 8;
55 } 40 }
56 41
57 self.onSegmentLoadComplete = function(response) { 42 self.onSegmentLoadComplete = function(response) {
58 self.responseTimestamp = new Date().getTime(); 43 var output;
44
45 self.responseTimestamp = +new Date();
59 46
60 var output = self.parseSegment(response); 47 output = self.parseSegment(response);
61 48
62 if(self.onDataCallback != undefined) 49 if (self.onDataCallback !== undefined) {
63 {
64 self.onDataCallback(output); 50 self.onDataCallback(output);
65 } 51 }
66 }; 52 };
67 53
68 self.onSegmentLoadError = function(err) { 54 self.onSegmentLoadError = function(error) {
69 if(err) 55 if (error) {
70 { 56 console.log(error.message);
71 console.log(err.message);
72 } 57 }
73 58
74 if(self.onErrorCallback != undefined) 59 if (self.onErrorCallback !== undefined) {
75 { 60 onErrorCallback(error);
76 onErrorCallback((err != undefined) ? err : null);
77 } 61 }
78 }; 62 };
79 } 63 }
......
...@@ -249,14 +249,12 @@ ...@@ -249,14 +249,12 @@
249 249
250 test('should create my parser', function () { 250 test('should create my parser', function () {
251 ok(m3u8parser != undefined); 251 ok(m3u8parser != undefined);
252 } 252 });
253 );
254 253
255 test('should successfully parse manifest data', function () { 254 test('should successfully parse manifest data', function () {
256 var parsedData = m3u8parser.parse(window.playlistData); 255 var parsedData = m3u8parser.parse(window.playlistData);
257 ok(parsedData); 256 ok(parsedData);
258 } 257 });
259 );
260 258
261 test('test for expected results', function () { 259 test('test for expected results', function () {
262 var data = m3u8parser.parse(window.playlistData); 260 var data = m3u8parser.parse(window.playlistData);
...@@ -272,8 +270,7 @@ ...@@ -272,8 +270,7 @@
272 equal(data.mediaSequence, 0, 'MEDIA SEQUENCE is correct'); 270 equal(data.mediaSequence, 0, 'MEDIA SEQUENCE is correct');
273 equal(data.totalDuration, -1, "ZEN TOTAL DURATION is unknown as expected"); 271 equal(data.totalDuration, -1, "ZEN TOTAL DURATION is unknown as expected");
274 equal(data.hasEndTag, true, 'should have ENDLIST tag'); 272 equal(data.hasEndTag, true, 'should have ENDLIST tag');
275 } 273 });
276 );
277 274
278 module('brightcove playlist', { 275 module('brightcove playlist', {
279 setup: function () { 276 setup: function () {
...@@ -299,7 +296,6 @@ ...@@ -299,7 +296,6 @@
299 manifestController = new window.videojs.hls.ManifestController(); 296 manifestController = new window.videojs.hls.ManifestController();
300 this.vjsget = vjs.get; 297 this.vjsget = vjs.get;
301 vjs.get = function (url, success, error) { 298 vjs.get = function (url, success, error) {
302 console.log(url);
303 success(window.brightcove_playlist_data); 299 success(window.brightcove_playlist_data);
304 }; 300 };
305 }, 301 },
...@@ -316,29 +312,22 @@ ...@@ -316,29 +312,22 @@
316 var data = manifestController.parseManifest(window.brightcove_playlist_data); 312 var data = manifestController.parseManifest(window.brightcove_playlist_data);
317 313
318 ok(data); 314 ok(data);
319
320 equal(data.playlistItems.length, 4, 'Has correct rendition count'); 315 equal(data.playlistItems.length, 4, 'Has correct rendition count');
321 equal(data.playlistItems[0].bandwidth, 240000, 'First rendition index bandwidth is correct'); 316 equal(data.playlistItems[0].bandwidth, 240000, 'First rendition index bandwidth is correct');
322 equal(data.playlistItems[0]["program-id"], 1, 'First rendition index program-id is correct'); 317 equal(data.playlistItems[0]["program-id"], 1, 'First rendition index program-id is correct');
323 equal(data.playlistItems[0].resolution.width, 396, 'First rendition index resolution width is correct'); 318 equal(data.playlistItems[0].resolution.width, 396, 'First rendition index resolution width is correct');
324 equal(data.playlistItems[0].resolution.height, 224, 'First rendition index resolution height is correct'); 319 equal(data.playlistItems[0].resolution.height, 224, 'First rendition index resolution height is correct');
325 }) 320 });
326 321
327 test('should get a manifest from hermes', function () { 322 test('should get a manifest from hermes', function () {
328 var hermesUrl = "http://localhost:7070/test/basic-playback/brightcove/16x9-master.m3u8"; 323 manifestController.loadManifest('http://example.com/16x9-master.m3u8',
329 324 function(responseData) {
330 manifestController.loadManifest( 325 ok(responseData);
331 hermesUrl,
332 function (responseData) {
333 ok(true);
334 }, 326 },
335 function (errorData) { 327 function(errorData) {
336 console.log('got error data'); 328 ok(false, 'does not error');
337 }, 329 },
338 function (updateData) { 330 function(updateData) {});
339 console.log('got update data');
340 }
341 )
342 }); 331 });
343 332
344 module('segment controller', { 333 module('segment controller', {
...@@ -355,33 +344,11 @@ ...@@ -355,33 +344,11 @@
355 } 344 }
356 }); 345 });
357 346
358 test('should get a segment data', function () {
359 ok(true);
360 var hermesUrl = "http://localhost:7070/test/ts-files/brightcove/s-1.ts";
361
362 segmentController.loadSegment(
363 hermesUrl,
364 function (responseData) {
365 console.log('got response from segment controller');
366 ok(true);
367
368 },
369 function (errorData) {
370 console.log('got error data');
371 },
372 function (updateData) {
373 console.log('got update data');
374 }
375 )
376 }
377 )
378
379 test('bandwidth calulation test', function () { 347 test('bandwidth calulation test', function () {
380 var multiSecondData = segmentController.calculateThroughput(10000, 1000, 2000); 348 var
381 var subSecondData = segmentController.calculateThroughput(10000, 1000, 1500); 349 multiSecondData = segmentController.calculateThroughput(10000, 1000, 2000),
350 subSecondData = segmentController.calculateThroughput(10000, 1000, 1500);
382 equal(multiSecondData, 80000, 'MULTI-Second bits per second calculation'); 351 equal(multiSecondData, 80000, 'MULTI-Second bits per second calculation');
383 equal(subSecondData, 160000, 'SUB-Second bits per second calculation'); 352 equal(subSecondData, 160000, 'SUB-Second bits per second calculation');
384 353 });
385 })
386
387 })(this); 354 })(this);
......