Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML parser #3412

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
f4d956a
update package-lock.json
bbert Sep 21, 2020
d52688c
add txml parser dependency
bbert Sep 21, 2020
7d626f4
DashParser: use txml parser and add post-processing to simplify xml t…
bbert Sep 21, 2020
b807a62
remove '_asArray' notation
bbert Sep 21, 2020
322038f
DashParser: fix processAttr()
bbert Sep 22, 2020
462d78a
add tXml in externals and remove from dependencies, to avoid uglify i…
bbert Sep 22, 2020
56861ba
XlinkController: use parser (tXml) from DashParser
bbert Sep 22, 2020
174ba8b
DashParser: handle parsing failure
bbert Sep 23, 2020
5214418
MssParser: complete _asArray removal
bbert Sep 23, 2020
331a295
update unit tests
bbert Sep 23, 2020
bdbcbcd
update DashConstants
bbert Sep 23, 2020
2b963e6
Modify tXml to apply simplification proces (including attributes and …
bbert Sep 23, 2020
053eafc
Remove StringMatcher
bbert Sep 23, 2020
f4830da
Merge branch 'development' into xml-parser
bbert Feb 9, 2021
eb87794
update according to PR #3451 (update xml parser and remove _asArray n…
bbert Feb 10, 2021
1432481
update according to PR #3451 (update xml parser and remove _asArray n…
bbert Feb 10, 2021
666d1fa
update according to PR #3451 (update xml parser and remove _asArray n…
bbert Feb 10, 2021
3ca4a3a
Merge branch 'development' into xml-parser
bbert Mar 23, 2021
0841b38
Dash parser: add missing nodes (as array) PatchLocation, replace, add…
bbert Apr 16, 2021
79c3dfd
complete update according to PR #3451
bbert Apr 16, 2021
8f8a9b0
tXml: init attrMatchers as an array
bbert Apr 16, 2021
ee179c3
tXml: add attributes matchers and nodes as array in options parameter
bbert Apr 16, 2021
7f95a38
Fixed DashManifestModel.getLocation()
bbert Apr 16, 2021
f4ab78f
Fixed DashManifestModel.getPatchLocation()
bbert Apr 16, 2021
4df063c
Remove unuseful existence check on elements assumed to be as arrays
bbert Apr 16, 2021
7a93a22
Remove unuseful existence check on elements assumed to be as arrays
bbert Apr 16, 2021
c2f812b
DashAdapter::applyPatchToManifest(): check types of nodes (object vs …
bbert Apr 16, 2021
77e1d90
Merge branch 'development' into xml-parser
bbert Jun 8, 2021
f174876
update package-lock.json
bbert Jun 8, 2021
888830d
SimpleXPath: check id leaf element is array or not
bbert Jun 8, 2021
8fb49bf
Remove remaining asArray after rebase
bbert Jun 8, 2021
cd443ca
Fix unit tests
bbert Jun 8, 2021
282d23d
tXml: add suport for tag namespace
bbert Jun 9, 2021
8343cdf
Merge branch 'development' into xml-parser
bbert Mar 10, 2022
0792283
Merge branch 'development' into xml-parser
bbert Mar 10, 2022
4ad3d6a
Merge remote-tracking branch 'origin/development' into xml-parser
bbert Aug 10, 2022
5926140
xml parser: complete asArray removal
bbert Aug 10, 2022
47db0a6
xml parser: fix samples
bbert Aug 10, 2022
88f8369
xml parser: fix regression after merge
bbert Aug 10, 2022
bc18c42
Merge branch 'development' into xml-parser
bbert Aug 10, 2022
2181999
Update tXml parser to v4.0.1
bbert Aug 16, 2022
f517946
Modify tXml parser
bbert Aug 16, 2022
76fd9bc
Update DashParser according to new version of tXml
bbert Aug 16, 2022
b213172
UTCTiming to be stored as an array
bbert Aug 16, 2022
d5058e7
NumericMatcher: do not apply on attributes specified as string but th…
bbert Aug 16, 2022
1b735c7
Merge branch 'development' into xml-parser
bbert Aug 16, 2022
db9b4f3
Remove StringMatcher
bbert Aug 16, 2022
602a6ae
Merge remote-tracking branch 'origin/development' into xml-parser
bbert Sep 5, 2022
70dd5b7
Merge remote-tracking branch 'origin/development' into xml-parser
bbert Oct 3, 2022
f4e5a8b
Fix merge for LangMatcher
bbert Oct 3, 2022
d14cb7d
Merge remote-tracking branch 'origin/development' into xml-parser
bbert Oct 20, 2022
ef3389e
Merge branch 'development' into xml-parser
bbert Nov 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
540 changes: 540 additions & 0 deletions externals/tXml.js

Large diffs are not rendered by default.

53 changes: 48 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,838 changes: 17 additions & 1,821 deletions samples/advanced/load_with_manifest.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion samples/advanced/monitoring.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
var bufferLevel = dashMetrics.getCurrentBufferLevel('video', true);
var bitrate = repSwitch ? Math.round(dashAdapter.getBandwidthForRepresentation(repSwitch.to, periodIdx) / 1000) : NaN;
var adaptation = dashAdapter.getAdaptationForType(periodIdx, 'video', streamInfo);
var currentRep = adaptation.Representation_asArray.find(function (rep) {
var currentRep = adaptation.Representation.find(function (rep) {
return rep.id === repSwitch.to
})
var frameRate = currentRep.frameRate;
Expand Down
267 changes: 267 additions & 0 deletions samples/captioning/FakeHTMLMediaElement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@


class InternalEventTarget {

constructor() {
this.listeners = {};
}

addEventListener(type, callback) {
if (!(type in this.listeners)) {
this.listeners[type] = [];
}
this.listeners[type].push(callback);
}

removeEventListener(type, callback) {
if (!(type in this.listeners)) {
return;
}
var stack = this.listeners[type];
for (var i = 0, l = stack.length; i < l; i++) {
if (stack[i] === callback) {
stack.splice(i, 1);
return;
}
}
}

dispatchEvent(event) {
if (!(event.type in this.listeners)) {
return true;
}
var stack = this.listeners[event.type].slice();
for (var i = 0, l = stack.length; i < l; i++) {
stack[i].call(this, event);
}
return !event.defaultPrevented;
}
}

class FakeTextTrack extends InternalEventTarget {

constructor(kind, label, lang, isTTML, isEmbedded) {
super();
this.kind_ = kind;
this.label_ = label;
this.lang_ = lang;
this.isTTML_ = isTTML;
this.isEmbedded_ = isEmbedded;
this.cues_ = [];
this.activeCues_ = [];
this.currentVideoTime_ = -1;
this.mode_ = 'disabled';
this.log('New text track', label, lang);
}

log(...params) {
let message = '[FakeTextTrack][' + this.lang_ + '] ';
Array.apply(null, params).forEach(function (item) {
message += item + ' ';
});
console.log(message);
}

get kind() { return this.kind_; }
get label() { return this.label_; }
get lang() { return this.lang_; }
get language() { return this.lang_; }
get isTTML() { return this.isTTML_; }
get isEmbedded() { return this.isEmbedded_; }
get mode() { return this.mode_; }
get active() { return this.mode_ === 'showing'; }

set isTTML(value) { this.isTTML_ = value; }
set isEmbedded(value) { this.isEmbedded_ = value; }

set mode(mode) {
this.log('mode =', mode);
this.mode_ = mode;
}

get activeCues() { return this.activeCues_; }
get cues() { return this.cues_; }

addCue(cue) {
this.log('add cue', cue, cue.startTime);
if (this.cues_.indexOf(cue) === -1) {
this.cues_.push(cue);
}
}

removeCue(cue) {
this.log('remove cue', cue);
let cueIndex = this.cues_.indexOf(cue);
if (cueIndex > -1) {
this.cues_.splice(cueIndex, 1);
}
}

clearCues() {
this.cues_ = [];
this.log('cue changed', this.cues_);
}

notifyTimeChange(newTime) {

if (!this.active) { return; }

this.log('timechanged', newTime);

// debounce time updates
var deltaVTime = newTime - this.currentVideoTime_;
if (deltaVTime < 0.01 && deltaVTime > -0.01) {
return;
}
this.currentVideoTime_ = newTime;

const previousActivesCues = this.activeCues_.slice();
this.activeCues_ = this.cues_.filter(cue => this.isCueActive(cue, this.currentVideoTime_));

// For each old cue, exit cue
previousActivesCues.forEach(cue => {
if (this.activeCues_.indexOf(cue) === -1 && cue.onexit) {
this.log('exit cue:', cue);
cue.onexit();
}
});

// For each new cue, enter cue
this.activeCues_.forEach(cue => {
if (previousActivesCues.indexOf(cue) === -1 && cue.onenter) {
this.log('enter cue:', cue);
cue.onenter();
}
});
}

isCueActive(cue, time) {
// this.log('isCueActive cue:', cue);
return time >= cue.startTime && time <= cue.endTime;
}
}

class FakeMediaSource extends InternalEventTarget {

constructor () {
super();
this._readyState = '';
}

get readyState() { return this._readyState; }
get sourceBuffers() { return []; }

open() {
this._readyState = 'open';
this.dispatchEvent(new Event('sourceopen'));
}

endOfStream() {}
}


class FakeHTMLMediaElement extends InternalEventTarget {

constructor (parentNode) {
super();
this._parentNode = parentNode;
this.init();
}

init () {
if (this._textTracks) {
this._textTracks.forEach(track => track.clearCues());
}
this._textTracks = [];
this._paused = true;
this._readyState = 0;
this._duration = 0;
this._currentTime = 0;
this._playbackRate = 0;
this._ended = false;
this._clientWidth = 500;
this._clientHeight = 300;
this._videoWidth = 500;
this._videoHeight = 300;
this._preload = '';
}

// HTMLMediaElement API

get nodeName() { return 'FAKE'; }
get parentNode() { return this._parentNode; }
get classList() { return []; }

get readyState() { return this._readyState; }
get paused() { return this._paused; }
get duration() { return this._duration; }
get currentTime() { return this._currentTime; }
get playbackRate() { return this._playbackRate; }
get ended() { return this._ended; }
get textTracks() { return this._textTracks; }
get clientWidth() { return this._parentNode.getBoundingClientRect().width; }
get clientHeight() { return this._parentNode.getBoundingClientRect().height; }
get videoWidth() { return this._parentNode.getBoundingClientRect().width;; }
get videoHeight() { return this._parentNode.getBoundingClientRect().height; }

set readyState(value) {
if (this._readyState === value) return;
this._readyState = value;
}

set duration(value) {
if (this._duration === value) return;
this._duration = value;
this.dispatchEvent(new Event('durationchange'));
}

set playbackRate(value) {
if (this._playbackRate === value) return;
this._playbackRate = value;
this.dispatchEvent(new Event('ratechange'));
}

set currentTime(value) {
this.updateCurrentTime(value, false);
this.dispatchEvent(new Event('seeking'));
this.dispatchEvent(new Event('seeked'));
}

pause() {
if (this.paused) return;
this._paused = true;
this.dispatchEvent(new Event('pause'));
}

play() {
if (!this.paused) return;
this._paused = false;
this.dispatchEvent(new Event('playing'));
}

addTextTrack(kind, label, lang) {
let track = new FakeTextTrack(kind, label, lang);
this._textTracks.push(track);
return track;
}

load() {}
removeAttribute() {}
appendChild() {}
removeChild() {}

getBoundingClientRect() {
return this._parentNode.getBoundingClientRect();
}

// Specific methods

updateCurrentTime(value, fireTimeupdate = true) {
if (this._currentTime === value) return;
this._currentTime = value;
if (fireTimeupdate) {
this.dispatchEvent(new Event('timeupdate'));
}
this._textTracks.forEach(track => track.notifyTimeChange(this._currentTime));
}
}
Loading