本文整理汇总了Java中com.coremedia.iso.boxes.sampleentry.AudioSampleEntry类的典型用法代码示例。如果您正苦于以下问题:Java AudioSampleEntry类的具体用法?Java AudioSampleEntry怎么用?Java AudioSampleEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AudioSampleEntry类属于com.coremedia.iso.boxes.sampleentry包,在下文中一共展示了AudioSampleEntry类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAacAudioQuality
import com.coremedia.iso.boxes.sampleentry.AudioSampleEntry; //导入依赖的package包/类
private AudioQuality getAacAudioQuality(Track track, AudioSampleEntry ase) {
AudioQuality l = new AudioQuality();
final ESDescriptorBox esDescriptorBox = ase.getBoxes(ESDescriptorBox.class).get(0);
final AudioSpecificConfig audioSpecificConfig = esDescriptorBox.getEsDescriptor().getDecoderConfigDescriptor().getAudioSpecificInfo();
if (audioSpecificConfig.getSbrPresentFlag() == 1) {
l.fourCC = "AACH";
} else if (audioSpecificConfig.getPsPresentFlag() == 1) {
l.fourCC = "AACP"; //I'm not sure if that's what MS considers as AAC+ - because actually AAC+ and AAC-HE should be the same...
} else {
l.fourCC = "AACL";
}
l.bitrate = getBitrate(track);
l.audioTag = 255;
l.samplingRate = ase.getSampleRate();
l.channels = ase.getChannelCount();
l.bitPerSample = ase.getSampleSize();
l.packetSize = 4;
l.codecPrivateData = getAudioCodecPrivateData(audioSpecificConfig);
//Index="0" Bitrate="103000" AudioTag="255" SamplingRate="44100" Channels="2" BitsPerSample="16" packetSize="4" CodecPrivateData=""
return l;
}
示例2: LoadSpecificBox
import com.coremedia.iso.boxes.sampleentry.AudioSampleEntry; //导入依赖的package包/类
private void LoadSpecificBox( AudioSampleEntry box ) {
addViewForValue( "Bytes Per Frame:", box.getBytesPerFrame() );
addViewForValue( "Bytes Per Packet:", box.getBytesPerPacket() );
addViewForValue( "Bytes Per Sample:", box.getBytesPerSample() );
addViewForValue( "Channel Count:", box.getChannelCount() );
addViewForValue( "Compression Id:", box.getCompressionId() );
addViewForValue( "Packet Size:", box.getPacketSize() );
addViewForValue( "Reserved 1:", box.getReserved1() );
addViewForValue( "Reserved 2:", box.getReserved2() );
addViewForValue( "Sample Rate:", box.getSampleRate() );
addViewForValue( "Sample Size:", box.getSampleSize() );
addViewForValue( "Samples Per Packet:", box.getSamplesPerPacket() );
addViewForValue( "Size:", box.getSize() );
addViewForValue( "Sound Version:", box.getSoundVersion() );
addViewForValue( "Sound Version 2 Data:", box.getSoundVersion2Data() );
}
示例3: AppendTrack
import com.coremedia.iso.boxes.sampleentry.AudioSampleEntry; //导入依赖的package包/类
public AppendTrack(Track... tracks) throws IOException {
this.tracks = tracks;
for (Track track : tracks) {
if (stsd == null) {
stsd = track.getSampleDescriptionBox();
} else {
ByteArrayOutputStream curBaos = new ByteArrayOutputStream();
ByteArrayOutputStream refBaos = new ByteArrayOutputStream();
track.getSampleDescriptionBox().getBox(Channels.newChannel(curBaos));
stsd.getBox(Channels.newChannel(refBaos));
byte[] cur = curBaos.toByteArray();
byte[] ref = refBaos.toByteArray();
if (!Arrays.equals(ref, cur)) {
SampleDescriptionBox curStsd = track.getSampleDescriptionBox();
if (stsd.getBoxes().size() == 1 && curStsd.getBoxes().size() == 1) {
if (stsd.getBoxes().get(0) instanceof AudioSampleEntry && curStsd.getBoxes().get(0) instanceof AudioSampleEntry) {
AudioSampleEntry aseResult = mergeAudioSampleEntries((AudioSampleEntry) stsd.getBoxes().get(0), (AudioSampleEntry) curStsd.getBoxes().get(0));
if (aseResult != null) {
stsd.setBoxes(Collections.<Box>singletonList(aseResult));
return;
}
}
}
throw new IOException("Cannot append " + track + " to " + tracks[0] + " since their Sample Description Boxes differ: \n" + track.getSampleDescriptionBox() + "\n vs. \n" + tracks[0].getSampleDescriptionBox());
}
}
}
}
示例4: getAudioQuality
import com.coremedia.iso.boxes.sampleentry.AudioSampleEntry; //导入依赖的package包/类
private AudioQuality getAudioQuality(Track track, AudioSampleEntry ase) {
if (getFormat(ase).equals("mp4a")) {
return getAacAudioQuality(track, ase);
} else if (getFormat(ase).equals("ec-3")) {
return getEc3AudioQuality(track, ase);
} else if (getFormat(ase).startsWith("dts")) {
return getDtsAudioQuality(track, ase);
} else {
throw new InternalError("I don't know what to do with audio of type " + getFormat(ase));
}
}
示例5: parse
import com.coremedia.iso.boxes.sampleentry.AudioSampleEntry; //导入依赖的package包/类
private void parse(InputStream fin) throws IOException {
inputStream = fin;
bitRateAndFrameSizeTable = new int[19][2][3][2];
stts = new LinkedList<TimeToSampleBox.Entry>();
initBitRateAndFrameSizeTable();
if (!readVariables()) {
throw new IOException();
}
sampleDescriptionBox = new SampleDescriptionBox();
AudioSampleEntry audioSampleEntry = new AudioSampleEntry("ac-3");
audioSampleEntry.setChannelCount(2); // According to ETSI TS 102 366 Annex F
audioSampleEntry.setSampleRate(samplerate);
audioSampleEntry.setDataReferenceIndex(1);
audioSampleEntry.setSampleSize(16);
AC3SpecificBox ac3 = new AC3SpecificBox();
ac3.setAcmod(acmod);
ac3.setBitRateCode(frmsizecod >> 1);
ac3.setBsid(bsid);
ac3.setBsmod(bsmod);
ac3.setFscod(fscod);
ac3.setLfeon(lfeon);
ac3.setReserved(0);
audioSampleEntry.addBox(ac3);
sampleDescriptionBox.addBox(audioSampleEntry);
trackMetaData.setCreationTime(new Date());
trackMetaData.setModificationTime(new Date());
trackMetaData.setLanguage(lang);
trackMetaData.setTimescale(samplerate); // Audio tracks always use samplerate as timescale
samples = new LinkedList<ByteBuffer>();
if (!readSamples()) {
throw new IOException();
}
}
示例6: getDtsAudioQuality
import com.coremedia.iso.boxes.sampleentry.AudioSampleEntry; //导入依赖的package包/类
private AudioQuality getDtsAudioQuality(Track track, AudioSampleEntry ase) {
final DTSSpecificBox dtsSpecificBox = ase.getBoxes(DTSSpecificBox.class).get(0);
if (dtsSpecificBox == null) {
throw new RuntimeException("DTS track misses DTSSpecificBox!");
}
final ByteBuffer waveformatex = ByteBuffer.allocate(22);
final int frameDuration = dtsSpecificBox.getFrameDuration();
short samplesPerBlock = 0;
switch (frameDuration) {
case 0:
samplesPerBlock = 512;
break;
case 1:
samplesPerBlock = 1024;
break;
case 2:
samplesPerBlock = 2048;
break;
case 3:
samplesPerBlock = 4096;
break;
}
waveformatex.put((byte) (samplesPerBlock & 0xff));
waveformatex.put((byte) (samplesPerBlock >>> 8));
final int dwChannelMask = getNumChannelsAndMask(dtsSpecificBox)[1];
waveformatex.put((byte) (dwChannelMask & 0xff));
waveformatex.put((byte) (dwChannelMask >>> 8));
waveformatex.put((byte) (dwChannelMask >>> 16));
waveformatex.put((byte) (dwChannelMask >>> 24));
waveformatex.put(new byte[]{(byte)0xAE, (byte)0xE4, (byte)0xBF, (byte)0x5E, (byte)0x61, (byte)0x5E, (byte)0x41, (byte)0x87, (byte)0x92, (byte)0xFC, (byte)0xA4, (byte)0x81, (byte)0x26, (byte)0x99, (byte)0x02, (byte)0x11}); //DTS-HD GUID
final ByteBuffer dtsCodecPrivateData = ByteBuffer.allocate(8);
dtsCodecPrivateData.put((byte) dtsSpecificBox.getStreamConstruction());
final int channelLayout = dtsSpecificBox.getChannelLayout();
dtsCodecPrivateData.put((byte) (channelLayout & 0xff));
dtsCodecPrivateData.put((byte) (channelLayout >>> 8));
dtsCodecPrivateData.put((byte) (channelLayout >>> 16));
dtsCodecPrivateData.put((byte) (channelLayout >>> 24));
byte dtsFlags = (byte) (dtsSpecificBox.getMultiAssetFlag() << 1);
dtsFlags |= dtsSpecificBox.getLBRDurationMod();
dtsCodecPrivateData.put(dtsFlags);
dtsCodecPrivateData.put(new byte[]{0x00, 0x00}); //reserved
AudioQuality l = new AudioQuality();
l.fourCC = getFormat(ase);
l.bitrate = dtsSpecificBox.getAvgBitRate();
l.audioTag = 65534;
l.samplingRate = dtsSpecificBox.getDTSSamplingFrequency();
l.channels = getNumChannelsAndMask(dtsSpecificBox)[0];
l.bitPerSample = 16;
l.packetSize = track.getSamples().get(0).limit(); //assuming all are same size
l.codecPrivateData = Hex.encodeHex(waveformatex.array()) + Hex.encodeHex(dtsCodecPrivateData.array());
return l;
}
示例7: getDtsAudioQuality
import com.coremedia.iso.boxes.sampleentry.AudioSampleEntry; //导入依赖的package包/类
private AudioQuality getDtsAudioQuality(Track track, AudioSampleEntry ase) {
final DTSSpecificBox dtsSpecificBox = ase.getBoxes(DTSSpecificBox.class).get(0);
if (dtsSpecificBox == null) {
throw new RuntimeException("DTS track misses DTSSpecificBox!");
}
final ByteBuffer waveformatex = ByteBuffer.allocate(22);
final int frameDuration = dtsSpecificBox.getFrameDuration();
short samplesPerBlock = 0;
switch (frameDuration) {
case 0:
samplesPerBlock = 512;
break;
case 1:
samplesPerBlock = 1024;
break;
case 2:
samplesPerBlock = 2048;
break;
case 3:
samplesPerBlock = 4096;
break;
}
waveformatex.put((byte) (samplesPerBlock & 0xff));
waveformatex.put((byte) (samplesPerBlock >>> 8));
final int dwChannelMask = getNumChannelsAndMask(dtsSpecificBox)[1];
waveformatex.put((byte) (dwChannelMask & 0xff));
waveformatex.put((byte) (dwChannelMask >>> 8));
waveformatex.put((byte) (dwChannelMask >>> 16));
waveformatex.put((byte) (dwChannelMask >>> 24));
waveformatex.put(new byte[]{(byte) 0xAE, (byte) 0xE4, (byte) 0xBF, (byte) 0x5E, (byte) 0x61, (byte) 0x5E, (byte) 0x41, (byte) 0x87, (byte) 0x92, (byte) 0xFC, (byte) 0xA4, (byte) 0x81, (byte) 0x26, (byte) 0x99, (byte) 0x02, (byte) 0x11}); //DTS-HD GUID
final ByteBuffer dtsCodecPrivateData = ByteBuffer.allocate(8);
dtsCodecPrivateData.put((byte) dtsSpecificBox.getStreamConstruction());
final int channelLayout = dtsSpecificBox.getChannelLayout();
dtsCodecPrivateData.put((byte) (channelLayout & 0xff));
dtsCodecPrivateData.put((byte) (channelLayout >>> 8));
dtsCodecPrivateData.put((byte) (channelLayout >>> 16));
dtsCodecPrivateData.put((byte) (channelLayout >>> 24));
byte dtsFlags = (byte) (dtsSpecificBox.getMultiAssetFlag() << 1);
dtsFlags |= dtsSpecificBox.getLBRDurationMod();
dtsCodecPrivateData.put(dtsFlags);
dtsCodecPrivateData.put(new byte[]{0x00, 0x00}); //reserved
AudioQuality l = new AudioQuality();
l.fourCC = getFormat(ase);
l.bitrate = dtsSpecificBox.getAvgBitRate();
l.audioTag = 65534;
l.samplingRate = dtsSpecificBox.getDTSSamplingFrequency();
l.channels = getNumChannelsAndMask(dtsSpecificBox)[0];
l.bitPerSample = 16;
l.packetSize = (int) track.getSamples().get(0).getSize(); //assuming all are same size
l.codecPrivateData = Hex.encodeHex(waveformatex.array()) + Hex.encodeHex(dtsCodecPrivateData.array());
return l;
}