org.mp4parser.boxes.iso14496.part12.ProgressiveDownloadInformationBox Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of isoparser Show documentation
Show all versions of isoparser Show documentation
A generic parser and writer for all ISO 14496 based files (MP4, Quicktime, DCF, PDCF, ...)
package org.mp4parser.boxes.iso14496.part12;
import org.mp4parser.support.AbstractFullBox;
import org.mp4parser.tools.IsoTypeReader;
import org.mp4parser.tools.IsoTypeWriter;
import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
/**
* 4cc = "{@value #TYPE}"
*/
public class ProgressiveDownloadInformationBox extends AbstractFullBox {
public static final String TYPE = "pdin";
List entries = Collections.emptyList();
public ProgressiveDownloadInformationBox() {
super(TYPE);
}
@Override
protected long getContentSize() {
return 4 + entries.size() * 8;
}
@Override
protected void getContent(ByteBuffer byteBuffer) {
writeVersionAndFlags(byteBuffer);
for (Entry entry : entries) {
IsoTypeWriter.writeUInt32(byteBuffer, entry.getRate());
IsoTypeWriter.writeUInt32(byteBuffer, entry.getInitialDelay());
}
}
public List getEntries() {
return entries;
}
public void setEntries(List entries) {
this.entries = entries;
}
@Override
public void _parseDetails(ByteBuffer content) {
parseVersionAndFlags(content);
entries = new LinkedList();
while (content.remaining() >= 8) {
Entry entry = new Entry(IsoTypeReader.readUInt32(content), IsoTypeReader.readUInt32(content));
entries.add(entry);
}
}
@Override
public String toString() {
return "ProgressiveDownloadInfoBox{" +
"entries=" + entries +
'}';
}
public static class Entry {
long rate;
long initialDelay;
public Entry(long rate, long initialDelay) {
this.rate = rate;
this.initialDelay = initialDelay;
}
public long getRate() {
return rate;
}
public void setRate(long rate) {
this.rate = rate;
}
public long getInitialDelay() {
return initialDelay;
}
public void setInitialDelay(long initialDelay) {
this.initialDelay = initialDelay;
}
@Override
public String toString() {
return "Entry{" +
"rate=" + rate +
", initialDelay=" + initialDelay +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Entry entry = (Entry) o;
if (initialDelay != entry.initialDelay) return false;
if (rate != entry.rate) return false;
return true;
}
@Override
public int hashCode() {
int result = (int) (rate ^ (rate >>> 32));
result = 31 * result + (int) (initialDelay ^ (initialDelay >>> 32));
return result;
}
}
}