| 1 | package org.farng.mp3.id3; |
| 2 | |
| 3 | import org.farng.mp3.InvalidTagException; |
| 4 | import org.farng.mp3.object.ObjectByteArraySizeTerminated; |
| 5 | import org.farng.mp3.object.ObjectNumberHashMap; |
| 6 | import org.farng.mp3.object.ObjectStringNullTerminated; |
| 7 | |
| 8 | import java.io.IOException; |
| 9 | import java.io.RandomAccessFile; |
| 10 | |
| 11 | /** |
| 12 | * <h3>4.15. General encapsulated object</h3> |
| 13 | * <p/> |
| 14 | * <p> In this frame any type of file can be encapsulated. After the header,<br> 'Frame size' |
| 15 | * and 'Encoding' follows 'MIME type' [MIME] represented as<br> as a terminated string encoded with ISO |
| 16 | * 8859-1 [ISO-8859-1]. The<br> filename is case sensitive and is encoded as 'Encoding'. Then follows<br> |
| 17 | * <p/> |
| 18 | * a content description as terminated string, encoded as 'Encoding'.<br> The last thing in |
| 19 | * the frame is the actual object. The first two<br> strings may be omitted, leaving only their |
| 20 | * terminations. MIME type is<br> always an ISO-8859-1 text string. There may be more than one |
| 21 | * "GEOB"<br> |
| 22 | * <p/> |
| 23 | * frame in each tag, but only one with the same content descriptor.</p> |
| 24 | * <p/> |
| 25 | * <p> <Header for 'General encapsulated object', ID: "GEOB"><br> |
| 26 | * Text encoding $xx<br> |
| 27 | * MIME type |
| 28 | * <p/> |
| 29 | * <text string> $00<br> Filename |
| 30 | * <text string according to encoding> $00 (00)<br> Content description |
| 31 | * <text string according to encoding> $00 (00)<br> |
| 32 | * <p/> |
| 33 | * Encapsulated object <binary data><br> </p> |
| 34 | * |
| 35 | * @author Eric Farng |
| 36 | * @version $Revision: 1.4 $ |
| 37 | */ |
| 38 | public class FrameBodyGEOB extends AbstractID3v2FrameBody { |
| 39 | |
| 40 | /** |
| 41 | * Creates a new FrameBodyGEOB object. |
| 42 | */ |
| 43 | public FrameBodyGEOB() { |
| 44 | super(); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Creates a new FrameBodyGEOB object. |
| 49 | */ |
| 50 | public FrameBodyGEOB(final FrameBodyGEOB body) { |
| 51 | super(body); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Creates a new FrameBodyGEOB object. |
| 56 | */ |
| 57 | public FrameBodyGEOB(final byte textEncoding, |
| 58 | final String mimeType, |
| 59 | final String filename, |
| 60 | final String description, |
| 61 | final byte[] object) { |
| 62 | setObject("TextEncoding", new Byte(textEncoding)); |
| 63 | setObject("MIME Type", mimeType); |
| 64 | setObject("Filename", filename); |
| 65 | setObject("Description", description); |
| 66 | setObject("Encapsulated Object", object); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Creates a new FrameBodyGEOB object. |
| 71 | */ |
| 72 | public FrameBodyGEOB(final RandomAccessFile file) throws IOException, InvalidTagException { |
| 73 | this.read(file); |
| 74 | } |
| 75 | |
| 76 | public void setDescription(final String description) { |
| 77 | setObject("Description", description); |
| 78 | } |
| 79 | |
| 80 | public String getDescription() { |
| 81 | return (String) getObject("Description"); |
| 82 | } |
| 83 | |
| 84 | public String getIdentifier() { |
| 85 | return "GEOB" + ((char) 0) + getDescription(); |
| 86 | } |
| 87 | |
| 88 | protected void setupObjectList() { |
| 89 | appendToObjectList(new ObjectNumberHashMap(ObjectNumberHashMap.TEXT_ENCODING, 1)); |
| 90 | appendToObjectList(new ObjectStringNullTerminated("MIME Type")); |
| 91 | appendToObjectList(new ObjectStringNullTerminated("Filename")); |
| 92 | appendToObjectList(new ObjectStringNullTerminated("Description")); |
| 93 | appendToObjectList(new ObjectByteArraySizeTerminated("Encapsulated Object")); |
| 94 | } |
| 95 | } |