Skip to content

Commit

Permalink
Sometimes the Apple metadata is stored as a String. This fix will pre…
Browse files Browse the repository at this point in the history
…vent a ClassCastException
  • Loading branch information
Eunen van, M (Micha) authored and Eunen van, M (Micha) committed Sep 13, 2022
1 parent dca7468 commit 0b2d61b
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions Source/com/drew/metadata/apple/AppleRunTimeReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")));
}
}
}
}
Expand Down

0 comments on commit 0b2d61b

Please sign in to comment.