PROGRAMS GIVEN IN THE BOOK


HelloJMF.java

Demonstrates the method of playback of media by JMF. Plays an audio file that is present in the same directory wherein the HelloJMF.class file resides.


playerML.java

This example illustrates the method of creating a realized player from a MediaLocator to play a file that is present in the same directory wherein the playerML.class file is stored.


playerURL.java

Example illustrates the method of creating a realized player from an URL to play a file. The media file to be played should be present in the same directory where the playerURL.class file is located.


playerDS.java

Illustrates the method of creating a realized player from a Data Source to play a file that is present in the same directory where playerDS.class is located.


playerDSControl.java

Illustrates the method of creation of a realized Player from the Data Source. It also shows how one can control the access of media from the Data Source.


controllerTest.java

This example illustrates the method of creating a Player by going through its various states.


controllerIncorrect.java

This example Illustrates the fatal flaw in method of creating a Player by not using the ControllerListener


controllerState.java

This program allows one to progressively construct the player by stepping through its states.


CaptureDevDetails.java

This program queries the captureDeviceManager for the list of all audio capture devices supporting the linear encoding format and the list of all video capture devices supporting RGB ( or YUV) format. For each of the devices encountered the program lists all the output formats supported by that device.


captureDev.java

This program can be used to find the audio and video capture devices. The static method getAudioML () returns the MediaLocator of an audio capture device if one such device is present and registered in JMF registry. There is a similar method getVideoML () to return the MediaLocator of the video capture device.


captureTest.java

Presents captured audio or video. To execute this program you can keep the captureTest.class and captureDev.class in the same directory.


plugInList.java

This program gets the list of PlugIns (Codecs, Effects, Multiplexers, Demultiplexers) registered currently with the java.media.PlugInManager. The list of PlugIns is written into the file named PlugIn.txt. The file PlugIn.txt will be created in the same directory where the class PlugInList.class exists.
Note: The JMF Registry gives all these details nicely.


procModel.java

Program illustrates the use of the Processor Model to construct a Processor.


procExpt1.java

An Incorrect method of constructing the Processor. The configuration of the Processor is attempted immediately after calling the configure () method. The asynchronous nature of the configure () method can be understood by varying the parameter sleep Time.
Note: The file captureDev.class is needed by this program.


procExpt2.java

An Incorrect method of constructing the Processor. The Processor is configured in the ConfigureCompleteEvent handler. However the Processor might have been already reached the Realized state when we set the Format of the track. In such cases the setFormat () method is not guaranteed to work.


procExpt3.java

A correct method of constructing the Processor The Processor is created and the configure method is invoked. The code that handles ConfigureCompleteEvent configures the Processor and then calls the realize () method. Similarly the code that handles the RealizeCompleteEvent invokes the prefetch () and the start () method. Although the method is correct it is inelegant.


procExpt4.java

This explains construction of the Processor. The scheme invokes the asynchronous methods like configure (), or realize () and then waits busily for the Processor to reach the corresponding target state (Configured state or Realized state) before proceeding further. The method is not robust.


procSetFormat.java

Explains construction of the Processor. The scheme invokes the asynchronous methods like configure (), or realize () and then waits (by getting into the sleep mode) for the Processor to reach the corresponding target state (Configured state or Realized state) before proceeding further. The method is robust.


procSetCodec.java.

This program is used to set an array of codecs on the various tracks of a processor.Only the changes made in procSetFormat is given. For the complete program refer CDROM


procSetRenderer.java

This program is used to set renderer codecs on the various tracks of a processor. Only the changes made from procSetFormat is given below. For the complete program refer the accompanying CDROM


procUtil.java

procUtil.java is a utility class that can be used while configuring and constructing a Processor. To use it, instantiate procUtil.class by passing the Processor to be configured and constructed as the argument. Use syncConfigure (), syncRealize () and syncPrefetch () methods of the procUtil to configure, realize and prefetch the Processor. The method displayGUI () can be used to display the visual and control panel component of the Processor. The procUtil allows you to set the format of the audio track or video track, set a codec chain in the audio or video track, set an audio or video renderer.


