| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| FrameBodyCHAP |
|
| 1.0;1 |
| 1 | /* | |
| 2 | * Horizon Wimba Copyright (C)2006 | |
| 3 | * | |
| 4 | * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser | |
| 5 | * General Public License as published by the Free Software Foundation; either version 2.1 of the License, | |
| 6 | * or (at your option) any later version. | |
| 7 | * | |
| 8 | * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even | |
| 9 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
| 10 | * See the GNU Lesser General Public License for more details. | |
| 11 | * | |
| 12 | * You should have received a copy of the GNU Lesser General Public License along with this library; if not, | |
| 13 | * you can get a copy from http://www.opensource.org/licenses/lgpl-license.php or write to the Free Software | |
| 14 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 15 | */ | |
| 16 | package org.jaudiotagger.tag.id3.framebody; | |
| 17 | ||
| 18 | import org.jaudiotagger.tag.InvalidTagException; | |
| 19 | import org.jaudiotagger.tag.datatype.DataTypes; | |
| 20 | import org.jaudiotagger.tag.datatype.NumberFixedLength; | |
| 21 | import org.jaudiotagger.tag.datatype.StringNullTerminated; | |
| 22 | import org.jaudiotagger.tag.id3.ID3v2ChapterFrames; | |
| 23 | ||
| 24 | import java.nio.ByteBuffer; | |
| 25 | ||
| 26 | /** | |
| 27 | * Chapter frame. | |
| 28 | * <p/> | |
| 29 | * <p/> | |
| 30 | * The purpose of this frame is to describe a single chapter within an | |
| 31 | * audio file. There may be more than one frame of this type in a tag | |
| 32 | * but each must have an Element ID that is unique with respect to any | |
| 33 | * other "CHAP" frame or "CTOC" frame in the tag. | |
| 34 | * </p> | |
| 35 | * <table border="0" width="70%" align="center"> | |
| 36 | * <tr><td nowrap="nowrap"><ID3v2.3 or ID3v2.4 frame header, ID: "CHAP"></td><td rowspan="7"> </td><td>(10 bytes)</td></tr> | |
| 37 | * <tr><td>Element ID</td><td width="70%"><text string> $00</td></tr> | |
| 38 | * <tr><td>Start time</td><td>$xx xx xx xx</td></tr> | |
| 39 | * <tr><td>End time</td><td>$xx xx xx xx</td></tr> | |
| 40 | * <tr><td>Start offset</td><td>$xx xx xx xx</td></tr> | |
| 41 | * <tr><td>End offset</td><td>$xx xx xx xx</td></tr> | |
| 42 | * <tr><td><Optional embedded sub-frames></td></tr> | |
| 43 | * </table> | |
| 44 | * </p><p> | |
| 45 | * The Element ID uniquely identifies the frame. It is not intended to | |
| 46 | * be human readable and should not be presented to the end user. | |
| 47 | * </p><p> | |
| 48 | * The Start and End times are a count in milliseconds from the | |
| 49 | * beginning of the file to the start and end of the chapter | |
| 50 | * respectively. | |
| 51 | * </p><p> | |
| 52 | * The Start offset is a zero-based count of bytes from the beginning | |
| 53 | * of the file to the first byte of the first audio frame in the | |
| 54 | * chapter. If these bytes are all set to 0xFF then the value should be | |
| 55 | * ignored and the start time value should be utilized. | |
| 56 | * </p><p> | |
| 57 | * The End offset is a zero-based count of bytes from the beginning of | |
| 58 | * the file to the first byte of the audio frame following the end of | |
| 59 | * the chapter. If these bytes are all set to 0xFF then the value should | |
| 60 | * be ignored and the end time value should be utilized. | |
| 61 | * </p><p> | |
| 62 | * There then follows a sequence of optional frames that are embedded | |
| 63 | * within the "CHAP" frame and which describe the content of the chapter | |
| 64 | * (e.g. a "TIT2" frame representing the chapter name) or provide | |
| 65 | * related material such as URLs and images. These sub-frames are | |
| 66 | * contained within the bounds of the "CHAP" frame as signalled by the | |
| 67 | * size field in the "CHAP" frame header. If a parser does not recognise | |
| 68 | * "CHAP" frames it can skip them using the size field in the frame | |
| 69 | * header. When it does this it will skip any embedded sub-frames | |
| 70 | * carried within the frame. | |
| 71 | * </p> | |
| 72 | * <p/> | |
| 73 | * <p>For more details, please refer to the ID3 Chapter Frame specifications: | |
| 74 | * <ul> | |
| 75 | * <li><a href="http://www.id3.org/id3v2-chapters-1.0.txt">ID3 v2 Chapter Frame Spec</a> | |
| 76 | * </ul> | |
| 77 | * | |
| 78 | * @author Marc Gimpel, Horizon Wimba S.A. | |
| 79 | * @version $Id: FrameBodyCHAP.java,v 1.5 2008/07/21 10:45:42 paultaylor Exp $ | |
| 80 | */ | |
| 81 | public class FrameBodyCHAP extends AbstractID3v2FrameBody implements ID3v2ChapterFrameBody | |
| 82 | { | |
| 83 | /** | |
| 84 | * Creates a new FrameBodyCHAP datatype. | |
| 85 | */ | |
| 86 | public FrameBodyCHAP() | |
| 87 | 0 | { |
| 88 | 0 | } |
| 89 | ||
| 90 | /** | |
| 91 | * Creates a new FrameBodyCHAP datatype. | |
| 92 | * | |
| 93 | * @param body | |
| 94 | */ | |
| 95 | public FrameBodyCHAP(FrameBodyCHAP body) | |
| 96 | { | |
| 97 | 0 | super(body); |
| 98 | 0 | } |
| 99 | ||
| 100 | /** | |
| 101 | * Creates a new FrameBodyCHAP datatype. | |
| 102 | * | |
| 103 | * @param elementId | |
| 104 | * @param startTime | |
| 105 | * @param endTime | |
| 106 | * @param startOffset | |
| 107 | * @param endOffset | |
| 108 | */ | |
| 109 | public FrameBodyCHAP(String elementId, int startTime, int endTime, int startOffset, int endOffset) | |
| 110 | 0 | { |
| 111 | 0 | this.setObjectValue(DataTypes.OBJ_ELEMENT_ID, elementId); |
| 112 | 0 | this.setObjectValue(DataTypes.OBJ_START_TIME, startTime); |
| 113 | 0 | this.setObjectValue(DataTypes.OBJ_END_TIME, endTime); |
| 114 | 0 | this.setObjectValue(DataTypes.OBJ_START_OFFSET, startOffset); |
| 115 | 0 | this.setObjectValue(DataTypes.OBJ_END_OFFSET, endOffset); |
| 116 | 0 | } |
| 117 | ||
| 118 | /** | |
| 119 | * Creates a new FrameBodyAENC datatype. | |
| 120 | * | |
| 121 | * @throws InvalidTagException if unable to create framebody from buffer | |
| 122 | */ | |
| 123 | public FrameBodyCHAP(ByteBuffer byteBuffer, int frameSize) throws InvalidTagException | |
| 124 | { | |
| 125 | 0 | super(byteBuffer, frameSize); |
| 126 | 0 | } |
| 127 | ||
| 128 | /** | |
| 129 | * The ID3v2 frame identifier | |
| 130 | * | |
| 131 | * @return the ID3v2 frame identifier for this frame type | |
| 132 | */ | |
| 133 | public String getIdentifier() | |
| 134 | { | |
| 135 | 0 | return ID3v2ChapterFrames.FRAME_ID_CHAPTER; |
| 136 | } | |
| 137 | ||
| 138 | /** | |
| 139 | * | |
| 140 | */ | |
| 141 | protected void setupObjectList() | |
| 142 | { | |
| 143 | 0 | objectList.add(new StringNullTerminated(DataTypes.OBJ_ELEMENT_ID, this)); |
| 144 | 0 | objectList.add(new NumberFixedLength(DataTypes.OBJ_START_TIME, this, 4)); |
| 145 | 0 | objectList.add(new NumberFixedLength(DataTypes.OBJ_END_TIME, this, 4)); |
| 146 | 0 | objectList.add(new NumberFixedLength(DataTypes.OBJ_START_OFFSET, this, 4)); |
| 147 | 0 | objectList.add(new NumberFixedLength(DataTypes.OBJ_END_OFFSET, this, 4)); |
| 148 | 0 | } |
| 149 | } |