| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| StreamChunk |
|
| 1.0;1 |
| 1 | /* | |
| 2 | * Entagged Audio Tag library | |
| 3 | * Copyright (c) 2004-2005 Christian Laireiter <liree@web.de> | |
| 4 | * | |
| 5 | * This library is free software; you can redistribute it and/or | |
| 6 | * modify it under the terms of the GNU Lesser General Public | |
| 7 | * License as published by the Free Software Foundation; either | |
| 8 | * version 2.1 of the License, or (at your option) any later version. | |
| 9 | * | |
| 10 | * This library is distributed in the hope that it will be useful, | |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | * Lesser General Public License for more details. | |
| 14 | * | |
| 15 | * You should have received a copy of the GNU Lesser General Public | |
| 16 | * License along with this library; if not, write to the Free Software | |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 18 | */ | |
| 19 | package org.jaudiotagger.audio.asf.data; | |
| 20 | ||
| 21 | import java.math.BigInteger; | |
| 22 | ||
| 23 | import org.jaudiotagger.audio.asf.util.Utils; | |
| 24 | ||
| 25 | /** | |
| 26 | * This class is the base for all handled stream contents. <br> | |
| 27 | * A Stream chunk delivers information about a audio or video stream. Because of | |
| 28 | * this the stream chunk identifies in one field what type of stream it is | |
| 29 | * describing and so other data is provided. However some information is common | |
| 30 | * to all stream chunks which are stored in this hierarchy of the class tree. | |
| 31 | * | |
| 32 | * @author Christian Laireiter | |
| 33 | */ | |
| 34 | 5 | public abstract class StreamChunk extends Chunk |
| 35 | { | |
| 36 | ||
| 37 | /** | |
| 38 | * If <code>true</code>, the stream data is encrypted. | |
| 39 | */ | |
| 40 | private boolean contentEncrypted; | |
| 41 | ||
| 42 | /** | |
| 43 | * This field stores the number of the current stream. <br> | |
| 44 | */ | |
| 45 | private int streamNumber; | |
| 46 | ||
| 47 | /** | |
| 48 | * @see #typeSpecificDataSize | |
| 49 | */ | |
| 50 | private long streamSpecificDataSize; | |
| 51 | ||
| 52 | /** | |
| 53 | * Something technical. <br> | |
| 54 | * Format time in 100-ns steps. | |
| 55 | */ | |
| 56 | private long timeOffset; | |
| 57 | ||
| 58 | /** | |
| 59 | * Stores the stream type.<br> | |
| 60 | * @see GUID#GUID_AUDIOSTREAM | |
| 61 | * @see GUID#GUID_VIDEOSTREAM | |
| 62 | */ | |
| 63 | private GUID type; | |
| 64 | ||
| 65 | /** | |
| 66 | * Stores the size of type specific data structure within chunk. | |
| 67 | */ | |
| 68 | private long typeSpecificDataSize; | |
| 69 | ||
| 70 | /** | |
| 71 | * Creates an instance | |
| 72 | * | |
| 73 | * @param streamType The GUID which tells the stream type represented ({@link GUID#GUID_AUDIOSTREAM} | |
| 74 | * or {@link GUID#GUID_VIDEOSTREAM}): | |
| 75 | * @param chunkLen length of chunk | |
| 76 | */ | |
| 77 | public StreamChunk(GUID streamType, BigInteger chunkLen) | |
| 78 | { | |
| 79 | 55 | super(GUID.GUID_STREAM, chunkLen); |
| 80 | 55 | assert GUID.GUID_AUDIOSTREAM.equals(streamType) || GUID.GUID_VIDEOSTREAM.equals(streamType); |
| 81 | 55 | this.type = streamType; |
| 82 | 55 | } |
| 83 | ||
| 84 | /** | |
| 85 | * @return Returns the streamNumber. | |
| 86 | */ | |
| 87 | public int getStreamNumber() | |
| 88 | { | |
| 89 | 0 | return streamNumber; |
| 90 | } | |
| 91 | ||
| 92 | /** | |
| 93 | * @return Returns the streamSpecificDataSize. | |
| 94 | */ | |
| 95 | public long getStreamSpecificDataSize() | |
| 96 | { | |
| 97 | 0 | return streamSpecificDataSize; |
| 98 | } | |
| 99 | ||
| 100 | /** | |
| 101 | * Returns the stream type of the stream chunk.<br> | |
| 102 | * | |
| 103 | * @return {@link GUID#GUID_AUDIOSTREAM} or {@link GUID#GUID_VIDEOSTREAM}. | |
| 104 | */ | |
| 105 | public GUID getStreamType() | |
| 106 | { | |
| 107 | 0 | return this.type; |
| 108 | } | |
| 109 | ||
| 110 | /** | |
| 111 | * @return Returns the timeOffset. | |
| 112 | */ | |
| 113 | public long getTimeOffset() | |
| 114 | { | |
| 115 | 0 | return timeOffset; |
| 116 | } | |
| 117 | ||
| 118 | /** | |
| 119 | * @return Returns the typeSpecificDataSize. | |
| 120 | */ | |
| 121 | public long getTypeSpecificDataSize() | |
| 122 | { | |
| 123 | 0 | return typeSpecificDataSize; |
| 124 | } | |
| 125 | ||
| 126 | /** | |
| 127 | * @return Returns the contentEncrypted. | |
| 128 | */ | |
| 129 | public boolean isContentEncrypted() | |
| 130 | { | |
| 131 | 0 | return contentEncrypted; |
| 132 | } | |
| 133 | ||
| 134 | /** | |
| 135 | * (overridden) | |
| 136 | * | |
| 137 | * @see org.jaudiotagger.audio.asf.data.Chunk#prettyPrint(String) | |
| 138 | */ | |
| 139 | public String prettyPrint(final String prefix) | |
| 140 | { | |
| 141 | 0 | StringBuffer result = new StringBuffer(super.prettyPrint(prefix)); |
| 142 | 0 | result.append(prefix + " |-> Stream number: " + getStreamNumber() + Utils.LINE_SEPARATOR); |
| 143 | 0 | result |
| 144 | .append(prefix + " |-> Type specific data size : " + getTypeSpecificDataSize() + Utils.LINE_SEPARATOR); | |
| 145 | 0 | result |
| 146 | .append(prefix + " |-> Stream specific data size: " + getStreamSpecificDataSize() + Utils.LINE_SEPARATOR); | |
| 147 | 0 | result.append(prefix + " |-> Time Offset : " + getTimeOffset() + Utils.LINE_SEPARATOR); |
| 148 | 0 | result.append(prefix + " |-> Content Encryption : " + isContentEncrypted() + Utils.LINE_SEPARATOR); |
| 149 | 0 | return result.toString(); |
| 150 | } | |
| 151 | ||
| 152 | /** | |
| 153 | * @param cntEnc The contentEncrypted to set. | |
| 154 | */ | |
| 155 | public void setContentEncrypted(boolean cntEnc) | |
| 156 | { | |
| 157 | 55 | this.contentEncrypted = cntEnc; |
| 158 | 55 | } |
| 159 | ||
| 160 | /** | |
| 161 | * @param streamNum The streamNumber to set. | |
| 162 | */ | |
| 163 | public void setStreamNumber(int streamNum) | |
| 164 | { | |
| 165 | 55 | this.streamNumber = streamNum; |
| 166 | 55 | } |
| 167 | ||
| 168 | /** | |
| 169 | * @param strSpecDataSize The streamSpecificDataSize to set. | |
| 170 | */ | |
| 171 | public void setStreamSpecificDataSize(long strSpecDataSize) | |
| 172 | { | |
| 173 | 55 | this.streamSpecificDataSize = strSpecDataSize; |
| 174 | 55 | } |
| 175 | ||
| 176 | /** | |
| 177 | * @param timeOffs sets the time offset | |
| 178 | */ | |
| 179 | public void setTimeOffset(long timeOffs) | |
| 180 | { | |
| 181 | 55 | this.timeOffset = timeOffs; |
| 182 | 55 | } |
| 183 | ||
| 184 | /** | |
| 185 | * @param typeSpecDataSize The typeSpecificDataSize to set. | |
| 186 | */ | |
| 187 | public void setTypeSpecificDataSize(long typeSpecDataSize) | |
| 188 | { | |
| 189 | 55 | this.typeSpecificDataSize = typeSpecDataSize; |
| 190 | 55 | } |
| 191 | } |