Skip to content

Commit 09e9281

Browse files
authored
Various fixes (#3)
* feat: Sync with matroska v4 spec. * fix: Skips adding some element if no data was provided. * fix: Fix adding all tracks in the cue. We used to add only the track of the current frame when flushing, so it does not guarantee all tracks inclusion. With current approach we will have in a cluster all tracks on their first frame added. * fix: Fixes updating segment size on closing file. * fix: Updates tags entry creation. * feat: Adds duration in segment. * fix: Fixes Date computation.
1 parent 1299842 commit 09e9281

13 files changed

+172
-97
lines changed

src/main/java/org/ebml/DateElement.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
public class DateElement extends SignedIntegerElement
2626
{
2727
// const uint64 EbmlDate::UnixEpochDelay = 978307200; // 2001/01/01 00:00:00 UTC
28-
public static final long UnixEpochDelay = 978307200; // 2001/01/01 00:00:00 UTC
28+
public static final long UnixEpochDelay = 978307200000L; // 2001/01/01 00:00:00 UTC
2929
private static final int MIN_SIZE_LENGTH = 8;
3030

3131
public DateElement(final byte[] type)
@@ -40,18 +40,18 @@ public DateElement()
4040

4141
/**
4242
* Set the Date of this element
43-
*
43+
*
4444
* @param value Date to set
4545
*/
4646
public void setDate(final Date value)
4747
{
48-
final long val = (value.getTime() - UnixEpochDelay) * 1000000000;
48+
final long val = (value.getTime() - UnixEpochDelay) * 1000000;
4949
setData(ByteBuffer.wrap(packInt(val, MIN_SIZE_LENGTH)));
5050
}
5151

5252
/**
5353
* Get the Date value of this element
54-
*
54+
*
5555
* @return Date of this element
5656
*/
5757
public Date getDate()
@@ -61,7 +61,7 @@ public Date getDate()
6161
* long diff1 = start.getTime(); long diff2 = end.getTime(); long diff3 = Date.UTC(2001, 1, 1, 0, 0, 0) - Date.UTC(1970, 1, 1, 0, 0, 0);
6262
*/
6363
long val = getValue();
64-
val = val / 1000000000 + UnixEpochDelay;
64+
val = val / 1000000 + UnixEpochDelay;
6565
return new Date(val);
6666
}
6767

src/main/java/org/ebml/matroska/MatroskaDocType.java

+16-8
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ public enum MatroskaDocType
2222
DocTypeReadVersion(MatroskaDocTypes.DocTypeReadVersion),
2323
Void(MatroskaDocTypes.Void),
2424
CRC_32(MatroskaDocTypes.CRC_32),
25-
SignatureSlot(MatroskaDocTypes.SignatureSlot),
26-
SignatureAlgo(MatroskaDocTypes.SignatureAlgo),
27-
SignatureHash(MatroskaDocTypes.SignatureHash),
28-
SignaturePublicKey(MatroskaDocTypes.SignaturePublicKey),
29-
Signature(MatroskaDocTypes.Signature),
30-
SignatureElements(MatroskaDocTypes.SignatureElements),
31-
SignatureElementList(MatroskaDocTypes.SignatureElementList),
32-
SignedElement(MatroskaDocTypes.SignedElement),
3325
Segment(MatroskaDocTypes.Segment),
3426
SeekHead(MatroskaDocTypes.SeekHead),
3527
Seek(MatroskaDocTypes.Seek),
@@ -92,6 +84,11 @@ public enum MatroskaDocType
9284
FlagEnabled(MatroskaDocTypes.FlagEnabled),
9385
FlagDefault(MatroskaDocTypes.FlagDefault),
9486
FlagForced(MatroskaDocTypes.FlagForced),
87+
FlagHearingImpaired(MatroskaDocTypes.FlagHearingImpaired),
88+
FlagVisualImpaired(MatroskaDocTypes.FlagVisualImpaired),
89+
FlagTextDescriptions(MatroskaDocTypes.FlagTextDescriptions),
90+
FlagOriginal(MatroskaDocTypes.FlagOriginal),
91+
FlagCommentary(MatroskaDocTypes.FlagCommentary),
9592
FlagLacing(MatroskaDocTypes.FlagLacing),
9693
MinCache(MatroskaDocTypes.MinCache),
9794
MaxCache(MatroskaDocTypes.MaxCache),
@@ -100,6 +97,11 @@ public enum MatroskaDocType
10097
TrackTimecodeScale(MatroskaDocTypes.TrackTimecodeScale),
10198
TrackOffset(MatroskaDocTypes.TrackOffset),
10299
MaxBlockAdditionID(MatroskaDocTypes.MaxBlockAdditionID),
100+
BlockAdditionMapping(MatroskaDocTypes.BlockAdditionMapping),
101+
BlockAddIDValue(MatroskaDocTypes.BlockAddIDValue),
102+
BlockAddIDName(MatroskaDocTypes.BlockAddIDName),
103+
BlockAddIDType(MatroskaDocTypes.BlockAddIDType),
104+
BlockAddIDExtraData(MatroskaDocTypes.BlockAddIDExtraData),
103105
Name(MatroskaDocTypes.Name),
104106
Language(MatroskaDocTypes.Language),
105107
LanguageIETF(MatroskaDocTypes.LanguageIETF),
@@ -174,6 +176,7 @@ public enum MatroskaDocType
174176
Channels(MatroskaDocTypes.Channels),
175177
ChannelPositions(MatroskaDocTypes.ChannelPositions),
176178
BitDepth(MatroskaDocTypes.BitDepth),
179+
Emphasis(MatroskaDocTypes.Emphasis),
177180
TrackOperation(MatroskaDocTypes.TrackOperation),
178181
TrackCombinePlanes(MatroskaDocTypes.TrackCombinePlanes),
179182
TrackPlane(MatroskaDocTypes.TrackPlane),
@@ -234,6 +237,9 @@ public enum MatroskaDocType
234237
EditionFlagHidden(MatroskaDocTypes.EditionFlagHidden),
235238
EditionFlagDefault(MatroskaDocTypes.EditionFlagDefault),
236239
EditionFlagOrdered(MatroskaDocTypes.EditionFlagOrdered),
240+
EditionDisplay(MatroskaDocTypes.EditionDisplay),
241+
EditionString(MatroskaDocTypes.EditionString),
242+
EditionLanguageIETF(MatroskaDocTypes.EditionLanguageIETF),
237243
ChapterAtom(MatroskaDocTypes.ChapterAtom),
238244
ChapterUID(MatroskaDocTypes.ChapterUID),
239245
ChapterStringUID(MatroskaDocTypes.ChapterStringUID),
@@ -242,6 +248,7 @@ public enum MatroskaDocType
242248
ChapterFlagHidden(MatroskaDocTypes.ChapterFlagHidden),
243249
ChapterFlagEnabled(MatroskaDocTypes.ChapterFlagEnabled),
244250
ChapterSegmentUID(MatroskaDocTypes.ChapterSegmentUID),
251+
ChapterSkipType(MatroskaDocTypes.ChapterSkipType),
245252
ChapterSegmentEditionUID(MatroskaDocTypes.ChapterSegmentEditionUID),
246253
ChapterPhysicalEquiv(MatroskaDocTypes.ChapterPhysicalEquiv),
247254
ChapterTrack(MatroskaDocTypes.ChapterTrack),
@@ -271,6 +278,7 @@ public enum MatroskaDocType
271278
TagLanguage(MatroskaDocTypes.TagLanguage),
272279
TagLanguageIETF(MatroskaDocTypes.TagLanguageIETF),
273280
TagDefault(MatroskaDocTypes.TagDefault),
281+
TagDefaultBogus(MatroskaDocTypes.TagDefaultBogus),
274282
TagString(MatroskaDocTypes.TagString),
275283
TagBinary(MatroskaDocTypes.TagBinary),
276284
UNKNOWN(MatroskaDocTypes.Void); // Not a recognized element type

src/main/java/org/ebml/matroska/MatroskaDocTypes.java

+16-8
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@ public final class MatroskaDocTypes
2525
public static final ProtoType<UnsignedIntegerElement> DocTypeReadVersion = new ProtoType<>(UnsignedIntegerElement.class, "DocTypeReadVersion", new byte[] {(byte) 0x42, (byte) 0x85 }, 1);
2626
public static final ProtoType<BinaryElement> Void = new ProtoType<>(BinaryElement.class, "Void", new byte[] {(byte) 0xEC }, -1);
2727
public static final ProtoType<BinaryElement> CRC_32 = new ProtoType<>(BinaryElement.class, "CRC_32", new byte[] {(byte) 0xBF }, -1);
28-
public static final ProtoType<MasterElement> SignatureSlot = new ProtoType<>(MasterElement.class, "SignatureSlot", new byte[] {(byte) 0x1B, (byte) 0x53, (byte) 0x86, (byte) 0x67 }, -1);
29-
public static final ProtoType<UnsignedIntegerElement> SignatureAlgo = new ProtoType<>(UnsignedIntegerElement.class, "SignatureAlgo", new byte[] {(byte) 0x7E, (byte) 0x8A }, 1);
30-
public static final ProtoType<UnsignedIntegerElement> SignatureHash = new ProtoType<>(UnsignedIntegerElement.class, "SignatureHash", new byte[] {(byte) 0x7E, (byte) 0x9A }, 1);
31-
public static final ProtoType<BinaryElement> SignaturePublicKey = new ProtoType<>(BinaryElement.class, "SignaturePublicKey", new byte[] {(byte) 0x7E, (byte) 0xA5 }, 1);
32-
public static final ProtoType<BinaryElement> Signature = new ProtoType<>(BinaryElement.class, "Signature", new byte[] {(byte) 0x7E, (byte) 0xB5 }, 1);
33-
public static final ProtoType<MasterElement> SignatureElements = new ProtoType<>(MasterElement.class, "SignatureElements", new byte[] {(byte) 0x7E, (byte) 0x5B }, 1);
34-
public static final ProtoType<MasterElement> SignatureElementList = new ProtoType<>(MasterElement.class, "SignatureElementList", new byte[] {(byte) 0x7E, (byte) 0x7B }, 2);
35-
public static final ProtoType<BinaryElement> SignedElement = new ProtoType<>(BinaryElement.class, "SignedElement", new byte[] {(byte) 0x65, (byte) 0x32 }, 3);
3628
public static final ProtoType<MasterElement> Segment = new ProtoType<>(MasterElement.class, "Segment", new byte[] {(byte) 0x18, (byte) 0x53, (byte) 0x80, (byte) 0x67 }, 0);
3729
public static final ProtoType<MasterElement> SeekHead = new ProtoType<>(MasterElement.class, "SeekHead", new byte[] {(byte) 0x11, (byte) 0x4D, (byte) 0x9B, (byte) 0x74 }, 1);
3830
public static final ProtoType<MasterElement> Seek = new ProtoType<>(MasterElement.class, "Seek", new byte[] {(byte) 0x4D, (byte) 0xBB }, 2);
@@ -95,6 +87,11 @@ public final class MatroskaDocTypes
9587
public static final ProtoType<UnsignedIntegerElement> FlagEnabled = new ProtoType<>(UnsignedIntegerElement.class, "FlagEnabled", new byte[] {(byte) 0xB9 }, 3);
9688
public static final ProtoType<UnsignedIntegerElement> FlagDefault = new ProtoType<>(UnsignedIntegerElement.class, "FlagDefault", new byte[] {(byte) 0x88 }, 3);
9789
public static final ProtoType<UnsignedIntegerElement> FlagForced = new ProtoType<>(UnsignedIntegerElement.class, "FlagForced", new byte[] {(byte) 0x55, (byte) 0xAA }, 3);
90+
public static final ProtoType<UnsignedIntegerElement> FlagHearingImpaired = new ProtoType<>(UnsignedIntegerElement.class, "FlagHearingImpaired", new byte[] {(byte) 0x55, (byte) 0xAB }, 3);
91+
public static final ProtoType<UnsignedIntegerElement> FlagVisualImpaired = new ProtoType<>(UnsignedIntegerElement.class, "FlagVisualImpaired", new byte[] {(byte) 0x55, (byte) 0xAC }, 3);
92+
public static final ProtoType<UnsignedIntegerElement> FlagTextDescriptions = new ProtoType<>(UnsignedIntegerElement.class, "FlagTextDescriptions", new byte[] {(byte) 0x55, (byte) 0xAD }, 3);
93+
public static final ProtoType<UnsignedIntegerElement> FlagOriginal = new ProtoType<>(UnsignedIntegerElement.class, "FlagOriginal", new byte[] {(byte) 0x55, (byte) 0xAE }, 3);
94+
public static final ProtoType<UnsignedIntegerElement> FlagCommentary = new ProtoType<>(UnsignedIntegerElement.class, "FlagCommentary", new byte[] {(byte) 0x55, (byte) 0xAF }, 3);
9895
public static final ProtoType<UnsignedIntegerElement> FlagLacing = new ProtoType<>(UnsignedIntegerElement.class, "FlagLacing", new byte[] {(byte) 0x9C }, 3);
9996
public static final ProtoType<UnsignedIntegerElement> MinCache = new ProtoType<>(UnsignedIntegerElement.class, "MinCache", new byte[] {(byte) 0x6D, (byte) 0xE7 }, 3);
10097
public static final ProtoType<UnsignedIntegerElement> MaxCache = new ProtoType<>(UnsignedIntegerElement.class, "MaxCache", new byte[] {(byte) 0x6D, (byte) 0xF8 }, 3);
@@ -103,6 +100,11 @@ public final class MatroskaDocTypes
103100
public static final ProtoType<FloatElement> TrackTimecodeScale = new ProtoType<>(FloatElement.class, "TrackTimecodeScale", new byte[] {(byte) 0x23, (byte) 0x31, (byte) 0x4F }, 3);
104101
public static final ProtoType<SignedIntegerElement> TrackOffset = new ProtoType<>(SignedIntegerElement.class, "TrackOffset", new byte[] {(byte) 0x53, (byte) 0x7F }, 3);
105102
public static final ProtoType<UnsignedIntegerElement> MaxBlockAdditionID = new ProtoType<>(UnsignedIntegerElement.class, "MaxBlockAdditionID", new byte[] {(byte) 0x55, (byte) 0xEE }, 3);
103+
public static final ProtoType<UnsignedIntegerElement> BlockAdditionMapping = new ProtoType<>(UnsignedIntegerElement.class, "BlockAdditionMapping", new byte[] {(byte) 0x41, (byte) 0xE4 }, 3);
104+
public static final ProtoType<UnsignedIntegerElement> BlockAddIDValue = new ProtoType<>(UnsignedIntegerElement.class, "BlockAddIDValue", new byte[] {(byte) 0x41, (byte) 0xF0 }, 3);
105+
public static final ProtoType<UnsignedIntegerElement> BlockAddIDName = new ProtoType<>(UnsignedIntegerElement.class, "BlockAddIDName", new byte[] {(byte) 0x41, (byte) 0xA4 }, 3);
106+
public static final ProtoType<UnsignedIntegerElement> BlockAddIDType = new ProtoType<>(UnsignedIntegerElement.class, "BlockAddIDType", new byte[] {(byte) 0x41, (byte) 0xE7 }, 3);
107+
public static final ProtoType<UnsignedIntegerElement> BlockAddIDExtraData = new ProtoType<>(UnsignedIntegerElement.class, "BlockAddIDExtraData", new byte[] {(byte) 0x41, (byte) 0xED }, 3);
106108
public static final ProtoType<UTF8StringElement> Name = new ProtoType<>(UTF8StringElement.class, "Name", new byte[] {(byte) 0x53, (byte) 0x6E }, 3);
107109
public static final ProtoType<StringElement> Language = new ProtoType<>(StringElement.class, "Language", new byte[] {(byte) 0x22, (byte) 0xB5, (byte) 0x9C }, 3);
108110
public static final ProtoType<StringElement> LanguageIETF = new ProtoType<>(StringElement.class, "LanguageIETF", new byte[] {(byte) 0x22, (byte) 0xB5, (byte) 0x9D }, 3);
@@ -177,6 +179,7 @@ public final class MatroskaDocTypes
177179
public static final ProtoType<UnsignedIntegerElement> Channels = new ProtoType<>(UnsignedIntegerElement.class, "Channels", new byte[] {(byte) 0x9F }, 4);
178180
public static final ProtoType<BinaryElement> ChannelPositions = new ProtoType<>(BinaryElement.class, "ChannelPositions", new byte[] {(byte) 0x7D, (byte) 0x7B }, 4);
179181
public static final ProtoType<UnsignedIntegerElement> BitDepth = new ProtoType<>(UnsignedIntegerElement.class, "BitDepth", new byte[] {(byte) 0x62, (byte) 0x64 }, 4);
182+
public static final ProtoType<UnsignedIntegerElement> Emphasis = new ProtoType<>(UnsignedIntegerElement.class, "Emphasis", new byte[] {(byte) 0x52, (byte) 0xF1 }, 4);
180183
public static final ProtoType<MasterElement> TrackOperation = new ProtoType<>(MasterElement.class, "TrackOperation", new byte[] {(byte) 0xE2 }, 3);
181184
public static final ProtoType<MasterElement> TrackCombinePlanes = new ProtoType<>(MasterElement.class, "TrackCombinePlanes", new byte[] {(byte) 0xE3 }, 4);
182185
public static final ProtoType<MasterElement> TrackPlane = new ProtoType<>(MasterElement.class, "TrackPlane", new byte[] {(byte) 0xE4 }, 5);
@@ -237,6 +240,9 @@ public final class MatroskaDocTypes
237240
public static final ProtoType<UnsignedIntegerElement> EditionFlagHidden = new ProtoType<>(UnsignedIntegerElement.class, "EditionFlagHidden", new byte[] {(byte) 0x45, (byte) 0xBD }, 3);
238241
public static final ProtoType<UnsignedIntegerElement> EditionFlagDefault = new ProtoType<>(UnsignedIntegerElement.class, "EditionFlagDefault", new byte[] {(byte) 0x45, (byte) 0xDB }, 3);
239242
public static final ProtoType<UnsignedIntegerElement> EditionFlagOrdered = new ProtoType<>(UnsignedIntegerElement.class, "EditionFlagOrdered", new byte[] {(byte) 0x45, (byte) 0xDD }, 3);
243+
public static final ProtoType<UnsignedIntegerElement> EditionDisplay = new ProtoType<>(UnsignedIntegerElement.class, "EditionDisplay", new byte[] {(byte) 0x45, (byte) 0x20 }, 3);
244+
public static final ProtoType<UnsignedIntegerElement> EditionString = new ProtoType<>(UnsignedIntegerElement.class, "EditionString", new byte[] {(byte) 0x45, (byte) 0x21 }, 3);
245+
public static final ProtoType<UnsignedIntegerElement> EditionLanguageIETF = new ProtoType<>(UnsignedIntegerElement.class, "EditionLanguageIETF", new byte[] {(byte) 0x45, (byte) 0xE4 }, 3);
240246
public static final ProtoType<MasterElement> ChapterAtom = new ProtoType<>(MasterElement.class, "ChapterAtom", new byte[] {(byte) 0xB6 }, 3);
241247
public static final ProtoType<UnsignedIntegerElement> ChapterUID = new ProtoType<>(UnsignedIntegerElement.class, "ChapterUID", new byte[] {(byte) 0x73, (byte) 0xC4 }, 4);
242248
public static final ProtoType<UTF8StringElement> ChapterStringUID = new ProtoType<>(UTF8StringElement.class, "ChapterStringUID", new byte[] {(byte) 0x56, (byte) 0x54 }, 4);
@@ -245,6 +251,7 @@ public final class MatroskaDocTypes
245251
public static final ProtoType<UnsignedIntegerElement> ChapterFlagHidden = new ProtoType<>(UnsignedIntegerElement.class, "ChapterFlagHidden", new byte[] {(byte) 0x98 }, 4);
246252
public static final ProtoType<UnsignedIntegerElement> ChapterFlagEnabled = new ProtoType<>(UnsignedIntegerElement.class, "ChapterFlagEnabled", new byte[] {(byte) 0x45, (byte) 0x98 }, 4);
247253
public static final ProtoType<BinaryElement> ChapterSegmentUID = new ProtoType<>(BinaryElement.class, "ChapterSegmentUID", new byte[] {(byte) 0x6E, (byte) 0x67 }, 4);
254+
public static final ProtoType<BinaryElement> ChapterSkipType = new ProtoType<>(BinaryElement.class, "ChapterSkipType", new byte[] {(byte) 0x45, (byte) 0x88 }, 4);
248255
public static final ProtoType<UnsignedIntegerElement> ChapterSegmentEditionUID = new ProtoType<>(UnsignedIntegerElement.class, "ChapterSegmentEditionUID", new byte[] {(byte) 0x6E, (byte) 0xBC }, 4);
249256
public static final ProtoType<UnsignedIntegerElement> ChapterPhysicalEquiv = new ProtoType<>(UnsignedIntegerElement.class, "ChapterPhysicalEquiv", new byte[] {(byte) 0x63, (byte) 0xC3 }, 4);
250257
public static final ProtoType<MasterElement> ChapterTrack = new ProtoType<>(MasterElement.class, "ChapterTrack", new byte[] {(byte) 0x8F }, 4);
@@ -274,6 +281,7 @@ public final class MatroskaDocTypes
274281
public static final ProtoType<StringElement> TagLanguage = new ProtoType<>(StringElement.class, "TagLanguage", new byte[] {(byte) 0x44, (byte) 0x7A }, 4);
275282
public static final ProtoType<StringElement> TagLanguageIETF = new ProtoType<>(StringElement.class, "TagLanguageIETF", new byte[] {(byte) 0x44, (byte) 0x7B }, 4);
276283
public static final ProtoType<UnsignedIntegerElement> TagDefault = new ProtoType<>(UnsignedIntegerElement.class, "TagDefault", new byte[] {(byte) 0x44, (byte) 0x84 }, 4);
284+
public static final ProtoType<UnsignedIntegerElement> TagDefaultBogus = new ProtoType<>(UnsignedIntegerElement.class, "TagDefaultBogus", new byte[] {(byte) 0x44, (byte) 0xB4 }, 4);
277285
public static final ProtoType<UTF8StringElement> TagString = new ProtoType<>(UTF8StringElement.class, "TagString", new byte[] {(byte) 0x44, (byte) 0x87 }, 4);
278286
public static final ProtoType<BinaryElement> TagBinary = new ProtoType<>(BinaryElement.class, "TagBinary", new byte[] {(byte) 0x44, (byte) 0x85 }, 4);
279287

src/main/java/org/ebml/matroska/MatroskaFile.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -448,10 +448,13 @@ private synchronized void fillFrameQueue()
448448
{
449449
parseNextCluster(level1);
450450
clusterReadIndex++;
451+
level1.skipData(ioDS);
451452
}
452453

453-
level1.skipData(ioDS);
454-
level1 = ((MasterElement) level0).readNextChild(reader);
454+
if (frameQueue.isEmpty())
455+
{
456+
level1 = ((MasterElement) level0).readNextChild(reader);
457+
}
455458
}
456459
}
457460

