|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jaudiotagger.audio.mp4.Mp4TagWriter
public class Mp4TagWriter
Writes metadata from mp4, the metadata tags are held under the ilst atom as shown below
When writing changes the size of all the atoms upto ilst has to be recalculated, then if the size of the metadata is increased the size of the free atom (below meta) should be reduced accordingly or vice versa. If the size of the metadata has increased by more than the size of the free atom then the size of meta, udta and moov should be recalculated and the top level free atom reduced accordingly If there is not enough space even if using both of the free atoms, then the mdat atom has to be shifted down accordingly to make space, and the stco atom has to have its offsets to mdat chunks table adjusted accordingly. Exceptions are that the meta/udta/ilst do not currently exist, in which udta/meta/ilst are created. Note it is valid to have meta/ilst without udta but this is less common so we always try to write files according to the Apple/iTunes specification. *|--- ftyp |--- moov |......| |......|----- mvdh |......|----- trak |......|----- udta |..............| |..............|-- meta |....................| |....................|-- hdlr |....................|-- ilst |....................|.. ..| |....................|.....|---- @nam (Optional for each metadatafield) |....................|.....|.......|-- data |....................|.....|....... ecetera |....................|.....|---- ---- (Optional for reverse dns field) |....................|.............|-- mean |....................|.............|-- name |....................|.............|-- data |....................|................ ecetere |....................|-- free |--- free |--- mdat
Field Summary | |
---|---|
static java.util.logging.Logger |
logger
|
private Mp4TagCreator |
tc
|
Constructor Summary | |
---|---|
Mp4TagWriter()
|
Method Summary | |
---|---|
private void |
adjustSizeOfMoovHeader(Mp4BoxHeader moovHeader,
java.nio.ByteBuffer moovBuffer,
int sizeAdjustment,
Mp4BoxHeader udtaHeader,
Mp4BoxHeader metaHeader)
When the size of the metadata has changed and it cant be compensated for by free atom we have to adjust the size of the size field upto the moovheader level for the udta atom and its child meta atom. |
private void |
checkFileWrittenCorrectly(java.io.RandomAccessFile rafTemp,
Mp4BoxHeader mdatHeader,
java.nio.channels.FileChannel fileWriteChannel,
Mp4StcoBox stco)
Check File Written Correctly |
private void |
createMetadataAtoms(Mp4BoxHeader moovHeader,
java.nio.ByteBuffer moovBuffer,
int sizeAdjustment,
Mp4BoxHeader udtaHeader,
Mp4BoxHeader metaHeader)
|
void |
delete(java.io.RandomAccessFile raf,
java.io.RandomAccessFile rafTemp)
Delete the tag |
void |
write(Tag tag,
java.io.RandomAccessFile raf,
java.io.RandomAccessFile rafTemp)
Write tag to rafTemp file |
private void |
writeMetadataSameSize(java.nio.ByteBuffer rawIlstData,
long oldIlstSize,
long startIstWithinFile,
java.nio.channels.FileChannel fileReadChannel,
java.nio.channels.FileChannel fileWriteChannel)
Replace the ilst metadata Because it is the same size as the original data nothing else has to be modified |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.util.logging.Logger logger
private Mp4TagCreator tc
Constructor Detail |
---|
public Mp4TagWriter()
Method Detail |
---|
private void writeMetadataSameSize(java.nio.ByteBuffer rawIlstData, long oldIlstSize, long startIstWithinFile, java.nio.channels.FileChannel fileReadChannel, java.nio.channels.FileChannel fileWriteChannel) throws CannotWriteException, java.io.IOException
rawIlstData
- oldIlstSize
- startIstWithinFile
- fileReadChannel
- fileWriteChannel
-
CannotWriteException
java.io.IOException
private void adjustSizeOfMoovHeader(Mp4BoxHeader moovHeader, java.nio.ByteBuffer moovBuffer, int sizeAdjustment, Mp4BoxHeader udtaHeader, Mp4BoxHeader metaHeader) throws java.io.IOException
moovHeader
- moovBuffer
- sizeAdjustment
- can be negative or positive *udtaHeader
- metaHeader
-
java.io.IOException
private void createMetadataAtoms(Mp4BoxHeader moovHeader, java.nio.ByteBuffer moovBuffer, int sizeAdjustment, Mp4BoxHeader udtaHeader, Mp4BoxHeader metaHeader) throws java.io.IOException
java.io.IOException
public void write(Tag tag, java.io.RandomAccessFile raf, java.io.RandomAccessFile rafTemp) throws CannotWriteException, java.io.IOException
tag
- tag dataraf
- current filerafTemp
- temporary file for writing
CannotWriteException
java.io.IOException
private void checkFileWrittenCorrectly(java.io.RandomAccessFile rafTemp, Mp4BoxHeader mdatHeader, java.nio.channels.FileChannel fileWriteChannel, Mp4StcoBox stco) throws CannotWriteException, java.io.IOException
rafTemp
- mdatHeader
- fileWriteChannel
- stco
-
CannotWriteException
java.io.IOException
public void delete(java.io.RandomAccessFile raf, java.io.RandomAccessFile rafTemp) throws java.io.IOException
This is achieved by writing an empty ilst atom
raf
- rafTemp
-
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |