mirror of
https://github.com/jwetzell/ddp-js.git
synced 2026-07-26 09:58:41 +00:00
add timecode field to encoding
This commit is contained in:
@@ -174,6 +174,15 @@ export function encode(packet: DDPPacket): Uint8Array {
|
|||||||
view.setUint32(4, packet.header.dataOffset);
|
view.setUint32(4, packet.header.dataOffset);
|
||||||
view.setUint16(8, packet.header.dataLength);
|
view.setUint16(8, packet.header.dataLength);
|
||||||
|
|
||||||
|
if(packet.header.flags.timecode){
|
||||||
|
if(packet.header.timecode !== undefined){
|
||||||
|
view.setUint16(10, packet.header.timecode?.seconds)
|
||||||
|
view.setUint16(12, packet.header.timecode?.fractionalSeconds)
|
||||||
|
}else{
|
||||||
|
throw new Error("DDP packet had timecode flag set but no timecode value supplied")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// const bytes = new Uint8Array([flagByte, sequenceNumberByte, dataTypeByte, packet.header.sourceOrDestinationID])
|
// const bytes = new Uint8Array([flagByte, sequenceNumberByte, dataTypeByte, packet.header.sourceOrDestinationID])
|
||||||
const headerBytes = new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
|
const headerBytes = new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,36 @@ const goodTests = [
|
|||||||
data: new Uint8Array([]),
|
data: new Uint8Array([]),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: 'DDP packet with timecode',
|
||||||
|
expected: new Uint8Array([0x50, 0x0f, 0x92, 0x01, 0x45, 0x67, 0x89, 0x10, 0x10, 0x11, 0x10, 0x11, 0x11, 0x10]),
|
||||||
|
packet: {
|
||||||
|
header: {
|
||||||
|
flags: {
|
||||||
|
version: 1,
|
||||||
|
timecode: true,
|
||||||
|
storage: false,
|
||||||
|
reply: false,
|
||||||
|
query: false,
|
||||||
|
push: false,
|
||||||
|
},
|
||||||
|
sequenceNumber: 15,
|
||||||
|
dataType: {
|
||||||
|
standard: false,
|
||||||
|
type: 2,
|
||||||
|
bitsPerPixel: 4,
|
||||||
|
},
|
||||||
|
sourceOrDestinationID: 1,
|
||||||
|
dataOffset: 1164413200,
|
||||||
|
dataLength: 4113,
|
||||||
|
timecode: {
|
||||||
|
seconds: 4113,
|
||||||
|
fractionalSeconds: 4368,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data: new Uint8Array([]),
|
||||||
|
},
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const badTests = [];
|
const badTests = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user