Skip to content

Commit

Permalink
Sync with master for TS changes (#193)
Browse files Browse the repository at this point in the history
* isCodecSupportedInMp4 test audio codecs as audio

Fixes video-dev#1824.

* Do not show `undefined`

* package: rm npm-run-all as it contains "event-stream" (and maybe other dormant exploits?). see "flatmap-stream"

* rewrite package-lock: removed event-stream and all deps got not fixed versions instead of a hat

* update lock-file generated with npm v6.4.1

* package deps: npm remove --save mversion jshint

* Added OpenPlayerJS to the list of players that support HLS.js (video-dev#2023)

* NIT: fix typos in readme

1.  Fix spelling of interdependent and environment
2. Correct the agreement in the phrase: 'imported/required by each other.'

* Revert video-dev#2004 (video-dev#2027)

* Fix 0.11.1 Regressions (video-dev#2028)

* Create sourceBuffers if the max of 2 tracks has been reached, regardless of buffer codec events received

* Replace Object.values with [].slice.call

* Remux according to initial PTS so that streams start at 0 (video-dev#2030)

* Buffer streams starting at 0 initPTS

* Use PTS to determine if segments are contiguous

* Remove code setting startPosition to buffer start

* Remove seek to buffered start logic

* Simplify EOS check by using frag states, move logic into shared superclass (video-dev#2040)

* Simplify EOS check by using frag states, move logic into shared superclass

* Move shared seek logic into base, clear fragCurrent on seek out of buffered range

* Revert PTS wrapping code which produces incorrect cue times (video-dev#2044)

* deploy demo/docs to netlify, not gh-pages

* update demo links in issue template

* format commit as code

because it is slightly more readable

* remove accidental "/" in readme

* update note to access specific version api docs

* include tag in idShort

* escape `

* Check if PTS has wrapped after applying PTS time offset (video-dev#2056)

* Check if PTS has wrapped after applying PTS time offset

* Fix bug accessing buffered track array

* Intialize vttCCs map with cc 0 (video-dev#2058)

* Intiialize vttCCs map with cc 0

* use the version from package.json when deploying

and include this in the deployments readme

* fix: abrFactor greater than in docs

* Changes clone function used in webpack config to be the webpack recommended merging library.

* prod: add bandwidthEstimate method

* docs: add bandwidthEstimate

* test: add autotest

* Convert buffer-controller.js to TypeScript

Thank you to Tom Jenkinson for acting as a reviewer for this work, including writing some suggestions via the GitHub PR github.com/video-dev/pull/2073. The commit history has been squashed as it was a fairly lengthly process to get everything working to support the conversion to TypeScript.

Early in the history of this commit, we converted properties to be initialized to `null`. This was incorrect, as it changes the behaviour of code that uses `Object.keys` calls to check if an object has any keys on it. Before, they would be empty, but if the properties are set to null, this check is no longer valid and it changes the behaviour. This is something to look out for in the future of other conversions, as the values themselves are often times reset to the `null`, but begin as undefined.

Added a common `types` folder for interfaces where the ownership of the type wasn't clear for the individual file. The default no-op logger which is the inferred usage did not have any arguments in it's method signature. By adding an argument, TypeScript is able to infer the correct interface. As well the Karma and Webpack configuration had to be updated to enable building TypeScript, and getting testing coverage information from Istanbul.

Define lib "es2015" and "dom" to add HTMLMediaElement, SourceBuffer and Number.isFinite definitions to the TypeScript binary when it is doing type-checking.

When attempting to lint the older version of `typescript-eslint-parser` would emit `no-undef` errors for TypeScript interfaces. Updating the package fixes this issue.

Tom pointed out that we should not use global module declarations to extend default HTML types since users will eventually be importing *.d.ts files from the hls.js project and this would also extend their types. Due to this feedback switched to defining a module local type `ExtendedSourceBuffer`. Which instead extends with the `ended` prop.

Event Handlers were set to be part of the private scope. While this has no effect now, it will be important to ensure other modules do not directly invoke the event handlers. Other methods that were prefixed with a `_` were also set into the private scope.

Where possible, code was switched to early-exit to lower the cognitive load in conditional statements, an example of this was the doAppend method. Another cleanup statement was switching handling of error codes and the comments to be closer to the conditional to which they applied.

Switched to using the Record<Key, Value> type to help support access via the index signature [key: T] syntax in the future.

An issue that was fixed in this commit was that The controller previous exposed the local `pendingTracks` property through the event and did not set the buffer on `this.tracks` instead opting to set it on the individual track, which bubbled up to the pendingTracks object, whose reference was lost in the buffer-controller module. This commit changes this behaviour so that the controller publishes `tracks` from the public variable on the controller rather than the pendingTracks which are passed into createSourceBuffers. This also means that this fixes the `.buffer.buffered` being undefined on the demo page. Added unit tests to cover the new behaviour of throwing an error if createSourceBuffer is called without an attached media element.

* test: review changes

* docs: review fix

* prod: add review fix

* docs: update

Co-Authored-By: Beraliv <beraliv.spb@gmail.com>

* docs: update 2

* docs: fix link

* test: equal => strictEqual

* test: add mocked _bwEstimator

* test: change description

* test: (() => { ... }) => function () { ... }

* Increase BufferHelper test coverage to 100% (video-dev#2052)

* Increase adts.js test coverage to 100% (video-dev#2053)

* Increase adts.js test coverage to 100%

* Convert eme-controller to TypeScript.

Added TypeScript types to the code.

Handled media detached and removing the encrypted event listener.

* Listen to media detached

Clears the encrypted event listener from the HTMLMediaElement in controller, and releases the stored reference.

* Choose bitrate in Bps (video-dev#2091)

Simplify bandwidth calculation by making; change docs to correctly reference bandwidth in bits/s

* Upgrade tests to Chai BDD & optimize runner (video-dev#2037)

* Convert tests to Chai BDD

* Invoke mocha with exit so that travis doesnt hang on func test completion

* Fix video-dev#2061

* configure netlify for PR's

this follows the same process that runs for canary releases

* check if repo is shallow before fetching

because on netlify it clones the whole thing

* handle 'netlifyPr' in set-package-version

* tabs => spaces

* add commit to version when PR

* always trim command output

* Update Fragment and LevelKey to typescript.

* Update usage of Fragment and LevelKey.

* Don't pass prevFrag into EXT-X-MAP handling.

* Add tests for parsing byte range as seperate call.

* Only parse byte range if it exists.

* Apply suggestions from code review

Co-Authored-By: itsjamie <1956521+itsjamie@users.noreply.github.com>

* Review changes.

parseByteRange -> setByteRange
- removed it returning the parsed value since its usage was like a setter.

* Review comments pt.2

* Change tests to call setByteRange

* Explicit handling of 'initSegment' conversion for bitwise operation.

* Fix lint warnings in m3u8-parser.js in prep for TS conversion. (video-dev#2106)

* fix console null reference in logger (in webworkers) (video-dev#2095)

Fix null reference in logger when console is not available

* (misc) Adding ace editor to demo to enable advanced customization (video-dev#2077)

* Add handling for AES-128 encrypted initialization segments needing IV.

* Change IV handling for initSegments to just log a warning.

* Update webpack to use babel loader with support for TS. (video-dev#2119)

* Upgrade to webpack 4, babel 7

* Use straight git link for webworkify dep

* Use simpler git url

* Re-add globalObject workaround

* Bump karma dep versions

* Dont preprocess non-test files

* Use @babel/register over ts-node

* Update demo `const` usage.

* Use webpack debug config in Karma configuration rather than duplication.

* Delete duplicate declaration
  • Loading branch information
johnBartos committed Feb 22, 2019
1 parent 194bb41 commit d6c5559
Show file tree
Hide file tree
Showing 52 changed files with 5,310 additions and 3,302 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
@@ -1,5 +1,6 @@
module.exports = {
'env': {
'browser': true,
'commonjs': true,
'es6': true
},
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Expand Up @@ -15,9 +15,9 @@ about: Create a report to help us improve
### Checklist
<!-- Replace [ ] with [x] to check off the list -->
- [ ] The issue observed is not already reported by searching on Github under https://github.com/video-dev/hls.js/issues
- [ ] The issue occurs in the stable client on https://video-dev.github.io/hls.js/stable/demo and not just on my page
- [ ] The issue occurs in the stable client on https://hls-js.netlify.com/demo and not just on my page
<!-- The stable client is built from the latest release -->
- [ ] The issue occurs in the latest client on https://video-dev.github.io/hls.js/latest/demo and not just on my page
- [ ] The issue occurs in the latest client on https://hls-js-latest.netlify.com/demo and not just on my page
<!-- The latest client is built from the head of the master branch -->
- [ ] The stream has correct Access-Control-Allow-Origin headers (CORS)
- [ ] There are no network errors such as 404s in the browser console when trying to play the stream
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -14,5 +14,5 @@ coverage/

# Build
/dist
/gh-pages
/netlify
/api-docs
17 changes: 9 additions & 8 deletions README.md
Expand Up @@ -18,7 +18,7 @@ hls.js does not need any player, it works directly on top of a standard HTML```<

hls.js is written in [ECMAScript6] (`*.js`) and [TypeScript] (`*.ts`) (strongly typed superset of ES6), and transpiled in ECMAScript5 using the [TypeScript compiler].

Modules written in TS and plain JS/ES6 can be interdepent and imported/required by each others.
Modules written in TS and plain JS/ES6 can be interdependent and imported/required by each other.

To build our distro bundle and serve our development environment we use [Webpack].

Expand All @@ -35,21 +35,21 @@ To build our distro bundle and serve our development environment we use [Webpack

* [API and usage docs, with code examples](./docs/API.md)

* [Auto-Generated Docs (Latest Release)](http://video-dev.github.io/hls.js/stable/api-docs)
* [Auto-Generated Docs (Master)](http://video-dev.github.io/hls.js/latest/api-docs)
* [Auto-Generated Docs (Latest Release)](https://hls-js.netlify.com/api-docs)
* [Auto-Generated Docs (Master)](https://hls-js-latest.netlify.com/api-docs)

_Note you can access the docs for a particular version using "http://video-dev.github.io/hls.js/v[x.y.z]/api-docs"_
_Note you can access the docs for a particular version using "[https://github.com/video-dev/hls.js/blob/deployments/README.md](https://github.com/video-dev/hls.js/blob/deployments/README.md)"_

## Demo

### Latest Release
[https://video-dev.github.io/hls.js/stable/demo](https://video-dev.github.io/hls.js/stable/demo)
[https://hls-js.netlify.com/demo](https://hls-js.netlify.com/demo)

### Master
[https://video-dev.github.io/hls.js/latest/demo](https://video-dev.github.io/hls.js/latest/demo)
[https://hls-js-latest.netlify.com/demo](https://hls-js-latest.netlify.com/demo)

### Specific Version
"http://video-dev.github.io/hls.js/v[x.y.z]/demo"
Find the commit on [https://github.com/video-dev/hls.js/blob/deployments/README.md](https://github.com/video-dev/hls.js/blob/deployments/README.md).


## Getting Started
Expand Down Expand Up @@ -114,6 +114,7 @@ hls.js is (being) integrated in the following players:
- [Videojs](http://videojs.com) through [videojs-hls.js](https://github.com/streamroot/videojs-hls.js). hls.js is integrated as a SourceHandler -- new feature in Video.js 5.
- [Videojs](http://videojs.com) through [videojs-contrib-hls.js](https://github.com/Peer5/videojs-contrib-hls.js). Production ready plug-in with full fallback compatibility built-in.
- [Fluid Player](https://www.fluidplayer.com)
- [OpenPlayerJS](https://www.openplayerjs.com), as part of the [OpenPlayer project](https://github.com/openplayerjs)

## Chrome/Firefox integration

Expand Down Expand Up @@ -254,7 +255,7 @@ Pull requests are welcome. Here is a quick guide on how to start.
- First, checkout the repository and install required dependencies
```sh
git clone https://github.com/video-dev/hls.js.git
# setup dev environement
# setup dev environment
cd hls.js
npm install
# build dist/hls.js, watch file change for rebuild and launch demo page
Expand Down
112 changes: 50 additions & 62 deletions demo/index.html
@@ -1,23 +1,16 @@
<!DOCTYPE html>
<html>

<head>

<meta charset="utf-8"/>

<meta charset="utf-8">
<title>hls.js demo</title>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">

<link rel="stylesheet" href="style.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.3/FileSaver.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.2/ace.js"></script>
</head>

<body>
<div class="header-container">
<header class="wrapper clearfix">
Expand Down Expand Up @@ -50,49 +43,27 @@ <h3>
</p>
</header>
<div id="controls">
<div class="demo-controls-wrapper">
<select id="streamSelect" class="innerControls">
<option value="" selected>Select a test-stream from drop-down menu. Or enter custom URL below</option>
</select>

<div id="customButtons"></div>

<select id="streamSelect" class="innerControls">
<option value="" selected>Select a test-stream from drop-down menu. Or enter custom URL below</option>
</select>

<input id="streamURL" class="innerControls" type=text value=""/>

<label class="innerControls">
Enable streaming:
<input id="enableStreaming" type=checkbox checked/>
</label>
<input id="streamURL" class="innerControls" type=text value=""/>

<label class="innerControls">
Auto-recover media-errors:
<input id="autoRecoverError" type=checkbox checked/>
</label>
<label class="innerControls">
Enable streaming:
<input id="enableStreaming" type=checkbox checked/>
</label>

<label class="innerControls">
Enable worker for transmuxing:
<input id="enableWorker" type=checkbox checked/>
</label>
<label class="innerControls">
Auto-recover media-errors:
<input id="autoRecoverError" type=checkbox checked/>
</label>

<label class="innerControls">
Dump transmuxed fMP4 data:
<input id="dumpfMP4" type=checkbox unchecked/>
</label>

<label class="innerControls">
Widevine DRM license-server URL:
<input id="widevineLicenseUrl" style="width: 50%"/>
</label>

<label class="innerControls">
Level-cap'ing (max limit):
<input id="levelCapping" style="width: 8em" type=number/>
</label>

<label class="innerControls">
Default audio-codec:
<input style="width: 8em" id="defaultAudioCodec"/>
</label>
<label class="innerControls">
Dump transmuxed fMP4 data:
<input id="dumpfMP4" type=checkbox unchecked/>
</label>

<label class="innerControls">
Player size:
Expand All @@ -105,27 +76,44 @@ <h3>
</select>
</label>

<label class="innerControls">
Current video-resolution:
<span id="currentResolution">/</span>
</label>
<label class="innerControls">
Current video-resolution:
<span id="currentResolution">/</span>
</label>

<label class="innerControls">
Permalink:&nbsp;
<span id="StreamPermalink" style="width: 50%"></span>
</label>
<label class="innerControls">
Permalink:
<span id="StreamPermalink"></span>
</label>
</div>

<div class="config-editor-wrapper">
<div class="config-editor-container">
<div id="config-editor">
Loading...
</div>
</div>
<div class="config-editor-commands">
<label for="config-persistence">
Persist
<input name="config-persistence" id="configPersistence" type="checkbox">
</label>
<button name="config-apply" onclick="applyConfigEditorValue()">Apply</button>
</div>
</div>

</div>

<video id="video" controls autoplay class="videoCentered"></video>

<br>
<canvas id="bufferedCanvas" height="15" class="videoCentered" onclick="onClickBufferedRange(event);"></canvas>
<br>
<br>
<label class="center">Status:</label>
<pre id="statusOut" class="center" style="white-space: pre-wrap;"></pre>

<canvas id="buffered_c" height="15" class="videoCentered" onclick="onClickBufferedRange(event);"></canvas>

<br><br>

<pre id="HlsStatus" class="center" style="white-space: pre-wrap;"></pre>
<label class="center">Error:</label>
<pre id="errorOut" class="center" style="white-space: pre-wrap;"></pre>

<div class="center" style="text-align: center;" id="toggleButtons">
<button type="button" class="btn btn-sm" onclick="$('#PlaybackControl').toggle();">Playback controls</button>
Expand Down

0 comments on commit d6c5559

Please sign in to comment.