Java Media Framework (JMF)
JMF
-
JMF is a set of classes to handle multimedia data
-
It can deal with audio and video
-
It can read from sources and write to sinks
-
Sources can be files, devices or the network
-
Sinks can be files, devices or the network
Audio file formats
There are a huge number of different file formats
-
PCM (Pulse code modulated): raw digital data e.g. from a CD
-
ALAW: U.S.
and international standards for logarithmic telephone sound
compression
-
GSM: a standard used for telephone sound compression in
European countries
-
Music sound formats such as AU, WAV, MP3, ...
Video formats
There are also a huge number of video formats
Handling formats
-
JMF does its best to handle all these formats with as little
programmer intervention as possible
-
It detects devices automatically, and uses converters automatically
-
It doesn't seem to leave enough programmer control at times
Player
-
JMF uses a
Player
to deliver data to a suitable output
device
-
The output device is selected by the Player based on media type - if possible
-
Players are created using a
Manager
factory
-
This allows the set of Players to be extended
-
A Player will generate events such as
StartEvent, StopEvent
-
A Player has methods such as
stop()
and start()
plus many others for control of media and time
Play a file
Presentation
-
A Player can be controlled by calling its methods
-
A Player may also have an associated user interface for controlling it
-
The control panel is obtained by
getControlPanelComponent()
which returns an AWT Component
-
The control panel may have e.g. buttons for stop and start
-
A Player which can display video data can also have a visual component
which is obtained by
getVisualComponent()
Play a file with a UI
Processor
-
To manipulate data a Processor object is used
-
A Processor has a source and a sink
-
Based on the media types of the source and the sink, the
Presentation may convert the data from one format to another
-
A Processor goes through the stages of
-
configuration
-
realization
-
prefetching data
-
started
-
Selection of a converter is supposed to take place automatically,
but may not
-
When a processor is created (from a
Manager
)
the source is set
-
The sink cannot be set until the processor has been realized
-
But, the processor may do things after configuration
but before realization that limit possible sink types
-
Note:
configure()
and
realize()
act asynchronously, and return
immediately
Copy a file
Capture devices
-
When JMF is installed, it attempts to find all the A/V devices attached
to the computer
-
This list is stored in the JMF properties files, and is used to determine
which DLLs are loaded
-
A
CaptureDeviceManager
can be queried for all devices,
or for devices supporting a particular Format
e.g. an AudioFormat
supporting a LINEAR
encoding with a sample rate of 44100 samples per second, 16 bits stereo
(a CD player)
List capture devices
Playing from a device
This program should copy from the sound card to a file.
It doesn't work on my laptop as "interface TargetDataLine supporting format PCM_SIGNED..."
is not found
Real-time protocol RTP
-
LANs based on ethernet are not "real time" with guaranteed time of delivery
of packets, due to the collision algorithm used (back off a random amount
of time)
-
The IP protocol does not guarantee delivery between hosts, let alone a guaranteed time of
delivery
-
TCP gives reliable delivery between ports, or at least a failure message
-
UDP gives unreliable delivery between ports, with no time guarantee.
But in practise, on LANs, UDP is reliable and time is not usually too
much of a problem
-
RTP sits above UDP, and offers limited guarantees of delivery and timeliness
RTP client
The following client uses a simple way of getting streaming RTP data from a server.
It must be running on a different machine to the server. If you try on the
same machine, then since they both use UDP they will try to connect to the same port
and one will fail.
RTP server
This must tbe run on a different machine to the client.
Jan Newmarch (http://jan.newmarch.name)
jan@newmarch.name
Last modified: Tue Jun 3 00:44:33 EST 2003
Copyright ©Jan Newmarch