net.sf.ext.mediamanager
Class FilePropertiesASF

java.lang.Object
  extended by net.sf.ext.mediamanager.FilePropertiesASF

public class FilePropertiesASF
extends java.lang.Object

This class provides a FileProperties extension for the use of ASF media files.
It would have been nice if it also use a DataInputStream in order to read the contents. However, since it uses the "Entagged"-Audio-Library a RandomAccessFile is mandatory.

Author:
Christian Laireiter

Constructor Summary
FilePropertiesASF()
           
 
Method Summary
 boolean containsVideoStream()
          Returns true if the last call of process(RandomAccessFile) has found a video stream.
Only the this objects fields have been refilled.
protected  java.lang.String findName(java.io.InputStream stream, java.lang.String id)
          Searchs in the inputStream stream the name following the string id (seperated by a \t).
protected  int getAudioBitRate()
          Returns the audio bit rate.
protected  int getAudioChannels()
          Returns the audio channels.
protected  java.lang.String getAudioCodec()
          Returns the audio codec.
protected  int getAudioRate()
          Returns the audio rate.
protected  java.lang.String getContainer()
          Returns the container.
 int getDecimalValue(int[] bits, int start, int stop, boolean printBits)
          Returns the decimal value of a specified bumber of bytes from a specific part of a byte.
protected  int getDuration()
          Returns the duration.
protected  java.lang.String getMediaType()
          Returns the Media Type.
protected  java.util.ArrayList getMetaData()
          Returns the meta data ArrayList.
protected  java.lang.String getSubtitles()
          Returns the subtitles.
protected  int getUnsignedInt16(byte byte1, byte byte2)
          Returns a 16-bit integer.
protected  int getUnsignedInt16(int byte1, int byte2)
          Returns a 16-bit integer.
protected  int getUnsignedInt32(byte byte1, byte byte2)
          Returns an unsigned 32-bit integer.
protected  int getUnsignedInt32(int byte1, int byte2)
          Returns an unsigned 32-bit integer.
protected  int getVideoBitRate()
          Returns the video bit rate.
protected  java.lang.String getVideoCodec()
          Returns the video codec.
protected  int getVideoRate()
          Returns the video rate.
protected  java.lang.String getVideoResolution()
          Returns the resolution.
 void process(java.io.RandomAccessFile file)
          This method will read the file and interprets it as an asf-media-file.
protected  int readUnsignedByte(byte[] b, int offset)
          Reads an unsigned 8-bit integer.
protected  int readUnsignedByte(java.io.RandomAccessFile dataStream)
          Reads an unsigned byte and returns its int representation.
protected  int[] readUnsignedBytes(java.io.RandomAccessFile dataStream, int n)
          Reads n unsigned bytes and returns it in an int[n].
protected  int readUnsignedInt16(byte[] b, int offset)
          Reads an unsigned 16-bit integer.
protected  int readUnsignedInt16(java.io.RandomAccessFile dataStream)
          Reads an unsigned 16-bit integer.
protected  int readUnsignedInt32(byte[] b, int offset)
          Reads an unsigned 32-bit integer.
protected  int readUnsignedInt32(java.io.RandomAccessFile dataStream)
          Reads an unsigned 32-bit integer.
protected  void setAudioBitRate(int audioBitRate)
          Sets the audio bit rate.
protected  void setAudioChannels(int audioChannels)
          Sets the audio channels.
protected  void setAudioCodec(java.lang.String audioCodec)
          Sets the audio codec (auds handler).
protected  void setAudioRate(int audioRate)
          Sets the audio rate.
protected  void setContainer(java.lang.String container)
          Sets the container.
protected  void setDuration(int duration)
          Sets the duration.
protected  void setMediaType(java.lang.String mediaType)
          Sets the Media Type.
protected  void setMetaData(java.util.ArrayList metaData)
          Sets the meta data ArrayList.
protected  void setSubtitles(java.lang.String subtitles)
          Sets the subtitles.
protected  void setVideoBitRate(int videoBitRate)
          Sets the video bit rate.
protected  void setVideoCodec(java.lang.String videoCodec)
          Sets the video codec (vids handler).
protected  void setVideoRate(int videoRate)
          Sets the video rate.
protected  void setVideoResolution(java.lang.String videoResolution)
          Sets the resolution.
protected  void skipBytes(java.io.RandomAccessFile dataStream, int n)
          Discards n bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilePropertiesASF

public FilePropertiesASF()
Method Detail

containsVideoStream

public boolean containsVideoStream()
Returns true if the last call of process(RandomAccessFile) has found a video stream.
Only the this objects fields have been refilled.

Returns:
true if video stream was found.

process

public void process(java.io.RandomAccessFile file)
             throws java.lang.Exception
This method will read the file and interprets it as an asf-media-file.

Parameters:
file - The asf media file, which should be parsed.
Throws:
java.lang.Exception - Thrown on IOErrors, or failure in interpreting the file as asf.

getSubtitles

protected java.lang.String getSubtitles()
Returns the subtitles.


getVideoResolution

