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.