Commit 8c4a545f authored by Dan Sparacio's avatar Dan Sparacio

merging development into master test

parents c63e9ebf 4fe12bc9
......@@ -12,6 +12,7 @@ npm-debug.log
.grunt
_SpecRunner.html
reports
jsdocs
#################
## Eclipse
......@@ -152,8 +153,6 @@ Desktop.ini
# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
......@@ -177,3 +176,4 @@ pip-log.txt
# Mac crap
.DS_Store
language: node_js
node_js:
- "0.11"
- "0.10"
script: cd build && npm install && npm test
\ No newline at end of file
module.exports = function(grunt) {
grunt.initConfig({
connect: {
default_options: {},
dev: {
options: {
port: 9999,
keepalive: true
}
}
},
watch: {},
jshint: {
all: ["app/js/*/**/*.js"],
options: {
jshintrc: ".jshintrc"
}
},
uglify : {
min : {
files: {
"dash.min.js" : [
"app/js/streaming/MediaPlayer.js",
"app/js/streaming/Context.js",
"app/js/dash/Dash.js",
"app/js/dash/DashContext.js",
"app/lib/q.js",
"app/lib/xml2json.js",
"app/lib/objectiron.js",
"app/lib/dijon.js",
"app/js/*/**/*.js"],
}
},
all : {
files: {
"dash.all.js" : [
"./app/lib/q.js",
"./app/lib/xml2json.js",
"./app/lib/objectiron.js",
"./app/lib/dijon.js",
"./app/lib/Math.js",
"./app/lib/long.js",
"./app/lib/base64.js",
"./app/js/streaming/MediaPlayer.js",
"./app/js/streaming/Context.js",
"./app/js/dash/Dash.js",
"./app/js/dash/DashContext.js",
"./app/js/*/**/*.js"]
}
}
},
jasmine: {
tests: {
src: [
"./app/js/streaming/MediaPlayer.js",
"./app/js/streaming/Context.js",
"./app/js/dash/Dash.js",
"./app/js/dash/DashContext.js",
"./app/js/*/**/*.js"],
options: {
host: 'http://127.0.0.1:8000/',
keepRunner: true,
helpers: [
"./test/js/utils/MPDfiles.js",
"./test/js/utils/Utils.js",
"./test/js/utils/ValidateUrl.js",
"./app/js/Main.js"],
specs: [
'./test/js/dash/DashParser_Suite.js',
'./test/js/dash/FragmentExtensions_Suite.js',
'./test/js/dash/DashMetricsExtensions_Suite.js',
'./test/js/dash/DashMetricsConverter_Suite.js',
'./test/js/dash/DashManifestExtensions_Suite.js',
'./test/js/dash/DashManifestExtensionsNeg_Suite.js',
'./test/js/dash/DashHandler_Suite.js',
'./test/js/streaming/MediaPlayer_Suite.js',
'./test/js/streaming/Stream_Suite.js',
'./test/js/streaming/AbrController_Suite.js',
'./test/js/streaming/BufferController_Suite.js',
'./test/js/streaming/Capabilities_Suite.js',
'./test/js/streaming/MetricsModel_Suite.js',
'./test/js/streaming/ManifestUpdater_Suite.js',
'./test/js/streaming/FragmentController_Suite.js',
"./test/js/streaming/VideoModel_Suite.js",
'./test/js/streaming/ManifestLoader_Suite.js'
],
vendor: [
"./app/lib/jquery/jquery-1.10.2.min.js",
"./app/lib/q.js",
"./app/lib/xml2json.js",
"./app/lib/objectiron.js",
"./app/lib/Math.js",
"./app/lib/long.js",
"./app/lib/kendo/kendo.web.min.js",
"./app/lib/dijon.js",
"./app/lib/base64.js"],
template : require('grunt-template-jasmine-istanbul'),
templateOptions: {
coverage: 'reports/coverage.json',
report: 'reports/coverage'},
junit: {
path: grunt.option('jsunit-path'),
consolidate: true}
}
}
}
});
// Require needed grunt-modules
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
// Define tasks
grunt.registerTask('default', ['jshint','connect:default_options','jasmine','uglify']);
};
# dash.js BSD License Agreement
The copyright in this software is being made available under the BSD License, included below. This software may be subject to other third party and contributor rights, including patent rights, and no such rights are granted under this license.
**Copyright (c) 2015, Dash Industry Forum.
**All rights reserved.**
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the Dash Industry Forum nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
**THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.**
\ No newline at end of file
# dash.js
JSHint and Jasmine status: [![JSHint and Jasmine](http://img.shields.io/travis/Dash-Industry-Forum/dash.js/development.svg?style=flat-square)](https://travis-ci.org/Dash-Industry-Forum/dash.js)
A reference client implementation for the playback of MPEG DASH via JavaScript and compliant browsers. Learn more about DASH IF Reference Client.
If your intent is to use the player code without contributing back to this project, then use the MASTER branch which holds the approved and stable public releases.
......@@ -19,9 +21,59 @@ Download 'master' or latest tagged release, extract and open main folder dash.js
3. [install grunt-template-jasmine-istanbul](https://github.com/maenu/grunt-template-jasmine-istanbul)
* npm install grunt-template-jasmine-istanbul --save-dev
4. install some other dependencies:
* npm install grunt-contrib-connect grunt-contrib-watch grunt-contrib-jshint grunt-contrib-uglify
* npm install grunt-contrib-connect grunt-contrib-watch grunt-contrib-jshint grunt-contrib-uglify grunt-jsdoc-plugin grunt-jsdoc
### Build / Run tests:
```
grunt --config Gruntfile.js --force
```
## Getting Started
Create a video element somewhere in your html. For our purposes, make sure to set the controls property to true.
```
<video id="videoPlayer" controls="true"></video>
```
Add dash.all.js to the end of the body.
```
<body>
...
<script src="yourPathToDash/dash.all.js"></script>
</body>
```
Now comes the good stuff. We need to create a dash context. Then from that context we create a media player, initialize it, attach it to our "videoPlayer" and then tell it where to get the video from. We will do this in an anonymous self executing function, that way it will run as soon as the page loads. So, here is how we do it:
``` js
(function(){
var url = "http://dash.edgesuite.net/dash264/TestCases/1c/qualcomm/2/MultiRate.mpd";
var context = new Dash.di.DashContext();
var player = new MediaPlayer(context);
player.startup();
player.attachView(document.querySelector("#videoPlayer"));
player.attachSource(url);
})();
```
When it is all done, it should look similar to this:
```
<!doctype html>
<html>
<head>
<title>Dash.js Rocks</title>
</head>
<body>
<div>
<video id="videoPlayer" controls="true"></video>
</div>
<script src="yourPathToDash/dash.all.js"></script>
<script>
(function(){
var url = "http://dash.edgesuite.net/akamai/test/caption_test/ElephantsDream/elephants_dream_480p_heaac5_1.mpd";
var context = new Dash.di.DashContext();
var player = new MediaPlayer(context);
player.startup();
player.attachView(document.querySelector("#videoPlayer"));
player.attachSource(url);
})();
</script>
</body>
</html>
```
This diff is collapsed.
This diff is collapsed.
/*
* The copyright in this software is being made available under the BSD License, included below. This software may be subject to other third party and contributor rights, including patent rights, and no such rights are granted under this license.
*
* Copyright (c) 2013, Digital Primates
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* • Neither the name of the Digital Primates nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
MediaPlayer.dependencies.BufferExtensions = function () {
"use strict";
var minBufferTarget,
currentBufferTarget,
topAudioQualityIndex = 0,
topVideoQualityIndex = 0,
audioData = null,
videoData = null,
getCurrentHttpRequestLatency = function(metrics) {
var httpRequest = this.metricsExt.getCurrentHttpRequest(metrics);
if (httpRequest !== null) {
return (httpRequest.tresponse.getTime() - httpRequest.trequest.getTime()) / 1000;
}
return 0;
},
isPlayingAtTopQuality = function() {
var self = this,
audioQuality,
videoQuality,
isAtTop;
audioQuality = audioData ? self.abrController.getQualityFor("audio") : topAudioQualityIndex;
videoQuality = videoData ? self.abrController.getQualityFor("video") : topVideoQualityIndex;
isAtTop = (audioQuality === topAudioQualityIndex) &&
(videoQuality === topVideoQualityIndex);
return isAtTop;
};
return {
system:undefined,
videoModel: undefined,
manifestExt: undefined,
metricsExt: undefined,