1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-04 18:29:39 +02:00
This commit is contained in:
Daniel Neto 2023-11-10 09:36:43 -03:00
parent 0e3fa24329
commit 4e95a0e94c
369 changed files with 16946 additions and 89882 deletions

161
node_modules/mux.js/dist/mux-mp4.js generated vendored
View file

@ -1,4 +1,4 @@
/*! @name mux.js @version 6.3.0 @license Apache-2.0 */
/*! @name mux.js @version 7.0.1 @license Apache-2.0 */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('global/window')) :
typeof define === 'function' && define.amd ? define(['global/window'], factory) :
@ -3339,19 +3339,33 @@
var nextByte = packetData[i + 1];
var win = service.currentWindow;
var char;
var charCodeArray; // Use the TextDecoder if one was created for this service
var charCodeArray; // Converts an array of bytes to a unicode hex string.
function toHexString(byteArray) {
return byteArray.map(function (byte) {
return ('0' + (byte & 0xFF).toString(16)).slice(-2);
}).join('');
}
if (isMultiByte) {
charCodeArray = [currentByte, nextByte];
i++;
} else {
charCodeArray = [currentByte];
} // Use the TextDecoder if one was created for this service
if (service.textDecoder_ && !isExtended) {
if (isMultiByte) {
charCodeArray = [currentByte, nextByte];
i++;
} else {
charCodeArray = [currentByte];
}
char = service.textDecoder_.decode(new Uint8Array(charCodeArray));
} else {
char = get708CharFromCode(extended | currentByte);
// We assume any multi-byte char without a decoder is unicode.
if (isMultiByte) {
var unicode = toHexString(charCodeArray); // Takes a unicode hex string and creates a single character.
char = String.fromCharCode(parseInt(unicode, 16));
} else {
char = get708CharFromCode(extended | currentByte);
}
}
if (win.pendingNewLine && !win.isEmpty()) {
@ -3995,13 +4009,19 @@
var ROWS = [0x1100, 0x1120, 0x1200, 0x1220, 0x1500, 0x1520, 0x1600, 0x1620, 0x1700, 0x1720, 0x1000, 0x1300, 0x1320, 0x1400, 0x1420]; // CEA-608 captions are rendered onto a 34x15 matrix of character
// cells. The "bottom" row is the last element in the outer array.
// We keep track of positioning information as we go by storing the
// number of indentations and the tab offset in this buffer.
var createDisplayBuffer = function createDisplayBuffer() {
var result = [],
i = BOTTOM_ROW + 1;
while (i--) {
result.push('');
result.push({
text: '',
indent: 0,
offset: 0
});
}
return result;
@ -4070,9 +4090,9 @@
this.startPts_ = packet.pts;
} else if (data === this.BACKSPACE_) {
if (this.mode_ === 'popOn') {
this.nonDisplayed_[this.row_] = this.nonDisplayed_[this.row_].slice(0, -1);
this.nonDisplayed_[this.row_].text = this.nonDisplayed_[this.row_].text.slice(0, -1);
} else {
this.displayed_[this.row_] = this.displayed_[this.row_].slice(0, -1);
this.displayed_[this.row_].text = this.displayed_[this.row_].text.slice(0, -1);
}
} else if (data === this.ERASE_DISPLAYED_MEMORY_) {
this.flushDisplayed(packet.pts);
@ -4105,9 +4125,9 @@
// backspace the "e" and insert "è".
// Delete the previous character
if (this.mode_ === 'popOn') {
this.nonDisplayed_[this.row_] = this.nonDisplayed_[this.row_].slice(0, -1);
this.nonDisplayed_[this.row_].text = this.nonDisplayed_[this.row_].text.slice(0, -1);
} else {
this.displayed_[this.row_] = this.displayed_[this.row_].slice(0, -1);
this.displayed_[this.row_].text = this.displayed_[this.row_].text.slice(0, -1);
} // Bitmask char0 so that we can apply character transformations
// regardless of field and data channel.
// Then byte-shift to the left and OR with char1 so we can pass the
@ -4139,7 +4159,11 @@
// increments, with an additional offset code of 1-3 to reach any
// of the 32 columns specified by CEA-608. So all we need to do
// here is increment the column cursor by the given offset.
this.column_ += char1 & 0x03; // Detect PACs (Preamble Address Codes)
var offset = char1 & 0x03; // For an offest value 1-3, set the offset for that caption
// in the non-displayed array.
this.nonDisplayed_[this.row_].offset = offset;
this.column_ += offset; // Detect PACs (Preamble Address Codes)
} else if (this.isPAC(char0, char1)) {
// There's no logic for PAC -> row mapping, so we have to just
// find the row code in an array and use its index :(
@ -4173,7 +4197,10 @@
// increments the column cursor by 4, so we can get the desired
// column position by bit-shifting to the right (to get n/2)
// and multiplying by 4.
this.column_ = ((data & 0xe) >> 1) * 4;
var indentations = (data & 0xe) >> 1;
this.column_ = indentations * 4; // add to the number of indentations for positioning
this.nonDisplayed_[this.row_].indent += indentations;
}
if (this.isColorPAC(char1)) {
@ -4204,29 +4231,52 @@
// display buffer
Cea608Stream.prototype.flushDisplayed = function (pts) {
var content = this.displayed_ // remove spaces from the start and end of the string
.map(function (row, index) {
try {
return row.trim();
} catch (e) {
// Ordinarily, this shouldn't happen. However, caption
// parsing errors should not throw exceptions and
// break playback.
this.trigger('log', {
level: 'warn',
message: 'Skipping a malformed 608 caption at index ' + index + '.'
});
return '';
var _this = this;
var logWarning = function logWarning(index) {
_this.trigger('log', {
level: 'warn',
message: 'Skipping a malformed 608 caption at index ' + index + '.'
});
};
var content = [];
this.displayed_.forEach(function (row, i) {
if (row && row.text && row.text.length) {
try {
// remove spaces from the start and end of the string
row.text = row.text.trim();
} catch (e) {
// Ordinarily, this shouldn't happen. However, caption
// parsing errors should not throw exceptions and
// break playback.
logWarning(i);
} // See the below link for more details on the following fields:
// https://dvcs.w3.org/hg/text-tracks/raw-file/default/608toVTT/608toVTT.html#positioning-in-cea-608
if (row.text.length) {
content.push({
// The text to be displayed in the caption from this specific row, with whitespace removed.
text: row.text,
// Value between 1 and 15 representing the PAC row used to calculate line height.
line: i + 1,
// A number representing the indent position by percentage (CEA-608 PAC indent code).
// The value will be a number between 10 and 80. Offset is used to add an aditional
// value to the position if necessary.
position: 10 + Math.min(70, row.indent * 10) + row.offset * 2.5
});
}
} else if (row === undefined || row === null) {
logWarning(i);
}
}, this) // combine all text rows to display in one cue
.join('\n') // and remove blank rows from the start and end, but not the middle
.replace(/^\n+|\n+$/g, '');
});
if (content.length) {
this.trigger('data', {
startPts: this.startPts_,
endPts: pts,
text: content,
content: content,
stream: this.name_
});
}
@ -4435,7 +4485,11 @@
// move currently displayed captions (up or down) to the new base row
for (var i = 0; i < this.rollUpRows_; i++) {
this.displayed_[newBaseRow - i] = this.displayed_[this.row_ - i];
this.displayed_[this.row_ - i] = '';
this.displayed_[this.row_ - i] = {
text: '',
indent: 0,
offset: 0
};
}
}
@ -4472,27 +4526,35 @@
Cea608Stream.prototype.popOn = function (pts, text) {
var baseRow = this.nonDisplayed_[this.row_]; // buffer characters
var baseRow = this.nonDisplayed_[this.row_].text; // buffer characters
baseRow += text;
this.nonDisplayed_[this.row_] = baseRow;
this.nonDisplayed_[this.row_].text = baseRow;
};
Cea608Stream.prototype.rollUp = function (pts, text) {
var baseRow = this.displayed_[this.row_];
var baseRow = this.displayed_[this.row_].text;
baseRow += text;
this.displayed_[this.row_] = baseRow;
this.displayed_[this.row_].text = baseRow;
};
Cea608Stream.prototype.shiftRowsUp_ = function () {
var i; // clear out inactive rows
for (i = 0; i < this.topRow_; i++) {
this.displayed_[i] = '';
this.displayed_[i] = {
text: '',
indent: 0,
offset: 0
};
}
for (i = this.row_ + 1; i < BOTTOM_ROW + 1; i++) {
this.displayed_[i] = '';
this.displayed_[i] = {
text: '',
indent: 0,
offset: 0
};
} // shift displayed rows up
@ -4501,13 +4563,17 @@
} // clear out the bottom row
this.displayed_[this.row_] = '';
this.displayed_[this.row_] = {
text: '',
indent: 0,
offset: 0
};
};
Cea608Stream.prototype.paintOn = function (pts, text) {
var baseRow = this.displayed_[this.row_];
var baseRow = this.displayed_[this.row_].text;
baseRow += text;
this.displayed_[this.row_] = baseRow;
this.displayed_[this.row_].text = baseRow;
}; // exports
@ -7077,7 +7143,7 @@
this.push = function (output) {
// buffer incoming captions until the associated video segment
// finishes
if (output.text) {
if (output.content || output.text) {
return this.pendingCaptions.push(output);
} // buffer incoming id3 tags until the final flush
@ -7758,7 +7824,10 @@
* @return {?Object[]} parsedCaptions - A list of captions or null if no video tracks
* @return {Number} parsedCaptions[].startTime - The time to show the caption in seconds
* @return {Number} parsedCaptions[].endTime - The time to stop showing the caption in seconds
* @return {String} parsedCaptions[].text - The visible content of the caption
* @return {Object[]} parsedCaptions[].content - A list of individual caption segments
* @return {String} parsedCaptions[].content.text - The visible content of the caption segment
* @return {Number} parsedCaptions[].content.line - The line height from 1-15 for positioning of the caption segment
* @return {Number} parsedCaptions[].content.position - The column indent percentage for cue positioning from 10-80
**/