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.ObjectNumberFixedLength; |
6 | import org.farng.mp3.object.ObjectStringNullTerminated; |
7 | |
8 | import java.io.IOException; |
9 | import java.io.RandomAccessFile; |
10 | |
11 | /** |
12 | * <h3>4.19. Audio encryption</h3> |
13 | * <p/> |
14 | * <p> This frame indicates if the actual audio stream is encrypted, and by<br> |
15 | * <p/> |
16 | * whom. Since standardisation of such encryption scheme is beyond this<br> document, all |
17 | * "AENC" frames begin with a terminated string with a<br> URL containing an email address, or a |
18 | * link to a location where an<br> email address can be found, that belongs to the organisation<br> |
19 | * <p/> |
20 | * responsible for this specific encrypted audio file. Questions<br> regarding the encrypted |
21 | * audio should be sent to the email address<br> specified. If a $00 is found directly after the 'Frame |
22 | * size' and the<br> audio file indeed is encrypted, the whole file may be considered<br> |
23 | * useless.</p> |
24 | * <p/> |
25 | * <p> After the 'Owner identifier', a pointer to an unencrypted part of the<br> audio can be |
26 | * specified. The 'Preview start' and 'Preview length' is<br> described in frames. If no part is |
27 | * unencrypted, these fields should<br> be left zeroed. After the 'preview length' field follows optionally |
28 | * a<br> data block required for decryption of the audio. There may be more<br> |
29 | * <p/> |
30 | * than one "AENC" frames in a tag, but only one with the same 'Owner<br> |
31 | * identifier'.</p> |
32 | * <p/> |
33 | * <p> <Header for 'Audio encryption', ID: "AENC"><br> |
34 | * Owner identifier <text string> $00<br> |
35 | * <p/> |
36 | * Preview start $xx xx<br> Preview |
37 | * length $xx xx<br> Encryption info <binary |
38 | * data><br> |
39 | * <p/> |
40 | * </p> |
41 | * |
42 | * @author Eric Farng |
43 | * @version $Revision: 1.4 $ |
44 | */ |
45 | public class FrameBodyAENC extends AbstractID3v2FrameBody { |
46 | |
47 | /** |
48 | * Creates a new FrameBodyAENC object. |
49 | */ |
50 | public FrameBodyAENC() { |
51 | super(); |
52 | } |
53 | |
54 | /** |
55 | * Creates a new FrameBodyAENC object. |
56 | */ |
57 | public FrameBodyAENC(final FrameBodyAENC body) { |
58 | super(body); |
59 | } |
60 | |
61 | /** |
62 | * Creates a new FrameBodyAENC object. |
63 | */ |
64 | public FrameBodyAENC(final String owner, final short previewStart, final short previewLength, final byte[] data) { |
65 | super(); |
66 | setObject("Owner", owner); |
67 | setObject("Preview Start", new Short(previewStart)); |
68 | setObject("Preview Length", new Short(previewLength)); |
69 | setObject("Encryption Info", data); |
70 | } |
71 | |
72 | /** |
73 | * Creates a new FrameBodyAENC object. |
74 | */ |
75 | public FrameBodyAENC(final RandomAccessFile file) throws IOException, InvalidTagException { |
76 | super(); |
77 | read(file); |
78 | } |
79 | |
80 | public String getIdentifier() { |
81 | return "AENC" + (char) 0 + getOwner(); |
82 | } |
83 | |
84 | public String getOwner() { |
85 | return (String) getObject("Owner"); |
86 | } |
87 | |
88 | public void getOwner(final String description) { |
89 | setObject("Owner", description); |
90 | } |
91 | |
92 | protected void setupObjectList() { |
93 | appendToObjectList(new ObjectStringNullTerminated("Owner")); |
94 | appendToObjectList(new ObjectNumberFixedLength("Preview Start", 2)); |
95 | appendToObjectList(new ObjectNumberFixedLength("Preview Length", 2)); |
96 | appendToObjectList(new ObjectByteArraySizeTerminated("Encryption Info")); |
97 | } |
98 | } |