Class Transcode

java.lang.Object
  extended by Transcode
All Implemented Interfaces:
javax.media.ControllerListener, javax.media.datasink.DataSinkListener

public class Transcode
extends Object
implements javax.media.ControllerListener, javax.media.datasink.DataSinkListener

A sample program to transcode an input source to an output location with different data formats.


Field Summary
(package private)  boolean fileDone
           
(package private)  boolean fileSuccess
           
(package private)  boolean stateTransitionOK
           
(package private)  Object waitFileSync
           
(package private)  Object waitSync
           
 
Constructor Summary
Transcode()
           
 
Method Summary
 void controllerUpdate(javax.media.ControllerEvent evt)
          Controller Listener.
(package private)  javax.media.DataSink createDataSink(javax.media.Processor p, javax.media.MediaLocator outML)
          Create the DataSink.
(package private) static javax.media.MediaLocator createMediaLocator(String url)
          Create a media locator from the given string.
 void dataSinkUpdate(javax.media.datasink.DataSinkEvent evt)
          Event handler for the file writer.
 boolean doIt(javax.media.MediaLocator inML, javax.media.MediaLocator outML, javax.media.Format[] fmts, int start, int end)
          Given a source media locator, destination media locator and an array of formats, this method will transcode the source to the dest into the specified formats.
(package private)  javax.media.protocol.ContentDescriptor fileExtToCD(String name)
          Convert a file name to a content type.
static void main(String[] args)
          Main program
(package private) static javax.media.Format parseAudioFormat(String fmtStr)
          Parse the audio format specifier and generate an AudioFormat.
(package private) static javax.media.Format parseVideoFormat(String fmtStr)
          Parse the video format specifier and generate an VideoFormat.
(package private) static void prUsage()
           
(package private)  void setContentDescriptor(javax.media.Processor p, javax.media.MediaLocator outML)
          Set the content descriptor based on the given output MediaLocator.
(package private)  boolean setEachTrackFormat(javax.media.Processor p, javax.media.control.TrackControl[] tcs, javax.media.Format fmt)
          We'll loop through the tracks and try to find a track that can be converted to the given format.
(package private)  void setJPEGQuality(javax.media.Player p, float val)
          Setting the encoding quality to the specified value on the JPEG encoder.
(package private)  boolean setTrackFormats(javax.media.Processor p, javax.media.Format[] fmts)
          Set the target transcode format on the processor.
(package private)  boolean waitForFileDone()
          Block until file writing is done.
(package 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

waitSync

Object waitSync

stateTransitionOK

boolean stateTransitionOK

waitFileSync

Object waitFileSync

fileDone

boolean fileDone

fileSuccess

boolean fileSuccess
Constructor Detail

Transcode

public Transcode()
Method Detail

doIt

public boolean doIt(javax.media.MediaLocator inML,
                    javax.media.MediaLocator outML,
                    javax.media.Format[] fmts,
                    int start,
                    int end)
Given a source media locator, destination media locator and an array of formats, this method will transcode the source to the dest into the specified formats.


setContentDescriptor

void setContentDescriptor(javax.media.Processor p,
                          javax.media.MediaLocator outML)
Set the content descriptor based on the given output MediaLocator.


setTrackFormats

boolean setTrackFormats(javax.media.Processor p,
                        javax.media.Format[] fmts)
Set the target transcode format on the processor.


setEachTrackFormat

boolean setEachTrackFormat(javax.media.Processor p,
                           javax.media.control.TrackControl[] tcs,
                           javax.media.Format fmt)
We'll loop through the tracks and try to find a track that can be converted to the given format.


setJPEGQuality

void setJPEGQuality(javax.media.Player p,
                    float val)
Setting the encoding quality to the specified value on the JPEG encoder. 0.5 is a good default.


createDataSink

javax.media.DataSink createDataSink(javax.media.Processor p,
                                    javax.media.MediaLocator outML)
Create the DataSink.


waitForState

boolean waitForState(javax.media.Processor p,
                     int state)
Block until the processor has transitioned to the given state. Return false if the transition failed.


controllerUpdate

public void controllerUpdate(javax.media.ControllerEvent evt)
Controller Listener.

Specified by:
controllerUpdate in interface javax.media.ControllerListener

waitForFileDone

boolean waitForFileDone()
Block until file writing is done.


dataSinkUpdate

public void dataSinkUpdate(javax.media.datasink.DataSinkEvent evt)
Event handler for the file writer.

Specified by:
dataSinkUpdate in interface javax.media.datasink.DataSinkListener

fileExtToCD

javax.media.protocol.ContentDescriptor fileExtToCD(String name)
Convert a file name to a content type. The extension is parsed to determine the content type.


main

public static void main(String[] args)
Main program


createMediaLocator

static javax.media.MediaLocator createMediaLocator(String url)
Create a media locator from the given string.


parseAudioFormat

static javax.media.Format parseAudioFormat(String fmtStr)
Parse the audio format specifier and generate an AudioFormat. A valid audio format specifier is of the form: [encoding]:[rate]:[sizeInBits]:[channels]:[big|little]:[signed|unsigned]


parseVideoFormat

static javax.media.Format parseVideoFormat(String fmtStr)
Parse the video format specifier and generate an VideoFormat. A valid video format specifier is of the form: [encoding]:[widthXheight]


prUsage

static void prUsage()


MMBase 2.0-SNAPSHOT - null