Methods Summary |
---|
protected void | build(java.nio.ByteBuffer data)
//Read mean box, set the issuer and skip over data
Mp4BoxHeader meanBoxHeader = new Mp4BoxHeader(data);
Mp4MeanBox meanBox = new Mp4MeanBox(meanBoxHeader, data);
setIssuer(meanBox.getIssuer());
data.position(data.position() + meanBoxHeader.getDataLength());
//Read name box, identify what type of field it is
Mp4BoxHeader nameBoxHeader = new Mp4BoxHeader(data);
Mp4NameBox nameBox = new Mp4NameBox(nameBoxHeader, data);
setDescriptor(nameBox.getName());
data.position(data.position() + nameBoxHeader.getDataLength());
//Issue 198:There is not actually a data atom there cannot cant be because no room for one
if (parentHeader.getDataLength() == meanBoxHeader.getLength() + nameBoxHeader.getLength())
{
id = IDENTIFIER + ":" + issuer + ":" + descriptor;
setContent("");
logger.warning(ErrorMessage.MP4_REVERSE_DNS_FIELD_HAS_NO_DATA.getMsg(id));
}
//Usual Case
else
{
//Read data box, identify the data
Mp4BoxHeader dataBoxHeader = new Mp4BoxHeader(data);
Mp4DataBox dataBox = new Mp4DataBox(dataBoxHeader, data);
setContent(dataBox.getContent());
data.position(data.position() + dataBoxHeader.getDataLength());
//Now calculate the id which in order to be unique needs to use all htree values
id = IDENTIFIER + ":" + issuer + ":" + descriptor;
}
|
public void | copyContent(org.jaudiotagger.tag.TagField field)
if (field instanceof Mp4TagReverseDnsField)
{
this.issuer = ((Mp4TagReverseDnsField) field).getIssuer();
this.descriptor = ((Mp4TagReverseDnsField) field).getDescriptor();
this.content = ((Mp4TagReverseDnsField) field).getContent();
}
|
public java.lang.String | getContent()
return content;
|
protected byte[] | getDataBytes()
return content.getBytes(getEncoding());
|
public java.lang.String | getDescriptor()
return descriptor;
|
public java.lang.String | getEncoding()
return Mp4BoxHeader.CHARSET_UTF_8;
|
public Mp4FieldType | getFieldType()
//TODO always assuming text at moment but may not always be the case (though dont have any concrete
//examples)
return Mp4FieldType.TEXT;
|
public java.lang.String | getIssuer()
return issuer;
|
public byte[] | getRawContent()Convert back to raw content, includes ----,mean,name and data atom as views as one thing externally
try
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
//Create Meanbox data
byte[] issuerRawData = issuer.getBytes(getEncoding());
baos.write(Utils.getSizeBEInt32(Mp4BoxHeader.HEADER_LENGTH + Mp4MeanBox.PRE_DATA_LENGTH + issuerRawData.length));
baos.write(Utils.getDefaultBytes(Mp4MeanBox.IDENTIFIER, "ISO-8859-1"));
baos.write(new byte[]{0, 0, 0, 0});
baos.write(issuerRawData);
//Create Namebox data
byte[] nameRawData = descriptor.getBytes(getEncoding());
baos.write(Utils.getSizeBEInt32(Mp4BoxHeader.HEADER_LENGTH + Mp4NameBox.PRE_DATA_LENGTH + nameRawData.length));
baos.write(Utils.getDefaultBytes(Mp4NameBox.IDENTIFIER, "ISO-8859-1"));
baos.write(new byte[]{0, 0, 0, 0});
baos.write(nameRawData);
//Create DataBox data if we have data only
if (content.length() > 0)
{
baos.write(getRawContentDataOnly());
}
//Now wrap with reversedns box
ByteArrayOutputStream outerbaos = new ByteArrayOutputStream();
outerbaos.write(Utils.getSizeBEInt32(Mp4BoxHeader.HEADER_LENGTH + baos.size()));
outerbaos.write(Utils.getDefaultBytes(IDENTIFIER, "ISO-8859-1"));
outerbaos.write(baos.toByteArray());
return outerbaos.toByteArray();
}
catch (IOException ioe)
{
//This should never happen as were not actually writing to/from a file
throw new RuntimeException(ioe);
}
|
public byte[] | getRawContentDataOnly()
logger.fine("Getting Raw data for:" + getId());
try
{
//Create DataBox data
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] dataRawData = content.getBytes(getEncoding());
baos.write(Utils.getSizeBEInt32(Mp4BoxHeader.HEADER_LENGTH + Mp4DataBox.PRE_DATA_LENGTH + dataRawData.length));
baos.write(Utils.getDefaultBytes(Mp4DataBox.IDENTIFIER, "ISO-8859-1"));
baos.write(new byte[]{0});
baos.write(new byte[]{0, 0, (byte) getFieldType().getFileClassId()});
baos.write(new byte[]{0, 0, 0, 0});
baos.write(dataRawData);
return baos.toByteArray();
}
catch (IOException ioe)
{
//This should never happen as were not actually writing to/from a file
throw new RuntimeException(ioe);
}
|
public boolean | isBinary()
return false;
|
public boolean | isEmpty()
return this.content.trim().equals("");
|
public void | setContent(java.lang.String s)
this.content = s;
|
public void | setDescriptor(java.lang.String descriptor)Set the descriptor for the data (what type of data it is)
this.descriptor = descriptor;
|
public void | setEncoding(java.lang.String s)
/* Not allowed */
|
public void | setIssuer(java.lang.String issuer)Set the issuer, usually reverse dns of the Companies domain
this.issuer = issuer;
|
public java.lang.String | toString()
return content;
|