From 945b36766cf767d14a37231f34b6307d8e9212b9 Mon Sep 17 00:00:00 2001 From: MediaPipe Team Date: Thu, 2 Mar 2023 13:49:39 -0800 Subject: [PATCH] Let web API add empty packets to input streams PiperOrigin-RevId: 513630040 --- mediapipe/web/graph_runner/graph_runner.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/mediapipe/web/graph_runner/graph_runner.ts b/mediapipe/web/graph_runner/graph_runner.ts index eaec5c49..cda7f77a 100644 --- a/mediapipe/web/graph_runner/graph_runner.ts +++ b/mediapipe/web/graph_runner/graph_runner.ts @@ -80,6 +80,9 @@ export declare interface WasmModule { _addProtoToInputStream: (dataPtr: number, dataSize: number, protoNamePtr: number, streamNamePtr: number, timestamp: number) => void; + _addEmptyPacketToInputStream: + (streamNamePtr: number, timestamp: number) => void; + // Input side packets _addBoolToInputSidePacket: (data: boolean, 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. * @param data The boolean data to send.