diff --git a/mediapipe/java/com/google/mediapipe/framework/PacketGetter.java b/mediapipe/java/com/google/mediapipe/framework/PacketGetter.java index 5ea12872a..3d6b16ce6 100644 --- a/mediapipe/java/com/google/mediapipe/framework/PacketGetter.java +++ b/mediapipe/java/com/google/mediapipe/framework/PacketGetter.java @@ -128,6 +128,16 @@ public final class PacketGetter { return ProtoUtil.unpack(result, defaultInstance); } + public static T getProto(final Packet packet, Parser messageParser) { + SerializedMessage result = new SerializedMessage(); + nativeGetProto(packet.getNativeHandle(), result); + try { + return messageParser.parseFrom(result.value); + } catch (InvalidProtocolBufferException e) { + throw new IllegalArgumentException(e); + } + } + /** * @deprecated {@link #getProto(Packet, MessageLite)} is safer to use in obfuscated builds. */