本文整理汇总了Java中org.mp4parser.boxes.sampleentry.SampleEntry类的典型用法代码示例。如果您正苦于以下问题:Java SampleEntry类的具体用法?Java SampleEntry怎么用?Java SampleEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SampleEntry类属于org.mp4parser.boxes.sampleentry包,在下文中一共展示了SampleEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFormat
import org.mp4parser.boxes.sampleentry.SampleEntry; //导入依赖的package包/类
public static String getFormat(Track track) {
List<SampleEntry> ses = track.getSampleEntries();
String format = null;
for (SampleEntry se : ses) {
OriginalFormatBox frma = Path.getPath((Container) se, "sinf/frma");
if (frma != null) {
if (format == null || format.equals(frma.getDataFormat())) {
format = frma.getDataFormat();
} else {
throw new RuntimeException("cant determine format of track");
}
} else {
if (format == null || format.equals(se.getType())) {
format = se.getType();
} else {
throw new RuntimeException("cant determine format of track");
}
}
}
return format;
}
示例2: Avc1ToAvc3TrackImpl
import org.mp4parser.boxes.sampleentry.SampleEntry; //导入依赖的package包/类
public Avc1ToAvc3TrackImpl(Track parent) throws IOException {
super(parent);
for (SampleEntry sampleEntry : parent.getSampleEntries()) {
if (sampleEntry.getType().equals("avc1")) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
// This creates a copy cause I can't change the original instance
sampleEntry.getBox(Channels.newChannel(baos));
VisualSampleEntry avc3SampleEntry = (VisualSampleEntry) new IsoFile(new ByteBufferByteChannel(ByteBuffer.wrap(baos.toByteArray()))).getBoxes().get(0);
avc3SampleEntry.setType("avc3");
avc1toavc3.put(sampleEntry, avc3SampleEntry);
} catch (IOException e) {
throw new RuntimeException("Dumping sample entry to memory failed");
}
} else {
avc1toavc3.put(sampleEntry, sampleEntry);
}
}
samples = new ReplaceSyncSamplesList(parent.getSamples());
}
示例3: CencEncryptingSampleList
import org.mp4parser.boxes.sampleentry.SampleEntry; //导入依赖的package包/类
public CencEncryptingSampleList(
RangeStartMap<Integer, KeyIdKeyPair> keys,
RangeStartMap<Integer, SampleEntry> sampleEntries,
List<Sample> parent,
List<CencSampleAuxiliaryDataFormat> auxiliaryDataFormats) {
this.sampleEntries = sampleEntries;
this.auxiliaryDataFormats = auxiliaryDataFormats;
this.keys = keys;
this.parent = parent;
try {
ciphers.put("cenc", Cipher.getInstance("AES/CTR/NoPadding"));
ciphers.put("cbc1", Cipher.getInstance("AES/CBC/NoPadding"));
} catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
throw new RuntimeException(e);
}
}
示例4: mergeStsds
import org.mp4parser.boxes.sampleentry.SampleEntry; //导入依赖的package包/类
private SampleDescriptionBox mergeStsds(SampleDescriptionBox stsd1, SampleDescriptionBox stsd2) throws IOException {
ByteArrayOutputStream curBaos = new ByteArrayOutputStream();
ByteArrayOutputStream refBaos = new ByteArrayOutputStream();
try {
stsd1.getBox(Channels.newChannel(curBaos));
stsd2.getBox(Channels.newChannel(refBaos));
} catch (IOException e) {
LOG.error(e.getMessage());
return null;
}
byte[] cur = curBaos.toByteArray();
byte[] ref = refBaos.toByteArray();
if (!Arrays.equals(ref, cur)) {
SampleEntry se = mergeSampleEntry(stsd1.getBoxes(SampleEntry.class).get(0), stsd2.getBoxes(SampleEntry.class).get(0));
if (se != null) {
stsd1.setBoxes(Collections.<ParsableBox>singletonList(se));
} else {
throw new IOException("Cannot merge " + stsd1.getBoxes(SampleEntry.class).get(0) + " and " + stsd2.getBoxes(SampleEntry.class).get(0));
}
}
return stsd1;
}
示例5: FragmentedMp4SampleList
import org.mp4parser.boxes.sampleentry.SampleEntry; //导入依赖的package包/类
public FragmentedMp4SampleList(long track, Container isofile, RandomAccessSource randomAccess) {
this.isofile = isofile;
this.randomAccess = randomAccess;
List<TrackBox> tbs = Path.getPaths(isofile, "moov[0]/trak");
for (TrackBox tb : tbs) {
if (tb.getTrackHeaderBox().getTrackId() == track) {
trackBox = tb;
}
}
if (trackBox == null) {
throw new RuntimeException("This MP4 does not contain track " + track);
}
List<TrackExtendsBox> trexs = Path.getPaths(isofile, "moov[0]/mvex[0]/trex");
for (TrackExtendsBox box : trexs) {
if (box.getTrackId() == trackBox.getTrackHeaderBox().getTrackId()) {
trex = box;
}
}
sampleEntries = new ArrayList<>(trackBox.getSampleTableBox().getSampleDescriptionBox().getBoxes(SampleEntry.class));
if (sampleEntries.size() != trackBox.getSampleTableBox().getSampleDescriptionBox().getBoxes().size())
throw new AssertionError("stsd contains not only sample entries. Something's wrong here! Bailing out");
sampleCache = (SoftReference<Sample>[]) Array.newInstance(SoftReference.class, size());
initAllFragments();
}
示例6: getFormat
import org.mp4parser.boxes.sampleentry.SampleEntry; //导入依赖的package包/类
static String getFormat(Track track) {
String type = null;
for (SampleEntry sampleEntry : track.getSampleEntries()) {
OriginalFormatBox frma;
frma = Path.getPath((Container) sampleEntry, "sinf/frma");
String _type;
if (frma != null) {
_type = frma.getDataFormat();
} else {
_type = sampleEntry.getType();
}
if (type == null) {
type = _type;
} else {
if (!type.equals(_type)) {
throw new RuntimeException("The SyncSampleIntersectionFindler only works when all SampleEntries are of the same type. " + type + " vs. " + _type);
}
}
}
return type;
}
示例7: createStsc
import org.mp4parser.boxes.sampleentry.SampleEntry; //导入依赖的package包/类
protected void createStsc(Track track, Map<Track, int[]> chunks, SampleTableBox stbl) {
int[] tracksChunkSizes = chunks.get(track);
SampleToChunkBox stsc = new SampleToChunkBox();
stsc.setEntries(new LinkedList<SampleToChunkBox.Entry>());
long lastChunkSize = Integer.MIN_VALUE; // to be sure the first chunks hasn't got the same size
long lastSampleDescriptionIndex = Integer.MIN_VALUE;
List<Sample> samples = track.getSamples();
int currentSampleIndex = 0;
List<SampleEntry> sampleEntries = track.getSampleEntries();
for (int i = 0; i < tracksChunkSizes.length; i++) {
Sample sample = samples.get(currentSampleIndex);
int currentSampleDescriptionIndex = sampleEntries.indexOf(sample.getSampleEntry()) + 1; // one base
if (lastChunkSize != tracksChunkSizes[i] || lastSampleDescriptionIndex != currentSampleDescriptionIndex) {
stsc.getEntries().add(new SampleToChunkBox.Entry(i + 1, tracksChunkSizes[i], currentSampleDescriptionIndex));
lastChunkSize = tracksChunkSizes[i];
lastSampleDescriptionIndex = currentSampleDescriptionIndex;
}
currentSampleIndex += tracksChunkSizes[i];
}
stbl.addBox(stsc);
}
示例8: SampleImpl
import org.mp4parser.boxes.sampleentry.SampleEntry; //导入依赖的package包/类
public SampleImpl(ByteBuffer[] data, SampleEntry sampleEntry) {
this.offset = -1;
int _size = 0;
for (ByteBuffer byteBuffer : data) {
_size += byteBuffer.remaining();
}
this.size = _size;
this.data = data;
this.sampleEntry = sampleEntry;
}
示例9: generateSamples
import org.mp4parser.boxes.sampleentry.SampleEntry; //导入依赖的package包/类
private List<Sample> generateSamples(DataSource dataSource, int dataOffset, long dataSize, int corePresent) throws IOException {
LookAhead la = new LookAhead(dataSource, dataOffset, dataSize, corePresent);
ByteBuffer sample;
List<Sample> mySamples = new ArrayList<Sample>();
while ((sample = la.findNextStart()) != null) {
final ByteBuffer finalSample = sample;
mySamples.add(new Sample() {
public void writeTo(WritableByteChannel channel) throws IOException {
channel.write((ByteBuffer) finalSample.rewind());
}
public long getSize() {
return finalSample.rewind().remaining();
}
public ByteBuffer asByteBuffer() {
return finalSample;
}
@Override
public SampleEntry getSampleEntry() {
return audioSampleEntry;
}
});
//System.err.println(finalSample.remaining());
}
System.err.println("all samples found");
return mySamples;
}
示例10: readSamples
import org.mp4parser.boxes.sampleentry.SampleEntry; //导入依赖的package包/类
private List<Sample> readSamples() throws IOException {
final int framesLeft = l2i((dataSource.size() - dataSource.position()) / frameSize);
List<Sample> mySamples = new ArrayList<Sample>(framesLeft);
for (int i = 0; i < framesLeft; i++) {
final int start = i * frameSize;
mySamples.add(new Sample() {
public void writeTo(WritableByteChannel channel) throws IOException {
dataSource.transferTo(start, frameSize, channel);
}
public long getSize() {
return frameSize;
}
public ByteBuffer asByteBuffer() {
try {
return dataSource.map(start, frameSize);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@Override
public SampleEntry getSampleEntry() {
return audioSampleEntry;
}
});
}
return mySamples;
}
示例11: CencDecryptingSampleList
import org.mp4parser.boxes.sampleentry.SampleEntry; //导入依赖的package包/类
public CencDecryptingSampleList(
RangeStartMap<Integer, SecretKey> keys,
RangeStartMap<Integer, SampleEntry> sampleEntries,
List<Sample> parent,
List<CencSampleAuxiliaryDataFormat> sencInfo
) {
this.sampleEntries = sampleEntries;
this.sencInfo = sencInfo;
this.keys = keys;
this.parent = parent;
}
示例12: init
import org.mp4parser.boxes.sampleentry.SampleEntry; //导入依赖的package包/类
private void init(Map<UUID, SecretKey> keys) {
CencDecryptingSampleEntryTransformer tx = new CencDecryptingSampleEntryTransformer();
List<Sample> encSamples = original.getSamples();
RangeStartMap<Integer, SecretKey> indexToKey = new RangeStartMap<>();
RangeStartMap<Integer, SampleEntry> indexToSampleEntry = new RangeStartMap<>();
SampleEntry previousSampleEntry = null;
for (int i = 0; i < encSamples.size(); i++) {
Sample encSample = encSamples.get(i);
SampleEntry current = encSample.getSampleEntry();
sampleEntries.add(tx.transform(encSample.getSampleEntry()));
if (previousSampleEntry != current) {
indexToSampleEntry.put(i, current);
TrackEncryptionBox tenc = Path.getPath((Container) encSample.getSampleEntry(), "sinf[0]/schi[0]/tenc[0]");
if (tenc != null) {
indexToKey.put(i, keys.get(tenc.getDefault_KID()));
} else {
indexToKey.put(i, null);
}
}
previousSampleEntry = current;
}
samples = new CencDecryptingSampleList(indexToKey, indexToSampleEntry, encSamples, original.getSampleEncryptionEntries());
}
示例13: mergeSampleEntry
import org.mp4parser.boxes.sampleentry.SampleEntry; //导入依赖的package包/类
private SampleEntry mergeSampleEntry(SampleEntry se1, SampleEntry se2) {
if (!se1.getType().equals(se2.getType())) {
return null;
} else if (se1 instanceof VisualSampleEntry && se2 instanceof VisualSampleEntry) {
return mergeVisualSampleEntry((VisualSampleEntry) se1, (VisualSampleEntry) se2);
} else if (se1 instanceof AudioSampleEntry && se2 instanceof AudioSampleEntry) {
return mergeAudioSampleEntries((AudioSampleEntry) se1, (AudioSampleEntry) se2);
} else {
return null;
}
}
示例14: test
import org.mp4parser.boxes.sampleentry.SampleEntry; //导入依赖的package包/类
@Test
public void test() throws IOException {
SecretKey key = new SecretKeySpec(new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, "AES");
UUID defaultKeyId = UUID.randomUUID();
SampleEntry clearSE = new VisualSampleEntry("avc1");
CencEncryptingSampleEntryTransformer tx = new CencEncryptingSampleEntryTransformer();
SampleEntry encSE = tx.transform(clearSE, "cenc", defaultKeyId);
CencSampleAuxiliaryDataFormat cencSampleAuxiliaryDataFormat = new CencSampleAuxiliaryDataFormat();
cencSampleAuxiliaryDataFormat.pairs = new CencSampleAuxiliaryDataFormat.Pair[2];
cencSampleAuxiliaryDataFormat.pairs[0] = cencSampleAuxiliaryDataFormat.createPair(101, 384);
cencSampleAuxiliaryDataFormat.pairs[1] = cencSampleAuxiliaryDataFormat.createPair(105, 640);
cencSampleAuxiliaryDataFormat.iv = new byte[16];
List<Sample> clearSamples = Collections.<Sample>singletonList(
new SampleImpl(ByteBuffer.wrap(new byte[1230]), clearSE));
UUID keyId = UUID.randomUUID();
CencEncryptingSampleList cencSamples =
new CencEncryptingSampleList(
new RangeStartMap<>(0, new KeyIdKeyPair(keyId, key)),
new RangeStartMap<>(0, encSE),
clearSamples,
Collections.singletonList(cencSampleAuxiliaryDataFormat));
Assert.assertEquals(1, cencSamples.size());
Sample encSample = cencSamples.get(0);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
encSample.writeTo(Channels.newChannel(baos));
Assert.assertEquals(encryptedWorking, Hex.encodeHex(baos.toByteArray()));
Assert.assertEquals(encryptedWorking, Hex.encodeHex(encSample.asByteBuffer().array()));
}
示例15: getSampleEntry
import org.mp4parser.boxes.sampleentry.SampleEntry; //导入依赖的package包/类
@Override
public SampleEntry getSampleEntry() {
return sampleEntry;
}