Coverage Report - org.jaudiotagger.audio.asf.data.StreamChunk
 
Classes in this File Line Coverage Branch Coverage Complexity
StreamChunk
53%
15/28
66%
4/6
1.077
 
 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 org.jaudiotagger.audio.asf.util.Utils;
 22  
 
 23  
 import java.math.BigInteger;
 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  4
 public abstract class StreamChunk extends Chunk {
 35  
 
 36  
     /**
 37  
      * If <code>true</code>, the stream data is encrypted.
 38  
      */
 39  
     private boolean contentEncrypted;
 40  
 
 41  
     /**
 42  
      * This field stores the number of the current stream. <br>
 43  
      */
 44  
     private int streamNumber;
 45  
 
 46  
     /**
 47  
      * @see #typeSpecificDataSize
 48  
      */
 49  
     private long streamSpecificDataSize;
 50  
 
 51  
     /**
 52  
      * Something technical. <br>
 53  
      * Format time in 100-ns steps.
 54  
      */
 55  
     private long timeOffset;
 56  
 
 57  
     /**
 58  
      * Stores the stream type.<br>
 59  
      * 
 60  
      * @see GUID#GUID_AUDIOSTREAM
 61  
      * @see GUID#GUID_VIDEOSTREAM
 62  
      */
 63  
     private final 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
 74  
      *            The GUID which tells the stream type represented (
 75  
      *            {@link GUID#GUID_AUDIOSTREAM} or {@link GUID#GUID_VIDEOSTREAM}
 76  
      *            ):
 77  
      * @param chunkLen
 78  
      *            length of chunk
 79  
      */
 80  
     public StreamChunk(final GUID streamType, final BigInteger chunkLen) {
 81  286
         super(GUID.GUID_STREAM, chunkLen);
 82  286
         assert GUID.GUID_AUDIOSTREAM.equals(streamType)
 83  
                 || GUID.GUID_VIDEOSTREAM.equals(streamType);
 84  286
         this.type = streamType;
 85  286
     }
 86  
 
 87  
     /**
 88  
      * @return Returns the streamNumber.
 89  
      */
 90  
     public int getStreamNumber() {
 91  0
         return this.streamNumber;
 92  
     }
 93  
 
 94  
     /**
 95  
      * @return Returns the streamSpecificDataSize.
 96  
      */
 97  
     public long getStreamSpecificDataSize() {
 98  0
         return this.streamSpecificDataSize;
 99  
     }
 100  
 
 101  
     /**
 102  
      * Returns the stream type of the stream chunk.<br>
 103  
      * 
 104  
      * @return {@link GUID#GUID_AUDIOSTREAM} or {@link GUID#GUID_VIDEOSTREAM}.
 105  
      */
 106  
     public GUID getStreamType() {
 107  0
         return this.type;
 108  
     }
 109  
 
 110  
     /**
 111  
      * @return Returns the timeOffset.
 112  
      */
 113  
     public long getTimeOffset() {
 114  0
         return this.timeOffset;
 115  
     }
 116  
 
 117  
     /**
 118  
      * @return Returns the typeSpecificDataSize.
 119  
      */
 120  
     public long getTypeSpecificDataSize() {
 121  0
         return this.typeSpecificDataSize;
 122  
     }
 123  
 
 124  
     /**
 125  
      * @return Returns the contentEncrypted.
 126  
      */
 127  
     public boolean isContentEncrypted() {
 128  0
         return this.contentEncrypted;
 129  
     }
 130  
 
 131  
     /**
 132  
      * (overridden)
 133  
      * 
 134  
      * @see org.jaudiotagger.audio.asf.data.Chunk#prettyPrint(String)
 135  
      */
 136  
     @Override
 137  
     public String prettyPrint(final String prefix) {
 138  0
         final StringBuilder result = new StringBuilder(super.prettyPrint(prefix));
 139  0
         result.append(prefix).append("  |-> Stream number: ").append(
 140  
                 getStreamNumber()).append(Utils.LINE_SEPARATOR);
 141  0
         result.append(prefix).append("  |-> Type specific data size  : ")
 142  
                 .append(getTypeSpecificDataSize()).append(Utils.LINE_SEPARATOR);
 143  0
         result.append(prefix).append("  |-> Stream specific data size: ")
 144  
                 .append(getStreamSpecificDataSize()).append(
 145  
                         Utils.LINE_SEPARATOR);
 146  0
         result.append(prefix).append("  |-> Time Offset              : ")
 147  
                 .append(getTimeOffset()).append(Utils.LINE_SEPARATOR);
 148  0
         result.append(prefix).append("  |-> Content Encryption       : ")
 149  
                 .append(isContentEncrypted()).append(Utils.LINE_SEPARATOR);
 150  0
         return result.toString();
 151  
     }
 152  
 
 153  
     /**
 154  
      * @param cntEnc
 155  
      *            The contentEncrypted to set.
 156  
      */
 157  
     public void setContentEncrypted(final boolean cntEnc) {
 158  278
         this.contentEncrypted = cntEnc;
 159  278
     }
 160  
 
 161  
     /**
 162  
      * @param streamNum
 163  
      *            The streamNumber to set.
 164  
      */
 165  
     public void setStreamNumber(final int streamNum) {
 166  278
         this.streamNumber = streamNum;
 167  278
     }
 168  
 
 169  
     /**
 170  
      * @param strSpecDataSize
 171  
      *            The streamSpecificDataSize to set.
 172  
      */
 173  
     public void setStreamSpecificDataSize(final long strSpecDataSize) {
 174  278
         this.streamSpecificDataSize = strSpecDataSize;
 175  278
     }
 176  
 
 177  
     /**
 178  
      * @param timeOffs
 179  
      *            sets the time offset
 180  
      */
 181  
     public void setTimeOffset(final long timeOffs) {
 182  278
         this.timeOffset = timeOffs;
 183  278
     }
 184  
 
 185  
     /**
 186  
      * @param typeSpecDataSize
 187  
      *            The typeSpecificDataSize to set.
 188  
      */
 189  
     public void setTypeSpecificDataSize(final long typeSpecDataSize) {
 190  278
         this.typeSpecificDataSize = typeSpecDataSize;
 191  278
     }
 192  
 }