From 0b2d61bbe58498994d24f074428df4c50beba658 Mon Sep 17 00:00:00 2001 From: "Eunen van, M (Micha)" Date: Tue, 13 Sep 2022 13:20:32 +0200 Subject: [PATCH] Sometimes the Apple metadata is stored as a String. This fix will prevent a ClassCastException --- .../metadata/apple/AppleRunTimeReader.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Source/com/drew/metadata/apple/AppleRunTimeReader.java b/Source/com/drew/metadata/apple/AppleRunTimeReader.java index 279b08053..97811f14b 100644 --- a/Source/com/drew/metadata/apple/AppleRunTimeReader.java +++ b/Source/com/drew/metadata/apple/AppleRunTimeReader.java @@ -67,13 +67,23 @@ private static void processAppleRunTime(@NotNull final AppleRunTimeMakernoteDire // https://developer.apple.com/documentation/coremedia/cmtime-u58 - byte flags = (Byte)values.get("flags"); - - if ((flags & 0x1) == 0x1) { - directory.setInt(AppleRunTimeMakernoteDirectory.CMTimeFlags, flags); - directory.setInt(AppleRunTimeMakernoteDirectory.CMTimeEpoch, (Byte)values.get("epoch")); - directory.setLong(AppleRunTimeMakernoteDirectory.CMTimeScale, (Long)values.get("timescale")); - directory.setLong(AppleRunTimeMakernoteDirectory.CMTimeValue, (Long)values.get("value")); + Object flagsObject = values.get("flags"); + if (flagsObject instanceof Byte) { + byte flags = (Byte) flagsObject; + if ((flags & 0x1) == 0x1) { + directory.setInt(AppleRunTimeMakernoteDirectory.CMTimeFlags, flags); + directory.setInt(AppleRunTimeMakernoteDirectory.CMTimeEpoch, (Byte) values.get("epoch")); + directory.setLong(AppleRunTimeMakernoteDirectory.CMTimeScale, (Long) values.get("timescale")); + directory.setLong(AppleRunTimeMakernoteDirectory.CMTimeValue, (Long) values.get("value")); + } + } else if (flagsObject instanceof String) { + byte flags = Byte.parseByte((String) flagsObject); + if ((flags & 0x1) == 0x1) { + directory.setInt(AppleRunTimeMakernoteDirectory.CMTimeFlags, flags); + directory.setInt(AppleRunTimeMakernoteDirectory.CMTimeEpoch, Byte.parseByte((String) values.get("epoch"))); + directory.setLong(AppleRunTimeMakernoteDirectory.CMTimeScale, Long.parseLong((String) values.get("timescale"))); + directory.setLong(AppleRunTimeMakernoteDirectory.CMTimeValue, Long.parseLong((String) values.get("value"))); + } } } }