Pushing changes
This commit is contained in:
4
node_modules/ebml/.jshintrc
generated
vendored
Normal file
4
node_modules/ebml/.jshintrc
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"eqnull": true,
|
||||
"indent": 4
|
||||
}
|
1
node_modules/ebml/.npmignore
generated
vendored
Normal file
1
node_modules/ebml/.npmignore
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules/
|
5
node_modules/ebml/.travis.yml
generated
vendored
Normal file
5
node_modules/ebml/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
language: node_js
|
||||
sudo: false
|
||||
node_js:
|
||||
- 0.12
|
||||
- 4.0
|
17
node_modules/ebml/LICENSE
generated
vendored
Normal file
17
node_modules/ebml/LICENSE
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
Copyright (c) 2013 Mark Schmale
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
|
53
node_modules/ebml/README.md
generated
vendored
Normal file
53
node_modules/ebml/README.md
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
# EBML [](https://travis-ci.org/themasch/node-ebml) [](https://www.npmjs.com/package/ebml)
|
||||
|
||||
[EBML](http://ebml.sourceforge.net/) stands for Extensible Binary Meta-Language
|
||||
and is some what of a binary version of XML.
|
||||
It's used for container formats like webm or [mkv](http://www.matroska.org/technical/specs/index.html)
|
||||
|
||||
# install
|
||||
|
||||
```
|
||||
npm install ebml
|
||||
```
|
||||
|
||||
# example
|
||||
|
||||
```
|
||||
var ebml = require('./index.js');
|
||||
var fs = require('fs');
|
||||
|
||||
var decoder = new ebml.Decoder();
|
||||
|
||||
decoder.on('data', function(chunk) {
|
||||
console.log(chunk);
|
||||
});
|
||||
|
||||
fs.readFile('media/test.webm', function(err, data) {
|
||||
if (err)
|
||||
throw err;
|
||||
decoder.write(data);
|
||||
});
|
||||
```
|
||||
|
||||
# state of this project
|
||||
|
||||
Parsing should work. If it doesn't, please create [an issue](https://github.com/themasch/node-ebml/issues/new).
|
||||
|
||||
Thanks to @chrisprice we got an encoder!
|
||||
|
||||
# license
|
||||
|
||||
MIT
|
||||
|
||||
# contributors
|
||||
|
||||
(in alphabetical order)
|
||||
|
||||
* [Chris Price](https://github.com/chrisprice)
|
||||
* [Davy Van Deursen](https://github.com/dvdeurse)
|
||||
* [Ed Markowski](https://github.com/siphontv)
|
||||
* [Manuel Wiedenmann](https://github.com/fsmanuel)
|
||||
* [Mark Schmale](https://github.com/themasch)
|
||||
* [Mathias Buus](https://github.com/mafintosh)
|
||||
* [Max Ogden](https://github.com/maxogden)
|
||||
* [Oliver Walzer](https://github.com/owcd)
|
14
node_modules/ebml/example.js
generated
vendored
Normal file
14
node_modules/ebml/example.js
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
var ebml = require('./index.js');
|
||||
var fs = require('fs');
|
||||
|
||||
var decoder = new ebml.Decoder();
|
||||
|
||||
decoder.on('data', function(chunk) {
|
||||
console.log(chunk);
|
||||
});
|
||||
|
||||
fs.readFile('media/test.webm', function(err, data) {
|
||||
if (err)
|
||||
throw err;
|
||||
decoder.write(data);
|
||||
});
|
27
node_modules/ebml/gulpfile.js
generated
vendored
Normal file
27
node_modules/ebml/gulpfile.js
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
var gulp = require('gulp');
|
||||
var jshint = require('gulp-jshint');
|
||||
var fixmyjs = require('gulp-fixmyjs');
|
||||
var stylish = require('jshint-stylish');
|
||||
var esformatter = require('gulp-esformatter');
|
||||
var os = require('os');
|
||||
|
||||
var paths = {
|
||||
'js': ['*.js', '**/*.js', '!node_modules/**/*.js']
|
||||
};
|
||||
|
||||
gulp.task('default', function() {
|
||||
return gulp.src(paths.js)
|
||||
.pipe(jshint())
|
||||
.pipe(jshint.reporter('default'))
|
||||
.pipe(esformatter({
|
||||
indent: {
|
||||
value: ' '
|
||||
}
|
||||
}))
|
||||
.pipe(gulp.dest('.'));
|
||||
});
|
||||
|
||||
// Not a good idea...
|
||||
// gulp.task('watch', function() {
|
||||
// gulp.watch(paths.js, ['default']);
|
||||
// });
|
1
node_modules/ebml/index.js
generated
vendored
Normal file
1
node_modules/ebml/index.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require('./lib/ebml/index.js');
|
174
node_modules/ebml/lib/ebml/decoder.js
generated
vendored
Normal file
174
node_modules/ebml/lib/ebml/decoder.js
generated
vendored
Normal file
@ -0,0 +1,174 @@
|
||||
var Transform = require('stream').Transform,
|
||||
tools = require('./tools.js'),
|
||||
schema = require('./schema.js'),
|
||||
debug = require('debug')('ebml:decoder');
|
||||
|
||||
var STATE_TAG = 1,
|
||||
STATE_SIZE = 2,
|
||||
STATE_CONTENT = 3;
|
||||
|
||||
|
||||
function EbmlDecoder(options) {
|
||||
options = options || {};
|
||||
options.readableObjectMode = true;
|
||||
Transform.call(this, options);
|
||||
|
||||
this._buffer = null;
|
||||
this._tag_stack = [];
|
||||
this._state = STATE_TAG;
|
||||
this._cursor = 0;
|
||||
this._total = 0;
|
||||
this._schema = schema;
|
||||
}
|
||||
|
||||
require('util').inherits(EbmlDecoder, Transform);
|
||||
|
||||
EbmlDecoder.prototype._transform = function(chunk, enc, done) {
|
||||
|
||||
if (this._buffer === null) {
|
||||
this._buffer = chunk;
|
||||
} else {
|
||||
this._buffer = Buffer.concat([this._buffer, chunk]);
|
||||
}
|
||||
|
||||
while (this._cursor < this._buffer.length) {
|
||||
if (this._state === STATE_TAG && !this.readTag()) {
|
||||
break;
|
||||
}
|
||||
if (this._state === STATE_SIZE && !this.readSize()) {
|
||||
break;
|
||||
}
|
||||
if (this._state === STATE_CONTENT && !this.readContent()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
done();
|
||||
};
|
||||
|
||||
EbmlDecoder.prototype.getSchemaInfo = function(tagStr) {
|
||||
return this._schema[tagStr] || {
|
||||
"type": "unknown",
|
||||
"name": "unknown"
|
||||
};
|
||||
};
|
||||
|
||||
EbmlDecoder.prototype.readTag = function() {
|
||||
|
||||
debug('parsing tag');
|
||||
|
||||
if (this._cursor >= this._buffer.length) {
|
||||
debug('waiting for more data');
|
||||
return false;
|
||||
}
|
||||
|
||||
var start = this._total;
|
||||
var tag = tools.readVint(this._buffer, this._cursor);
|
||||
|
||||
if (tag == null) {
|
||||
debug('waiting for more data');
|
||||
return false;
|
||||
}
|
||||
|
||||
var tagStr = this._buffer.toString('hex', this._cursor, this._cursor + tag.length);
|
||||
|
||||
this._cursor += tag.length;
|
||||
this._total += tag.length;
|
||||
this._state = STATE_SIZE;
|
||||
|
||||
tagObj = {
|
||||
tag: tag.value,
|
||||
tagStr: tagStr,
|
||||
type: this.getSchemaInfo(tagStr).type,
|
||||
name: this.getSchemaInfo(tagStr).name,
|
||||
start: start,
|
||||
end: start + tag.length
|
||||
};
|
||||
|
||||
this._tag_stack.push(tagObj);
|
||||
debug('read tag: ' + tagStr);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
EbmlDecoder.prototype.readSize = function() {
|
||||
|
||||
var tagObj = this._tag_stack[this._tag_stack.length - 1];
|
||||
|
||||
debug('parsing size for tag: ' + tagObj.tag.toString(16));
|
||||
|
||||
if (this._cursor >= this._buffer.length) {
|
||||
debug('waiting for more data');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
var size = tools.readVint(this._buffer, this._cursor);
|
||||
|
||||
if (size == null) {
|
||||
debug('waiting for more data');
|
||||
return false;
|
||||
}
|
||||
|
||||
this._cursor += size.length;
|
||||
this._total += size.length;
|
||||
this._state = STATE_CONTENT;
|
||||
tagObj.dataSize = size.value;
|
||||
|
||||
// unknown size
|
||||
if (size.value === -1) {
|
||||
tagObj.end = -1;
|
||||
} else {
|
||||
tagObj.end += size.value + size.length;
|
||||
}
|
||||
|
||||
debug('read size: ' + size.value);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
EbmlDecoder.prototype.readContent = function() {
|
||||
|
||||
var tagObj = this._tag_stack[this._tag_stack.length - 1];
|
||||
|
||||
debug('parsing content for tag: ' + tagObj.tag.toString(16));
|
||||
|
||||
if (tagObj.type === 'm') {
|
||||
debug('content should be tags');
|
||||
this.push(['start', tagObj]);
|
||||
this._state = STATE_TAG;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this._buffer.length < this._cursor + tagObj.dataSize) {
|
||||
debug('got: ' + this._buffer.length);
|
||||
debug('need: ' + (this._cursor + tagObj.dataSize));
|
||||
debug('waiting for more data');
|
||||
return false;
|
||||
}
|
||||
|
||||
var data = this._buffer.slice(this._cursor, this._cursor + tagObj.dataSize);
|
||||
this._total += tagObj.dataSize;
|
||||
this._state = STATE_TAG;
|
||||
this._buffer = this._buffer.slice(this._cursor + tagObj.dataSize);
|
||||
this._cursor = 0;
|
||||
|
||||
this._tag_stack.pop(); // remove the object from the stack
|
||||
|
||||
tagObj.data = data;
|
||||
this.push(['tag', tagObj]);
|
||||
|
||||
while (this._tag_stack.length > 0) {
|
||||
var topEle = this._tag_stack[this._tag_stack.length - 1];
|
||||
if (this._total < topEle.end) {
|
||||
break;
|
||||
}
|
||||
this.push(['end', topEle]);
|
||||
this._tag_stack.pop();
|
||||
}
|
||||
|
||||
debug('read data: ' + data.toString('hex'));
|
||||
return true;
|
||||
};
|
||||
|
||||
module.exports = EbmlDecoder;
|
132
node_modules/ebml/lib/ebml/encoder.js
generated
vendored
Normal file
132
node_modules/ebml/lib/ebml/encoder.js
generated
vendored
Normal file
@ -0,0 +1,132 @@
|
||||
var Transform = require('stream').Transform,
|
||||
tools = require('./tools.js'),
|
||||
schema = require('./schema.js'),
|
||||
debug = require('debug')('ebml:encoder'),
|
||||
Buffers = require('buffers');
|
||||
|
||||
function EbmlEncoder(options) {
|
||||
options = options || {};
|
||||
options.writableObjectMode = true;
|
||||
Transform.call(this, options);
|
||||
|
||||
this._schema = schema;
|
||||
this._buffer = null;
|
||||
this._corked = false;
|
||||
|
||||
this._stack = [];
|
||||
}
|
||||
|
||||
require('util').inherits(EbmlEncoder, Transform);
|
||||
|
||||
EbmlEncoder.prototype._transform = function(chunk, enc, done) {
|
||||
debug('encode ' + chunk[0] + ' ' + chunk[1].name);
|
||||
|
||||
if(chunk[0] === 'start') {
|
||||
this.startTag(chunk[1].name, chunk[1]);
|
||||
} else if(chunk[0] === 'tag') {
|
||||
this.writeTag(chunk[1].name, chunk[1].data);
|
||||
} else if(chunk[0] === 'end') {
|
||||
this.endTag(chunk[1].name);
|
||||
}
|
||||
|
||||
done();
|
||||
};
|
||||
|
||||
EbmlEncoder.prototype._flush = function(done) {
|
||||
done = done || function(){};
|
||||
if (!this._buffer || this._corked) {
|
||||
debug('no buffer/nothing pending');
|
||||
done();
|
||||
return;
|
||||
}
|
||||
|
||||
debug('writing ' + this._buffer.length + ' bytes');
|
||||
|
||||
var chunk = this._buffer.toBuffer();
|
||||
this._buffer = null;
|
||||
this.push(chunk);
|
||||
done();
|
||||
};
|
||||
|
||||
EbmlEncoder.prototype._bufferAndFlush = function(buffer) {
|
||||
if(this._buffer) {
|
||||
this._buffer.push(buffer);
|
||||
} else {
|
||||
this._buffer = Buffers([buffer]);
|
||||
}
|
||||
this._flush();
|
||||
};
|
||||
|
||||
EbmlEncoder.prototype.getSchemaInfo = function(tagName) {
|
||||
var tagStrs = Object.keys(this._schema);
|
||||
for (var i = 0; i < tagStrs.length; i++) {
|
||||
var tagStr = tagStrs[i];
|
||||
if (this._schema[tagStr].name === tagName) {
|
||||
return new Buffer(tagStr, 'hex');
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
EbmlEncoder.prototype.cork = function() {
|
||||
this._corked = true;
|
||||
};
|
||||
|
||||
EbmlEncoder.prototype.uncork = function() {
|
||||
this._corked = false;
|
||||
this._flush();
|
||||
};
|
||||
|
||||
EbmlEncoder.prototype._encodeTag = function(tagId, tagData, end) {
|
||||
return Buffers([tagId, end === -1 ? Buffer('01ffffffffffffff', 'hex') : tools.writeVint(tagData.length), tagData]);
|
||||
};
|
||||
|
||||
EbmlEncoder.prototype.writeTag = function(tagName, tagData) {
|
||||
var tagId = this.getSchemaInfo(tagName);
|
||||
if (!tagId) {
|
||||
throw new Error('No schema entry found for ' + tagName);
|
||||
}
|
||||
|
||||
var data = this._encodeTag(tagId, tagData);
|
||||
if(this._stack.length > 0) {
|
||||
this._stack[this._stack.length - 1].children.push({
|
||||
data: data
|
||||
});
|
||||
} else {
|
||||
this._bufferAndFlush(data.toBuffer());
|
||||
}
|
||||
};
|
||||
|
||||
EbmlEncoder.prototype.startTag = function(tagName, info) {
|
||||
var tagId = this.getSchemaInfo(tagName);
|
||||
if (!tagId) {
|
||||
throw new Error('No schema entry found for ' + tagName);
|
||||
}
|
||||
|
||||
var tag = {
|
||||
id: tagId,
|
||||
name: tagName,
|
||||
end: info.end,
|
||||
children: []
|
||||
};
|
||||
|
||||
if(this._stack.length > 0) {
|
||||
this._stack[this._stack.length - 1].children.push(tag);
|
||||
}
|
||||
this._stack.push(tag);
|
||||
};
|
||||
|
||||
EbmlEncoder.prototype.endTag = function(tagName) {
|
||||
var tag = this._stack.pop();
|
||||
|
||||
var childTagDataBuffers = tag.children.map(function(child) {
|
||||
return child.data;
|
||||
});
|
||||
tag.data = this._encodeTag(tag.id, Buffers(childTagDataBuffers), tag.end);
|
||||
|
||||
if (this._stack.length < 1) {
|
||||
this._bufferAndFlush(tag.data.toBuffer());
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = EbmlEncoder;
|
6
node_modules/ebml/lib/ebml/index.js
generated
vendored
Normal file
6
node_modules/ebml/lib/ebml/index.js
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
tools: require('./tools.js'),
|
||||
schema: require('./schema.js'),
|
||||
Decoder: require('./decoder.js'),
|
||||
Encoder: require('./encoder.js')
|
||||
};
|
2061
node_modules/ebml/lib/ebml/schema.js
generated
vendored
Normal file
2061
node_modules/ebml/lib/ebml/schema.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
56
node_modules/ebml/lib/ebml/tools.js
generated
vendored
Normal file
56
node_modules/ebml/lib/ebml/tools.js
generated
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
var tools = {
|
||||
readVint: function(buffer, start) {
|
||||
start = start || 0;
|
||||
for (var length = 1; length <= 8; length++) {
|
||||
if (buffer[start] >= Math.pow(2, 8 - length)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (length > 8) {
|
||||
throw new Error("Unrepresentable length: " + length + " " +
|
||||
buffer.toString('hex', start, start + length));
|
||||
}
|
||||
if (start + length > buffer.length) {
|
||||
return null;
|
||||
}
|
||||
var value = buffer[start] & (1 << (8 - length)) - 1;
|
||||
for (i = 1; i < length; i++) {
|
||||
if (i === 7) {
|
||||
if (value >= Math.pow(2, 53 - 8) && buffer[start + 7] > 0) {
|
||||
return {
|
||||
length: length,
|
||||
value: -1
|
||||
};
|
||||
}
|
||||
}
|
||||
value *= Math.pow(2, 8);
|
||||
value += buffer[start + i];
|
||||
}
|
||||
return {
|
||||
length: length,
|
||||
value: value
|
||||
};
|
||||
},
|
||||
|
||||
writeVint: function(value) {
|
||||
if (value < 0 || value > Math.pow(2, 53)) {
|
||||
throw new Error("Unrepresentable value: " + value);
|
||||
}
|
||||
for (var length = 1; length <= 8; length++) {
|
||||
if (value < Math.pow(2, 7 * length) - 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
var buffer = new Buffer(length);
|
||||
for (i = 1; i <= length; i++) {
|
||||
var b = value & 0xFF;
|
||||
buffer[length - i] = b;
|
||||
value -= b;
|
||||
value /= Math.pow(2, 8);
|
||||
}
|
||||
buffer[0] = buffer[0] | (1 << (8 - length));
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = tools;
|
BIN
node_modules/ebml/media/test.webm
generated
vendored
Normal file
BIN
node_modules/ebml/media/test.webm
generated
vendored
Normal file
Binary file not shown.
135
node_modules/ebml/package.json
generated
vendored
Normal file
135
node_modules/ebml/package.json
generated
vendored
Normal file
@ -0,0 +1,135 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "ebml@^2.1.0",
|
||||
"scope": null,
|
||||
"escapedName": "ebml",
|
||||
"name": "ebml",
|
||||
"rawSpec": "^2.1.0",
|
||||
"spec": ">=2.1.0 <3.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"/home/burchettm/statsbot/node_modules/discordie"
|
||||
]
|
||||
],
|
||||
"_from": "ebml@>=2.1.0 <3.0.0",
|
||||
"_id": "ebml@2.2.0",
|
||||
"_inCache": true,
|
||||
"_location": "/ebml",
|
||||
"_nodeVersion": "5.10.1",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-12-west.internal.npmjs.com",
|
||||
"tmp": "tmp/ebml-2.2.0.tgz_1467226236144_0.5761768305674195"
|
||||
},
|
||||
"_npmUser": {
|
||||
"name": "masch",
|
||||
"email": "masch@masch.it"
|
||||
},
|
||||
"_npmVersion": "3.8.3",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "ebml@^2.1.0",
|
||||
"scope": null,
|
||||
"escapedName": "ebml",
|
||||
"name": "ebml",
|
||||
"rawSpec": "^2.1.0",
|
||||
"spec": ">=2.1.0 <3.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/discordie"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/ebml/-/ebml-2.2.0.tgz",
|
||||
"_shasum": "22de549106e9d5bb0c4d319adab92707f6efd5c3",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "ebml@^2.1.0",
|
||||
"_where": "/home/burchettm/statsbot/node_modules/discordie",
|
||||
"author": {
|
||||
"name": "Mark Schmale",
|
||||
"email": "masch@masch.it"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/themasch/node-ebml/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Chris Price",
|
||||
"email": "price.c@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Davy Van Deursen",
|
||||
"email": "d.vandeursen@evs.com"
|
||||
},
|
||||
{
|
||||
"name": "Ed Markowski",
|
||||
"email": "siphon@protonmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Manuel Wiedenmann",
|
||||
"email": "manuel@funkensturm.de"
|
||||
},
|
||||
{
|
||||
"name": "Mathias Buus",
|
||||
"email": "mathiasbuus@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Max Ogden",
|
||||
"email": "max@maxogden.com"
|
||||
},
|
||||
{
|
||||
"name": "Oliver Walzer",
|
||||
"email": "walzer@incuray.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"buffers": "^0.1.1",
|
||||
"debug": "~0.7.2"
|
||||
},
|
||||
"description": "ebml parser",
|
||||
"devDependencies": {
|
||||
"gulp": "^3.6.2",
|
||||
"gulp-esformatter": "^0.2.0",
|
||||
"gulp-fixmyjs": "0.0.10",
|
||||
"gulp-jshint": "^1.6.1",
|
||||
"jsfmt": "^0.2.0",
|
||||
"jshint-stylish": "^0.2.0",
|
||||
"matcha": "~0.3.0",
|
||||
"mocha": "~1.12.1"
|
||||
},
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"dist": {
|
||||
"shasum": "22de549106e9d5bb0c4d319adab92707f6efd5c3",
|
||||
"tarball": "https://registry.npmjs.org/ebml/-/ebml-2.2.0.tgz"
|
||||
},
|
||||
"gitHead": "5c27602ed32dd32d23b43c6c51f914ded1cd94e1",
|
||||
"homepage": "https://github.com/themasch/node-ebml#readme",
|
||||
"keywords": [
|
||||
"ebml",
|
||||
"webm",
|
||||
"mkv",
|
||||
"matroska",
|
||||
"format"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "masch",
|
||||
"email": "masch@masch.it"
|
||||
}
|
||||
],
|
||||
"name": "ebml",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/themasch/node-ebml.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha test/"
|
||||
},
|
||||
"version": "2.2.0"
|
||||
}
|
123
node_modules/ebml/test/decoder.js
generated
vendored
Normal file
123
node_modules/ebml/test/decoder.js
generated
vendored
Normal file
@ -0,0 +1,123 @@
|
||||
var ebml = require('../lib/ebml/index.js'),
|
||||
assert = require('assert');
|
||||
|
||||
var STATE_TAG = 1,
|
||||
STATE_SIZE = 2,
|
||||
STATE_CONTENT = 3;
|
||||
|
||||
describe('embl', function() {
|
||||
describe('Decoder', function() {
|
||||
it('should wait for more data if a tag is longer than the buffer', function() {
|
||||
var decoder = new ebml.Decoder();
|
||||
decoder.write(new Buffer([0x1A, 0x45]));
|
||||
|
||||
assert.equal(STATE_TAG, decoder._state);
|
||||
assert.equal(2, decoder._buffer.length);
|
||||
assert.equal(0, decoder._cursor);
|
||||
});
|
||||
|
||||
it('should clear the buffer after a full tag is written in one chunk', function() {
|
||||
var decoder = new ebml.Decoder();
|
||||
decoder.write(new Buffer([0x42, 0x86, 0x81, 0x01]));
|
||||
|
||||
assert.equal(STATE_TAG, decoder._state);
|
||||
assert.equal(0, decoder._buffer.length);
|
||||
assert.equal(0, decoder._cursor);
|
||||
});
|
||||
|
||||
it('should clear the buffer after a full tag is written in multiple chunks', function() {
|
||||
var decoder = new ebml.Decoder();
|
||||
|
||||
decoder.write(new Buffer([0x42, 0x86]));
|
||||
decoder.write(new Buffer([0x81, 0x01]));
|
||||
|
||||
assert.equal(STATE_TAG, decoder._state);
|
||||
assert.equal(0, decoder._buffer.length);
|
||||
assert.equal(0, decoder._cursor);
|
||||
});
|
||||
|
||||
it('should increment the cursor on each step', function() {
|
||||
var decoder = new ebml.Decoder();
|
||||
|
||||
decoder.write(new Buffer([0x42])); // 4
|
||||
|
||||
assert.equal(STATE_TAG, decoder._state);
|
||||
assert.equal(1, decoder._buffer.length);
|
||||
assert.equal(0, decoder._cursor);
|
||||
|
||||
decoder.write(new Buffer([0x86])); // 5
|
||||
|
||||
assert.equal(STATE_SIZE, decoder._state);
|
||||
assert.equal(2, decoder._buffer.length);
|
||||
assert.equal(2, decoder._cursor);
|
||||
|
||||
decoder.write(new Buffer([0x81])); // 6 & 7
|
||||
|
||||
assert.equal(STATE_CONTENT, decoder._state);
|
||||
assert.equal(3, decoder._buffer.length);
|
||||
assert.equal(3, decoder._cursor);
|
||||
|
||||
decoder.write(new Buffer([0x01])); // 6 & 7
|
||||
|
||||
assert.equal(STATE_TAG, decoder._state);
|
||||
assert.equal(0, decoder._buffer.length);
|
||||
assert.equal(0, decoder._cursor);
|
||||
});
|
||||
|
||||
it('should emit correct tag events for simple data', function(done) {
|
||||
var decoder = new ebml.Decoder();
|
||||
decoder.on('data', function(data) {
|
||||
var state = data[0];
|
||||
data = data[1];
|
||||
assert.equal(state, 'tag');
|
||||
assert.equal(data.tag, 0x286);
|
||||
assert.equal(data.tagStr, "4286");
|
||||
assert.equal(data.dataSize, 0x01);
|
||||
assert.equal(data.type, 'u');
|
||||
assert.deepEqual(data.data, new Buffer([0x01]));
|
||||
done();
|
||||
});
|
||||
decoder.write(new Buffer([0x42, 0x86, 0x81, 0x01]));
|
||||
});
|
||||
|
||||
it('should emit correct EBML tag events for master tags', function(done) {
|
||||
var decoder = new ebml.Decoder();
|
||||
|
||||
decoder.on('data', function(data) {
|
||||
var state = data[0];
|
||||
data = data[1];
|
||||
assert.equal(state, 'start');
|
||||
assert.equal(data.tag, 0x0a45dfa3);
|
||||
assert.equal(data.tagStr, "1a45dfa3");
|
||||
assert.equal(data.dataSize, 0);
|
||||
assert.equal(data.type, 'm');
|
||||
assert.equal(data.data, undefined);
|
||||
done();
|
||||
});
|
||||
|
||||
decoder.write(new Buffer([0x1a, 0x45, 0xdf, 0xa3, 0x80]));
|
||||
});
|
||||
|
||||
it('should emit correct EBML:end events for master tags', function(done) {
|
||||
var decoder = new ebml.Decoder();
|
||||
var tags = 0;
|
||||
decoder.on('data', function(data) {
|
||||
var state = data[0];
|
||||
data = data[1];
|
||||
if(state != 'end') {
|
||||
tags++;
|
||||
} else {
|
||||
assert.equal(tags, 2); // two tags
|
||||
assert.equal(data.tag, 0x0a45dfa3);
|
||||
assert.equal(data.tagStr, "1a45dfa3");
|
||||
assert.equal(data.dataSize, 4);
|
||||
assert.equal(data.type, 'm');
|
||||
assert.equal(data.data, undefined);
|
||||
done();
|
||||
}
|
||||
});
|
||||
decoder.write(new Buffer([0x1a, 0x45, 0xdf, 0xa3]));
|
||||
decoder.write(new Buffer([0x84, 0x42, 0x86, 0x81, 0x00]));
|
||||
});
|
||||
});
|
||||
});
|
136
node_modules/ebml/test/ebml.js
generated
vendored
Normal file
136
node_modules/ebml/test/ebml.js
generated
vendored
Normal file
@ -0,0 +1,136 @@
|
||||
var ebml = require('../lib/ebml/index.js'),
|
||||
assert = require('assert');
|
||||
|
||||
describe('embl', function() {
|
||||
describe('tools', function() {
|
||||
describe('#readVint()', function() {
|
||||
function readVint(buffer, expected) {
|
||||
var vint = ebml.tools.readVint(buffer, 0);
|
||||
assert.equal(expected, vint.value);
|
||||
assert.equal(buffer.length, vint.length);
|
||||
}
|
||||
it('should read the correct value for all 1 byte ints', function() {
|
||||
for (var i = 0; i < 0x80; i++) {
|
||||
readVint(new Buffer([i | 0x80]), i);
|
||||
}
|
||||
});
|
||||
it('should read the correct value for 1 byte int with non-zero start', function() {
|
||||
var b = new Buffer([0x00, 0x81]);
|
||||
var vint = ebml.tools.readVint(b, 1);
|
||||
assert.equal(1, vint.value);
|
||||
assert.equal(1, vint.length);
|
||||
});
|
||||
it('should read the correct value for all 2 byte ints', function() {
|
||||
for (var i = 0; i < 0x40; i++)
|
||||
for (j = 0; j < 0xff; j++) {
|
||||
readVint(new Buffer([i | 0x40, j]), (i << 8) + j);
|
||||
}
|
||||
});
|
||||
it('should read the correct value for all 3 byte ints', function() {
|
||||
for (var i = 0; i < 0x20; i++)
|
||||
for (j = 0; j < 0xff; j += 2)
|
||||
for (k = 0; k < 0xff; k += 3) {
|
||||
readVint(new Buffer([i | 0x20, j, k]), (i << 16) + (j << 8) + k);
|
||||
}
|
||||
});
|
||||
// not brute forcing any more bytes, takes sooo long
|
||||
it('should read the correct value for 4 byte int min/max values', function() {
|
||||
readVint(new Buffer([0x10, 0x20, 0x00, 0x00]), Math.pow(2, 21));
|
||||
readVint(new Buffer([0x1F, 0xFF, 0xFF, 0xFF]), Math.pow(2, 28) - 1);
|
||||
});
|
||||
it('should read the correct value for 5 byte int min/max values', function() {
|
||||
readVint(new Buffer([0x08, 0x10, 0x00, 0x00, 0x00]), Math.pow(2, 28));
|
||||
readVint(new Buffer([0x0F, 0xFF, 0xFF, 0xFF, 0xFF]), Math.pow(2, 35) - 1);
|
||||
});
|
||||
it('should read the correct value for 6 byte int min/max values', function() {
|
||||
readVint(new Buffer([0x04, 0x08, 0x00, 0x00, 0x00, 0x00]), Math.pow(2, 35));
|
||||
readVint(new Buffer([0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]), Math.pow(2, 42) - 1);
|
||||
});
|
||||
it('should read the correct value for 7 byte int min/max values', function() {
|
||||
readVint(new Buffer([0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00]), Math.pow(2, 42));
|
||||
readVint(new Buffer([0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]), Math.pow(2, 49) - 1);
|
||||
});
|
||||
it('should read the correct value for 8 byte int min value', function() {
|
||||
readVint(new Buffer([0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]), Math.pow(2, 49));
|
||||
});
|
||||
it('should read the correct value for the max representable JS number (2^53)', function() {
|
||||
readVint(new Buffer([0x01, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]), Math.pow(2, 53));
|
||||
});
|
||||
// an unknown value is represented by -1
|
||||
it('should return value -1 for more than max representable JS number (2^53 + 1)', function() {
|
||||
readVint(new Buffer([0x01, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01]), -1);
|
||||
});
|
||||
it('should return value -1 for more than max representable JS number (8 byte int max value)', function() {
|
||||
readVint(new Buffer([0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]), -1);
|
||||
});
|
||||
it('should throw for 9+ byte int values', function() {
|
||||
assert.throws(function() {
|
||||
ebml.tools.readVint(new Buffer([0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF]));
|
||||
}, /Unrepresentable length/);
|
||||
});
|
||||
});
|
||||
describe('#writeVint()', function() {
|
||||
function writeVint(value, expected) {
|
||||
var actual = ebml.tools.writeVint(value);
|
||||
assert.equal(expected.toString('hex'), actual.toString('hex'));
|
||||
}
|
||||
it('should throw when writing -1', function() {
|
||||
assert.throws(function() {
|
||||
ebml.tools.writeVint(-1);
|
||||
}, /Unrepresentable value/);
|
||||
});
|
||||
it('should write all 1 byte ints', function() {
|
||||
for (var i = 0; i < 0x80 - 1; i++) {
|
||||
writeVint(i, new Buffer([i | 0x80]));
|
||||
}
|
||||
});
|
||||
it('should write 2 byte int min/max values', function() {
|
||||
writeVint(Math.pow(2, 7) - 1, new Buffer([0x40, 0x7F]));
|
||||
writeVint(Math.pow(2, 14) - 2, new Buffer([0x7F, 0xFE]));
|
||||
});
|
||||
it('should write 3 byte int min/max values', function() {
|
||||
writeVint(Math.pow(2, 14) - 1, new Buffer([0x20, 0x3F, 0xFF]));
|
||||
writeVint(Math.pow(2, 21) - 2, new Buffer([0x3F, 0xFF, 0xFE]));
|
||||
});
|
||||
it('should write 4 byte int min/max values', function() {
|
||||
writeVint(Math.pow(2, 21) - 1, new Buffer([0x10, 0x1F, 0xFF, 0xFF]));
|
||||
writeVint(Math.pow(2, 28) - 2, new Buffer([0x1F, 0xFF, 0xFF, 0xFE]));
|
||||
});
|
||||
it('should write 5 byte int min/max value', function() {
|
||||
writeVint(Math.pow(2, 28) - 1, new Buffer([0x08, 0x0F, 0xFF, 0xFF, 0xFF]));
|
||||
writeVint(Math.pow(2, 35) - 2, new Buffer([0x0F, 0xFF, 0xFF, 0xFF, 0xFE]));
|
||||
});
|
||||
it('should write 6 byte int min/max value', function() {
|
||||
writeVint(Math.pow(2, 35) - 1, new Buffer([0x04, 0x07, 0xFF, 0xFF, 0xFF, 0xFF]));
|
||||
writeVint(Math.pow(2, 42) - 2, new Buffer([0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE]));
|
||||
});
|
||||
it('should write 7 byte int min/max value', function() {
|
||||
writeVint(Math.pow(2, 42) - 1, new Buffer([0x02, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]));
|
||||
writeVint(Math.pow(2, 49) - 2, new Buffer([0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE]));
|
||||
});
|
||||
it('should write the correct value for 8 byte int min value', function() {
|
||||
writeVint(Math.pow(2, 49) - 1, new Buffer([0x01, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]));
|
||||
});
|
||||
it('should write the correct value for the max representable JS number (2^53)', function() {
|
||||
writeVint(Math.pow(2, 53), new Buffer([0x01, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]));
|
||||
});
|
||||
// Can't prevent this, 2^53 + 1 === 2^53
|
||||
// it('should throw for more than max representable JS number (2^53 + 1)', function() {
|
||||
// assert.throws(function() {
|
||||
// ebml.tools.writeVint(Math.pow(2, 53) + 1));
|
||||
// }, /Unrepresentable value/)
|
||||
// })
|
||||
it('should throw for more than max representable JS number (8 byte int max value)', function() {
|
||||
assert.throws(function() {
|
||||
ebml.tools.writeVint(Math.pow(2, 56) + 1);
|
||||
}, /Unrepresentable value/);
|
||||
});
|
||||
it('should throw for 9+ byte int values', function() {
|
||||
assert.throws(function() {
|
||||
ebml.tools.writeVint(Math.pow(2, 56) + 1);
|
||||
}, /Unrepresentable value/);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
35
node_modules/ebml/test/encoder.js
generated
vendored
Normal file
35
node_modules/ebml/test/encoder.js
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
var ebml = require('../lib/ebml/index.js'),
|
||||
assert = require('assert');
|
||||
|
||||
describe('embl', function() {
|
||||
describe('Encoder', function() {
|
||||
function createEncoder(expected, done) {
|
||||
var encoder = new ebml.Encoder();
|
||||
encoder.on('data', function(chunk) {
|
||||
assert.equal(chunk.toString('hex'), new Buffer(expected).toString('hex'));
|
||||
done();
|
||||
});
|
||||
return encoder;
|
||||
}
|
||||
it('should write a single tag', function(done) {
|
||||
var encoder = createEncoder([0x42, 0x86, 0x81, 0x01], done);
|
||||
encoder.write(['tag', {
|
||||
name: 'EBMLVersion',
|
||||
data: new Buffer([0x01])
|
||||
}]);
|
||||
});
|
||||
it('should write a tag with a single child', function(done) {
|
||||
var encoder = createEncoder([0x1a, 0x45, 0xdf, 0xa3, 0x84, 0x42, 0x86, 0x81, 0x00], done);
|
||||
encoder.write(['start', {
|
||||
name: 'EBML',
|
||||
}]);
|
||||
encoder.write(['tag', {
|
||||
name: 'EBMLVersion',
|
||||
data: new Buffer([0x00])
|
||||
}]);
|
||||
encoder.write(['end', {
|
||||
name: 'EBML',
|
||||
}]);
|
||||
});
|
||||
});
|
||||
});
|
1
node_modules/ebml/test/mocha.opts
generated
vendored
Normal file
1
node_modules/ebml/test/mocha.opts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
--reporter spec
|
33
node_modules/ebml/test/pipeline.js
generated
vendored
Normal file
33
node_modules/ebml/test/pipeline.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
var ebml = require('../lib/ebml/index.js'),
|
||||
assert = require('assert');
|
||||
|
||||
describe('embl', function() {
|
||||
describe('Pipeline', function() {
|
||||
it('should output input buffer', function(done) {
|
||||
var decoder = new ebml.Decoder();
|
||||
var encoder = new ebml.Encoder();
|
||||
var buffer = new Buffer([0x1a, 0x45, 0xdf, 0xa3, 0x84, 0x42, 0x86, 0x81, 0x00]);
|
||||
encoder.on('data', function(chunk) {
|
||||
assert.equal(chunk.toString('hex'), buffer.toString('hex'));
|
||||
done();
|
||||
});
|
||||
decoder.pipe(encoder);
|
||||
decoder.write(buffer);
|
||||
});
|
||||
|
||||
it('should support end === -1', function (done) {
|
||||
var decoder = new ebml.Decoder();
|
||||
var encoder = new ebml.Encoder();
|
||||
|
||||
encoder.write(['start', {name: 'Cluster', start: 0, end: -1}]);
|
||||
encoder.write(['end', {name: 'Cluster', start: 0, end: -1}]);
|
||||
|
||||
encoder.pipe(decoder).on('data', function (data) {
|
||||
assert.equal(data[1].name, 'Cluster');
|
||||
assert.equal(data[1].start, 0);
|
||||
assert.equal(data[1].end, -1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user