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.ObjectStringNullTerminated; |
6 | |
7 | import java.io.IOException; |
8 | import java.io.RandomAccessFile; |
9 | |
10 | /** |
11 | * <h3>4.20. Encrypted meta frame</h3> |
12 | * <p/> |
13 | * <p class=t> This frame contains one or more encrypted frames. This enables protection of copyrighted information such |
14 | * as pictures and text, that people might want to pay extra for. Since standardisation of such an encryption scheme is |
15 | * beyond this document, all "CRM" frames begin with a terminated string with a <a href="#url">URL</a> containing an |
16 | * email address, or a link to a location where an email adress can be found, that belongs to the organisation |
17 | * responsible for this specific encrypted meta frame. </p> |
18 | * <p/> |
19 | * <p class=t> Questions regarding the encrypted frame should be sent to the indicated email address. If a $00 is found |
20 | * directly after the 'Frame size', the whole frame should be ignored, and preferably be removed. The 'Owner identifier' |
21 | * is then followed by a short content description and explanation as to why it's encrypted. After the |
22 | * 'content/explanation' description, the actual encrypted block follows. </p> |
23 | * <p/> |
24 | * <p class=t> |
25 | * <p/> |
26 | * When an ID3v2 decoder encounters a "CRM" frame, it should send the datablock to the 'plugin' with the corresponding |
27 | * 'owner identifier' and expect to receive either a datablock with one or several ID3v2 frames after each other or an |
28 | * error. There may be more than one "CRM" frames in a tag, but only one with the same 'owner identifier'. </p> |
29 | * <p/> |
30 | * <p><center> <table border=0> <tr><td nowrap>Encrypted meta frame</td><td rowspan=5> </td><td |
31 | * width="100%">"CRM"</td></tr> <tr><td>Frame size</td><td>$xx xx xx</td></tr> <tr><td>Owner |
32 | * identifier</td><td><textstring> $00 (00)</td></tr> |
33 | * <p/> |
34 | * <tr><td>Content/explanation</td><td><textstring> $00 (00)</td></tr> <tr><td>Encrypted |
35 | * datablock</td><td><binary data></td></tr> </table> </center> |
36 | * |
37 | * @author Eric Farng |
38 | * @version $Revision: 1.4 $ |
39 | */ |
40 | public class FrameBodyCRM extends AbstractID3v2FrameBody { |
41 | |
42 | /** |
43 | * Creates a new FrameBodyCRM object. |
44 | */ |
45 | public FrameBodyCRM() { |
46 | super(); |
47 | } |
48 | |
49 | /** |
50 | * Creates a new FrameBodyCRM object. |
51 | */ |
52 | public FrameBodyCRM(final FrameBodyCRM body) { |
53 | super(body); |
54 | } |
55 | |
56 | /** |
57 | * Creates a new FrameBodyCRM object. |
58 | */ |
59 | public FrameBodyCRM(final String owner, final String description, final byte[] data) { |
60 | setObject("Owner", owner); |
61 | setObject("Description", description); |
62 | setObject("Encrypted datablock", data); |
63 | } |
64 | |
65 | /** |
66 | * Creates a new FrameBodyCRM object. |
67 | */ |
68 | public FrameBodyCRM(final RandomAccessFile file) throws IOException, InvalidTagException { |
69 | this.read(file); |
70 | } |
71 | |
72 | public String getIdentifier() { |
73 | return "CRM" + ((char) 0) + getOwner(); |
74 | } |
75 | |
76 | public String getOwner() { |
77 | return (String) getObject("Owner"); |
78 | } |
79 | |
80 | public void getOwner(final String description) { |
81 | setObject("Owner", description); |
82 | } |
83 | |
84 | protected void setupObjectList() { |
85 | appendToObjectList(new ObjectStringNullTerminated("Owner")); |
86 | appendToObjectList(new ObjectStringNullTerminated("Description")); |
87 | appendToObjectList(new ObjectByteArraySizeTerminated("Encrypted datablock")); |
88 | } |
89 | } |