procUtilDemo.java

The program procUtilDemo.java illustrates the usage of the utility procUtil.class.


FileStorage.java

This program captures audio from the microphone and stores the voice in a file. It uses the procUtil.class and the captureDev.class.


AVStore.java

Program AVStore.java captures and stores both audio and video into a file.


SimpleTransmit.java

Program to do media transmission using a Data sink. First we create a Processor for a given source whose media has to be transmitted. The output Data Source of the Processor and the Media Locator of the media destination are used to construct a Data Sink, which will transmit the media.


RtpPlayer.java

You may use this program to receive the media transmitted using the program simpleTransmit.java. This idea used in this example is given in JMF API guide. The locator String to be used in this program for the media reception should be the same as the locator String of the media destination which you used in simpleTransmit.java Compile this file. Run applet viewer on rtpPlayer.html.


PlayerApplet.java

An applet that plays a media file using JMF. Compile this program. Run applet viewer on playerApplet.html. The files playerApplet.class and the playerApplet.html should be in the same directory. You may also open the HTML file in a web browser.


ReceiveStreamListenerAdaptor.java

The class ReceiveStreamListenerAdaptor listens to the receiveStreams of a RTP session and invokes the appropriate ReceiveStreamEvent handlers. The handlers simply print the details of the event on their occurrence. You have to extend this class and override appropriate handlers if certain ReceiveStreamEvents have to be handled specifically. For example the class Receiver overrides and handles newReceiveStream events.


sendStreamListenerAdaptor.java

The class sendStreamListenerAdaptor listens to the SendStreamEvents of a session and invokes the appropriate SendStreamEvent handlers. The handlers simply print the details of the event on their occurrence. You have to extend this class and override appropriate handlers if certain sendStreamEvents have to be handled specifically.


SessionListenerAdapter.java

This class is a skeleton class implementing sessionListener interface. It listens to all session events and prints the details of event. This class can be adapted by extending and overriding the appropriate event handlers.


ReceiverPlayer.java

ReceiverPlayer.java is a ReceiveStreamListener that looks for NewReceiveStreams events. It extracts the media stream from the posted event, constructs a Player for the stream and presents the media to the user. This program requires the class ReceiveStreamListenerAdaptor.


RTPReceiver.java

The class RTPReceiver demonstrates reception of a RTP stream using a RTPManager. To run this program you need the class files of the programs ReceiverPlayer.java (or Receiver. java) and SessionListenerAdaptor.java, ReceiveStreamListenerAdaptor.java They can be present in the same directory of this program. You can test this program by transmitting a media stream from a different machine using JMStudio. Use the transmit option of JMStudio with the session address of the transmit option as the IP address of the machine that runs RTPReceiver. The port number of the transmit option should be the local port number you supply for running RTPReceiver. The program can be stopped by killing the corresponding process (ctrl-c in Windows Operating system).


Receiver. java

The class Receiver handles new receive streams. Receiver extends ReceiveStreamListenerAdaptor and overrides the newReceiveStreamHandler method. It extracts the stream from the posted event and gets the Data Source out of the stream. Then it constructs the Processor using the utility procUtil. The config () method and the handleProcessorOutput () methods should be written according to how we want to process and render the media data. In this example the received media is simply presented to the user without any processing.


RTPReceiverGUI .java

RTPReceiverGUI takes three arguments (i) remote IP address, (ii) remote port number and (iii) local port number from the user. Then it instantiates the RTPReceiver class by passing these arguments.


RTPTransmitter.java

The class RTPTransmitter demonstrates method of transmitting a RTP stream using a RTPManager. To test the RTPTransmitter class you have to run the JMStudio in another computer with the open RTPSession option. In the open RTPSession option use as session address the IP address of the machine in which RTPTransmitter is running .The port number of the RTPSession should be the same as the argument remote Port used in the RTPTransmitter. The parameter remoteIPAddress of the RTPTransmitter should be the IP address of the machine in which the JMStudio is running.


ProcFactory.java

