By Marcel Caraciolo http://mobideia.blogspot.com Chapter  13–  MMAPI SCMAD Certification  45mm 61mm
Agenda MMAPI Mobile Media API Controls: StopTimeControl, MetaDataControl Controls: RateControl, GUIControl Controls: VideoControl Controls: FramePositioningControl Controls: RecordControl Controls: MIDIControl, PitchControl Controls: TempoControl Protocols TimeBase
MMAPI – Mobile Media API Adds multimedia features to MIDP’s Sound API Does not depend on MIDP, runs on CLDC Added features: Video execution and capture Audio capture Metadata access MIDI generation The features are independent from each other. A device may, for instance, provide audio capabilities, but no video support . Optional features are accessed by controls.
MMAPI – Mobile Media API System properties (values are comma-separated): microedition.media.version:  MMAPI version supports.mixing:  “true” or “false”. When it’s true, at least two sounds  may be played at the same time supports.audio.capture:  If sound capture is supported supports.video.capture:  If video capture is supported supports.recording:  If some kind of recording is supported. audio.encodings:  Supported audio codecs video.encodings:  Supported video codecs video.snapshot.encodings:  Supported image encodings when taking pictures (VideoControl.getSnapshot) streamable.contents:  Data types that may be downloaded while are being executed
StopTimeControl, MetaDataControl StopControl: Sets a specific moment(based on media time) where the execution will be stopped. This controls  should be implemented by players that capture or execute audio or video MetaDataControl: Fetched media metadata (e.g. title, author). Define the methods: getKeys(): Name of all available attributes getKeyValue(key):  Attribute value
RateControl, GUIControl RateControl: Controls the execution “speed” (“events” rate by timebase). Its value is expressed in percent-thousands, hence, 100.000 is the default speed and 200.000 is twice the regular speed. Ranges from getMinRate() to getMaxRate(). GUIControl: UI-Integration control to merge the MMAPI and the GUI API (for MMAPI, only VideoControl extends this interface). Allows output only through the graphics API components.
VideoControl Operations for video capture and execution Methods: initDisplayMode( mode,arg):  Initializes how the video will interact with the platform.  Can be: USE_GUI_PRIMITIVE:  A component from the graphics API is returned. For CDC (Personal Profile) , you get a java.awt.Component. For MIDP, you get a LCDUI Item.  arg  must be null or a string with the fully qualified class name of the component that shall be returned (useful at platforms that support more than one API) USE_DIRECT_VIDEO:  Used only at LCDUI.  arg  must be  a Canvas, where the result will be rendered, and  null is returned.  setDisplayLocation(x,y) method specifies where the video will be rendered on the Canvas.
VideoControl:Methods setVisible (visible) : If the video is visible or not. When rendered as Gui Primitive, default is true. For Direct Video, default is false.  setDisplaySize(width,height):  Resizes the output. The device may not support resizing and then simply cut the video (if the size is smalled than the content) or leave a blank area (if the size is greater than the content). getSourceWidth(), getSourceHeight():  Original video size. getDisplayWidth(), getDisplayHeight():  Video display size. getSnapshot(imageType):  Captures the image being displayed on the video and return as byte array. The parameter specifies the image details (encoding, resolution, etc.)
FramePositioningControl Sets the video execution on a specific frame. The positioning may not be done on the specific frame because some frames might have been lost or the file may be corrupted and contain invalid frames. Defines the following methods: seek(frameNumber): Goes to a specific framer skip(framesToSkip): Skips the number of frames mapFrameToTime(frameNumber) and mapTimeToFrame(mediaTime): Converts frame in time and vice versa.
RecordControl Controls media recording (for audio and video). Records what is being executed by the player. Recording is done on a stream passed to the control. For instance, a URL that points to a video capture device (e.g. “ capture://video”)  exposes both a VideoControl and a RecordControl. This VideoControl keeps continuously showing camera captured images Methods: setRecordStream( stream):  Stream where data will be recorded setRecordLocation( locator):  Output URL to where data will be written (e.g.  file: ///data/video.mpg) getContentType(): Content type of what`s being recorded
RecordControl startRecord(): Starts recording. If the player is being executed, the output is recorded. If the player is stopped, this control will be on “stand-by” waiting for the execution to start only then start recording. stopRecord(): Stops recording. If the player is stopped before calling this method, this recorder returns to “stand-by” commit(): Finishes the recording process, sending data to the stream. This must be called before data on the stream is used. setRecordSizeLimit(size): Limit (in bytes) of data that may be recorded. reset(): Erases current recording. Does nothing if called after a commit.
MIDIControl, PitchControl MIDIControl: Controls devices that render and transmit MIDI (synthesizers). May be obtained opening a MIDI resource or though  Manager.MIDI_DEVICE_LOCATOR URL,  creating an empty player to be controlled programatically. PitchControl: Controls sound frequency. MIDI Players must implement this control. These methods are defined: setPitch(millisemitones): Sets pitch value. Negative values reduce the pitch, and positive values increase the pitch getMinPitch(), getMaxPitch(): Minimum and maximum pitch supported by the player.
TempoControl TempoControl: Controls “musical tempo” (beats per minute). Usually it’s only available for MIDI players. Extends RateControl and define the setTempo( millitempo)  method.
TempoControl TempoControl: Controls “musical tempo” (beats per minute). Usually it’s only available for MIDI players. Extends RateControl and define the setTempo( millitempo)  method.
Protocols: DataSource Data access customization is done through DataSources. DataSources are more sophisticated than InputStreams because they allow random access and seeking (while input streams allow only sequential access). DataSource: Class that manages resource access. For instance, when a network URL is used as locator, the Manager will internally use a DataSource to access the HTTP resource. DataSources may be created by the application when it needs to access a resource that the devices does no support. It has methods to  connect to the resource and expose the streams.
Protocols: DataSource SourceStream:  Used with data source, implements data access. Defines content size, read operations random access to the data ContentDescriptor: Used with SourceStream, identifies a content type.
TimeBase Players use time bases to control time passing Players may have their time bases synchronized with pa.setTimeBase(pb.getTimeBase())
Example Codes Some examples and MIDlets samples are available for reference and studying  at this link: http://www.dsc.upe.br/~ mpc/chapter13.rar The source codes include: MobileMediaMIDlet
Future Work Next Chapter: MIDP – Security Security Permissions Security-Free API Protection Domains Application Signing Permissions definition
References ALVES F. Eduardo. SCMAD Study Guide,  27/04/2008.  JAKL Andreas, Java Platform, Micro Edition Part  01 slides, 12/2007. Sun Certification Mobile Application Developer  Website:  [http://www.sun.com/training/certification/java/scmad.xml].

Scmad Chapter13

  • 1.
    By Marcel Caraciolohttp://mobideia.blogspot.com Chapter 13– MMAPI SCMAD Certification 45mm 61mm
  • 2.
    Agenda MMAPI MobileMedia API Controls: StopTimeControl, MetaDataControl Controls: RateControl, GUIControl Controls: VideoControl Controls: FramePositioningControl Controls: RecordControl Controls: MIDIControl, PitchControl Controls: TempoControl Protocols TimeBase
  • 3.
    MMAPI – MobileMedia API Adds multimedia features to MIDP’s Sound API Does not depend on MIDP, runs on CLDC Added features: Video execution and capture Audio capture Metadata access MIDI generation The features are independent from each other. A device may, for instance, provide audio capabilities, but no video support . Optional features are accessed by controls.
  • 4.
    MMAPI – MobileMedia API System properties (values are comma-separated): microedition.media.version: MMAPI version supports.mixing: “true” or “false”. When it’s true, at least two sounds may be played at the same time supports.audio.capture: If sound capture is supported supports.video.capture: If video capture is supported supports.recording: If some kind of recording is supported. audio.encodings: Supported audio codecs video.encodings: Supported video codecs video.snapshot.encodings: Supported image encodings when taking pictures (VideoControl.getSnapshot) streamable.contents: Data types that may be downloaded while are being executed
  • 5.
    StopTimeControl, MetaDataControl StopControl:Sets a specific moment(based on media time) where the execution will be stopped. This controls should be implemented by players that capture or execute audio or video MetaDataControl: Fetched media metadata (e.g. title, author). Define the methods: getKeys(): Name of all available attributes getKeyValue(key): Attribute value
  • 6.
    RateControl, GUIControl RateControl:Controls the execution “speed” (“events” rate by timebase). Its value is expressed in percent-thousands, hence, 100.000 is the default speed and 200.000 is twice the regular speed. Ranges from getMinRate() to getMaxRate(). GUIControl: UI-Integration control to merge the MMAPI and the GUI API (for MMAPI, only VideoControl extends this interface). Allows output only through the graphics API components.
  • 7.
    VideoControl Operations forvideo capture and execution Methods: initDisplayMode( mode,arg): Initializes how the video will interact with the platform. Can be: USE_GUI_PRIMITIVE: A component from the graphics API is returned. For CDC (Personal Profile) , you get a java.awt.Component. For MIDP, you get a LCDUI Item. arg must be null or a string with the fully qualified class name of the component that shall be returned (useful at platforms that support more than one API) USE_DIRECT_VIDEO: Used only at LCDUI. arg must be a Canvas, where the result will be rendered, and null is returned. setDisplayLocation(x,y) method specifies where the video will be rendered on the Canvas.
  • 8.
    VideoControl:Methods setVisible (visible): If the video is visible or not. When rendered as Gui Primitive, default is true. For Direct Video, default is false. setDisplaySize(width,height): Resizes the output. The device may not support resizing and then simply cut the video (if the size is smalled than the content) or leave a blank area (if the size is greater than the content). getSourceWidth(), getSourceHeight(): Original video size. getDisplayWidth(), getDisplayHeight(): Video display size. getSnapshot(imageType): Captures the image being displayed on the video and return as byte array. The parameter specifies the image details (encoding, resolution, etc.)
  • 9.
    FramePositioningControl Sets thevideo execution on a specific frame. The positioning may not be done on the specific frame because some frames might have been lost or the file may be corrupted and contain invalid frames. Defines the following methods: seek(frameNumber): Goes to a specific framer skip(framesToSkip): Skips the number of frames mapFrameToTime(frameNumber) and mapTimeToFrame(mediaTime): Converts frame in time and vice versa.
  • 10.
    RecordControl Controls mediarecording (for audio and video). Records what is being executed by the player. Recording is done on a stream passed to the control. For instance, a URL that points to a video capture device (e.g. “ capture://video”) exposes both a VideoControl and a RecordControl. This VideoControl keeps continuously showing camera captured images Methods: setRecordStream( stream): Stream where data will be recorded setRecordLocation( locator): Output URL to where data will be written (e.g. file: ///data/video.mpg) getContentType(): Content type of what`s being recorded
  • 11.
    RecordControl startRecord(): Startsrecording. If the player is being executed, the output is recorded. If the player is stopped, this control will be on “stand-by” waiting for the execution to start only then start recording. stopRecord(): Stops recording. If the player is stopped before calling this method, this recorder returns to “stand-by” commit(): Finishes the recording process, sending data to the stream. This must be called before data on the stream is used. setRecordSizeLimit(size): Limit (in bytes) of data that may be recorded. reset(): Erases current recording. Does nothing if called after a commit.
  • 12.
    MIDIControl, PitchControl MIDIControl:Controls devices that render and transmit MIDI (synthesizers). May be obtained opening a MIDI resource or though Manager.MIDI_DEVICE_LOCATOR URL, creating an empty player to be controlled programatically. PitchControl: Controls sound frequency. MIDI Players must implement this control. These methods are defined: setPitch(millisemitones): Sets pitch value. Negative values reduce the pitch, and positive values increase the pitch getMinPitch(), getMaxPitch(): Minimum and maximum pitch supported by the player.
  • 13.
    TempoControl TempoControl: Controls“musical tempo” (beats per minute). Usually it’s only available for MIDI players. Extends RateControl and define the setTempo( millitempo) method.
  • 14.
    TempoControl TempoControl: Controls“musical tempo” (beats per minute). Usually it’s only available for MIDI players. Extends RateControl and define the setTempo( millitempo) method.
  • 15.
    Protocols: DataSource Dataaccess customization is done through DataSources. DataSources are more sophisticated than InputStreams because they allow random access and seeking (while input streams allow only sequential access). DataSource: Class that manages resource access. For instance, when a network URL is used as locator, the Manager will internally use a DataSource to access the HTTP resource. DataSources may be created by the application when it needs to access a resource that the devices does no support. It has methods to connect to the resource and expose the streams.
  • 16.
    Protocols: DataSource SourceStream: Used with data source, implements data access. Defines content size, read operations random access to the data ContentDescriptor: Used with SourceStream, identifies a content type.
  • 17.
    TimeBase Players usetime bases to control time passing Players may have their time bases synchronized with pa.setTimeBase(pb.getTimeBase())
  • 18.
    Example Codes Someexamples and MIDlets samples are available for reference and studying at this link: http://www.dsc.upe.br/~ mpc/chapter13.rar The source codes include: MobileMediaMIDlet
  • 19.
    Future Work NextChapter: MIDP – Security Security Permissions Security-Free API Protection Domains Application Signing Permissions definition
  • 20.
    References ALVES F.Eduardo. SCMAD Study Guide, 27/04/2008. JAKL Andreas, Java Platform, Micro Edition Part 01 slides, 12/2007. Sun Certification Mobile Application Developer Website: [http://www.sun.com/training/certification/java/scmad.xml].