| 1 | package org.farng.mp3.id3; |
| 2 | |
| 3 | import org.farng.mp3.InvalidTagException; |
| 4 | import org.farng.mp3.object.ObjectNumberHashMap; |
| 5 | import org.farng.mp3.object.ObjectNumberVariableLength; |
| 6 | |
| 7 | import java.io.IOException; |
| 8 | import java.io.RandomAccessFile; |
| 9 | |
| 10 | /** |
| 11 | * <h3>4.21. Position synchronisation frame</h3> |
| 12 | * <p/> |
| 13 | * <p> This frame delivers information to the listener of how far into the<br> audio stream he |
| 14 | * picked up; in effect, it states the time offset from<br> the first frame in the stream. The frame layout |
| 15 | * is:</p> |
| 16 | * <p/> |
| 17 | * <p> <Head for 'Position synchronisation', ID: "POSS"><br> |
| 18 | * <p/> |
| 19 | * Time stamp format $xx<br> |
| 20 | * Position |
| 21 | * $xx (xx ...)</p> |
| 22 | * <p/> |
| 23 | * <p> Where time stamp format is:</p> |
| 24 | * <p/> |
| 25 | * <p> $01 Absolute time, 32 bit sized, using MPEG frames as unit<br> |
| 26 | * $02 Absolute time, 32 bit sized, using milliseconds as unit</p> |
| 27 | * <p/> |
| 28 | * <p> and position is where in the audio the listener starts to receive,<br> i.e. the |
| 29 | * beginning of the next frame. If this frame is used in the<br> |
| 30 | * <p/> |
| 31 | * beginning of a file the value is always 0. There may only be one<br> "POSS" frame |
| 32 | * in each tag.<br> </p> |
| 33 | * |
| 34 | * @author Eric Farng |
| 35 | * @version $Revision: 1.4 $ |
| 36 | */ |
| 37 | public class FrameBodyPOSS extends AbstractID3v2FrameBody { |
| 38 | |
| 39 | /** |
| 40 | * Creates a new FrameBodyPOSS object. |
| 41 | */ |
| 42 | public FrameBodyPOSS() { |
| 43 | super(); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Creates a new FrameBodyPOSS object. |
| 48 | */ |
| 49 | public FrameBodyPOSS(final FrameBodyPOSS body) { |
| 50 | super(body); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Creates a new FrameBodyPOSS object. |
| 55 | */ |
| 56 | public FrameBodyPOSS(final byte timeStampFormat, final long position) { |
| 57 | setObject(ObjectNumberHashMap.TIME_STAMP_FORMAT, new Byte(timeStampFormat)); |
| 58 | setObject("Position", new Long(position)); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Creates a new FrameBodyPOSS object. |
| 63 | */ |
| 64 | public FrameBodyPOSS(final RandomAccessFile file) throws IOException, InvalidTagException { |
| 65 | this.read(file); |
| 66 | } |
| 67 | |
| 68 | public String getIdentifier() { |
| 69 | return "POSS"; |
| 70 | } |
| 71 | |
| 72 | protected void setupObjectList() { |
| 73 | appendToObjectList(new ObjectNumberHashMap(ObjectNumberHashMap.TIME_STAMP_FORMAT, 1)); |
| 74 | appendToObjectList(new ObjectNumberVariableLength("Position", 1)); |
| 75 | } |
| 76 | } |