2d70b254 by David LaPalomento

Remove unused files

Get rid of leftovers from the previous iteration of managing manifest and stream downloading. That logic has been consolidated into the main plugin file.
1 parent 3f87ad97
......@@ -28,11 +28,8 @@ module.exports = function(grunt) {
'src/h264-stream.js',
'src/aac-stream.js',
'src/segment-parser.js',
'src/segment-controller.js',
'src/m3u8/m3u8-parser.js',
'src/manifest-controller.js',
'src/segment-controller.js',
'src/hls-playback-controller.js'],
'src/m3u8/m3u8-parser.js'
],
dest: 'dist/videojs.hls.js'
},
},
......
......@@ -21,14 +21,10 @@
<script src="src/h264-stream.js"></script>
<script src="src/aac-stream.js"></script>
<script src="src/segment-parser.js"></script>
<script src="src/segment-controller.js"></script>
<!-- m3u8 handling -->
<script src="src/stream.js"></script>
<script src="src/m3u8/m3u8-parser.js"></script>
<script src="src/manifest-controller.js"></script>
<script src="src/segment-controller.js"></script>
<script src="src/hls-playback-controller.js"></script>
<!-- example MPEG2-TS segments -->
<!-- bipbop -->
......
(function(window) {
var
ManifestController = window.videojs.hls.ManifestController,
SegmentController = window.videojs.hls.SegmentController,
MediaSource = window.videojs.MediaSource,
SegmentParser = window.videojs.hls.SegmentParser;
window.videojs.hls.HLSPlaybackController = function(player) {
var self = this;
self.player = player;
self.mediaSource = new MediaSource();
self.parser = new SegmentParser();
self.manifestLoaded = false;
self.currentSegment = 0;
// register external callbacks
self.rendition = function(rendition) {
self.currentRendition = rendition;
self.loadManifestWithMediaSources(self.currentRendition.url, self.onM3U8LoadComplete, self.onM3U8LoadError, self.onM3U8Update);
};
self.loadManifestWithMediaSources = function(manifestUrl,onDataCallback) {
self.manifestController = new ManifestController();
self.manifestController.loadManifest(manifestUrl, self.onM3U8LoadComplete, self.onM3U8LoadError, self.onM3U8Update);
if (onDataCallback) {
self.manifestLoadCompleteCallback = onDataCallback;
}
};
self.loadManifest = function(manifestUrl, onDataCallback) {
self.mediaSource.addEventListener('sourceopen', function() {
// feed parsed bytes into the player
self.sourceBuffer = self.mediaSource.addSourceBuffer('video/flv; codecs="vp6,aac"');
self.parser = new SegmentParser();
self.sourceBuffer.appendBuffer(self.parser.getFlvHeader(), self.player);
if (onDataCallback) {
self.manifestLoadCompleteCallback = onDataCallback;
}
self.manifestController = new ManifestController();
self.manifestController.loadManifest(manifestUrl, self.onM3U8LoadComplete, self.onM3U8LoadError, self.onM3U8Update);
}, false);
self.player.src({
src: window.videojs.URL.createObjectURL(self.mediaSource),
type: "video/flv"
});
};
self.onM3U8LoadComplete = function(m3u8) {
if (m3u8.invalidReasons.length === 0) {
if (m3u8.isPlaylist) {
self.currentPlaylist = m3u8;
self.rendition(self.currentPlaylist.playlistItems[0]);
} else {
self.currentManifest = m3u8;
self.manifestLoaded = true;
self.loadSegment(self.currentManifest.mediaItems[0]);
if (self.manifestLoadCompleteCallback) {
self.manifestLoadCompleteCallback(m3u8);
}
}
}
};
self.onM3U8LoadError = function() {};
self.onM3U8Update = function() {};
self.loadSegment = function(segment) {
self.segmentController = new SegmentController();
self.segmentController.loadSegment(segment.url, self.onSegmentLoadComplete, self.onSegmentLoadError);
};
self.onSegmentLoadComplete = function(segment) {
self.parser.parseSegmentBinaryData(segment.binaryData);
while (self.parser.tagsAvailable()) {
self.sourceBuffer.appendBuffer(self.parser.getNextTag().bytes, self.player);
}
if (self.currentSegment < self.currentManifest.mediaItems.length-1) {
self.loadNextSegment();
}
};
self.loadNextSegment = function() {
self.currentSegment++;
self.loadSegment(self.currentManifest.mediaItems[self.currentSegment]);
};
self.onSegmentLoadError = function() {};
};
})(this);
(function (window) {
var parser = window.videojs.hls.M3U8Parser;
window.videojs.hls.ManifestController = function() {
var self = this;
self.loadManifest = function(manifestUrl, onDataCallback, onErrorCallback, onUpdateCallback) {
self.url = manifestUrl;
if (onDataCallback) {
self.onDataCallback = onDataCallback;
}
if (onErrorCallback) {
self.onErrorCallback = onErrorCallback;
}
if (onUpdateCallback) {
self.onUpdateCallback = onUpdateCallback;
}
window.vjs.get(manifestUrl, self.onManifestLoadComplete, self.onManifestLoadError);
};
self.parseManifest = function(manifest) {
return parser.parse(manifest);
};
self.onManifestLoadComplete = function(response) {
var output = self.parseManifest(response);
if (self.onDataCallback !== undefined) {
self.onDataCallback(output);
}
};
self.onManifestLoadError = function(err) {
if (self.onErrorCallback !== undefined) {
self.onErrorCallback((err !== undefined) ? err : null);
}
};
};
})(this);
(function(window) {
window.videojs.hls.SegmentController = function() {
var self = this;
self.loadSegment = function(segmentUrl, onDataCallback, onErrorCallback, onUpdateCallback) {
var request = new XMLHttpRequest();
self.url = segmentUrl;
self.onDataCallback = onDataCallback;
self.onErrorCallback = onErrorCallback;
self.onUpdateCallback = onUpdateCallback;
self.requestTimestamp = +new Date();
request.open('GET', segmentUrl, true);
request.responseType = 'arraybuffer';
request.onload = function() {
self.onSegmentLoadComplete(new Uint8Array(request.response));
};
request.send(null);
};
self.parseSegment = function(incomingData) {
self.data = {};
self.data.binaryData = incomingData;
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,10) < 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) {
var output;
self.responseTimestamp = +new Date();
output = self.parseSegment(response);
if (self.onDataCallback !== undefined) {
self.onDataCallback(output);
}
};
self.onSegmentLoadError = function(error) {
if (error) {
throw error;
}
if (self.onErrorCallback !== undefined) {
self.onErrorCallback(error);
}
};
};
})(this);
......@@ -22,7 +22,6 @@
<!-- M3U8 -->
<script src="../src/stream.js"></script>
<script src="../src/m3u8/m3u8-parser.js"></script>
<script src="../src/manifest-controller.js"></script>
<!-- M3U8 TEST DATA -->
<script src="../tmp/manifests.js"></script>
<script src="../tmp/expected.js"></script>
......@@ -30,7 +29,6 @@
<!-- M3U8 -->
<!-- SEGMENT -->
<script src="tsSegment-bc.js"></script>
<script src="../src/segment-controller.js"></script>
<script src="../src/bin-utils.js"></script>
<!-- Test cases -->
......
......@@ -22,7 +22,6 @@
var
player,
segmentController,
oldFlashSupported,
oldXhr,
oldSourceBuffer,
......@@ -721,21 +720,4 @@ test('has no effect if native HLS is available', function() {
'no media source was opened');
});
module('segment controller', {
setup: function() {
segmentController = new window.videojs.hls.SegmentController();
},
teardown: function() {
window.videojs.get = this.vjsget;
}
});
test('bandwidth calulation test', function() {
var
multiSecondData = segmentController.calculateThroughput(10000, 1000, 2000),
subSecondData = segmentController.calculateThroughput(10000, 1000, 1500);
equal(multiSecondData, 80000, 'MULTI-Second bits per second calculation');
equal(subSecondData, 160000, 'SUB-Second bits per second calculation');
});
})(window, window.videojs);
......