1 | package org.farng.mp3.id3; |
2 | |
3 | import org.farng.mp3.InvalidTagException; |
4 | import org.farng.mp3.object.ObjectBooleanByte; |
5 | import org.farng.mp3.object.ObjectNumberFixedLength; |
6 | |
7 | import java.io.IOException; |
8 | import java.io.RandomAccessFile; |
9 | |
10 | /** |
11 | * <h3>4.18. Recommended buffer size</h3> |
12 | * <p/> |
13 | * <p> Sometimes the server from which an audio file is streamed is aware of<br> transmission |
14 | * or coding problems resulting in interruptions in the<br> audio stream. In these cases, the size of the |
15 | * buffer can be<br> recommended by the server using this frame. If the 'embedded info<br> |
16 | * <p/> |
17 | * flag' is true (1) then this indicates that an ID3 tag with the<br> maximum size described |
18 | * in 'Buffer size' may occur in the audio<br> stream. In such case the tag should reside between two MPEG |
19 | * [MPEG]<br> frames, if the audio is MPEG encoded. If the position of the next tag<br> is |
20 | * known, 'offset to next tag' may be used. The offset is calculated<br> |
21 | * <p/> |
22 | * from the end of tag in which this frame resides to the first byte of<br> the header in the |
23 | * next. This field may be omitted. Embedded tags are<br> generally not recommended since this could render |
24 | * unpredictable<br> behaviour from present software/hardware.</p> |
25 | * <p/> |
26 | * <p> For applications like streaming audio it might be an idea to embed<br> tags into the |
27 | * audio stream though. If the clients connects to<br> individual connections like HTTP and there is a |
28 | * possibility to begin<br> every transmission with a tag, then this tag should include a<br> |
29 | * 'recommended buffer size' frame. If the client is connected to a<br> |
30 | * <p/> |
31 | * arbitrary point in the stream, such as radio or multicast, then the<br> 'recommended buffer |
32 | * size' frame SHOULD be included in every tag.</p> |
33 | * <p/> |
34 | * <p> The 'Buffer size' should be kept to a minimum. There may only be one<br> |
35 | * "RBUF" frame in each tag.</p> |
36 | * <p/> |
37 | * <p> <Header for 'Recommended buffer size', ID: "RBUF"><br> |
38 | * Buffer size |
39 | * $xx xx xx<br> Embedded info flag %0000000x<br> |
40 | * <p/> |
41 | * Offset to next tag $xx xx xx xx<br> </p> |
42 | * |
43 | * @author Eric Farng |
44 | * @version $Revision: 1.4 $ |
45 | */ |
46 | public class FrameBodyRBUF extends AbstractID3v2FrameBody { |
47 | |
48 | /** |
49 | * Creates a new FrameBodyRBUF object. |
50 | */ |
51 | public FrameBodyRBUF() { |
52 | super(); |
53 | } |
54 | |
55 | /** |
56 | * Creates a new FrameBodyRBUF object. |
57 | */ |
58 | public FrameBodyRBUF(final FrameBodyRBUF body) { |
59 | super(body); |
60 | } |
61 | |
62 | /** |
63 | * Creates a new FrameBodyRBUF object. |
64 | */ |
65 | public FrameBodyRBUF(final byte bufferSize, final boolean embeddedInfoFlag, final byte offsetToNextTag) { |
66 | setObject("Buffer Size", new Byte(bufferSize)); |
67 | setObject("Embedded Info Flag", new Boolean(embeddedInfoFlag)); |
68 | setObject("Offset to Next Flag", new Byte(offsetToNextTag)); |
69 | } |
70 | |
71 | /** |
72 | * Creates a new FrameBodyRBUF object. |
73 | */ |
74 | public FrameBodyRBUF(final RandomAccessFile file) throws IOException, InvalidTagException { |
75 | this.read(file); |
76 | } |
77 | |
78 | public String getIdentifier() { |
79 | return "RBUF"; |
80 | } |
81 | |
82 | protected void setupObjectList() { |
83 | appendToObjectList(new ObjectNumberFixedLength("Buffer Size", 3)); |
84 | appendToObjectList(new ObjectBooleanByte("Embedded Info Flag", (byte) 1)); |
85 | appendToObjectList(new ObjectNumberFixedLength("Offset to Next Tag", 4)); |
86 | } |
87 | } |