I'm trying to write a PES packet using jBinary and PES.js implemented in this repo.
Something like:
var PES = require('./mpegts/mpegts_to_mp4/pes.js');
var jBinary = require('jbinary');
var streamId;
var data;
// ...
var pesHeaderLength = 11;
lastCameraModelPesPacketToSerialize = {
streamId: streamId,
length: data.length,
scramblingControl: 0,
priority: 0,
dataAlignmentIndicator: 0,
hasCopyright: 0,
isOriginal: 1,
//_hasPTS: 0,
//_hasDTS: 0,
//_hasESCR: 0,
//_hasESRate: 0,
dsmTrickMode: 0,
//_hasAdditionalCopyInfo: 0,
//_hasPESCRC: 0,
//_hasExtension: 0,
dataLength: 5,
data: data
};
var pesWriter = new jBinary(data.length + pesHeaderLength, PES);
pesWriter.write('PESPacket', pesPacket);
I get the following exception:
if (!(type in this.typeSet)) throw new ReferenceError("Unknown typ
^
ReferenceError: Unknown type: dependentField
at jBinary.proto._getType (\node_modules\jbinary\dist\node\jbinary.js:198:48)
I guess that it's a simple bug in the PES definition which arises when trying to WRITE PES packet (which is not the common scenario in this repo), or that I've done something stupid. But due to lack of internal knowledge in jBinary implementation I found it hard to debug the problem.
Any help is appreciated.
EDIT: The same error appears also when trying to write an mpegts packet using mpegts.js. (It does not necessary mean that the problem is in jBinary, because the implementation of FlagDependent and Flag types is duplicated and identical between MPEGTS and PES).