backend and frontend: port frame sending to flatbuffers
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
export { DecodeUnit } from './video-update/decode-unit.js';
|
||||
export { FrameType } from './video-update/frame-type.js';
|
||||
export { Setup } from './video-update/setup.js';
|
||||
export { Update } from './video-update/update.js';
|
||||
export { VideoUpdate } from './video-update/video-update.js';
|
||||
@@ -0,0 +1,103 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
import { FrameType } from '../video-update/frame-type.js';
|
||||
|
||||
|
||||
export class DecodeUnit {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):DecodeUnit {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
static getRootAsDecodeUnit(bb:flatbuffers.ByteBuffer, obj?:DecodeUnit):DecodeUnit {
|
||||
return (obj || new DecodeUnit()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getSizePrefixedRootAsDecodeUnit(bb:flatbuffers.ByteBuffer, obj?:DecodeUnit):DecodeUnit {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new DecodeUnit()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
frameNumber():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
frameType():FrameType {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 6);
|
||||
return offset ? this.bb!.readInt8(this.bb_pos + offset) : FrameType.PFRAME;
|
||||
}
|
||||
|
||||
receiveTimeMs():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 8);
|
||||
return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
data(index: number):number|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 10);
|
||||
return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
|
||||
}
|
||||
|
||||
dataLength():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 10);
|
||||
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
dataArray():Uint8Array|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 10);
|
||||
return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
|
||||
}
|
||||
|
||||
static startDecodeUnit(builder:flatbuffers.Builder) {
|
||||
builder.startObject(4);
|
||||
}
|
||||
|
||||
static addFrameNumber(builder:flatbuffers.Builder, frameNumber:number) {
|
||||
builder.addFieldInt16(0, frameNumber, 0);
|
||||
}
|
||||
|
||||
static addFrameType(builder:flatbuffers.Builder, frameType:FrameType) {
|
||||
builder.addFieldInt8(1, frameType, FrameType.PFRAME);
|
||||
}
|
||||
|
||||
static addReceiveTimeMs(builder:flatbuffers.Builder, receiveTimeMs:number) {
|
||||
builder.addFieldInt16(2, receiveTimeMs, 0);
|
||||
}
|
||||
|
||||
static addData(builder:flatbuffers.Builder, dataOffset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(3, dataOffset, 0);
|
||||
}
|
||||
|
||||
static createDataVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset {
|
||||
builder.startVector(1, data.length, 1);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addInt8(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
|
||||
static startDataVector(builder:flatbuffers.Builder, numElems:number) {
|
||||
builder.startVector(1, numElems, 1);
|
||||
}
|
||||
|
||||
static endDecodeUnit(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
|
||||
static createDecodeUnit(builder:flatbuffers.Builder, frameNumber:number, frameType:FrameType, receiveTimeMs:number, dataOffset:flatbuffers.Offset):flatbuffers.Offset {
|
||||
DecodeUnit.startDecodeUnit(builder);
|
||||
DecodeUnit.addFrameNumber(builder, frameNumber);
|
||||
DecodeUnit.addFrameType(builder, frameType);
|
||||
DecodeUnit.addReceiveTimeMs(builder, receiveTimeMs);
|
||||
DecodeUnit.addData(builder, dataOffset);
|
||||
return DecodeUnit.endDecodeUnit(builder);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
export enum FrameType {
|
||||
PFRAME = 0,
|
||||
IDR = 1
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
export class Setup {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):Setup {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
static getRootAsSetup(bb:flatbuffers.ByteBuffer, obj?:Setup):Setup {
|
||||
return (obj || new Setup()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getSizePrefixedRootAsSetup(bb:flatbuffers.ByteBuffer, obj?:Setup):Setup {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new Setup()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
videoFormat():string|null
|
||||
videoFormat(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
|
||||
videoFormat(optionalEncoding?:any):string|Uint8Array|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
|
||||
}
|
||||
|
||||
width():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 6);
|
||||
return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
height():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 8);
|
||||
return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
redrawRate():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 10);
|
||||
return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
static startSetup(builder:flatbuffers.Builder) {
|
||||
builder.startObject(4);
|
||||
}
|
||||
|
||||
static addVideoFormat(builder:flatbuffers.Builder, videoFormatOffset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(0, videoFormatOffset, 0);
|
||||
}
|
||||
|
||||
static addWidth(builder:flatbuffers.Builder, width:number) {
|
||||
builder.addFieldInt16(1, width, 0);
|
||||
}
|
||||
|
||||
static addHeight(builder:flatbuffers.Builder, height:number) {
|
||||
builder.addFieldInt16(2, height, 0);
|
||||
}
|
||||
|
||||
static addRedrawRate(builder:flatbuffers.Builder, redrawRate:number) {
|
||||
builder.addFieldInt16(3, redrawRate, 0);
|
||||
}
|
||||
|
||||
static endSetup(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
|
||||
static createSetup(builder:flatbuffers.Builder, videoFormatOffset:flatbuffers.Offset, width:number, height:number, redrawRate:number):flatbuffers.Offset {
|
||||
Setup.startSetup(builder);
|
||||
Setup.addVideoFormat(builder, videoFormatOffset);
|
||||
Setup.addWidth(builder, width);
|
||||
Setup.addHeight(builder, height);
|
||||
Setup.addRedrawRate(builder, redrawRate);
|
||||
return Setup.endSetup(builder);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
import { DecodeUnit } from '../video-update/decode-unit.js';
|
||||
import { Setup } from '../video-update/setup.js';
|
||||
|
||||
|
||||
export enum Update {
|
||||
NONE = 0,
|
||||
Setup = 1,
|
||||
DecodeUnit = 2
|
||||
}
|
||||
|
||||
export function unionToUpdate(
|
||||
type: Update,
|
||||
accessor: (obj:DecodeUnit|Setup) => DecodeUnit|Setup|null
|
||||
): DecodeUnit|Setup|null {
|
||||
switch(Update[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'Setup': return accessor(new Setup())! as Setup;
|
||||
case 'DecodeUnit': return accessor(new DecodeUnit())! as DecodeUnit;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function unionListToUpdate(
|
||||
type: Update,
|
||||
accessor: (index: number, obj:DecodeUnit|Setup) => DecodeUnit|Setup|null,
|
||||
index: number
|
||||
): DecodeUnit|Setup|null {
|
||||
switch(Update[type]) {
|
||||
case 'NONE': return null;
|
||||
case 'Setup': return accessor(index, new Setup())! as Setup;
|
||||
case 'DecodeUnit': return accessor(index, new DecodeUnit())! as DecodeUnit;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
import { Update, unionToUpdate, unionListToUpdate } from '../video-update/update.js';
|
||||
|
||||
|
||||
export class VideoUpdate {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):VideoUpdate {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
static getRootAsVideoUpdate(bb:flatbuffers.ByteBuffer, obj?:VideoUpdate):VideoUpdate {
|
||||
return (obj || new VideoUpdate()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getSizePrefixedRootAsVideoUpdate(bb:flatbuffers.ByteBuffer, obj?:VideoUpdate):VideoUpdate {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new VideoUpdate()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
updateType():Update {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb!.readUint8(this.bb_pos + offset) : Update.NONE;
|
||||
}
|
||||
|
||||
update<T extends flatbuffers.Table>(obj:any):any|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 6);
|
||||
return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null;
|
||||
}
|
||||
|
||||
static startVideoUpdate(builder:flatbuffers.Builder) {
|
||||
builder.startObject(2);
|
||||
}
|
||||
|
||||
static addUpdateType(builder:flatbuffers.Builder, updateType:Update) {
|
||||
builder.addFieldInt8(0, updateType, Update.NONE);
|
||||
}
|
||||
|
||||
static addUpdate(builder:flatbuffers.Builder, updateOffset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(1, updateOffset, 0);
|
||||
}
|
||||
|
||||
static endVideoUpdate(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
|
||||
static finishVideoUpdateBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
|
||||
builder.finish(offset);
|
||||
}
|
||||
|
||||
static finishSizePrefixedVideoUpdateBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
|
||||
builder.finish(offset, undefined, true);
|
||||
}
|
||||
|
||||
static createVideoUpdate(builder:flatbuffers.Builder, updateType:Update, updateOffset:flatbuffers.Offset):flatbuffers.Offset {
|
||||
VideoUpdate.startVideoUpdate(builder);
|
||||
VideoUpdate.addUpdateType(builder, updateType);
|
||||
VideoUpdate.addUpdate(builder, updateOffset);
|
||||
return VideoUpdate.endVideoUpdate(builder);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
export * as VideoUpdate from './video-update.js';
|
||||
Reference in New Issue
Block a user