|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jaudiotagger.audio.mp4.atom.Mp4BoxHeader
public class Mp4BoxHeader
Everything in MP4s are held in boxes (formally known as atoms), they are held as a hierachial tree within the MP4.
We are most interested in boxes that are used to hold metadata, but we have to know about some other boxes as well in order to find them. All boxes consist of a 4 byte box length (big Endian), and then a 4 byte identifier, this is the header which is model in this class. The length includes the length of the box including the identifier and the length itself. Then they may contain data and/or sub boxes, if they contain subboxes they are known as a parent box. Parent boxes shouldn't really contain data, but sometimes they do. Parent boxes length includes the length of their immediate sub boxes This class is normally used by instantiating with the empty constructor, then use the update method to pass the header data which is used to read the identifier and the the size of the box
Field Summary | |
---|---|
static java.lang.String |
CHARSET_UTF_8
|
protected java.nio.ByteBuffer |
dataBuffer
|
private long |
filePos
|
static int |
HEADER_LENGTH
|
private java.lang.String |
id
|
static int |
IDENTIFIER_LENGTH
|
static int |
IDENTIFIER_POS
|
protected int |
length
|
static java.util.logging.Logger |
logger
|
static int |
OFFSET_LENGTH
|
static int |
OFFSET_POS
|
Constructor Summary | |
---|---|
Mp4BoxHeader()
Construct empty header Can be populated later with update method |
|
Mp4BoxHeader(java.nio.ByteBuffer headerData)
Construct header Create header using headerdata, expected to find header at headerdata current position Note after processing adjusts position to immediately after header |
|
Mp4BoxHeader(java.lang.String id)
Construct header to allow manual creation of header for writing to file |
Method Summary | |
---|---|
int |
getDataLength()
|
java.lang.String |
getEncoding()
|
long |
getFilePos()
|
java.nio.ByteBuffer |
getHeaderData()
|
java.lang.String |
getId()
|
int |
getLength()
|
static Mp4BoxHeader |
seekWithinLevel(java.nio.ByteBuffer data,
java.lang.String id)
Seek for box with the specified id starting from the current location of filepointer, Note it won't find the box if it is contained with a level below the current level, nor if we are at a parent atom that also contains data and we havent yet processed the data. |
static Mp4BoxHeader |
seekWithinLevel(java.io.RandomAccessFile raf,
java.lang.String id)
Seek for box with the specified id starting from the current location of filepointer, Note it wont find the box if it is contained with a level below the current level, nor if we are at a parent atom that also contains data and we havent yet processed the data. |
void |
setFilePos(long filePos)
Set location in file of the start of file header (i.e where the 4 byte length field starts) |
void |
setId(int length)
Set the Id. |
void |
setLength(int length)
Set the length. |
java.lang.String |
toString()
|
void |
update(java.nio.ByteBuffer headerData)
Create header using headerdata, expected to find header at headerdata current position Note after processing adjusts position to immediately after header |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static java.util.logging.Logger logger
public static final int OFFSET_POS
public static final int IDENTIFIER_POS
public static final int OFFSET_LENGTH
public static final int IDENTIFIER_LENGTH
public static final int HEADER_LENGTH
private java.lang.String id
protected int length
private long filePos
protected java.nio.ByteBuffer dataBuffer
public static final java.lang.String CHARSET_UTF_8
Constructor Detail |
---|
public Mp4BoxHeader()
public Mp4BoxHeader(java.lang.String id)
id
- public Mp4BoxHeader(java.nio.ByteBuffer headerData)
headerData
- Method Detail |
---|
public void update(java.nio.ByteBuffer headerData)
headerData
- public java.lang.String getId()
public int getLength()
public void setLength(int length)
length
- public void setId(int length)
length
- public java.nio.ByteBuffer getHeaderData()
public int getDataLength()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getEncoding()
public static Mp4BoxHeader seekWithinLevel(java.io.RandomAccessFile raf, java.lang.String id) throws java.io.IOException
raf
- id
-
java.io.IOException
public static Mp4BoxHeader seekWithinLevel(java.nio.ByteBuffer data, java.lang.String id) throws java.io.IOException
data
- id
-
java.io.IOException
public long getFilePos()
public void setFilePos(long filePos)
filePos
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |