Copyright 2012-04-26 Werner Randelshofer

org.monte.media.quicktime
Class QuickTimeReader

java.lang.Object
  extended by org.monte.media.quicktime.AbstractQuickTimeStream
      extended by org.monte.media.quicktime.QuickTimeInputStream
          extended by org.monte.media.quicktime.QuickTimeReader
All Implemented Interfaces:
MovieReader

public class QuickTimeReader
extends QuickTimeInputStream
implements MovieReader

QuickTimeReader.

Version:
$Id: QuickTimeReader.java 199 2012-04-05 08:48:28Z werner $
Author:
Werner Randelshofer

Nested Class Summary
 
Nested classes/interfaces inherited from class org.monte.media.quicktime.AbstractQuickTimeStream
AbstractQuickTimeStream.Atom, AbstractQuickTimeStream.AudioTrack, AbstractQuickTimeStream.Chunk, AbstractQuickTimeStream.CompositeAtom, AbstractQuickTimeStream.DataAtom, AbstractQuickTimeStream.Edit, AbstractQuickTimeStream.Group, AbstractQuickTimeStream.Sample, AbstractQuickTimeStream.SampleSizeGroup, AbstractQuickTimeStream.States, AbstractQuickTimeStream.TimeToSampleGroup, AbstractQuickTimeStream.Track, AbstractQuickTimeStream.VideoTrack, AbstractQuickTimeStream.WideDataAtom
 
Field Summary
static Format QUICKTIME
           
 
Fields inherited from class org.monte.media.quicktime.QuickTimeInputStream
in
 
Fields inherited from class org.monte.media.quicktime.AbstractQuickTimeStream
creationTime, mdatAtom, mdatOffset, modificationTime, moovAtom, movieMatrix, movieTimeScale, out, state, streamOffset, tracks
 
Constructor Summary
QuickTimeReader(java.io.File file)
          Creates a new instance.
QuickTimeReader(javax.imageio.stream.ImageInputStream in)
          Creates a new instance.
 
Method Summary
 int findTrack(int fromTrack, Format format)
          Finds a track with the specified format.
 long getChunkCount(int track)
          Returns the number of media data chunks in the specified track.
 Rational getDuration()
          Returns the total duration of the movie in time scale units.
 Format getFileFormat()
          Returns the file format.
 Format getFormat(int track)
          Returns the media format of the specified track.
 Rational getReadTime(int track)
          Returns the current time of the track.
 int nextTrack()
          Returns the index of the next track in playback sequence.
 void read(int track, Buffer buffer)
          Reads the next sample chunk from the specified track.
 Rational sampleToTime(int track, long sample)
          Returns the time for the specified sample number.
 void setMovieReadTime(Rational newValue)
          Sets the read time of all tracks to the closest sync sample before or at the specified time.
 long timeToSample(int track, Rational seconds)
          Returns the sample number for the specified time.
 
Methods inherited from class org.monte.media.quicktime.QuickTimeInputStream
close, ensureRealized, getMediaDuration, getMediaTimeScale, getMovieDuration, getMovieTimeScale, getTrackCount
 
Methods inherited from class org.monte.media.quicktime.AbstractQuickTimeStream
getRelativeStreamPosition, intToType, seekRelative, typeToInt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.monte.media.MovieReader
close, getTrackCount
 

Field Detail

QUICKTIME

public static final Format QUICKTIME
Constructor Detail

QuickTimeReader

public QuickTimeReader(java.io.File file)
                throws java.io.IOException
Creates a new instance.

Parameters:
file - the input file
Throws:
java.io.IOException

QuickTimeReader

public QuickTimeReader(javax.imageio.stream.ImageInputStream in)
                throws java.io.IOException
Creates a new instance.

Parameters:
in - the input stream.
Throws:
java.io.IOException
Method Detail

timeToSample

public long timeToSample(int track,
                         Rational seconds)
Description copied from interface: MovieReader
Returns the sample number for the specified time.

Specified by:
timeToSample in interface MovieReader

sampleToTime

public Rational sampleToTime(int track,
                             long sample)
Description copied from interface: MovieReader
Returns the time for the specified sample number.

Specified by:
sampleToTime in interface MovieReader

getFileFormat

public Format getFileFormat()
                     throws java.io.IOException
Description copied from interface: MovieReader
Returns the file format.

Specified by:
getFileFormat in interface MovieReader
Throws:
java.io.IOException

getFormat

public Format getFormat(int track)
                 throws java.io.IOException
Description copied from interface: MovieReader
Returns the media format of the specified track.

Specified by:
getFormat in interface MovieReader
Parameters:
track - Track number.
Returns:
The media format of the track.
Throws:
java.io.IOException

getChunkCount

public long getChunkCount(int track)
                   throws java.io.IOException
Description copied from interface: MovieReader
Returns the number of media data chunks in the specified track. A chunk contains one or more samples.

Specified by:
getChunkCount in interface MovieReader
Throws:
java.io.IOException

read

public void read(int track,
                 Buffer buffer)
          throws java.io.IOException
Description copied from interface: MovieReader
Reads the next sample chunk from the specified track.

Specified by:
read in interface MovieReader
Parameters:
track - Track number.
buffer - The buffer into which to store the sample data.
Throws:
java.io.IOException

nextTrack

public int nextTrack()
              throws java.io.IOException
Description copied from interface: MovieReader
Returns the index of the next track in playback sequence.

Specified by:
nextTrack in interface MovieReader
Returns:
Index of next track or -1 if end of media reached.
Throws:
java.io.IOException

setMovieReadTime

public void setMovieReadTime(Rational newValue)
Description copied from interface: MovieReader
Sets the read time of all tracks to the closest sync sample before or at the specified time.

Specified by:
setMovieReadTime in interface MovieReader
Parameters:
newValue - Time in seconds.

getReadTime

public Rational getReadTime(int track)
                     throws java.io.IOException
Description copied from interface: MovieReader
Returns the current time of the track.

Specified by:
getReadTime in interface MovieReader
Throws:
java.io.IOException

getDuration

public Rational getDuration()
                     throws java.io.IOException
Description copied from interface: MovieReader
Returns the total duration of the movie in time scale units.

Specified by:
getDuration in interface MovieReader
Throws:
java.io.IOException

findTrack

public int findTrack(int fromTrack,
                     Format format)
              throws java.io.IOException
Description copied from interface: MovieReader
Finds a track with the specified format.

Specified by:
findTrack in interface MovieReader
Parameters:
fromTrack - the start track number.
format - A format specification.
Returns:
The track number >= fromTrack or -1 if no track has been found.
Throws:
java.io.IOException

Copyright 2012-04-26 Werner Randelshofer