-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: detect duplicate resource ids in virtual track #350
base: master
Are you sure you want to change the base?
Feature: detect duplicate resource ids in virtual track #350
Conversation
…ot include the hash. If different hashing algorithms are used for different resources, they could result in the same hash value.
return false; | ||
} | ||
IMFTrackFileResourceType otherImfTrackFileResourceType = (IMFTrackFileResourceType) o; | ||
return equivalent(otherImfTrackFileResourceType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a good idea to keep fields used in the implementation of equals and hashCode identical to each other. In this case, if the equivalent method implementation goes through some changes then equals and hashcode will not match.
@@ -236,6 +226,25 @@ private static Map<UUID, List<IMFBaseResourceType>> getVirtualTrackResourceMap(@ | |||
if (virtualTrackResourceMap.get(uuid) == null) { | |||
virtualTrackResourceMap.put(uuid, new ArrayList<IMFBaseResourceType>()); | |||
} | |||
/* | |||
Ensure that no two resources use the same ID, unless they are the same resource. ST-2067-3:2020, 6.11.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on this statement the equals and hashcode methods for the resource should include all the elements defined in the resource.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the PR so that the equals and hashcode methods include all elements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would interpret 6.11.1 as meaning that Resource IDs are unique throughout the entire composition:
"No two Resouces shall have the same ID value unless they are identical."
It looks like this check is limited to detecting duplicates only within the same Sequence.
As a practical matter, that is generally good enough. But I believe there are other possible scenarios that this check would still miss.
Spec says:
"The Id element shall identify this specific Resource instance. The means of identifying the underlying Asset is
left to subclasses. No two Resouces shall have the same ID value unless they are identical."
This is not currently being enforced. This PR adds a check for this condition.