Java Media Framework API

  • 3,604 views
Uploaded on

 

More in: Technology , Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
3,604
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
195
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Java (TM) Media Framework API Vladimir Sakhovski [email_address]
  • 2. Intro
    • Java Media Framework (JMF) is an API for manipulation and processing of time-based media in Java applications and applets.
    • A key characteristic of time-based media: it requires timely delivery and processing. Strict timing deadlines must be met for receiving and presentation of the data.
  • 3. Intro (cont)
    • JMF 1.0 API
      • support for presenting of time-based media.
    • JMF 2.0 API extends by
      • supporting capturing and storing of media data,
      • controlling of type of processing during playback,
      • custom processing on media data streams
      • plug-in API to customize and extend JMF functionality
    • JMF 2.1.1
      • no changes to the API, updates to the Sun‘s implementation
  • 4. Intro (cont)
    • JMF RTP APIs are not required by JMF specification
    • Reference implementation of JMF provided by Sun and IBM fully support JMF RTP APIs
    • RTP APIs enable developers to receive, transmit and play RTP streams using JMF
  • 5. Intro (cont)
    • There are JMF versions for Windows, Solaris, Linux, and pure-Java version (works on any JVM)
    • OS-specific versions should be used to increase performance
  • 6. JMF data processing model
    • Everyday-life model for operations with time-based media:
  • 7. JMF data processing model (cont)
    • JMF data processing model
  • 8. JMF data processing model (cont)
    • JMF data processing model, example
  • 9. JMF input
    • Input in JMF is generally represented by a javax.media.MediaLocator object.
    • MediaLocator is like an URL – it uniquely identifies a resource in a network
    • Example: media locator for an RTP session:
      • rtp://address:port[:ssrc]/content-type/[ttl]
  • 10. JMF input (cont)
    • From MediaLocator an instance of javax.media.protocol. DataSource object can be created. It represents input data, which is used in Player s , Processor s and DataSink s .
  • 11. JMF processors
    • Input data can be directly rendered to the output destination or some manipulations can be applied before this.
    • Processor (manipulation) component is represented by an instance of javax.media.Processor interface
  • 12. JMF output
    • The ouput of a Processor (just like the input) is presented with the instance of DataSource. This way:
      • Processor s can be chained to perform multiple operations on the same media
      • Output from Processor can be used as an input to a Player or DataSink (for rendering to the output destination)
  • 13. JMF output (cont)
    • Another way to represent output of the JMF process model is with javax.media.DataSink interface
    • DataSink reads media content and renders it to some destination
    • Example: output file, network
  • 14. Simple audio player
    • Example for a simple program to play a local audio file through a command-line interface
    • Import
      • import javax.media.*;
  • 15. Simple audio player (cont)
    • Player
      • private Player audioPlayer = null;
      • public SimpleAudioPlayer(File file) throws IOException, NoPlayerException, CannotRealizeException {
      • audioPlayer = Manager. createRealizedPlayer(file.toUrl());
      • }
  • 16. Simple audio player (cont)
    • Player processes an input media data stream and renders it at a precise time.
    • DataSource is used to deliver the input to the Player
    • Rendering destination depends on the type of the media (example: speakers, display...)
  • 17. Simple audio player (cont)
    • A Player can be in one of the six states
  • 18. Simple audio player (cont)
    • To get an instance of the Player we use Manager class. It acts as a factory for creating many of the specific interface types in JMF, including the Player interface
    • audioPlayer = Manager.createRealizedPlayer(file.toUrl());
  • 19. Simple audio player (cont)
    • Starting/stopping the player
    • public void play() {
    • audioPlayer.start();
    • }
    • public void stop() {
    • audioPlayer.stop();
    • audioPlayer.close();
    • }
  • 20. Simple audio player (cont)
    • Creating a player in the main()
    • File audioFile = new File(args[0]);
    • SimpleAudioPlayer player = new SimpleAudioPlayer(audioFile);
    • player.play();
    • ...
    • player.stop();
  • 21. Simple audio player (cont)
    • Simple (just a few lines of code)
    • No need not to know anything about the media file type to configure a player, everything is handled internally
  • 22. Simple video player
    • The main difference from the audio player – we must create a visual representation to display the video
  • 23. Simple video player (cont)
    • Player has methods to get references to visual components
    • player.getVisualComponent()
    • player.getGainControl()
    • player.
    • getControlPanelComponent()
  • 24. Simple video player (cont)
    • Controls returned are instances of the java.awt.Component class and may be added to the window frame.
    • They are tied directly to the Player – any manipulations on controls will have corresponding changes on the media played.
  • 25. Resources
    • http://java.sun.com/products/java-media/jmf/
      • 2.0 API Guide
      • Code Samples and Apps
    • http://www-106.ibm.com/developerworks/
    • edu/j-dw-javajmf-i.html