src/main/java/org/ebml/matroska/MatroskaFileCues.java

+3-8
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,20 @@ private MasterElement createCueTrackPositions(long positionInFile, int trackNumb
4545
cueTrackPositions.addChildElement(cueTrack);
4646

4747
UnsignedIntegerElement cueClusterPosition = MatroskaDocTypes.CueClusterPosition.getInstance();
48-
cueClusterPosition.setValue(getPositionRelativeToSegmentEbmlElement(positionInFile));
48+
cueClusterPosition.setValue(positionInFile - endOfEbmlHeaderBytePosition);
4949
cueTrackPositions.addChildElement(cueClusterPosition);
5050

5151
return cueTrackPositions;
5252
}
5353

54-
public Element write(DataWriter ioDW, MatroskaFileMetaSeek metaSeek)
54+
public long write(DataWriter ioDW, MatroskaFileMetaSeek metaSeek)
5555
{
5656
long currentBytePositionInFile = ioDW.getFilePointer();
5757
LOG.debug("Writing matroska cues at file byte position [{}]", currentBytePositionInFile);
5858
long numberOfBytesInCueData = cues.writeElement(ioDW);
5959
LOG.debug("Done writing matroska cues, number of bytes was [{}]", numberOfBytesInCueData);
6060

6161
metaSeek.addIndexedElement(cues, currentBytePositionInFile);
62-
return cues;
63-
}
64-
65-
private long getPositionRelativeToSegmentEbmlElement(long currentBytePositionInFile)
66-
{
67-
return currentBytePositionInFile - endOfEbmlHeaderBytePosition;
62+
return numberOfBytesInCueData;
6863
}
6964
}

