org.jaudiotagger.audio.asf.io
Class AsfStreamer

java.lang.Object
  extended by org.jaudiotagger.audio.asf.io.AsfStreamer

public class AsfStreamer
extends java.lang.Object

This class creates a modified copy of an ASF file.

Author:
Christian Laireiter

Constructor Summary
AsfStreamer()
           
 
Method Summary
private  void copyChunk(GUID guid, java.io.InputStream source, java.io.OutputStream destination)
          Simply copies a chunk from source to destination.
The method assumes, that the GUID has already been read and will write the provided one to the destination.
The chunk length however will be read and used to determine the amount of bytes to copy.
 void createModifiedCopy(java.io.InputStream source, java.io.OutputStream dest, java.util.List<ChunkModifier> modifiers)
          Reads the source and applies the modifications provided by the given modifiers, and puts it to dest.
Each modifier is used only once, so if one should be used multiple times, it should be added multiple times into the list.
private  void modifyFileHeader(java.io.InputStream source, java.io.OutputStream destination, long fileSizeDiff)
          This is a slight variation of copyChunk(GUID, InputStream, OutputStream), it only handles file property chunks correctly.
The copied chunk will have the file size field modified by the given fileSizeDiff value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsfStreamer

public AsfStreamer()
Method Detail

copyChunk

private void copyChunk(GUID guid,
                       java.io.InputStream source,
                       java.io.OutputStream destination)
                throws java.io.IOException
Simply copies a chunk from source to destination.
The method assumes, that the GUID has already been read and will write the provided one to the destination.
The chunk length however will be read and used to determine the amount of bytes to copy.

Parameters:
guid - GUID of the current chunk.
source - source of an ASF chunk, which is to be located at the chunk length field.
destination - the destination to copy the chunk to.
Throws:
java.io.IOException - on I/O errors.

createModifiedCopy

public void createModifiedCopy(java.io.InputStream source,
                               java.io.OutputStream dest,
                               java.util.List<ChunkModifier> modifiers)
                        throws java.io.IOException
Reads the source and applies the modifications provided by the given modifiers, and puts it to dest.
Each modifier is used only once, so if one should be used multiple times, it should be added multiple times into the list.

Parameters:
source - the source ASF file
dest - the destination to write the modified version to.
modifiers - list of chunk modifiers to apply.
Throws:
java.io.IOException - on I/O errors.

modifyFileHeader

private void modifyFileHeader(java.io.InputStream source,
                              java.io.OutputStream destination,
                              long fileSizeDiff)
                       throws java.io.IOException
This is a slight variation of copyChunk(GUID, InputStream, OutputStream), it only handles file property chunks correctly.
The copied chunk will have the file size field modified by the given fileSizeDiff value.

Parameters:
source - source of file properties chunk, located at its chunk length field.
destination - the destination to copy the chunk to.
fileSizeDiff - the difference which should be applied. (negative values would subtract the stored file size)
Throws:
java.io.IOException - on I/O errors.