protected java.lang.String getVideoResolution()
Returns the resolution.


getVideoCodec

protected java.lang.String getVideoCodec()
Returns the video codec.


getVideoRate

protected int getVideoRate()
Returns the video rate.


getVideoBitRate

protected int getVideoBitRate()
Returns the video bit rate.


getDuration

protected int getDuration()
Returns the duration.


getAudioCodec

protected java.lang.String getAudioCodec()
Returns the audio codec.


getAudioRate

protected int getAudioRate()
Returns the audio rate.


getAudioBitRate

protected int getAudioBitRate()
Returns the audio bit rate.


getAudioChannels

protected int getAudioChannels()
Returns the audio channels.


setSubtitles

protected void setSubtitles(java.lang.String subtitles)
Sets the subtitles.


setVideoResolution

protected void setVideoResolution(java.lang.String videoResolution)
Sets the resolution.


setVideoCodec

protected void setVideoCodec(java.lang.String videoCodec)
Sets the video codec (vids handler).


setVideoRate

protected void setVideoRate(int videoRate)
Sets the video rate.


setVideoBitRate

protected void setVideoBitRate(int videoBitRate)
Sets the video bit rate.


setDuration

protected void setDuration(int duration)
Sets the duration.


setAudioCodec

protected void setAudioCodec(java.lang.String audioCodec)
Sets the audio codec (auds handler).


setAudioRate

protected void setAudioRate(int audioRate)
Sets the audio rate.


setAudioBitRate

protected void setAudioBitRate(int audioBitRate)
Sets the audio bit rate.


setAudioChannels

protected void setAudioChannels(int audioChannels)
Sets the audio channels.


setContainer

protected void setContainer(java.lang.String container)
Sets the container.


getContainer

protected java.lang.String getContainer()
Returns the container.


setMediaType

protected void setMediaType(java.lang.String mediaType)
Sets the Media Type.


getMediaType

protected java.lang.String getMediaType()
Returns the Media Type.


setMetaData

protected void setMetaData(java.util.ArrayList metaData)
Sets the meta data ArrayList.


getMetaData

protected java.util.ArrayList getMetaData()
Returns the meta data ArrayList.


readUnsignedByte

protected int readUnsignedByte(byte[] b,
                               int offset)
                        throws java.lang.Exception
Reads an unsigned 8-bit integer.

Throws:
java.lang.Exception

readUnsignedInt16

protected int readUnsignedInt16(byte[] b,
                                int offset)
                         throws java.lang.Exception
Reads an unsigned 16-bit integer.

Throws:
java.lang.Exception

readUnsignedInt32

protected int readUnsignedInt32(byte[] b,
                                int offset)
                         throws java.lang.Exception
Reads an unsigned 32-bit integer.

Throws:
java.lang.Exception

getUnsignedInt16

protected int getUnsignedInt16(int byte1,
                               int byte2)
                        throws java.lang.Exception
Returns a 16-bit integer.

Throws:
java.lang.Exception

getUnsignedInt16

protected int getUnsignedInt16(byte byte1,
                               byte byte2)
                        throws java.lang.Exception
Returns a 16-bit integer.

Throws:
java.lang.Exception

getUnsignedInt32

protected int getUnsignedInt32(byte byte1,
                               byte byte2)
                        throws java.lang.Exception
Returns an unsigned 32-bit integer.

Throws:
java.lang.Exception

getUnsignedInt32

protected int getUnsignedInt32(int byte1,
                               int byte2)
                        throws java.lang.Exception
Returns an unsigned 32-bit integer.

Throws:
java.lang.Exception

readUnsignedByte

protected int readUnsignedByte(java.io.RandomAccessFile dataStream)
                        throws java.lang.Exception
Reads an unsigned byte and returns its int representation.

Throws:
java.lang.Exception

readUnsignedBytes

protected int[] readUnsignedBytes(java.io.RandomAccessFile dataStream,
                                  int n)
                           throws java.lang.Exception
Reads n unsigned bytes and returns it in an int[n].

Throws:
java.lang.Exception

readUnsignedInt16

protected int readUnsignedInt16(java.io.RandomAccessFile dataStream)
                         throws java.lang.Exception
Reads an unsigned 16-bit integer.

Throws:
java.lang.Exception

readUnsignedInt32

protected int readUnsignedInt32(java.io.RandomAccessFile dataStream)
                         throws java.lang.Exception
Reads an unsigned 32-bit integer.

Throws:
java.lang.Exception

skipBytes

protected void skipBytes(java.io.RandomAccessFile dataStream,
                         int n)
                  throws java.lang.Exception
Discards n bytes.

Throws:
java.lang.Exception

getDecimalValue

public int getDecimalValue(int[] bits,
                           int start,
                           int stop,
                           boolean printBits)
Returns the decimal value of a specified bumber of bytes from a specific part of a byte.


findName

protected java.lang.String findName(java.io.InputStream stream,
                                    java.lang.String id)
                             throws java.lang.Exception
Searchs in the inputStream stream the name following the string id (seperated by a \t).

Throws:
java.lang.Exception