Skip to content
Snippets Groups Projects
Commit 02733524 authored by Leo Ma's avatar Leo Ma
Browse files

Add new files for mp4 parser


Signed-off-by: default avatarLeo Ma <begeekmyfriend@gmail.com>
parent 4b67a064
No related branches found
No related tags found
No related merge requests found
Showing
with 612 additions and 0 deletions
package com.coremedia.iso.boxes.apple;
import com.googlecode.mp4parser.AbstractContainerBox;
/**
*
*/
public final class AppleGenericBox extends AbstractContainerBox {
public static final String TYPE = "----";
public AppleGenericBox() {
super(TYPE);
}
}
\ No newline at end of file
package com.coremedia.iso.boxes.apple;
/**
* itunes MetaData comment box.
*/
public final class AppleGroupingBox extends AbstractAppleMetaDataBox {
public static final String TYPE = "\u00a9grp";
public AppleGroupingBox() {
super(TYPE);
appleDataBox = AppleDataBox.getStringAppleDataBox();
}
}
\ No newline at end of file
package com.coremedia.iso.boxes.apple;
/**
*
*/
public final class AppleIdBox extends AbstractAppleMetaDataBox {
public static final String TYPE = "apID";
public AppleIdBox() {
super(TYPE);
appleDataBox = AppleDataBox.getStringAppleDataBox();
}
}
\ No newline at end of file
package com.coremedia.iso.boxes.apple;
import com.googlecode.mp4parser.AbstractContainerBox;
/**
* undocumented iTunes MetaData Box.
*/
public class AppleItemListBox extends AbstractContainerBox {
public static final String TYPE = "ilst";
public AppleItemListBox() {
super(TYPE);
}
}
package com.coremedia.iso.boxes.apple;
import com.coremedia.iso.IsoTypeReader;
import com.coremedia.iso.IsoTypeWriter;
import com.googlecode.mp4parser.AbstractFullBox;
import java.nio.ByteBuffer;
/**
*
*/
public final class AppleLosslessSpecificBox extends AbstractFullBox {
public static final String TYPE = "alac";
/*
Extradata: 32bit size 32bit tag (=alac) 32bit zero?
32bit max sample per frame 8bit ?? (zero?) 8bit sample
size 8bit history mult 8bit initial history 8bit kmodifier
8bit channels? 16bit ?? 32bit max coded frame size 32bit
bitrate? 32bit samplerate
*/
private long maxSamplePerFrame; // 32bi
private int unknown1; // 8bit
private int sampleSize; // 8bit
private int historyMult; // 8bit
private int initialHistory; // 8bit
private int kModifier; // 8bit
private int channels; // 8bit
private int unknown2; // 16bit
private long maxCodedFrameSize; // 32bit
private long bitRate; // 32bit
private long sampleRate; // 32bit
public long getMaxSamplePerFrame() {
return maxSamplePerFrame;
}
public void setMaxSamplePerFrame(int maxSamplePerFrame) {
this.maxSamplePerFrame = maxSamplePerFrame;
}
public int getUnknown1() {
return unknown1;
}
public void setUnknown1(int unknown1) {
this.unknown1 = unknown1;
}
public int getSampleSize() {
return sampleSize;
}
public void setSampleSize(int sampleSize) {
this.sampleSize = sampleSize;
}
public int getHistoryMult() {
return historyMult;
}
public void setHistoryMult(int historyMult) {
this.historyMult = historyMult;
}
public int getInitialHistory() {
return initialHistory;
}
public void setInitialHistory(int initialHistory) {
this.initialHistory = initialHistory;
}
public int getKModifier() {
return kModifier;
}
public void setKModifier(int kModifier) {
this.kModifier = kModifier;
}
public int getChannels() {
return channels;
}
public void setChannels(int channels) {
this.channels = channels;
}
public int getUnknown2() {
return unknown2;
}
public void setUnknown2(int unknown2) {
this.unknown2 = unknown2;
}
public long getMaxCodedFrameSize() {
return maxCodedFrameSize;
}
public void setMaxCodedFrameSize(int maxCodedFrameSize) {
this.maxCodedFrameSize = maxCodedFrameSize;
}
public long getBitRate() {
return bitRate;
}
public void setBitRate(int bitRate) {
this.bitRate = bitRate;
}
public long getSampleRate() {
return sampleRate;
}
public void setSampleRate(int sampleRate) {
this.sampleRate = sampleRate;
}
@Override
public void _parseDetails(ByteBuffer content) {
parseVersionAndFlags(content);
maxSamplePerFrame = IsoTypeReader.readUInt32(content);
unknown1 = IsoTypeReader.readUInt8(content);
sampleSize = IsoTypeReader.readUInt8(content);
historyMult = IsoTypeReader.readUInt8(content);
initialHistory = IsoTypeReader.readUInt8(content);
kModifier = IsoTypeReader.readUInt8(content);
channels = IsoTypeReader.readUInt8(content);
unknown2 = IsoTypeReader.readUInt16(content);
maxCodedFrameSize = IsoTypeReader.readUInt32(content);
bitRate = IsoTypeReader.readUInt32(content);
sampleRate = IsoTypeReader.readUInt32(content);
}
@Override
protected void getContent(ByteBuffer byteBuffer) {
writeVersionAndFlags(byteBuffer);
IsoTypeWriter.writeUInt32(byteBuffer, maxSamplePerFrame);
IsoTypeWriter.writeUInt8(byteBuffer, unknown1);
IsoTypeWriter.writeUInt8(byteBuffer, sampleSize);
IsoTypeWriter.writeUInt8(byteBuffer, historyMult);
IsoTypeWriter.writeUInt8(byteBuffer, initialHistory);
IsoTypeWriter.writeUInt8(byteBuffer, kModifier);
IsoTypeWriter.writeUInt8(byteBuffer, channels);
IsoTypeWriter.writeUInt16(byteBuffer, unknown2);
IsoTypeWriter.writeUInt32(byteBuffer, maxCodedFrameSize);
IsoTypeWriter.writeUInt32(byteBuffer, bitRate);
IsoTypeWriter.writeUInt32(byteBuffer, sampleRate);
}
public AppleLosslessSpecificBox() {
super("alac");
}
protected long getContentSize() {
return 28;
}
}
package com.coremedia.iso.boxes.apple;
import com.coremedia.iso.IsoTypeReader;
import com.coremedia.iso.Utf8;
import com.googlecode.mp4parser.AbstractFullBox;
import java.nio.ByteBuffer;
/**
* Apple Meaning box. Allowed as subbox of "----" box.
*
* @see com.coremedia.iso.boxes.apple.AppleGenericBox
*/
public final class AppleMeanBox extends AbstractFullBox {
public static final String TYPE = "mean";
private String meaning;
public AppleMeanBox() {
super(TYPE);
}
protected long getContentSize() {
return 4 + Utf8.utf8StringLengthInBytes(meaning);
}
@Override
public void _parseDetails(ByteBuffer content) {
parseVersionAndFlags(content);
meaning = IsoTypeReader.readString(content, content.remaining());
}
@Override
protected void getContent(ByteBuffer byteBuffer) {
writeVersionAndFlags(byteBuffer);
byteBuffer.put(Utf8.convert(meaning));
}
public String getMeaning() {
return meaning;
}
public void setMeaning(String meaning) {
this.meaning = meaning;
}
}
package com.coremedia.iso.boxes.apple;
import java.util.HashMap;
import java.util.Map;
/**
* itunes MetaData comment box.
*/
public class AppleMediaTypeBox extends AbstractAppleMetaDataBox {
private static Map<String, String> mediaTypes = new HashMap<String, String>();
static {
mediaTypes.put("0", "Movie (is now 9)");
mediaTypes.put("1", "Normal (Music)");
mediaTypes.put("2", "Audiobook");
mediaTypes.put("6", "Music Video");
mediaTypes.put("9", "Movie");
mediaTypes.put("10", "TV Show");
mediaTypes.put("11", "Booklet");
mediaTypes.put("14", "Ringtone");
}
public static final String TYPE = "stik";
public AppleMediaTypeBox() {
super(TYPE);
appleDataBox = AppleDataBox.getUint8AppleDataBox();
}
public String getReadableValue() {
if (mediaTypes.containsKey(getValue())) {
return mediaTypes.get(getValue());
} else {
return "unknown media type " + getValue();
}
}
}
\ No newline at end of file
package com.coremedia.iso.boxes.apple;
import com.coremedia.iso.IsoTypeReader;
import com.coremedia.iso.Utf8;
import com.googlecode.mp4parser.AbstractFullBox;
import java.nio.ByteBuffer;
/**
* Apple Name box. Allowed as subbox of "----" box.
*
* @see AppleGenericBox
*/
public final class AppleNameBox extends AbstractFullBox {
public static final String TYPE = "name";
private String name;
public AppleNameBox() {
super(TYPE);
}
protected long getContentSize() {
return 4 + Utf8.convert(name).length;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public void _parseDetails(ByteBuffer content) {
parseVersionAndFlags(content);
name = IsoTypeReader.readString(content, content.remaining());
}
@Override
protected void getContent(ByteBuffer byteBuffer) {
writeVersionAndFlags(byteBuffer);
byteBuffer.put(Utf8.convert(name));
}
}
package com.coremedia.iso.boxes.apple;
/**
*
*/
public final class AppleNetworkBox extends AbstractAppleMetaDataBox {
public static final String TYPE = "tvnn";
public AppleNetworkBox() {
super(TYPE);
appleDataBox = AppleDataBox.getStringAppleDataBox();
}
}
\ No newline at end of file
package com.coremedia.iso.boxes.apple;
/**
*
*/
public final class ApplePurchaseDateBox extends AbstractAppleMetaDataBox {
public static final String TYPE = "purd";
public ApplePurchaseDateBox() {
super(TYPE);
appleDataBox = AppleDataBox.getStringAppleDataBox();
}
}
\ No newline at end of file
package com.coremedia.iso.boxes.apple;
/**
* iTunes Rating Box.
*/
public final class AppleRatingBox extends AbstractAppleMetaDataBox {
public static final String TYPE = "rtng";
public AppleRatingBox() {
super(TYPE);
appleDataBox = AppleDataBox.getUint8AppleDataBox();
}
}
package com.coremedia.iso.boxes.apple;
/**
*
*/
public class AppleRecordingYearBox extends AbstractAppleMetaDataBox {
public static final String TYPE = "\u00a9day";
public AppleRecordingYearBox() {
super(TYPE);
appleDataBox = AppleDataBox.getStringAppleDataBox();
}
}
\ No newline at end of file
/*
* Copyright 2009 castLabs GmbH, Berlin
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.coremedia.iso.boxes.apple;
import com.googlecode.mp4parser.AbstractContainerBox;
public class AppleReferenceMovieBox extends AbstractContainerBox {
public static final String TYPE = "rmra";
public AppleReferenceMovieBox() {
super(TYPE);
}
}
/*
* Copyright 2009 castLabs GmbH, Berlin
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.coremedia.iso.boxes.apple;
import com.googlecode.mp4parser.AbstractContainerBox;
public class AppleReferenceMovieDescriptorBox extends AbstractContainerBox {
public static final String TYPE = "rmda";
public AppleReferenceMovieDescriptorBox() {
super(TYPE);
}
}
package com.coremedia.iso.boxes.apple;
/**
*
*/
public final class AppleShowBox extends AbstractAppleMetaDataBox {
public static final String TYPE = "tvsh";
public AppleShowBox() {
super(TYPE);
appleDataBox = AppleDataBox.getStringAppleDataBox();
}
}
\ No newline at end of file
package com.coremedia.iso.boxes.apple;
/**
*
*/
public final class AppleSortAlbumBox extends AbstractAppleMetaDataBox {
public static final String TYPE = "soal";
public AppleSortAlbumBox() {
super(TYPE);
appleDataBox = AppleDataBox.getStringAppleDataBox();
}
}
\ No newline at end of file
package com.coremedia.iso.boxes.apple;
/**
*
*/
public final class AppleStandardGenreBox extends AbstractAppleMetaDataBox {
public static final String TYPE = "gnre";
public AppleStandardGenreBox() {
super(TYPE);
appleDataBox = AppleDataBox.getUint16AppleDataBox();
}
}
\ No newline at end of file
package com.coremedia.iso.boxes.apple;
/**
* itunes MetaData comment box.
*/
public class AppleStoreAccountTypeBox extends AbstractAppleMetaDataBox {
public static final String TYPE = "akID";
public AppleStoreAccountTypeBox() {
super(TYPE);
appleDataBox = AppleDataBox.getUint8AppleDataBox();
}
public String getReadableValue() {
byte value = this.appleDataBox.getData()[0];
switch (value) {
case 0:
return "iTunes Account";
case 1:
return "AOL Account";
default:
return "unknown Account";
}
}
}
\ No newline at end of file
package com.coremedia.iso.boxes.apple;
import java.util.HashMap;
import java.util.Map;
/**
* itunes MetaData comment box.
*/
public class AppleStoreCountryCodeBox extends AbstractAppleMetaDataBox {
private static Map<String, String> countryCodes = new HashMap<String, String>();
static {
countryCodes.put("143460", "Australia");
countryCodes.put("143445", "Austria");
countryCodes.put("143446", "Belgium");
countryCodes.put("143455", "Canada");
countryCodes.put("143458", "Denmark");
countryCodes.put("143447", "Finland");
countryCodes.put("143442", "France");
countryCodes.put("143443", "Germany");
countryCodes.put("143448", "Greece");
countryCodes.put("143449", "Ireland");
countryCodes.put("143450", "Italy");
countryCodes.put("143462", "Japan");
countryCodes.put("143451", "Luxembourg");
countryCodes.put("143452", "Netherlands");
countryCodes.put("143461", "New Zealand");
countryCodes.put("143457", "Norway");
countryCodes.put("143453", "Portugal");
countryCodes.put("143454", "Spain");
countryCodes.put("143456", "Sweden");
countryCodes.put("143459", "Switzerland");
countryCodes.put("143444", "United Kingdom");
countryCodes.put("143441", "United States");
}
public static final String TYPE = "sfID";
public AppleStoreCountryCodeBox() {
super(TYPE);
appleDataBox = AppleDataBox.getUint32AppleDataBox();
}
public String getReadableValue() {
if (countryCodes.containsKey(getValue())) {
return countryCodes.get(getValue());
} else {
return "unknown country code " + getValue();
}
}
}
\ No newline at end of file
package com.coremedia.iso.boxes.apple;
/**
*
*/
public final class AppleSynopsisBox extends AbstractAppleMetaDataBox {
public static final String TYPE = "ldes";
public AppleSynopsisBox() {
super(TYPE);
appleDataBox = AppleDataBox.getStringAppleDataBox();
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment