| 1 | |
package org.jaudiotagger.tag.mp4.atom; |
| 2 | |
|
| 3 | |
import org.jaudiotagger.audio.generic.Utils; |
| 4 | |
import org.jaudiotagger.audio.mp4.atom.AbstractMp4Box; |
| 5 | |
import org.jaudiotagger.audio.mp4.atom.Mp4BoxHeader; |
| 6 | |
|
| 7 | |
import java.nio.ByteBuffer; |
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
public class Mp4NameBox extends AbstractMp4Box |
| 13 | |
{ |
| 14 | |
public static final String IDENTIFIER = "name"; |
| 15 | |
|
| 16 | |
private String name; |
| 17 | |
|
| 18 | |
|
| 19 | |
public static final int VERSION_LENGTH = 1; |
| 20 | |
public static final int FLAGS_LENGTH = 3; |
| 21 | |
public static final int PRE_DATA_LENGTH = VERSION_LENGTH + FLAGS_LENGTH; |
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
public Mp4NameBox(Mp4BoxHeader header, ByteBuffer dataBuffer) |
| 28 | 450 | { |
| 29 | 450 | this.header = header; |
| 30 | |
|
| 31 | |
|
| 32 | 450 | if (!header.getId().equals(IDENTIFIER)) |
| 33 | |
{ |
| 34 | 0 | throw new RuntimeException("Unable to process name box because identifier is:" + header.getId()); |
| 35 | |
} |
| 36 | |
|
| 37 | |
|
| 38 | 450 | this.dataBuffer = dataBuffer.slice(); |
| 39 | |
|
| 40 | |
|
| 41 | 450 | this.name = Utils.getString(this.dataBuffer, PRE_DATA_LENGTH, header.getDataLength() - PRE_DATA_LENGTH, header.getEncoding()); |
| 42 | 450 | } |
| 43 | |
|
| 44 | |
public String getName() |
| 45 | |
{ |
| 46 | 450 | return name; |
| 47 | |
} |
| 48 | |
} |