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

AsfHeader

public final class AsfHeader extends ChunkContainer
Each ASF file starts with a so called header.
This header contains other chunks. Each chunk starts with a 16 byte GUID followed by the length (in bytes) of the chunk (including GUID). The length number takes 8 bytes and is unsigned. Finally the chunk's data appears.
author
Christian Laireiter

Fields Summary
public static final Charset
ASF_CHARSET
The charset "UTF-16LE" is mandatory for ASF handling.
public static final byte[]
ZERO_TERM
Byte sequence representing the zero term character.
private final long
chunkCount
An ASF header contains multiple chunks.
The count of those is stored here.
Constructors Summary
public AsfHeader(long pos, BigInteger chunkLen, long chunkCnt)
Creates an instance.

param
pos see {@link Chunk#position}
param
chunkLen see {@link Chunk#chunkLength}
param
chunkCnt

        super(GUID.GUID_HEADER, pos, chunkLen);
        this.chunkCount = chunkCnt;
    
Methods Summary
public ContentDescriptionfindContentDescription()
This method looks for an content description object in this header instance, if not found there, it tries to get one from a contained ASF header extension object.

return
content description if found, null otherwise.

        ContentDescription result = getContentDescription();
        if (result == null && getExtendedHeader() != null) {
            result = getExtendedHeader().getContentDescription();
        }
        return result;
    
public MetadataContainerfindExtendedContentDescription()
This method looks for an extended content description object in this header instance, if not found there, it tries to get one from a contained ASF header extension object.

return
extended content description if found, null otherwise.

        MetadataContainer result = getExtendedContentDescription();
        if (result == null && getExtendedHeader() != null) {
            result = getExtendedHeader().getExtendedContentDescription();
        }
        return result;
    
public MetadataContainerfindMetadataContainer(ContainerType type)
This method searches for a metadata container of the given type.

param
type the type of the container to look up.
return
a container of specified type, of null if not contained.

        MetadataContainer result = (MetadataContainer) getFirst(type
                .getContainerGUID(), MetadataContainer.class);
        if (result == null) {
            result = (MetadataContainer) getExtendedHeader().getFirst(
                    type.getContainerGUID(), MetadataContainer.class);
        }
        return result;
    
public AudioStreamChunkgetAudioStreamChunk()
This method returns the first audio stream chunk found in the asf file or stream.

return
Returns the audioStreamChunk.

        AudioStreamChunk result = null;
        final List<Chunk> streamChunks = assertChunkList(GUID.GUID_STREAM);
        for (int i = 0; i < streamChunks.size() && result == null; i++) {
            if (streamChunks.get(i) instanceof AudioStreamChunk) {
                result = (AudioStreamChunk) streamChunks.get(i);
            }
        }
        return result;
    
public longgetChunkCount()
Returns the amount of chunks, when this instance was created.
If chunks have been added, this won't be reflected with this call.
For that use {@link #getChunks()}.

return
Chunkcount at instance creation.

        return this.chunkCount;
    
public ContentDescriptiongetContentDescription()

return
Returns the contentDescription.

        return (ContentDescription) getFirst(GUID.GUID_CONTENTDESCRIPTION,
                ContentDescription.class);
    
public EncodingChunkgetEncodingChunk()

return
Returns the encodingChunk.

        return (EncodingChunk) getFirst(GUID.GUID_ENCODING, EncodingChunk.class);
    
public EncryptionChunkgetEncryptionChunk()

return
Returns the encodingChunk.

        return (EncryptionChunk) getFirst(GUID.GUID_CONTENT_ENCRYPTION,
                EncryptionChunk.class);
    
public MetadataContainergetExtendedContentDescription()

return
Returns the tagHeader.

        return (MetadataContainer) getFirst(
                GUID.GUID_EXTENDED_CONTENT_DESCRIPTION, MetadataContainer.class);
    
public AsfExtendedHeadergetExtendedHeader()

return
Returns the extended header.

        return (AsfExtendedHeader) getFirst(GUID.GUID_HEADER_EXTENSION,
                AsfExtendedHeader.class);
    
public FileHeadergetFileHeader()

return
Returns the fileHeader.

        return (FileHeader) getFirst(GUID.GUID_FILE, FileHeader.class);
    
public StreamBitratePropertiesChunkgetStreamBitratePropertiesChunk()

return
Returns the streamBitratePropertiesChunk.

        return (StreamBitratePropertiesChunk) getFirst(
                GUID.GUID_STREAM_BITRATE_PROPERTIES,
                StreamBitratePropertiesChunk.class);
    
public java.lang.StringprettyPrint(java.lang.String prefix)
{@inheritDoc}

        final StringBuilder result = new StringBuilder(super.prettyPrint(prefix,
                prefix + "  | : Contains: \"" + getChunkCount() + "\" chunks"
                        + Utils.LINE_SEPARATOR));
        return result.toString();