src/main/java/org/ebml/matroska/MatroskaFileMetaSeek.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,16 @@ public long write(final DataWriter ioDW)
5353
*
5454
* @param ioDW the data stream containing this object
5555
*/
56-
public void update(final DataWriter ioDW)
56+
public long update(final DataWriter ioDW)
5757
{
5858
assert ioDW.isSeekable();
5959
final long pos = ioDW.getFilePointer();
6060
ioDW.seek(myPosition);
61-
write(ioDW);
61+
long len = write(ioDW);
6262
ioDW.seek(pos);
6363
LOG.debug("Updated metaseek section.");
64+
65+
return len;
6466
}
6567

6668
/**

src/main/java/org/ebml/matroska/MatroskaFileTagEntry.java

+22
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public class MatroskaFileTagEntry
3333
public ArrayList<Long> trackUID = new ArrayList<>();
3434
public ArrayList<Long> chapterUID = new ArrayList<>();
3535
public ArrayList<Long> attachmentUID = new ArrayList<>();
36+
public ArrayList<Long> editionUID = new ArrayList<>();
37+
3638
public List<MatroskaFileSimpleTag> simpleTags = new ArrayList<>();
3739

3840
public void addSimpleTag(final MatroskaFileSimpleTag simpleTag)
@@ -45,6 +47,26 @@ Element toElement()
4547
MasterElement tagEntryElem = MatroskaDocTypes.Tag.getInstance();
4648

4749
MasterElement targetsEntryElem = MatroskaDocTypes.Targets.getInstance();
50+
trackUID.forEach((uid) -> {
51+
UnsignedIntegerElement trackUIDElem = MatroskaDocTypes.TagTrackUID.getInstance();
52+
trackUIDElem.setValue(uid);
53+
targetsEntryElem.addChildElement(trackUIDElem);
54+
});
55+
chapterUID.forEach((uid) -> {
56+
UnsignedIntegerElement chapterUIDElem = MatroskaDocTypes.TagChapterUID.getInstance();
57+
chapterUIDElem.setValue(uid);
58+
targetsEntryElem.addChildElement(chapterUIDElem);
59+
});
60+
attachmentUID.forEach((uid) -> {
61+
UnsignedIntegerElement attachmentUIDElem = MatroskaDocTypes.TagAttachmentUID.getInstance();
62+
attachmentUIDElem.setValue(uid);
63+
targetsEntryElem.addChildElement(attachmentUIDElem);
64+
});
65+
editionUID.forEach((uid) -> {
66+
UnsignedIntegerElement editionUIDElem = MatroskaDocTypes.TagEditionUID.getInstance();
67+
editionUIDElem.setValue(uid);
68+
targetsEntryElem.addChildElement(editionUIDElem);
69+
});
4870
tagEntryElem.addChildElement(targetsEntryElem);
4971

5072
for (MatroskaFileSimpleTag simpleTag : simpleTags)

0 commit comments

Comments
 (0)