Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Java Media Framework API


Published on

Published in: Technology, Education
  • Be the first to comment

Java Media Framework API

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