The class ProcFactory is a factory to create audio Processor and video Processor for the RTPTransmitter application. The static method createAudioProcessor returns an audio Processor with a RTP encoded audio track. It takes the Data Source of an audio source and a String representing the audio encoding format as its arguments. The static method createVideoProcessor returns a video Processor with a RTP encoded video track. It takes the Data Source of a video source and a String representing the video encoding format as its arguments. For audio the String that indicates the encoding can be "GSM" or "G723" or "DVI". For video the String that indicates the encoding can be "H263" or "JPEG".


RTPTransmitterGUI.java

RTPTransmitterGUI is the GUI for RTPTransmitter. On pressing the start button it takes the arguments remoteIPAddress, remote Port, and local Port. It then instantiates the class RTPTransmitter. The instantiated RTPTransmitter object is destroyed by pressing the stop button.


TransRecv.java

The class TransRecv demonstrates method of simultaneous transmission and reception of RTP stream using a RTPManager. To test this program run JMStudio in another machine and check the reception and transmission separately. Alternatively run TransRecv.class on two machines. The argument IP address of the TransRecv running in one machine should be the IP address of the other machine and vice versa. The remote port number used in one machine should be the local port number used in another machine, and vice versa. You may run TransRecv using TransRecvGUI.java for convenience. This program needs the following classes (a) RecieveStreamListenerAdaptor, (b) ReceiverPlayer, (c) SendStreamListenerAdaptor, (d) SessionListenerAdaptor, (e) ProcFactory, and (b) captureDev. You may edit the transmit () method to choose the audio or video transmission format.


TransRecvGUI.java

TransResvGUI is the GUI for TransRecv. On pressing the start button it takes the arguments remoteIPAddress, remote Port, and local Port and instantiates the class TransRecv. The instantiated TransRecv object is destroyed by pressing the stop button.


AVTransmitter.java

The class AVTransmitter demonstrates the method of transmitting both audio and video from a single application. This program may be run by executing its companion AVTransmitterGUI or as it is. The class AVTransmitter can be tested by receiving the transmitted media using JMStudio or by using the AVReceiver.


AVTransmitterGUI.java

AVTransmitterGUI is the GUI for AVTransmitter. The remoteIPAddress parameter should be the IP address of the machine where the receiver application (JMStudio or AVReceiver) runs. The default value of the remote and local ports parameters are fixed such that they will work with the corresponding default values of AVReceiver. Of course you can also modify them.


AVReceiver.java

The class AVReceiver demonstrates reception of both audio and video. To test AVReceiver you may transmit audio and video using the transmit option of JMStudio. In the transmit option use as session address the IP address of the machine in which AVReceiver runs. The port number of the transmit option of JMStudio should be the same as the AVReceiver’s local Port parameter of the corresponding media (audio or video). You may also test AVReceiver with AVTransmitter.


AVReceiverGUI.java

AVReceiverGUI is the GUI for AVReceiver. You can test it by running AVTransmitter in a different machine. You may wish to leave all the default values of the parameters (local and remote audio and video port) in bothAVTransmitter and AVReceiver untouched. The remoteIPAddress parameter of AVReceiverGUI should be the IP address of the machine in which AVTRansmitterGUI runs and vice versa.


ReceiverStore.java

The class ReceiverStore handles new receive streams. ReceiverStore extends receiveStreamListenerAdaptor and overrides the NewReceiveStreamHandler method. It extracts the stream from the posted event and gets the Data Source out of the stream. Then it constructs a Processor using the utility procUtil. The config () method and the handleProcessorOutput () methods should be written according to how we want to process and render the media data. In this example the received media is stored in a file.


ReceiverTransmit.java

The class ReceiverTransmit handles new receives and streams. Receiver extends receiveStreamListenerAdaptor and overrides the newReceiveStreamHandler method. It extracts the stream from the posted event and gets the Data Source out of the stream. Then it constructs processor from the Data Source. The Processor is configured, Realized and Prefetched using the utility procUtil. The config () method and the handleProcessorOutput () methods should be written according to how we want to process and render the media data. In this example the received media is simply retransmitted. For retransmission we simply use the data sink method.
Note: The format of the media transmitted to this program should be convertible to the format in which we want to retransmit. Otherwise JMF will fail to build flow graph as can be seen in jmf.log. To be safe transmit the media in the format in which we retransmit. For example the format of retransmission used in this program is Audio Format (AudioFormat.GSM_RTP, 8000, 16, 1, AudioFormat.BIG_ENDIAN, AudioFormat.SIGNED).


