Class MovieMaker

  • All Implemented Interfaces:
    javax.media.ControllerListener, javax.media.datasink.DataSinkListener

    public class MovieMaker
    extends java.lang.Object
    implements javax.media.ControllerListener, javax.media.datasink.DataSinkListener
    This class creates AVIs (.avi) out of a list of JPEG files or out of an array of java.awt.Image objects.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  MovieMaker.AWTImageSourceStream
      The java.awt.Image-based source stream to go along with ImageDataSource.
      private static class  MovieMaker.ImageDataSource
      A DataSource to read from a list of JPEG image files or java.awt.Images, and turn that into a stream of JMF buffers.
      private static class  MovieMaker.JpegSourceStream
      The jpeg-based source stream to go along with ImageDataSource.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean fileDone
      DOCUMENT ME!
      private boolean fileSuccess
      DOCUMENT ME!
      private javax.media.MediaLocator outML
      Media locator for the output file.
      private javax.media.Processor processor
      Video processor reference.
      private boolean stateTransitionOK
      DOCUMENT ME!
      private java.lang.Object waitFileSync
      DOCUMENT ME!
      private java.lang.Object waitSync
      Synchonization control variables.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        MovieMaker​(int width, int height, int frameRate, java.io.File outputFile, java.awt.Image[] images)
      Constructor.
        MovieMaker​(int width, int height, int frameRate, java.io.File outputFile, java.io.File[] jpegFiles)
      Constructor.
      private MovieMaker​(java.io.File outputFile, MovieMaker.ImageDataSource ids)
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void controllerUpdate​(javax.media.ControllerEvent evt)
      Controller Listener.
      private static javax.media.DataSink createDataSink​(javax.media.Processor p, javax.media.MediaLocator outML)
      Create the DataSink.
      private javax.media.Processor createProcessor​(java.io.File outputFile, MovieMaker.ImageDataSource ids)
      Create video processor from the given source image files and output file.
      void dataSinkUpdate​(javax.media.datasink.DataSinkEvent evt)
      Event handler for the file writer.
      void makeMovie()
      Method actually does the transcoding from JPeg images file to AVI.
      private boolean waitForFileDone()
      Block until file writing is done.
      private boolean waitForState​(javax.media.Processor p, int state)
      Block until the processor has transitioned to the given state.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • fileDone

        private boolean fileDone
        DOCUMENT ME!
      • fileSuccess

        private boolean fileSuccess
        DOCUMENT ME!
      • outML

        private final javax.media.MediaLocator outML
        Media locator for the output file.
      • processor

        private final javax.media.Processor processor
        Video processor reference.
      • stateTransitionOK

        private boolean stateTransitionOK
        DOCUMENT ME!
      • waitFileSync

        private final java.lang.Object waitFileSync
        DOCUMENT ME!
      • waitSync

        private final java.lang.Object waitSync
        Synchonization control variables.
    • Constructor Detail

      • MovieMaker

        public MovieMaker​(int width,
                          int height,
                          int frameRate,
                          java.io.File outputFile,
                          java.io.File[] jpegFiles)
                   throws java.lang.Exception
        Constructor.
        Parameters:
        width - frame width
        height - frame height
        frameRate - frame rate
        outputFile - AVI output file
        jpegFiles - jpeg images list.
        Throws:
        java.lang.Exception - DOCUMENT ME!
      • MovieMaker

        public MovieMaker​(int width,
                          int height,
                          int frameRate,
                          java.io.File outputFile,
                          java.awt.Image[] images)
                   throws java.lang.Exception
        Constructor.
        Parameters:
        width - frame width
        height - frame height
        frameRate - frame rate
        outputFile - AVI output file
        images - source images list.
        Throws:
        java.lang.Exception - DOCUMENT ME!
      • MovieMaker

        private MovieMaker​(java.io.File outputFile,
                           MovieMaker.ImageDataSource ids)
                    throws java.lang.Exception
        Constructor.
        Parameters:
        outputFile - AVI output file.
        ids - jpegs image data source.
        Throws:
        java.lang.Exception - DOCUMENT ME!
    • Method Detail

      • controllerUpdate

        public void controllerUpdate​(javax.media.ControllerEvent evt)
        Controller Listener.
        Specified by:
        controllerUpdate in interface javax.media.ControllerListener
        Parameters:
        evt - controller event.
      • dataSinkUpdate

        public void dataSinkUpdate​(javax.media.datasink.DataSinkEvent evt)
        Event handler for the file writer.
        Specified by:
        dataSinkUpdate in interface javax.media.datasink.DataSinkListener
        Parameters:
        evt - DOCUMENT ME!
      • makeMovie

        public void makeMovie()
                       throws java.lang.Exception
        Method actually does the transcoding from JPeg images file to AVI.
        Throws:
        java.lang.Exception - DOCUMENT ME!
      • createDataSink

        private static javax.media.DataSink createDataSink​(javax.media.Processor p,
                                                           javax.media.MediaLocator outML)
                                                    throws java.io.IOException,
                                                           javax.media.NoDataSinkException
        Create the DataSink.
        Parameters:
        p - DOCUMENT ME!
        outML - DOCUMENT ME!
        Returns:
        DOCUMENT ME!
        Throws:
        java.io.IOException - DOCUMENT ME!
        javax.media.NoDataSinkException - DOCUMENT ME!
      • createProcessor

        private javax.media.Processor createProcessor​(java.io.File outputFile,
                                                      MovieMaker.ImageDataSource ids)
                                               throws java.lang.Exception
        Create video processor from the given source image files and output file.
        Parameters:
        outputFile - output file
        ids - ImageDataSource jpeg images file source.
        Returns:
        Processor the created vedio processor.
        Throws:
        java.lang.Exception - DOCUMENT ME!
        java.io.IOException - DOCUMENT ME!
        java.lang.IllegalArgumentException - DOCUMENT ME!
      • waitForFileDone

        private boolean waitForFileDone()
                                 throws java.lang.InterruptedException
        Block until file writing is done.
        Returns:
        DOCUMENT ME!
        Throws:
        java.lang.InterruptedException - DOCUMENT ME!
      • waitForState

        private boolean waitForState​(javax.media.Processor p,
                                     int state)
                              throws java.lang.InterruptedException
        Block until the processor has transitioned to the given state. Return false if the transition failed.
        Parameters:
        p - reference.
        state - processor transcoding state.
        Returns:
        DOCUMENT ME!
        Throws:
        java.lang.InterruptedException - DOCUMENT ME!