2
* MusicTag Copyright (C)2003,2004
4
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser
5
* General Public License as published by the Free Software Foundation; either version 2.1 of the License,
6
* or (at your option) any later version.
8
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
9
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
* See the GNU Lesser General Public License for more details.
12
* You should have received a copy of the GNU Lesser General Public License along with this library; if not,
13
* you can get a copy from http://www.opensource.org/licenses/lgpl-license.php or write to the Free Software
14
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
package org.jaudiotagger.tag.id3.framebody;
18
import org.jaudiotagger.tag.InvalidTagException;
19
import org.jaudiotagger.tag.datatype.*;
20
import org.jaudiotagger.tag.id3.ID3v24Frames;
21
import org.jaudiotagger.tag.id3.valuepair.TextEncoding;
23
import java.io.ByteArrayOutputStream;
24
import java.io.IOException;
25
import java.nio.ByteBuffer;
28
* General encapsulated object frame.
31
* In this frame any type of file can be encapsulated. After the header,
32
* 'Frame size' and 'Encoding' follows 'MIME type' represented as
33
* as a terminated string encoded with ISO-8859-1. The
34
* filename is case sensitive and is encoded as 'Encoding'. Then follows
35
* a content description as terminated string, encoded as 'Encoding'.
36
* The last thing in the frame is the actual object. The first two
37
* strings may be omitted, leaving only their terminations. There may be more than one "GEOB"
38
* frame in each tag, but only one with the same content descriptor.
39
* </p><p><table border=0 width="70%">
40
* <tr><td colspan=2> <Header for 'General encapsulated object', ID: "GEOB"></td></tr>
41
* <tr><td>Text encoding </td><td>$xx </td></tr>
42
* <tr><td>MIME type </td><td><text string> $00 </td></tr>
43
* <tr><td>Filename </td><td><text string according to encoding> $00 (00)</td></tr>
44
* <tr><td>Content description </td><td><text string according to enc�ding> $00 (00)</td></tr>
45
* <tr><td>Encapsulated object </td><td><binary data> </td></tr>
48
* <p>For more details, please refer to the ID3 specifications:
50
* <li><a href="http://www.id3.org/id3v2.3.0.txt">ID3 v2.3.0 Spec</a>
53
* @author : Paul Taylor
54
* @author : Eric Farng
55
* @version $Id: FrameBodyGEOB.java,v 1.13 2007/11/13 14:24:34 paultaylor Exp $
57
public class FrameBodyGEOB extends AbstractID3v2FrameBody implements ID3v24FrameBody,ID3v23FrameBody
61
* Creates a new FrameBodyGEOB datatype.
63
public FrameBodyGEOB()
65
this.setObjectValue(DataTypes.OBJ_TEXT_ENCODING, TextEncoding.ISO_8859_1);
66
this.setObjectValue(DataTypes.OBJ_MIME_TYPE, "");
67
this.setObjectValue(DataTypes.OBJ_FILENAME, "");
68
this.setObjectValue(DataTypes.OBJ_DESCRIPTION, "");
69
this.setObjectValue(DataTypes.OBJ_DATA, new byte[0]);
72
public FrameBodyGEOB(FrameBodyGEOB body)
78
* Creates a new FrameBodyGEOB datatype.
86
public FrameBodyGEOB(byte textEncoding, String mimeType, String filename, String description, byte[] object)
88
this.setObjectValue(DataTypes.OBJ_TEXT_ENCODING, textEncoding);
89
this.setObjectValue(DataTypes.OBJ_MIME_TYPE, mimeType);
90
this.setObjectValue(DataTypes.OBJ_FILENAME, filename);
91
this.setObjectValue(DataTypes.OBJ_DESCRIPTION, description);
92
this.setObjectValue(DataTypes.OBJ_DATA, object);
96
* Creates a new FrameBodyGEOB datatype.
98
* @throws InvalidTagException if unable to create framebody from buffer
100
public FrameBodyGEOB(ByteBuffer byteBuffer, int frameSize)
101
throws InvalidTagException
103
super(byteBuffer, frameSize);
111
public void setDescription(String description)
113
setObjectValue(DataTypes.OBJ_DESCRIPTION, description);
119
* @return the description field
121
public String getDescription()
123
return (String) getObjectValue(DataTypes.OBJ_DESCRIPTION);
131
public String getIdentifier()
133
return ID3v24Frames.FRAME_ID_GENERAL_ENCAPS_OBJECT ;
137
/** If the filename or description cannot be encoded using current encoder, change the encoder */
138
public void write(ByteArrayOutputStream tagBuffer)
140
if (((AbstractString) getObject(DataTypes.OBJ_FILENAME)).canBeEncoded() == false)
142
this.setTextEncoding(TextEncoding.UTF_16);
144
if (((AbstractString) getObject(DataTypes.OBJ_DESCRIPTION)).canBeEncoded() == false)
146
this.setTextEncoding(TextEncoding.UTF_16);
148
super.write(tagBuffer);
154
protected void setupObjectList()
156
objectList.add(new NumberHashMap(DataTypes.OBJ_TEXT_ENCODING, this, TextEncoding.TEXT_ENCODING_FIELD_SIZE));
157
objectList.add(new StringNullTerminated(DataTypes.OBJ_MIME_TYPE, this));
158
objectList.add(new TextEncodedStringNullTerminated(DataTypes.OBJ_FILENAME, this));
159
objectList.add(new TextEncodedStringNullTerminated(DataTypes.OBJ_DESCRIPTION, this));
160
objectList.add(new ByteArraySizeTerminated(DataTypes.OBJ_DATA, this));