First release
This commit is contained in:
commit
fa6c85266e
2339 changed files with 761050 additions and 0 deletions
18
node_modules/mux.js/lib/utils/bin.js
generated
vendored
Normal file
18
node_modules/mux.js/lib/utils/bin.js
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* mux.js
|
||||
*
|
||||
* Copyright (c) Brightcove
|
||||
* Licensed Apache-2.0 https://github.com/videojs/mux.js/blob/master/LICENSE
|
||||
*/
|
||||
var toUnsigned = function(value) {
|
||||
return value >>> 0;
|
||||
};
|
||||
|
||||
var toHexString = function(value) {
|
||||
return ('00' + value.toString(16)).slice(-2);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
toUnsigned: toUnsigned,
|
||||
toHexString: toHexString
|
||||
};
|
58
node_modules/mux.js/lib/utils/clock.js
generated
vendored
Normal file
58
node_modules/mux.js/lib/utils/clock.js
generated
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
* mux.js
|
||||
*
|
||||
* Copyright (c) Brightcove
|
||||
* Licensed Apache-2.0 https://github.com/videojs/mux.js/blob/master/LICENSE
|
||||
*/
|
||||
var
|
||||
ONE_SECOND_IN_TS = 90000, // 90kHz clock
|
||||
secondsToVideoTs,
|
||||
secondsToAudioTs,
|
||||
videoTsToSeconds,
|
||||
audioTsToSeconds,
|
||||
audioTsToVideoTs,
|
||||
videoTsToAudioTs,
|
||||
metadataTsToSeconds;
|
||||
|
||||
secondsToVideoTs = function(seconds) {
|
||||
return seconds * ONE_SECOND_IN_TS;
|
||||
};
|
||||
|
||||
secondsToAudioTs = function(seconds, sampleRate) {
|
||||
return seconds * sampleRate;
|
||||
};
|
||||
|
||||
videoTsToSeconds = function(timestamp) {
|
||||
return timestamp / ONE_SECOND_IN_TS;
|
||||
};
|
||||
|
||||
audioTsToSeconds = function(timestamp, sampleRate) {
|
||||
return timestamp / sampleRate;
|
||||
};
|
||||
|
||||
audioTsToVideoTs = function(timestamp, sampleRate) {
|
||||
return secondsToVideoTs(audioTsToSeconds(timestamp, sampleRate));
|
||||
};
|
||||
|
||||
videoTsToAudioTs = function(timestamp, sampleRate) {
|
||||
return secondsToAudioTs(videoTsToSeconds(timestamp), sampleRate);
|
||||
};
|
||||
|
||||
/**
|
||||
* Adjust ID3 tag or caption timing information by the timeline pts values
|
||||
* (if keepOriginalTimestamps is false) and convert to seconds
|
||||
*/
|
||||
metadataTsToSeconds = function(timestamp, timelineStartPts, keepOriginalTimestamps) {
|
||||
return videoTsToSeconds(keepOriginalTimestamps ? timestamp : timestamp - timelineStartPts);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
ONE_SECOND_IN_TS: ONE_SECOND_IN_TS,
|
||||
secondsToVideoTs: secondsToVideoTs,
|
||||
secondsToAudioTs: secondsToAudioTs,
|
||||
videoTsToSeconds: videoTsToSeconds,
|
||||
audioTsToSeconds: audioTsToSeconds,
|
||||
audioTsToVideoTs: audioTsToVideoTs,
|
||||
videoTsToAudioTs: videoTsToAudioTs,
|
||||
metadataTsToSeconds: metadataTsToSeconds
|
||||
};
|
153
node_modules/mux.js/lib/utils/exp-golomb.js
generated
vendored
Normal file
153
node_modules/mux.js/lib/utils/exp-golomb.js
generated
vendored
Normal file
|
@ -0,0 +1,153 @@
|
|||
/**
|
||||
* mux.js
|
||||
*
|
||||
* Copyright (c) Brightcove
|
||||
* Licensed Apache-2.0 https://github.com/videojs/mux.js/blob/master/LICENSE
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var ExpGolomb;
|
||||
|
||||
/**
|
||||
* Parser for exponential Golomb codes, a variable-bitwidth number encoding
|
||||
* scheme used by h264.
|
||||
*/
|
||||
ExpGolomb = function(workingData) {
|
||||
var
|
||||
// the number of bytes left to examine in workingData
|
||||
workingBytesAvailable = workingData.byteLength,
|
||||
|
||||
// the current word being examined
|
||||
workingWord = 0, // :uint
|
||||
|
||||
// the number of bits left to examine in the current word
|
||||
workingBitsAvailable = 0; // :uint;
|
||||
|
||||
// ():uint
|
||||
this.length = function() {
|
||||
return (8 * workingBytesAvailable);
|
||||
};
|
||||
|
||||
// ():uint
|
||||
this.bitsAvailable = function() {
|
||||
return (8 * workingBytesAvailable) + workingBitsAvailable;
|
||||
};
|
||||
|
||||
// ():void
|
||||
this.loadWord = function() {
|
||||
var
|
||||
position = workingData.byteLength - workingBytesAvailable,
|
||||
workingBytes = new Uint8Array(4),
|
||||
availableBytes = Math.min(4, workingBytesAvailable);
|
||||
|
||||
if (availableBytes === 0) {
|
||||
throw new Error('no bytes available');
|
||||
}
|
||||
|
||||
workingBytes.set(workingData.subarray(position,
|
||||
position + availableBytes));
|
||||
workingWord = new DataView(workingBytes.buffer).getUint32(0);
|
||||
|
||||
// track the amount of workingData that has been processed
|
||||
workingBitsAvailable = availableBytes * 8;
|
||||
workingBytesAvailable -= availableBytes;
|
||||
};
|
||||
|
||||
// (count:int):void
|
||||
this.skipBits = function(count) {
|
||||
var skipBytes; // :int
|
||||
if (workingBitsAvailable > count) {
|
||||
workingWord <<= count;
|
||||
workingBitsAvailable -= count;
|
||||
} else {
|
||||
count -= workingBitsAvailable;
|
||||
skipBytes = Math.floor(count / 8);
|
||||
|
||||
count -= (skipBytes * 8);
|
||||
workingBytesAvailable -= skipBytes;
|
||||
|
||||
this.loadWord();
|
||||
|
||||
workingWord <<= count;
|
||||
workingBitsAvailable -= count;
|
||||
}
|
||||
};
|
||||
|
||||
// (size:int):uint
|
||||
this.readBits = function(size) {
|
||||
var
|
||||
bits = Math.min(workingBitsAvailable, size), // :uint
|
||||
valu = workingWord >>> (32 - bits); // :uint
|
||||
// if size > 31, handle error
|
||||
workingBitsAvailable -= bits;
|
||||
if (workingBitsAvailable > 0) {
|
||||
workingWord <<= bits;
|
||||
} else if (workingBytesAvailable > 0) {
|
||||
this.loadWord();
|
||||
}
|
||||
|
||||
bits = size - bits;
|
||||
if (bits > 0) {
|
||||
return valu << bits | this.readBits(bits);
|
||||
}
|
||||
return valu;
|
||||
};
|
||||
|
||||
// ():uint
|
||||
this.skipLeadingZeros = function() {
|
||||
var leadingZeroCount; // :uint
|
||||
for (leadingZeroCount = 0; leadingZeroCount < workingBitsAvailable; ++leadingZeroCount) {
|
||||
if ((workingWord & (0x80000000 >>> leadingZeroCount)) !== 0) {
|
||||
// the first bit of working word is 1
|
||||
workingWord <<= leadingZeroCount;
|
||||
workingBitsAvailable -= leadingZeroCount;
|
||||
return leadingZeroCount;
|
||||
}
|
||||
}
|
||||
|
||||
// we exhausted workingWord and still have not found a 1
|
||||
this.loadWord();
|
||||
return leadingZeroCount + this.skipLeadingZeros();
|
||||
};
|
||||
|
||||
// ():void
|
||||
this.skipUnsignedExpGolomb = function() {
|
||||
this.skipBits(1 + this.skipLeadingZeros());
|
||||
};
|
||||
|
||||
// ():void
|
||||
this.skipExpGolomb = function() {
|
||||
this.skipBits(1 + this.skipLeadingZeros());
|
||||
};
|
||||
|
||||
// ():uint
|
||||
this.readUnsignedExpGolomb = function() {
|
||||
var clz = this.skipLeadingZeros(); // :uint
|
||||
return this.readBits(clz + 1) - 1;
|
||||
};
|
||||
|
||||
// ():int
|
||||
this.readExpGolomb = function() {
|
||||
var valu = this.readUnsignedExpGolomb(); // :int
|
||||
if (0x01 & valu) {
|
||||
// the number is odd if the low order bit is set
|
||||
return (1 + valu) >>> 1; // add 1 to make it even, and divide by 2
|
||||
}
|
||||
return -1 * (valu >>> 1); // divide by two then make it negative
|
||||
};
|
||||
|
||||
// Some convenience functions
|
||||
// :Boolean
|
||||
this.readBoolean = function() {
|
||||
return this.readBits(1) === 1;
|
||||
};
|
||||
|
||||
// ():int
|
||||
this.readUnsignedByte = function() {
|
||||
return this.readBits(8);
|
||||
};
|
||||
|
||||
this.loadWord();
|
||||
};
|
||||
|
||||
module.exports = ExpGolomb;
|
141
node_modules/mux.js/lib/utils/stream.js
generated
vendored
Normal file
141
node_modules/mux.js/lib/utils/stream.js
generated
vendored
Normal file
|
@ -0,0 +1,141 @@
|
|||
/**
|
||||
* mux.js
|
||||
*
|
||||
* Copyright (c) Brightcove
|
||||
* Licensed Apache-2.0 https://github.com/videojs/mux.js/blob/master/LICENSE
|
||||
*
|
||||
* A lightweight readable stream implemention that handles event dispatching.
|
||||
* Objects that inherit from streams should call init in their constructors.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var Stream = function() {
|
||||
this.init = function() {
|
||||
var listeners = {};
|
||||
/**
|
||||
* Add a listener for a specified event type.
|
||||
* @param type {string} the event name
|
||||
* @param listener {function} the callback to be invoked when an event of
|
||||
* the specified type occurs
|
||||
*/
|
||||
this.on = function(type, listener) {
|
||||
if (!listeners[type]) {
|
||||
listeners[type] = [];
|
||||
}
|
||||
listeners[type] = listeners[type].concat(listener);
|
||||
};
|
||||
/**
|
||||
* Remove a listener for a specified event type.
|
||||
* @param type {string} the event name
|
||||
* @param listener {function} a function previously registered for this
|
||||
* type of event through `on`
|
||||
*/
|
||||
this.off = function(type, listener) {
|
||||
var index;
|
||||
if (!listeners[type]) {
|
||||
return false;
|
||||
}
|
||||
index = listeners[type].indexOf(listener);
|
||||
listeners[type] = listeners[type].slice();
|
||||
listeners[type].splice(index, 1);
|
||||
return index > -1;
|
||||
};
|
||||
/**
|
||||
* Trigger an event of the specified type on this stream. Any additional
|
||||
* arguments to this function are passed as parameters to event listeners.
|
||||
* @param type {string} the event name
|
||||
*/
|
||||
this.trigger = function(type) {
|
||||
var callbacks, i, length, args;
|
||||
callbacks = listeners[type];
|
||||
if (!callbacks) {
|
||||
return;
|
||||
}
|
||||
// Slicing the arguments on every invocation of this method
|
||||
// can add a significant amount of overhead. Avoid the
|
||||
// intermediate object creation for the common case of a
|
||||
// single callback argument
|
||||
if (arguments.length === 2) {
|
||||
length = callbacks.length;
|
||||
for (i = 0; i < length; ++i) {
|
||||
callbacks[i].call(this, arguments[1]);
|
||||
}
|
||||
} else {
|
||||
args = [];
|
||||
i = arguments.length;
|
||||
for (i = 1; i < arguments.length; ++i) {
|
||||
args.push(arguments[i]);
|
||||
}
|
||||
length = callbacks.length;
|
||||
for (i = 0; i < length; ++i) {
|
||||
callbacks[i].apply(this, args);
|
||||
}
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Destroys the stream and cleans up.
|
||||
*/
|
||||
this.dispose = function() {
|
||||
listeners = {};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Forwards all `data` events on this stream to the destination stream. The
|
||||
* destination stream should provide a method `push` to receive the data
|
||||
* events as they arrive.
|
||||
* @param destination {stream} the stream that will receive all `data` events
|
||||
* @param autoFlush {boolean} if false, we will not call `flush` on the destination
|
||||
* when the current stream emits a 'done' event
|
||||
* @see http://nodejs.org/api/stream.html#stream_readable_pipe_destination_options
|
||||
*/
|
||||
Stream.prototype.pipe = function(destination) {
|
||||
this.on('data', function(data) {
|
||||
destination.push(data);
|
||||
});
|
||||
|
||||
this.on('done', function(flushSource) {
|
||||
destination.flush(flushSource);
|
||||
});
|
||||
|
||||
this.on('partialdone', function(flushSource) {
|
||||
destination.partialFlush(flushSource);
|
||||
});
|
||||
|
||||
this.on('endedtimeline', function(flushSource) {
|
||||
destination.endTimeline(flushSource);
|
||||
});
|
||||
|
||||
this.on('reset', function(flushSource) {
|
||||
destination.reset(flushSource);
|
||||
});
|
||||
|
||||
return destination;
|
||||
};
|
||||
|
||||
// Default stream functions that are expected to be overridden to perform
|
||||
// actual work. These are provided by the prototype as a sort of no-op
|
||||
// implementation so that we don't have to check for their existence in the
|
||||
// `pipe` function above.
|
||||
Stream.prototype.push = function(data) {
|
||||
this.trigger('data', data);
|
||||
};
|
||||
|
||||
Stream.prototype.flush = function(flushSource) {
|
||||
this.trigger('done', flushSource);
|
||||
};
|
||||
|
||||
Stream.prototype.partialFlush = function(flushSource) {
|
||||
this.trigger('partialdone', flushSource);
|
||||
};
|
||||
|
||||
Stream.prototype.endTimeline = function(flushSource) {
|
||||
this.trigger('endedtimeline', flushSource);
|
||||
};
|
||||
|
||||
Stream.prototype.reset = function(flushSource) {
|
||||
this.trigger('reset', flushSource);
|
||||
};
|
||||
|
||||
module.exports = Stream;
|
Loading…
Add table
Add a link
Reference in a new issue