FileDocCategorySizeDatePackage
StreamBitratePropertiesChunk.javaAPI DocJaudiotagger 2.0.43861Wed Mar 30 16:11:50 BST 2011org.jaudiotagger.audio.asf.data

StreamBitratePropertiesChunk

public class StreamBitratePropertiesChunk extends Chunk
This class represents the "Stream Bitrate Properties" chunk of an ASF media file.
It is optional, but contains useful information about the streams bitrate.
author
Christian Laireiter

Fields Summary
private final List
bitRates
For each call of {@link #addBitrateRecord(int,long)} an {@link Long} object is appended, which represents the average bitrate.
private final List
streamNumbers
For each call of {@link #addBitrateRecord(int,long)} an {@link Integer} object is appended, which represents the stream-number.
Constructors Summary
public StreamBitratePropertiesChunk(BigInteger chunkLen)
Creates an instance.

param
chunkLen Length of current chunk.

        super(GUID.GUID_STREAM_BITRATE_PROPERTIES, chunkLen);
        this.bitRates = new ArrayList<Long>();
        this.streamNumbers = new ArrayList<Integer>();
    
Methods Summary
public voidaddBitrateRecord(int streamNum, long averageBitrate)
Adds the public values of a stream-record.

param
streamNum The number of the referred stream.
param
averageBitrate Its average bitrate.

        this.streamNumbers.add(streamNum);
        this.bitRates.add(averageBitrate);
    
public longgetAvgBitrate(int streamNumber)
Returns the average bitrate of the given stream.

param
streamNumber Number of the stream whose bitrate to determine.
return
The average bitrate of the numbered stream. -1 if no information was given.

        final Integer seach = streamNumber;
        final int index = this.streamNumbers.indexOf(seach);
        long result;
        if (index == -1) {
            result = -1;
        } else {
            result = this.bitRates.get(index);
        }
        return result;
    
public java.lang.StringprettyPrint(java.lang.String prefix)
(overridden)

see
org.jaudiotagger.audio.asf.data.Chunk#prettyPrint(String)

        final StringBuilder result = new StringBuilder(super.prettyPrint(prefix));
        for (int i = 0; i < this.bitRates.size(); i++) {
            result.append(prefix).append("  |-> Stream no. \"").append(
                    this.streamNumbers.get(i)).append(
                    "\" has an average bitrate of \"").append(
                    this.bitRates.get(i)).append('"").append(
                    Utils.LINE_SEPARATOR);
        }
        return result.toString();