ebml-stream
Version:
Ebml parser and encoder
34 lines (33 loc) • 992 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const tools_1 = require("../../tools");
const Block_1 = require("./Block");
const EbmlTagId_1 = require("../enums/EbmlTagId");
class SimpleBlock extends Block_1.Block {
constructor() {
super(EbmlTagId_1.EbmlTagId.SimpleBlock);
}
encodeContent() {
let flags = this.writeFlagsBuffer();
if (this.keyframe) {
flags[0] |= 0x80;
}
if (this.discardable) {
flags[0] |= 0x01;
}
return Buffer.concat([
this.writeTrackBuffer(),
this.writeValueBuffer(),
flags,
this.payload
]);
}
parseContent(data) {
super.parseContent(data);
const track = tools_1.Tools.readVint(data);
let flags = data[track.length + 2];
this.keyframe = Boolean(flags & 0x80);
this.discardable = Boolean(flags & 0x01);
}
}
exports.SimpleBlock = SimpleBlock;
;