Coverage Report - org.jaudiotagger.audio.asf.io.StreamBitratePropertiesReader
 
Classes in this File Line Coverage Branch Coverage Complexity
StreamBitratePropertiesReader
100%
14/14
100%
2/2
1.25
 
 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.io;
 20  
 
 21  
 import org.jaudiotagger.audio.asf.data.Chunk;
 22  
 import org.jaudiotagger.audio.asf.data.GUID;
 23  
 import org.jaudiotagger.audio.asf.data.StreamBitratePropertiesChunk;
 24  
 import org.jaudiotagger.audio.asf.util.Utils;
 25  
 
 26  
 import java.io.IOException;
 27  
 import java.io.InputStream;
 28  
 import java.math.BigInteger;
 29  
 
 30  
 /**
 31  
  * This class reads the chunk containing the stream bitrate properties.<br>
 32  
  *
 33  
  * @author Christian Laireiter
 34  
  */
 35  
 public class StreamBitratePropertiesReader implements ChunkReader
 36  
 {
 37  
 
 38  
     /**
 39  
      * Should not be used for now.
 40  
      */
 41  
     protected StreamBitratePropertiesReader()
 42  42
     {
 43  
         // NOTHING toDo
 44  42
     }
 45  
 
 46  
     /**
 47  
      * {@inheritDoc}
 48  
      */
 49  
     public boolean canFail()
 50  
     {
 51  16
         return false;
 52  
     }
 53  
 
 54  
     /**
 55  
      * {@inheritDoc}
 56  
      */
 57  
     public GUID getApplyingId()
 58  
     {
 59  42
         return GUID.GUID_STREAM_BITRATE_PROPERTIES;
 60  
     }
 61  
 
 62  
     /**
 63  
      * {@inheritDoc}
 64  
      */
 65  
     public Chunk read(final GUID guid, final InputStream stream, final long chunkStart) throws IOException
 66  
     {
 67  16
         StreamBitratePropertiesChunk result = null;
 68  16
         BigInteger chunkLen = Utils.readBig64(stream);
 69  16
         result = new StreamBitratePropertiesChunk(chunkLen);
 70  
 
 71  
         /*
 72  
             * Read the amount of bitrate records
 73  
             */
 74  16
         long recordCount = Utils.readUINT16(stream);
 75  32
         for (int i = 0; i < recordCount; i++)
 76  
         {
 77  16
             int flags = Utils.readUINT16(stream);
 78  16
             long avgBitrate = Utils.readUINT32(stream);
 79  16
             result.addBitrateRecord(flags & 0x00FF, avgBitrate);
 80  
         }
 81  
 
 82  16
         result.setPosition(chunkStart);
 83  
 
 84  16
         return result;
 85  
     }
 86  
 
 87  
 }