package org.farng.mp3.id3; import java.io.IOException; import java.io.RandomAccessFile; import org.farng.mp3.InvalidTagException; import org.farng.mp3.object.ObjectByteArraySizeTerminated; import org.farng.mp3.object.ObjectNumberFixedLength; import org.farng.mp3.object.ObjectStringNullTerminated; /** * <h3>4.19.   Audio encryption</h3> * <p/> * <p>   This frame indicates if the actual audio stream is encrypted, and by<br> * <p/> *    whom. Since standardisation of such encryption scheme is beyond this<br>    document, all * "AENC" frames begin with a terminated string with a<br>    URL containing an email address, or a * link to a location where an<br>    email address can be found, that belongs to the organisation<br> * <p/> *    responsible for this specific encrypted audio file. Questions<br>    regarding the encrypted * audio should be sent to the email address<br>    specified. If a $00 is found directly after the 'Frame * size' and the<br>    audio file indeed is encrypted, the whole file may be considered<br>    * useless.</p> * <p/> * <p>   After the 'Owner identifier', a pointer to an unencrypted part of the<br>    audio can be * specified. The 'Preview start' and 'Preview length' is<br>    described in frames. If no part is * unencrypted, these fields should<br>    be left zeroed. After the 'preview length' field follows optionally * a<br>    data block required for decryption of the audio. There may be more<br> * <p/> *    than one "AENC" frames in a tag, but only one with the same 'Owner<br>    * identifier'.</p> * <p/> * <p>     <Header for 'Audio encryption', ID: "AENC"><br>      * Owner identifier   <text string> $00<br> * <p/> *      Preview start      $xx xx<br>      Preview * length     $xx xx<br>      Encryption info    <binary * data><br> * <p/> * </p> * * @author Eric Farng * @version $Revision: 2374 $ */ public class FrameBodyAENC extends AbstractID3v2FrameBody { /** * Creates a new FrameBodyAENC object. */ public FrameBodyAENC() { super(); } /** * Creates a new FrameBodyAENC object. */ public FrameBodyAENC(final FrameBodyAENC body) { super(body); } /** * Creates a new FrameBodyAENC object. */ public FrameBodyAENC(final String owner, final short previewStart, final short previewLength, final byte[] data) { super(); setObject("Owner", owner); setObject("Preview Start", new Short(previewStart)); setObject("Preview Length", new Short(previewLength)); setObject("Encryption Info", data); } /** * Creates a new FrameBodyAENC object. */ public FrameBodyAENC(final RandomAccessFile file) throws IOException, InvalidTagException { super(); read(file); } public String getIdentifier() { return "AENC" + (char) 0 + getOwner(); } public String getOwner() { return (String) getObject("Owner"); } public void getOwner(final String description) { setObject("Owner", description); } protected void setupObjectList() { appendToObjectList(new ObjectStringNullTerminated("Owner")); appendToObjectList(new ObjectNumberFixedLength("Preview Start", 2)); appendToObjectList(new ObjectNumberFixedLength("Preview Length", 2)); appendToObjectList(new ObjectByteArraySizeTerminated("Encryption Info")); } }