PlayerControl.java

Player to play a media file. It has audio control to mute or enable sound, and volume adjustment through a slider bar on the top. The slider on the side can be used to adjust the rate.


BufferControl.java

The class BufferControl illustrates the effect of controlling the size and threshold of the capture buffer and the size of the rendered buffer on improving the quality of the media.


qualityControlDemo.java

The program qualityControlDemo.java illustrates the use of quality control in making a suitable tradeoff between the media quality and the amount of processing required to encode the media or the bandwidth occupied by the media.


cloning.java

Illustrates the method of creation of a many clones of a Data Source and using them for different purposes. Here the captured media is 1) presented 2) stored in a file as well as transmitted. The storageClone.java implements storage in a file. The transmitClone.java implements media transmission.


storageClone.java

This storageClone object takes a Data Source as its parameter and stores the media in a file.


transmitClone.java

Program to do media transmission using a Data sink. The program takes a (cloned) Data Source as its argument. First we create a Processor for the given source whose media has to be transmitted. The output Data Source of the Processor and the MediaLocator of the media destination are used to construct a Data Sink which will transmit the media. The class is designed to be a thread.


AVMerging.java

This program captures audio from the Microphone and video from the camera. It then creates a merged Data Source from the audio and video Data Sources. The merged media is stored in the file store.avi in the local directory.


multipleControllers.java

Program multipleControllers.java illustrates how a Player can be used to synchronize and control other Players.


TestBeanPlayer.java

Illustrates how the Media Player class can be instantiated and used to play media files. It also explains how the various properties of the Media Player bean can be set programmatically.


PassthroEffectPlugIn.java

The PassthroEffect PlugIn is an Effect PlugIn with supported input and output formats as linear Audio Format. It simply passes the audio through it adding no effect to the audio. This program follows the guideline given in the implementation of Gain Effect PlugIn illustrated in the JMF API guide.


procSetCodec.java

procSetCodec.java can set an array of Codecs on a track of a Processor. This program is used to demonstrate the working of various Effect Codecs


AddPlugIn.java

Program to register a PlugIn with the PlugInManager. Here we add the passThroEffect PlugIn to PlugInManager


EchoEffect.java

The EchoEffectPlugIn adds echo effect to the captured audio before presentation.


RGBEffect.java

Effect Plug In that allows adjustment of the gain of the red, green and blue color of the video.


VolumeBar.java

Volume Bar Effect Plug In. It can be used on a audio track. It has linear Audio Format as the input and output format. It displays the audio sample strength as a bar chart


monoTonePlayer.java

monotonePlayer is about generating a single tone. Tone generation is important on low end devices, since it may be the only form of multimedia capability of such devices.


ToneSequenceplayer.java

It plays a sequence of tones.


wavPlayer.java

This program plays a wav file that is available as a resource of the MIDlet. It plays the file with simple playback control.


midiPlayer.java

It plays a MIDI file that is accessed over the network using the HTTP protocol.


audioCapture.java

MMAPI supports media capture. The Reference implementation of MMAPI 1.0 supports audio capture only. The MIDlet for audio capture is very similar to the audio playback except that the locator string used is "capture://audio”.


audioCapture.java

The following program captures the audio and records it. The Player is first created by passing the locator string for the audio capture device. Then we query and get the Record Control of the Player. The record location of the Record Control is set to be a file. We then invoke the start Record () method of the Record Control to start the recording process. We then wait for 1 second by letting the current thread to sleep. The recording is then stopped and the recording is then committed to complete the recording process.


mpegPlayer.java

This program accesses a MPEG file using HTTP protocol over the network and plays the file. It is called mpegPlayer.java It has playback control such as start stop, volume control, rate control, media-time setting, etc.