Let web API add empty packets to input streams

PiperOrigin-RevId: 513630040
This commit is contained in:
MediaPipe Team 2023-03-02 13:49:39 -08:00 committed by Copybara-Service
parent 0ba35cf1a7
commit 945b36766c

View File

@ -80,6 +80,9 @@ export declare interface WasmModule {
_addProtoToInputStream: _addProtoToInputStream:
(dataPtr: number, dataSize: number, protoNamePtr: number, (dataPtr: number, dataSize: number, protoNamePtr: number,
streamNamePtr: number, timestamp: number) => void; streamNamePtr: number, timestamp: number) => void;
_addEmptyPacketToInputStream:
(streamNamePtr: number, timestamp: number) => void;
// Input side packets // Input side packets
_addBoolToInputSidePacket: (data: boolean, streamNamePtr: number) => void; _addBoolToInputSidePacket: (data: boolean, streamNamePtr: number) => void;
_addDoubleToInputSidePacket: (data: number, streamNamePtr: number) => void; _addDoubleToInputSidePacket: (data: number, streamNamePtr: number) => void;
@ -682,6 +685,20 @@ export class GraphRunner {
}); });
} }
/**
* Sends an empty packet into the specified stream at the given timestamp,
* effectively advancing that input stream's timestamp bounds without
* sending additional data packets.
* @param streamName The name of the graph input stream to send the empty
* packet into.
* @param timestamp The timestamp of the empty packet, in ms.
*/
addEmptyPacketToStream(streamName: string, timestamp: number): void {
this.wrapStringPtr(streamName, (streamNamePtr: number) => {
this.wasmModule._addEmptyPacketToInputStream(streamNamePtr, timestamp);
});
}
/** /**
* Attaches a boolean packet to the specified input_side_packet. * Attaches a boolean packet to the specified input_side_packet.
* @param data The boolean data to send. * @param data The boolean data to send.