JMF BASICS ~ MY Thoughts & Learnings

Saturday, July 11, 2009

JMF BASICS

hi,

Ever wanted to work with multimedia files,capturing data from the camera and processing encoding as per the requirement.Yes i know this looks quite interesting let's get started with basics :

Java™ Media Framework (JMF)

1. Provides a unified architecture and mes-saging protocol for managing the acquisition, processing, and delivery of time-based media data.

2. JMF is designed to support most standard media content types, such as AIFF, AU, AVI, GSM, MIDI, MPEG, QuickTime, RMF, and WAV.

I have tried to divide things in components so that it is easier to understand

Media Streams -
  • Can be media from file,network,camera.media format
  • Some have media stream containg multiple channel of data called tracks.hence Demultiplexing is required to get the data.such is called complex media stream.

To locate the source-

1. File protocol is used for files as sources
2. HTTP protocol for network
3. MediaLocator to locate media when URL can't be used

Media Streams Types:

1. Pull type - initiated and controlled by client - file and http protocol
2. Push type - from the server side initiated like RTP,SGI MediaBase used for VOD(video on demand)

CLASSES FOR SOURCES

1. Pull Data Source - Types of pull data sources:
  • PullDataSource
  • PullBufferDataSource, which uses a Buffer object as its unit of transfer.
2. Push Data Source - Types of push data sources:
  • PushDataSource
  • PushBufferDataSource, which uses a Buffer object as its unit of transfer Specialty DataSources

JMF defines two types of specialty data sources

1. Cloneable data sources

2. Merging data sources.


1. Cloneable Data Source -
  • Can be used to create clones of either a pull or push DataSource.
  • To create a Cloneable DataSource, you have to call the Manager cloneableDataSource method and pass in the DataSource you want to clone. Once a DataSource has been passed to create CloneableData-Source, you should only interact with the cloneable
  • DataSource and its clones
  1. the original DataSource should no longer be used directly.Cloneable data sources implement the SourceCloneable interface, which defines one method, createClone. By calling createClone, you can create any number of clones of the DataSource that was used to construct the Cloneable DataSource.
  2. The clones can be controlled through the cloneable DataSource used to create them.
  3. The clones don’t necessarily have the same properties as the cloneable data source used to create them or the original DataSource. For example, a cloneable data source created for a capture device might function as a master data source for its clones—in this case, unless the cloneable data source is used, the clones won’t produce any data. If you hook up both the cloneable data source and one or more clones, the clones will produce data at the same rate as the master.

2.MergingDataSource -
  • Can be used to combine the SourceStreams from several DataSources into a single DataSource.
  • This enables a set of Data-Sources to be managed from a single point of control—when connect, disconnect, start, or stop is called on the MergingDataSource, the method calls are made to the merged DataSources.To construct a MergingDataSource, you call the Manager createMerging-DataSource method and pass in an array that contains the data sources you want to merge. To be merged, all of the DataSources must be of the Understanding JMF 19 same type.For example, you cannot merge a PullDataSource and a Push-DataSource. The duration of the merged DataSource is the maximum of the merged DataSource objects’ durations.

Latency - it is the time lag between actual start of the video after clicking start button.when synchronizing multiple streams then it must check for latency of each stream.
  • For example if i want to save the video captured by a camera to a file
1. Audio and video tracks are captured
2. Each individual tracks would be encoded and then multiplexed into a single media stream.
3. Multiplexed data is saved to file.

Codecs
  • A codec performs media-data compression and decompression.
  • When a track is encoded, it is converted to a compressed format suitable for storage or transmission; when it is decoded it is converted to a non-compressed (raw) format suitable for presentation.effect filters are applied to uncompressed (raw) data if needed.

Renderer -
  • A renderer is an abstraction of a presentation device. For audio, the presentation device is typically the computer’s hardware audio card that out-puts sound to the speakers. For video, the presentation device is typically the computer monitor.

