當前位置: 首頁>>代碼示例>>Java>>正文


Java SampleEntry類代碼示例

本文整理匯總了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;
}
 
開發者ID:castlabs,項目名稱:dashencrypt,代碼行數:24,代碼來源:DashHelper2.java

示例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());
}
 
開發者ID:sannies,項目名稱:mp4parser,代碼行數:23,代碼來源:Avc1ToAvc3TrackImpl.java

示例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);
    }
}
 
開發者ID:sannies,項目名稱:mp4parser,代碼行數:18,代碼來源:CencEncryptingSampleList.java

示例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;
}
 
開發者ID:sannies,項目名稱:mp4parser,代碼行數:24,代碼來源:AppendTrack.java

示例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();
}
 
開發者ID:sannies,項目名稱:mp4parser,代碼行數:27,代碼來源:FragmentedMp4SampleList.java

示例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;
}
 
開發者ID:sannies,項目名稱:mp4parser,代碼行數:23,代碼來源:SyncSampleIntersectFinderImpl.java

示例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);
}
 
開發者ID:sannies,項目名稱:mp4parser,代碼行數:26,代碼來源:DefaultMp4Builder.java

示例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;
}
 
開發者ID:sannies,項目名稱:mp4parser,代碼行數:11,代碼來源:SampleImpl.java

示例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;
}
 
開發者ID:sannies,項目名稱:mp4parser,代碼行數:31,代碼來源:DTSTrackImpl.java

示例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;
}
 
開發者ID:sannies,項目名稱:mp4parser,代碼行數:32,代碼來源:EC3TrackImpl.java

示例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;
}
 
開發者ID:sannies,項目名稱:mp4parser,代碼行數:12,代碼來源:CencDecryptingSampleList.java

示例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());

}
 
開發者ID:sannies,項目名稱:mp4parser,代碼行數:29,代碼來源:CencDecryptingTrackImpl.java

示例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;
    }
}
 
開發者ID:sannies,項目名稱:mp4parser,代碼行數:12,代碼來源:AppendTrack.java

示例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()));


}
 
開發者ID:sannies,項目名稱:mp4parser,代碼行數:36,代碼來源:CencSampleListsTest.java

示例15: getSampleEntry

import org.mp4parser.boxes.sampleentry.SampleEntry; //導入依賴的package包/類
@Override
public SampleEntry getSampleEntry() {
    return sampleEntry;
}
 
開發者ID:sannies,項目名稱:mp4parser,代碼行數:5,代碼來源:SampleImpl.java


注:本文中的org.mp4parser.boxes.sampleentry.SampleEntry類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。