Media Stuff - PowerPoint PPT Presentation

1 / 25
About This Presentation
Title:

Media Stuff

Description:

Java Media Framework (JMF) is a large and versatile API used to process time ... be rendered, with the Player unconcerned about where the DataSource originated ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 26
Provided by: bas44
Category:

less

Transcript and Presenter's Notes

Title: Media Stuff


1
Media Stuff
  • JMF Plays wonders

2
Introduction to JMF
  • Java Media Framework (JMF) is a large and
    versatile API used to process time-based media.

3
JMF Model
  • Consider a Cassette/CD-Player as an example to
    understand JMF objects
  • We insert CD/Cassette as media contents, theres
    a player that reads data from this media and
    plays to the speakers
  • When recording, a small microphone is a capture
    device that can give data for recording

4
JMF Objects
  • Following are the JMF objects you must know about
  • Data source
  • Capture device
  • Player
  • Processor
  • DataSink
  • Format
  • Manager

5
DataSource
  • A data source encapsulates the media stream much
    like a music CD.
  • In JMF, a DataSource object represents the audio
    media, video media, or a combination of the two.
  • A DataSource can be a file or an incoming stream
    from the Internet.
  • Once created, a DataSource can be fed into a
    Player to be rendered, with the Player
    unconcerned about where the DataSource originated
    or what was its original form.

6
Types of Data Sources
  • DataSource type can depend on the nature of the
    source. There are two types of data sources
  • Pull data source The client initiates the data
    transfer and controls the data flow from the
    source. HTTP and FILE serve as examples of
    established protocols for this type of data.
  • Push data source The server initiates the data
    transfer and controls the data flow from a push
    data source. Push data source examples include
    broadcast media and video on demand.

7
Capture Device
  • A capture device represents the hardware you use
    to capture data, such as a microphone, a still
    camera, or a video camera.
  • Captured media data can be fed into a Player to
    be rendered, processed to convert the data into
    another format, or stored for future use.

8
Player
  • A Player takes as input a stream of audio or
    video data and renders it to a speaker or a
    screen, much like a CD player reads a CD and
    outputs music to the speaker.
  • A Player can have states, which exist naturally
    because a Player has to prepare itself and its
    data source before it can start playing the
    media.

9
Player States
  • JMF defines six states in a Player
  • Unrealized
  • Realizing
  • Realized
  • Prefetching
  • Prefetched
  • Started

10
Processor
  • A Processor is a type of Player.
  • In the JMF API, a Processor interface extends
    Player.
  • As such, a Processor supports the same
    presentation controls as a Player. Unlike a
    Player, though, a Processor has control over what
    processing is performed on the input media
    stream.
  • In addition to rendering a data source, a
    Processor can also output media data through a
    DataSource so it can be presented by another
    Player or Processor, further processed by another
    Processor, or converted to some other format.

11
Processor States
  • Besides the six aforementioned Player states, a
    Processor includes two additional states that
    occur before the Processor enters the realizing
    state but after the unrealized state
  • Configuring A Processor enters the configuring
    state from the unrealized state when the
    configure() method is called. A Processor exists
    in the configuring state when it connects to the
    DataSource, demultiplexes the input stream, and
    accesses information about the format of the
    input data.
  • Configured From the configuring state, a
    Processor moves into the configured state when it
    is connected to the DataSource and the data
    format has been determined.

12
Data Sink
  • The DataSink is a base interface for objects that
    read media content delivered by a DataSource and
    render the media to some destination.
  • As an example DataSink, consider a file-writer
    object that stores the media in a file.

13
Format
  • A Format object represents an object's exact
    media format.
  • The format itself carries no encoding-specific
    parameters or global-timing information it
    describes the format's encoding name and the type
    of data the format requires.

14
Subclasses of Format
  • Format has following 2 subclasses
  • AudioFormat
  • VideoFormat.
  • VideoFormat contains six direct subclasses
  • H261Format
  • H263Format
  • IndexedColorFormat
  • JPEGFormat
  • RGBFormat
  • YUVFormat

15
Manager
  • Manager is the boss object used for management
    (what else?)
  • Manager can be used for
  • Create players
  • Create processors
  • Creating Data sources
  • Creating data sinks

16
A very simple JMF tasOpeneing and playing a file
  • Steps involved are
  • Create a Data Source
  • Associate it with a Player
  • Wait for the right state (Realized)
  • Get the visual components of player
  • Get the control panel of player
  • Add them to a GUI
  • Start the player (optional)

17
Code for playing butterfly.mpg
  • import java.awt.
  • import javax.media.
  • import javax.media.protocol.
  • import java.io.
  • import java.net.

18
Code continues
  • class MediaTest implements ControllerListener
  • Frame f
  • Component v
  • Player p
  • MediaTest() throws Exception
  • String url file/C/media/butterfly.mpg
  • URL u new URL(url)
  • DataSource ds Manager.createDataSource(u)

19
  • p Manager.createPlayer( ds )
  • p.addControllerListener(this)
  • f new Frame()
  • f.setSize(400,350)
  • f.show()
  • p.start()

20
  • public void controllerUpdate(
  • ControllerEvent e)
  • if (e instanceof RealizeCompleteEvent)
  • v p.getVisualComponent()
  • if(v!null)
  • f.add(v ,BorderLayout.CENTER)
  • v p.getControlPanelComponent()
  • if(v!null)
  • f.add(v, BorderLayout.SOUTH)
  • f.doLayout()
  • // end of method
  • // end of class

21
Running the code
Visual Component
Control Panel
22
Creating Data Source
  • String url file/C/media/butterfly.mpg
  • URL u new URL(url)
  • DataSource ds Manager.createDataSource(u)

23
Creating Player
  • p Manager.createPlayer( ds )
  • p.addControllerListener(this)

24
Getting Adding visual and control panel
components
  • v p.getVisualComponent()
  • if(v!null)
  • f.add(v ,BorderLayout.CENTER)
  • v p.getControlPanelComponent()
  • if(v!null)
  • f.add(v, BorderLayout.SOUTH)

25
Starting a player
  • p.start( )
  • That was tough !!! ?
Write a Comment
User Comments (0)
About PowerShow.com