Compositing -
  • Certain specialized devices support compositing. Compositing time-based media is the process of combining multiple tracks of data onto a single presentation medium.
  • For example, overlaying text on a video presentation is one common form of compositing. Compositing can be done in either hardware or software. A device that performs compositing can be abstracted as a renderer that can receive multiple tracks of input data
General Path of Data Acquisition

Capture Device(camera) --> Data Source(video tape i.e all streams multiplexed) --> player --->Destination(HDD or Output)

TIMING IS VERY IMPORTANT

WE use Time Class object which implements Clock having functions for basic Synchronising and presentation of streams. Clock derives it's timing from the Time-base(system clock) after using a prescaler.

To keep track of the current media time, a Clock uses:

• The time-base start time that it reports when thepresentation begins.
• The Media start-time—the position in the media stream where presentation begins.
• The Playback rate—how fast the Clock is running in relation to its TimeBase. The rate is a scale factor that is applied to the TimeBase.
Foexample, a rate of 1.0 represents the normal playback rate for the media stream, while a rate of 2.0 indicates that the presentation will run at twice the normal rate. A negative rate indicates that the Clock irunning in the opposite direction from its TimeBase—for example, a negative rate might be used to play a media stream backward.


The JMF API consists mainly of interfaces that define the behavior and interaction of objects used to capture, process, and present time-based media. Implementations of these interfaces operate within the structure of the framework. By using intermediary objects called managers, JMF makes it easy to integrate new implementations of key interfaces that can be used seamlessly with existing classes.

JMF uses four managers:
  • Manager—handles the construction of Players, Processors, DataSources, and DataSinks. This level of indirection allows new implementations to be integrated seamlessly with JMF.
  • PackageManager—maintains a registry of packages that contain JMF classes, such as custom Players, Processors, DataSources, and DataSinks.
  • CaptureDeviceManager—maintains a registry of available capture devices.
  • PlugInManager—maintains a registry of available JMF plug-in processing components, such as Multiplexers, Demultiplexers, Codecs, Effects, and Renderers.

HOW TO USE MANAGERS
To write programs based on JMF, you’ll need to use the Manager create methods to construct the Players, Processors, DataSources, and DataSinks for your application. If you’re capturing media data from an input device, you’ll use the CaptureDeviceManager to find out what devices are available and access information about them. If you’re interested in controlling what processing is performed on the data, you might also query the Plug-InManager to determine what plug-ins have been registered.

Event MODEL

  • Whenever a JMF object needs to report on the current conditions, it posts a MediaEvent.
  • MediaEvent is subclassed to identify many particular types of events. These objects follow the established Java Beans patterns for events.For each type of JMF object that can post MediaEvents, JMF defines a corresponding listener interface.addListner are used to handle posted MediaEvent.
Controller objects (such as Players and Processors) and certain Control objects such as GainControl post media events.RTPSessionManager objects post RTP EVENTS

SOME BASIC PLAYER CONTROLS

1. CachingControl - enables download progress to be monitored and dis-played. If a Player or Processor can report its download progress, it implements this interface so that a progress bar can be displayed to the user.

2. GainControl enables audio volume adjustments such as setting the level and muting the output of a Player or Processor. It also supports a listener mechanism for volume changes.

3. FramePositioningControl and FrameGrabbingControl - export frame-based capabilities for Players and Processors. FramePositioningControl enables precise frame positioning within a Player or Processor object’s media stream. FrameGrabbingControl provides a mechanism for grabbing a still video frame from the video stream. The FrameGrabbingControl can also be supported at the Renderer level.

Names of few frewuently used controls : BufferControl,PortControl,MonitorControl,FormatControl,TrackControlcontrol methods -getControlComponent returns awt default of a control componentPlayer methods - getVisualComponent,getCOntrolPanelComponent

BYE HAVE A GOOD DAY

0 comments: