Jsr135 sup

794 views

Published on

SMI UP PPT

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
794
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
15
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Jsr135 sup

  1. 1. <ul><li>JSR 135 </li></ul>
  2. 2. Introduction <ul><li>Called MMAPI or sometimes JSR-135 (name of the standard) </li></ul><ul><li>Audio and video API for J2ME for time based media </li></ul><ul><li>Minimum requirement CLDC 1.0 </li></ul><ul><li>For video some UI technology is needed (e.g. LCDUI of MIDP or AWT of Personal Profile) </li></ul><ul><li>Does not mandate any formats </li></ul><ul><li>Not targeted for any specific formats </li></ul><ul><li>MMAPI 1.0, June 2002 </li></ul><ul><li>MMAPI 1.1, June 2003 </li></ul>
  3. 3. MMAPI Features <ul><li>Support for Tone Generation, Playback, and Recording of Time-Based Media </li></ul><ul><li>Small Footprint </li></ul><ul><li>Protocol- and Content-Agnostic </li></ul><ul><li>Extensible </li></ul><ul><li>Options for Implementers </li></ul><ul><li>Snapshots from camera </li></ul>
  4. 4. MMAPI Overview <ul><li>There are two parts to multimedia processing: </li></ul><ul><li>Protocol Handling : reading data from a source such as a file or a streaming server into a media-processing system. </li></ul><ul><li>Content Handling : parsing or decoding the media data and rendering it to an output device such as an audio speaker or video display. </li></ul>
  5. 5. MMAPI Overview <ul><li>A DataSource encapsulates protocol handling </li></ul><ul><li>A Player reads from the DataSource, processes the data, and renders the media to the output device. </li></ul><ul><li>A factory mechanism, the Manager, creates Players from DataSources </li></ul>
  6. 6. MMAPI Properties <ul><li>microedition.media.version </li></ul><ul><li>The string returned designates the version of the MMAPI specification that is implemented </li></ul><ul><li>supports.mixing </li></ul><ul><li>Query for whether audio mixing is supported. The string returned is either &quot;true&quot; or &quot;false&quot; </li></ul><ul><li>supports.audio.capture </li></ul><ul><li>Query for whether audio capture is supported. The string returned is either true or false. </li></ul><ul><li>supports.video.capture </li></ul><ul><li>Query for whether video capture is supported. The string returned is either true or false. </li></ul><ul><li>supports.recording </li></ul><ul><li>Query for whether recording is supported. The string returned is either true or false </li></ul><ul><li>audio.encodings </li></ul><ul><li>The string returned specifies the supported capture audio formats. Each format is specified in the audio encoding syntax </li></ul><ul><li>video.encodings </li></ul><ul><li>The string returned specifies the supported capture video formats. Each format is specified in the video encoding syntax </li></ul><ul><li>video.snapshot.encodings </li></ul><ul><li>The string returned specifies the supported capture image formats. Each format is specified in the image encoding syntax. </li></ul><ul><li>streamable.contents </li></ul><ul><li>The string returned specifies the supported streamable content types </li></ul>
  7. 7. MMAPI Package <ul><li>javax.microedition.media provides some interfaces, an exception, </li></ul><ul><li>and the Manager class, which is the access point for obtaining </li></ul><ul><li>system-dependent resources such as Players for multimedia </li></ul><ul><li>processing. </li></ul><ul><li>javax.microedition.media.control defines the specific control </li></ul><ul><li>types that can be used with a Player: VolumeControl, VideoControl, </li></ul><ul><li>and Others </li></ul><ul><li>javax.microedition.media.protocol defines the protocols for </li></ul><ul><li>handling custom controls. For example, it includes the DataSource </li></ul><ul><li>class, which is an abstraction for media-control handlers </li></ul>
  8. 8. Player Life Cycle <ul><li>Player life Cycle includes the five state & six of method in translation </li></ul><ul><li>Status Methods </li></ul>UNREALIZED REALIZED, PREFETCHED, STARTED, CLOSED realize() prefetch() start() stop() deallocate() close()
  9. 9. Player states <ul><li>Control the resource usage and the need for open connections </li></ul>
  10. 10. How To Play Audio With Looping <ul><li>//URL of mp3 song </li></ul><ul><li>URL= http://webserver/music.mp3; </li></ul><ul><li>try { </li></ul><ul><li>//Retrieve the Player object from createPlayer() method of Manager class </li></ul><ul><li>Player p = Manager.createPlayer(URL); </li></ul><ul><li>//Set indefinite loop count </li></ul><ul><li>p.setLoopCount(-1); </li></ul><ul><li>//Start the player </li></ul><ul><li>p.start(); </li></ul><ul><li>} catch (IOException ioe) { </li></ul><ul><li>} catch (MediaException me) {} </li></ul>
  11. 11. How To Play Video <ul><li>//URL of mpeg song </li></ul><ul><li>URL= http://webserver/movie.mpg; </li></ul><ul><li>//Retrieve the Player object from createPlayer() method of Manager </li></ul><ul><li>//class </li></ul><ul><li>Player p = Manager.createPlayer(URL); </li></ul><ul><li>//Realize the player </li></ul><ul><li>p.realize(); </li></ul><ul><li>//Grab the video control and set it to the current display </li></ul><ul><li>VideoControl vc = (VideoControl)p.getControl(&quot;VideoControl&quot;); </li></ul>
  12. 12. How To Play Video <ul><li>//Now append the display mode to Form </li></ul><ul><li>if (vc != null) { </li></ul><ul><li>Form form = new Form(&quot;video&quot;); </li></ul><ul><li>//If video is displayed in high level UI pass parameters </li></ul><ul><li>//vc.USE_GUI_PRIMITIVE and null and for low Level UI pass parameters </li></ul><ul><li>VideoControl.USE_DIRECT_VIDEO and canvas object </li></ul><ul><li>form.append((Item)vc.initDisplayMode(vc.USE_GUI_PRIMITIVE,null)); </li></ul><ul><li>Display.getDisplay(midlet).setCurrent(form); </li></ul><ul><li>} </li></ul><ul><li>//Start the player </li></ul><ul><li>p.start(); </li></ul>
  13. 13. How To Play From RMS <ul><li>RecordStore rs; </li></ul><ul><li>int recordID; </li></ul><ul><li>: // code to set up the record store. </li></ul><ul><li>try { </li></ul><ul><li>//Get the inputstream data from recordstore </li></ul><ul><li>InputStream is = new ByteArrayInputStream(rs.getRecord(recordID)); </li></ul><ul><li>//Now in createPlayer() method of manager class pass parameters inputstream object and MIME type of the player </li></ul><ul><li>Player p = Manager.createPlayer(is, &quot;audio/X-wav&quot;); </li></ul><ul><li>//start the player </li></ul><ul><li>p.start(); </li></ul><ul><li>} catch (IOException ioe) { </li></ul><ul><li>} catch (MediaException me) { } </li></ul>
  14. 14. How To Play From JAR <ul><li>try { </li></ul><ul><li>//get the inputstream data from jar </li></ul><ul><li>InputStream is = getClass().getResourceAsStream(“/audio.wav&quot;); </li></ul><ul><li>//Now in createPlayer() method of manager class pass parameters inputstream object and MIME type of the player </li></ul><ul><li>Player p = Manager.createPlayer(is, &quot;audio/X-wav&quot;); </li></ul><ul><li>//start the player </li></ul><ul><li>p.start(); </li></ul><ul><li>} catch (IOException ioe) { </li></ul><ul><li>} catch (MediaException me) { } </li></ul>
  15. 15. How To Take SnapShot <ul><li>//Retrieve the Player object from createPlayer() method of Manager class </li></ul><ul><li>//A special locator, capture://video, indicates that pictures will be captured </li></ul><ul><li>//from the camera using a default image size. </li></ul><ul><li>Player p = Manager.createPlayer(&quot;capture://video&quot;); </li></ul><ul><li>//realize the player </li></ul><ul><li>p.realize(); </li></ul><ul><li>//Grab the video control and set it to the current display </li></ul><ul><li>VideoControl vc = (VideoControl)p.getControl(&quot;VideoControl&quot;); </li></ul><ul><li>//Now append the display mode to Form </li></ul><ul><li>if (vc != null) { </li></ul><ul><li>Form form = new Form(&quot;video&quot;); form.append((Item)vc.initDisplayMode(vc.USE_GUI_PRIMITIVE, null)); </li></ul><ul><li>Display.getDisplay(midlet).setCurrent(form); </li></ul><ul><li>} </li></ul>
  16. 16. How To Take SnapShot <ul><li>//Now start the video </li></ul><ul><li>p.start(); </li></ul><ul><li>//Get the array of bytes which is image data using getSnapShot() </li></ul><ul><li>//method of VideoControl Class </li></ul><ul><li>byte[] image = vc.getSnapshot(null); </li></ul><ul><li>//Create image using this byte array of image data </li></ul><ul><li>Image image = Image.createImage(raw, 0, raw.length); </li></ul>
  17. 17. How To Record Audio <ul><li>//Create a DataSource that captures live audio. </li></ul><ul><li>Player p = Manager.createPlayer(&quot;capture://audio&quot;); </li></ul><ul><li>p.realize(); </li></ul><ul><li>//Get the RecordControl, set the record location, and </li></ul><ul><li>//start the Player and record for 5 seconds. </li></ul><ul><li>RecordControl rc = (RecordControl)p.getControl(&quot;RecordControl&quot;); </li></ul><ul><li>rc.setRecordLocation(&quot;file:/tmp/audio.wav&quot;); </li></ul><ul><li>rc.startRecord(); </li></ul><ul><li>p.start(); </li></ul><ul><li>//Record the audio for 5sec </li></ul><ul><li>Thread.currentThread().sleep(5000); </li></ul><ul><li>//Stop the player and recording </li></ul><ul><li>p.stop(); </li></ul><ul><li>rc.stopRecord(); </li></ul><ul><li>//Call commit() method to save the audio in above mentioned file path </li></ul><ul><li>rc.commit(); </li></ul>
  18. 18. <ul><li>Thank You </li></ul>

×