@Test public void testAddTimingCode() { final FrameBodyETCO body = new FrameBodyETCO(); body.addTimingCode(10, 0); body.addTimingCode(5, 0); body.addTimingCode(5, 1); body.addTimingCode(11, 1, 2); final Map<Long, int[]> timingCodes = body.getTimingCodes(); Assert.assertTrue(Arrays.equals(new int[]{0}, timingCodes.get(10L))); Assert.assertTrue(Arrays.equals(new int[]{0, 1}, timingCodes.get(5L))); Assert.assertTrue(Arrays.equals(new int[]{1, 2}, timingCodes.get(11L))); long lastTimestamp = 0; for (final Long timestamp : timingCodes.keySet()) { Assert.assertTrue(timestamp >= lastTimestamp); lastTimestamp = timestamp; } }
public void addTimingCode(final long timestamp, final int... types) { final List<EventTimingCode> codes = (List<EventTimingCode>)getObjectValue(DataTypes.OBJ_TIMED_EVENT_LIST); long lastTimestamp = 0; int insertIndex = 0; if (!codes.isEmpty() && codes.get(0).getTimestamp() <= timestamp) { for (final EventTimingCode code : codes) { final long translatedTimestamp = code.getTimestamp() == 0 ? lastTimestamp : code.getTimestamp(); if (timestamp < translatedTimestamp) { break; } insertIndex++; lastTimestamp = translatedTimestamp; } } for (final int type : types) { codes.add(insertIndex, new EventTimingCode(DataTypes.OBJ_TIMED_EVENT, this, type, timestamp)); insertIndex++; } }
FrameBodyETCO extends AbstractID3v2FrameBody implements ID3v24FrameBody, ID3v23FrameBody { public void addTimingCode(final long timestamp, final int... types) { final List<EventTimingCode> codes = (List<EventTimingCode>)getObjectValue(DataTypes.OBJ_TIMED_EVENT_LIST); long lastTimestamp = 0; int insertIndex = 0; if (!codes.isEmpty() && codes.get(0).getTimestamp() <= timestamp) { for (final EventTimingCode code : codes) { final long translatedTimestamp = code.getTimestamp() == 0 ? lastTimestamp : code.getTimestamp(); if (timestamp < translatedTimestamp) { break; } insertIndex++; lastTimestamp = translatedTimestamp; } } for (final int type : types) { codes.add(insertIndex, new EventTimingCode(DataTypes.OBJ_TIMED_EVENT, this, type, timestamp)); insertIndex++; } } }
FrameBodyETCO extends AbstractID3v2FrameBody implements ID3v24FrameBody, ID3v23FrameBody { public void addTimingCode(final long timestamp, final int... types) { final List<EventTimingCode> codes = (List<EventTimingCode>)getObjectValue(DataTypes.OBJ_TIMED_EVENT_LIST); long lastTimestamp = 0; int insertIndex = 0; if (!codes.isEmpty() && codes.get(0).getTimestamp() <= timestamp) { for (final EventTimingCode code : codes) { final long translatedTimestamp = code.getTimestamp() == 0 ? lastTimestamp : code.getTimestamp(); if (timestamp < translatedTimestamp) { break; } insertIndex++; lastTimestamp = translatedTimestamp; } } for (final int type : types) { codes.add(insertIndex, new EventTimingCode(DataTypes.OBJ_TIMED_EVENT, this, type, timestamp)); insertIndex++; } } FrameBodyETCO();  FrameBodyETCO(final FrameBodyETCO body);  FrameBodyETCO(final ByteBuffer byteBuffer, final int frameSize);  FrameBodyETCO(final Buffer byteBuffer, final int frameSize); }
FrameBodyETCO extends AbstractID3v2FrameBody implements ID3v24FrameBody, ID3v23FrameBody { public void addTimingCode(final long timestamp, final int... types) { final List<EventTimingCode> codes = (List<EventTimingCode>)getObjectValue(DataTypes.OBJ_TIMED_EVENT_LIST); long lastTimestamp = 0; int insertIndex = 0; if (!codes.isEmpty() && codes.get(0).getTimestamp() <= timestamp) { for (final EventTimingCode code : codes) { final long translatedTimestamp = code.getTimestamp() == 0 ? lastTimestamp : code.getTimestamp(); if (timestamp < translatedTimestamp) { break; } insertIndex++; lastTimestamp = translatedTimestamp; } } for (final int type : types) { codes.add(insertIndex, new EventTimingCode(DataTypes.OBJ_TIMED_EVENT, this, type, timestamp)); insertIndex++; } } FrameBodyETCO();  FrameBodyETCO(final FrameBodyETCO body);  FrameBodyETCO(final ByteBuffer byteBuffer, final int frameSize);  FrameBodyETCO(final Buffer byteBuffer, final int frameSize); int getTimestampFormat(); void setTimestampFormat(final int timestampFormat); Map<Long, int[]> getTimingCodes(); List<Long> getTimestamps(final int... type); void addTimingCode(final long timestamp, final int... types); boolean removeTimingCode(final long timestamp, final int... types); void clearTimingCodes(); @Override void read(final ByteBuffer byteBuffer); @Override String getIdentifier(); }
FrameBodyETCO extends AbstractID3v2FrameBody implements ID3v24FrameBody, ID3v23FrameBody { public void addTimingCode(final long timestamp, final int... types) { final List<EventTimingCode> codes = (List<EventTimingCode>)getObjectValue(DataTypes.OBJ_TIMED_EVENT_LIST); long lastTimestamp = 0; int insertIndex = 0; if (!codes.isEmpty() && codes.get(0).getTimestamp() <= timestamp) { for (final EventTimingCode code : codes) { final long translatedTimestamp = code.getTimestamp() == 0 ? lastTimestamp : code.getTimestamp(); if (timestamp < translatedTimestamp) { break; } insertIndex++; lastTimestamp = translatedTimestamp; } } for (final int type : types) { codes.add(insertIndex, new EventTimingCode(DataTypes.OBJ_TIMED_EVENT, this, type, timestamp)); insertIndex++; } } FrameBodyETCO();  FrameBodyETCO(final FrameBodyETCO body);  FrameBodyETCO(final ByteBuffer byteBuffer, final int frameSize);  FrameBodyETCO(final Buffer byteBuffer, final int frameSize); int getTimestampFormat(); void setTimestampFormat(final int timestampFormat); Map<Long, int[]> getTimingCodes(); List<Long> getTimestamps(final int... type); void addTimingCode(final long timestamp, final int... types); boolean removeTimingCode(final long timestamp, final int... types); void clearTimingCodes(); @Override void read(final ByteBuffer byteBuffer); @Override String getIdentifier(); static final int MPEG_FRAMES; static final int MILLISECONDS; }