-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #455 from drewnoakes/uuid
Add support for MP4 UUID and MOV XMP boxes
- Loading branch information
Showing
12 changed files
with
306 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2002-2019 Drew Noakes and contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* More information about this project is available at: | ||
* | ||
* https://drewnoakes.com/code/exif/ | ||
* https://github.com/drewnoakes/metadata-extractor | ||
*/ | ||
package com.drew.metadata.mp4.boxes; | ||
|
||
import com.drew.lang.SequentialReader; | ||
import com.drew.metadata.mp4.Mp4BoxTypes; | ||
import com.drew.metadata.mp4.Mp4Directory; | ||
|
||
import java.io.IOException; | ||
import java.nio.ByteBuffer; | ||
import java.util.UUID; | ||
|
||
import static com.drew.metadata.mp4.media.Mp4UuidBoxDirectory.*; | ||
|
||
public class UuidBox extends Box | ||
{ | ||
private byte[] userData; | ||
|
||
public UuidBox(SequentialReader reader, Box box) throws IOException | ||
{ | ||
super(box); | ||
|
||
if (type.equals(Mp4BoxTypes.BOX_USER_DEFINED)) { | ||
usertype = getUuid(reader.getBytes(16)); | ||
} | ||
|
||
userData = reader.getBytes(reader.available()); | ||
} | ||
|
||
public void addMetadata(Mp4Directory directory) | ||
{ | ||
directory.setString(TAG_UUID, usertype); | ||
directory.setByteArray(TAG_USER_DATA, userData); | ||
} | ||
|
||
private String getUuid(byte[] bytes) { | ||
ByteBuffer bb = ByteBuffer.wrap(bytes); | ||
UUID uuid = new UUID(bb.getLong(), bb.getLong()); | ||
|
||
return uuid.toString(); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
Source/com/drew/metadata/mp4/media/Mp4UuidBoxDescriptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2002-2019 Drew Noakes and contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* More information about this project is available at: | ||
* | ||
* https://drewnoakes.com/code/exif/ | ||
* https://github.com/drewnoakes/metadata-extractor | ||
*/ | ||
package com.drew.metadata.mp4.media; | ||
|
||
import com.drew.metadata.TagDescriptor; | ||
|
||
public class Mp4UuidBoxDescriptor extends TagDescriptor<Mp4UuidBoxDirectory> | ||
{ | ||
public Mp4UuidBoxDescriptor(Mp4UuidBoxDirectory directory) | ||
{ | ||
super(directory); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
Source/com/drew/metadata/mp4/media/Mp4UuidBoxDirectory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2002-2019 Drew Noakes and contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* More information about this project is available at: | ||
* | ||
* https://drewnoakes.com/code/exif/ | ||
* https://github.com/drewnoakes/metadata-extractor | ||
*/ | ||
package com.drew.metadata.mp4.media; | ||
|
||
import com.drew.lang.annotations.NotNull; | ||
|
||
import java.util.HashMap; | ||
|
||
public class Mp4UuidBoxDirectory extends Mp4MediaDirectory | ||
{ | ||
public static final Integer TAG_UUID = 901; | ||
public static final Integer TAG_USER_DATA = 902; | ||
|
||
@NotNull | ||
private static final HashMap<Integer, String> _tagNameMap = new HashMap<Integer, String>(); | ||
|
||
static | ||
{ | ||
Mp4UuidBoxDirectory.addMp4MediaTags(_tagNameMap); | ||
_tagNameMap.put(TAG_UUID, "uuid"); | ||
_tagNameMap.put(TAG_USER_DATA, "data"); | ||
} | ||
|
||
public Mp4UuidBoxDirectory() | ||
{ | ||
this.setDescriptor(new Mp4UuidBoxDescriptor(this)); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String getName() | ||
{ | ||
return "UUID"; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
protected HashMap<Integer, String> getTagNameMap() | ||
{ | ||
return _tagNameMap; | ||
} | ||
} |
Oops, something went wrong.