This commit is contained in:
Marco Castelluccio 2014-11-14 20:27:24 +01:00
Родитель 8f15bd1a2c
Коммит b421fbf827
18 изменённых файлов: 2459 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,180 @@
/*
* Copyright 1990-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 only, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is
* included at /legal/license.txt).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 or visit www.sun.com if you need additional
* information or have any questions.
*/
package com.sun.amms;
import com.sun.midp.events.EventListener;
import com.sun.midp.events.Event;
import com.sun.midp.events.EventTypes;
import com.sun.midp.events.EventQueue;
import com.sun.midp.events.NativeEvent;
import com.sun.midp.security.SecurityToken;
import com.sun.midp.security.ImplicitlyTrustedClass;
import com.sun.midp.security.SecurityInitializer;
import com.sun.mmedia.PlayerImpl;
import com.sun.mmedia.BasicPlayer;
import javax.microedition.amms.control.tuner.RDSControl;
import javax.microedition.amms.control.camera.SnapshotControl;
class AMMSEventType {
/**
* the following constants must be consistent
* with javacall_amms_notification_type enum values
* JAVACALL_EVENT_AMMS_***, defined in javacall_multimedia_advanced.h
*
* IMPL_NOTE: Current javanotify_multimedia_advanced.h version
* defines this values implicitly
*/
public static final int MEDIA_PROCESSOR_COMPLETED = 0;
public static final int MEDIA_PROCESSOR_ERROR = 1;
public static final int RDS_RADIO_CHANGED = 2;
public static final int RDS_RDS_NEW_ALARM = 3;
public static final int RDS_RDS_NEW_DATA = 4;
public static final int SNAP_SHOOTING_STOPPED = 5;
public static final int SNAP_STORAGE_ERROR = 6;
}
public class AMMSMPEventListener implements EventListener {
private static class SecurityTrusted implements ImplicitlyTrustedClass{};
private static SecurityToken classSecurityToken;
private static AMMSMPEventListener _instance;
public static AMMSMPEventListener getInstance()
{
if (null == _instance)
_instance = new AMMSMPEventListener();
return _instance;
}
private AMMSMPEventListener()
{
classSecurityToken =
SecurityInitializer.requestToken(new SecurityTrusted());
EventQueue evtq =
EventQueue.getEventQueue(classSecurityToken);
evtq.registerEventListener(EventTypes.AMMS_EVENT, this);
}
public boolean preprocess(Event event, Event waitingEvent) {
return true;
}
/**
* Process an event.
* This method will get called in the event queue processing thread.
*
* @param event event to process
*/
public void process(Event event) {
NativeEvent nevt = (NativeEvent)event;
int native_event_type = nevt.intParam4;
BasicPlayer player = null;
if( native_event_type != AMMSEventType.MEDIA_PROCESSOR_ERROR &&
native_event_type != AMMSEventType.MEDIA_PROCESSOR_COMPLETED )
{
player = PlayerImpl.get( nevt.intParam1 );
if (player == null)
{
System.out.println( "Could not identify the Player #" + nevt.intParam1 +
", unable to dispatch event, type=" + native_event_type );
}
else
{
System.out.println( "Dispatching event to " + player +
" (#" + nevt.intParam1 +
"), ev=" + native_event_type );
switch( native_event_type )
{
case AMMSEventType.RDS_RADIO_CHANGED:
player.sendEvent( RDSControl.RADIO_CHANGED,
new Short( (short)nevt.intParam2 ) );
break;
case AMMSEventType.RDS_RDS_NEW_ALARM:
player.sendEvent( RDSControl.RDS_NEW_ALARM,
new Short( (short)nevt.intParam2 ) );
break;
case AMMSEventType.RDS_RDS_NEW_DATA:
player.sendEvent( RDSControl.RDS_NEW_DATA,
new Short( (short)nevt.intParam2 ) );
break;
case AMMSEventType.SNAP_SHOOTING_STOPPED:
player.sendEvent( SnapshotControl.SHOOTING_STOPPED,
new String( nevt.stringParam1 ) );
break;
case AMMSEventType.SNAP_STORAGE_ERROR:
player.sendEvent( SnapshotControl.STORAGE_ERROR,
new String( nevt.stringParam1 ) );
break;
}
}
}
else
{
/// Notification may be long
AMMSMPEventNotifier mpN = new AMMSMPEventNotifier(
nevt.intParam4, nevt.intParam1 );
new Thread( mpN ).start();
}
}
}
class AMMSMPEventNotifier implements Runnable
{
int type;
int intParam1;
AMMSMPEventNotifier(int type, int intParam1) {
this.type = type;
this.intParam1 = intParam1;
}
public void run() {
BasicMediaProcessor mp;
mp = BasicMediaProcessor.get(intParam1);
if (mp != null)
{
switch (type)
{
case AMMSEventType.MEDIA_PROCESSOR_COMPLETED:
mp.notifyCompleted(true);
break;
case AMMSEventType.MEDIA_PROCESSOR_ERROR:
mp.notifyCompleted(false);
break;
}
}
}
}

Просмотреть файл

@ -0,0 +1,129 @@
/*
* Copyright 1990-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 only, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is
* included at /legal/license.txt).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 or visit www.sun.com if you need additional
* information or have any questions.
*/
package com.sun.amms;
import java.util.Hashtable;
import javax.microedition.media.Controllable;
import javax.microedition.media.Control;
import javax.microedition.media.MediaException;
import javax.microedition.amms.Spectator;
import com.sun.amms.directcontrol.DirectAMMSControl;
abstract class AbstractDirectControllable implements Controllable
{
private Hashtable _hControls;
private Control[] _aControls;
AbstractDirectControllable()
{
_hControls = new Hashtable();
_aControls = null;
}
protected abstract String [] getSupportedControlNames();
public final Control [] getControls()
{
if( _aControls != null )
{
return _aControls;
}
String[] names = getSupportedControlNames();
_aControls = new Control [ names.length ];
for( int i = 0; i < names.length; i++ )
{
System.out.println( "AK debug: the control " + names [i] + " was declared as supported" );
System.out.flush();
_aControls[ i ] = ( Control )_hControls.get( names[ i ] );
if( _aControls[ i ] == null )
{
_aControls[ i ] = createControl( names[ i ] );
}
if( _aControls[ i ] == null )
{
throw new RuntimeException(
"Failed to find native implementation of "
+ names[ i ] +
" which was declared to be supported" );
}
}
return _aControls;
}
public final Control getControl( String controlType )
{
if (controlType == null) throw new IllegalArgumentException();
String type;
// Prepend the package name if the type given does not
// have the package prefix.
if (controlType.indexOf('.') < 0) {
type = "javax.microedition.media.control." + controlType;
} else {
type = controlType;
}
Control c;
if( ( c = ( Control )_hControls.get( type ) ) != null )
{
return c;
}
if( _aControls != null )
{
return null;
}
return createControl( type );
}
protected abstract int getControlPeer( String controlType );
private Control createControl( String type )
{
int control_peer = getControlPeer( type );
if( control_peer == 0 )
{
return null;
}
Control c = DirectAMMSControl.createDirectAMMSControl( type,
control_peer );
if( c != null )
{
_hControls.put( type, c );
}
return c;
}
}

Просмотреть файл

@ -0,0 +1,266 @@
/*
* Copyright 1990-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 only, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is
* included at /legal/license.txt).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 or visit www.sun.com if you need additional
* information or have any questions.
*/
package com.sun.amms;
import javax.microedition.amms.Module;
import javax.microedition.media.Player;
import javax.microedition.media.MediaException;
import java.util.Hashtable;
import java.util.Enumeration;
abstract class BasicDirectModule extends AbstractDirectControllable
implements Module
{
private class PlayerConnectionInfo
{
private int _channels_mask;
private boolean _added_wholly;
PlayerConnectionInfo()
{
_added_wholly = true;
_channels_mask = 0;
}
PlayerConnectionInfo( int channel )
{
_added_wholly = false;
_channels_mask = ( 1 << channel );
}
boolean canAddMIDIChannel( int channel )
{
return ( ( _added_wholly == false ) &&
( ( _channels_mask & ( 1 << channel ) ) == 0 ) );
}
boolean allChannelsRemoved()
{
return ( _added_wholly == false && _channels_mask == 0 );
}
void addMIDIChannel( int channel )
{
_channels_mask |= ( 1 << channel );
}
boolean canRemoveMIDIChannel( int channel )
{
return ( _added_wholly == false &&
( _channels_mask & ( 1 << channel ) ) != 0 );
}
boolean isAddedWholly()
{
return _added_wholly;
}
void removeMIDIChannel( int channel )
{
_channels_mask &= ~( 1 << channel );
}
}
private Hashtable _players;
BasicDirectModule()
{
_players = new Hashtable();
}
private static void checkChannelNumberRange( int channel_number )
{
if( channel_number < 0 || channel_number > 15 )
{
throw new IllegalArgumentException(
"The MIDI channel number should be from 0 to 15" );
}
}
private static boolean isPlayerMIDI( Player p )
{
return p.getContentType().toLowerCase().indexOf( "midi" ) != -1;
}
private static void checkIfPlayerIsMIDI( Player p )
{
if( !isPlayerMIDI( p ) )
{
throw new IllegalArgumentException(
"JSR-234 Module: Cannot add/remove a MIDI channel of a " +
"Player that is not a MIDI Player" );
}
}
private static void checkIfPlayerIsNull( Player player )
{
if( player == null )
{
throw new IllegalArgumentException(
"JSR-234 Module: Cannot add/remove a null player" );
}
}
private static boolean isPlayerStateAcceptable( Player p )
{
return ( p.getState() != Player.PREFETCHED &&
p.getState() != Player.STARTED );
}
private void checkPlayerStates( Player playerToAddOrRemove )
{
if( !isPlayerStateAcceptable( playerToAddOrRemove ) )
{
throw new IllegalStateException(
"JSR-234 Module: Cannot add/remove a Player in PREFETCHED or STARTED state" );
}
Enumeration e = _players.keys();
while( e.hasMoreElements() )
{
if( !isPlayerStateAcceptable( ( Player )e.nextElement() ) )
{
throw new IllegalStateException(
"JSR-234 Module: Cannot add/remove a Player when connected " +
"with any other Player in PREFETCHED or STARTED state" );
}
}
}
protected abstract void doAddMIDIChannel( Player player, int channel )
throws MediaException;
public void addMIDIChannel( Player player, int channel )
throws MediaException
{
checkChannelNumberRange( channel );
checkIfPlayerIsNull( player );
checkIfPlayerIsMIDI( player );
checkPlayerStates( player );
PlayerConnectionInfo conn =
( PlayerConnectionInfo )_players.get( player );
if( conn != null )
{
if( !conn.canAddMIDIChannel( channel ) )
{
throw new IllegalArgumentException(
"Cannot add a MIDI channel to a Module if either the channel or the whole " +
"Player is already part of the Module" );
}
}
doAddMIDIChannel( player, channel );
if( conn != null )
{
conn.addMIDIChannel( channel );
}
else
{
conn = new PlayerConnectionInfo( channel );
_players.put( player, conn );
}
}
protected abstract void doAddPlayer( Player player ) throws MediaException;
public void addPlayer( Player player ) throws MediaException
{
checkIfPlayerIsNull( player );
checkPlayerStates( player );
if( _players.containsKey( player ) )
{
throw new IllegalArgumentException(
"Cannot add a Player to a Module if either the Player or one " +
"of its MIDI channels is already part of the Module" );
}
doAddPlayer( player );
_players.put( player, new PlayerConnectionInfo() );
}
protected abstract void doRemoveMIDIChannel( Player player, int channel );
public void removeMIDIChannel( Player player, int channel )
{
checkChannelNumberRange( channel );
checkIfPlayerIsNull( player );
checkIfPlayerIsMIDI( player );
checkPlayerStates( player );
PlayerConnectionInfo conn =
( PlayerConnectionInfo )_players.get( player );
if( conn == null )
{
throw new IllegalArgumentException(
"Cannot remove a MIDI channel that is not a part of the Module" );
}
if( !conn.canRemoveMIDIChannel( channel ) )
{
throw new IllegalArgumentException(
"Cannot remove a MIDI channel that is not a part of the Module" );
}
doRemoveMIDIChannel( player, channel );
conn.removeMIDIChannel( channel );
if( conn.allChannelsRemoved() )
{
_players.remove( player );
}
}
protected abstract void doRemovePlayer( Player player );
public void removePlayer( Player player )
{
checkIfPlayerIsNull( player );
checkPlayerStates( player );
if( !isAddedWholly( player ) )
{
throw new IllegalArgumentException(
"Cannot remove the Player because it is not a part of the Module" );
}
doRemovePlayer( player );
_players.remove( player );
}
protected boolean isAddedWholly( Player p )
{
boolean added = false;
PlayerConnectionInfo conn =
( PlayerConnectionInfo )_players.get( p );
if( conn != null )
{
added = conn.isAddedWholly();
}
return added;
}
}

Просмотреть файл

@ -0,0 +1,702 @@
/*
* Copyright 1990-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 only, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is
* included at /legal/license.txt).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 or visit www.sun.com if you need additional
* information or have any questions.
*/
package com.sun.amms;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Vector;
import javax.microedition.amms.MediaProcessor;
import javax.microedition.amms.MediaProcessorListener;
import javax.microedition.media.Control;
import javax.microedition.media.MediaException;
import java.util.Hashtable;
public abstract class BasicMediaProcessor implements MediaProcessor {
/*
* Several comments and rules:
*
* 1). this class implements public methods of MediaProcessor I/F.
* For some of them it defines internal requestXXX() & doXXX()
* methods that are to be redefined and implemented in derived classes.
* Public methods, that have "internal" pair assumed to be "final"
* and SHALL NOT be redefined in derived classes.
* These are: start(), stop(), complete(), abort(),
* setInput(), setOutput().
*
* In general, a public method updates the state and invokes callback,
* while its internal pair does all object-specific processing and return
* true/false to indicate success/failure. Based on these return codes
* public methods update state, invoke appropriate callbacks and
* throw MediaException when needed.
*
* 2). state changes & callbacks shall be done in a synchronized section
* (use "stateLock" object for that). A dedicated object instead of 'this"
* is used to protect algorithm from accidental use of "this"-based
* synchronization for different purposes in derived classes.
*
* 3). "abort()", "stop()" & "notifyCompleted()" can conflict
* in resulting state and invoked callback.
*
*/
/* Input and output parameters */
protected InputStream inputStream = null;
protected int inputStreamLength;
protected Object inputObject = null;
protected OutputStream outputStream = null;
private boolean inputWasSet = false;
/* Current media processor state */
protected int state;
/* Media processor controls */
private Control[] controls;
private String[] controlNames;
/* Media processor listeners */
private Vector listeners;
private boolean listenersModified;
/* Media processor synchronizers */
private Object stateLock = new Object();
private Object processorLock = new Object();
private static Object idLock = new Object();
private static int curID = 0;
protected int mediaProcessorID;
/* Listener for complete events */
private MPListenerWait mpWait = new MPListenerWait();
/**
* hashtable to map processorsID to instances
*/
private static Hashtable mprocessors = new Hashtable(4);
/**
* Amount of work completed (0 - 100%)
*
* Subclasses need to set this value!
*/
protected int progress = UNKNOWN;
protected void setControls(Control[] controls, String[] controlNames) {
this.controls = controls;
this.controlNames = controlNames;
}
/**
* BasicMediaProcessorInternal I/F method
* Subclasses need to implement this to perform implementation specific
* checks, allocations, etc
*
* @param input input stream.
* @param length length of input stream or UNKNOWN.
* @return true on success, false otherwise
* @throws MediaException if the input could not be set
* and exception shall be delivered to user.
*/
protected abstract boolean doSetInput(InputStream input, int length)
throws MediaException;
/**
* BasicMediaProcessorInternal I/F method
* Subclasses need to implement this to perform implementation specific
* checks, allocations, etc
*
* @return true on success, false otherwise
* @throws MediaException if the input could not be set
* and exception shall be delivered to user.
*/
protected abstract boolean doSetInput(Object image) throws MediaException;
/**
* BasicMediaProcessorInternal I/F method
* Subclasses need to implement this to start
* the <code>MediaProcessor</code>.
*
* @return true on success (signal to move to STARTED state)
* @throws MediaException if the <code>MediaProcessor</code>
* could not be started and exception shall be delivered to user.
*/
protected abstract boolean doStart() throws MediaException;
/**
* BasicMediaProcessorInternal I/F method
* Subclasses need to implement this to stop
* the <code>MediaProcessor</code>.
*
* @return true on success (MediaProcessor going to stop)
* @throws MediaException if the <code>MediaProcessor</code>
* could not be stopped.
*/
protected abstract boolean doStop() throws MediaException;
/**
* BasicMediaProcessorInternal I/F method
* Subclasses need to implement this to continue execution
* the <code>MediaProcessor</code>.
*
* @return true on success (MediaProcessor continued)
* @throws MediaException if the <code>MediaProcessor</code>
* could not be continued.
*/
protected abstract boolean doContinue() throws MediaException;
/**
* BasicMediaProcessorInternal I/F method
* Writes output data to the stream.
*
* @return true on successful completion, false otherwise
* (processing errors)
*/
protected abstract boolean doOutput();
/**
* BasicMediaProcessorInternal I/F method
* Aborts media processing.
*
* @return true on successful completion,
*/
protected abstract boolean doAbort();
/**
* Public constructor.
*
* @param allCtrls acceptable controls lists.
*
*/
public BasicMediaProcessor() {
this.controlNames = new String[0];
this.controls = new Control[0];
mediaProcessorID = 0;
synchronized (idLock) {
mediaProcessorID = (curID + 1) & 32767;
curID = mediaProcessorID;
}
mprocessors.put(new Integer(mediaProcessorID), this);
listeners = new Vector();
inputStream = null;
outputStream = null;
state = UNREALIZED;
}
public Control getControl(String controlType) {
if (controlType == null)
throw new IllegalArgumentException("Invalid control type");
/* Currently, the specification say, that controls may be get in unrealized
state, but in the proposals for JSR 234 (N20) suggested to forbid it. */
/* if (state == UNREALIZED)
throw new IllegalStateException("Invalid state: " + state);*/
// Prepend the package name if the type given does not
// have the package prefix.
String type = (controlType.indexOf('.') < 0)
? ("javax.microedition.media.control." + controlType)
: controlType;
for (int i = 0; i < controlNames.length; i++)
if (type.equals(controlNames[i]))
return controls[i];
return null;
}
public Control[] getControls() {
/* Currently, the specification say, that controls may be get in unrealized
state, but in the proposals for JSR 234 (N20) suggested to forbid it. */
/* if (state == UNREALIZED)
throw new IllegalStateException("Invalid state: " + state);*/
Control[] result = new Control[controls.length];
System.arraycopy(controls, 0, result, 0, controls.length);
return result;
}
/**
* Sets the input of the media processor.
* @param input The <code>InputStream</code> to be used as input.
* @param length The estimated length of the processed media in bytes. Since the input
* is given as an <code>InputStream</code>, the implementation cannot find out
* what is the length of the media until it has been processed. The estimated
* length is used only when the <code>progress</code> method is used to query the
* progress of the processing. If the length is not known, UNKNOWN should be passed
* as a length.
* @throws IllegalStateException if the <code>MediaProcessor</code>
* was not in UNREALIZED or REALIZED state.
* @throws javax.microedition.media.MediaException if input can not be given as a stream.
* @throws IllegalArgumentException if input is null.
* @throws IllegalArgumentException if length < 1 and length != UNKNOWN.
*
*/
public void setInput(InputStream input, int length)
throws javax.microedition.media.MediaException {
inputWasSet = false;
synchronized (stateLock) {
if (state != UNREALIZED && state != REALIZED) {
throw new IllegalStateException("Invalid state " + state);
}
if (null == input) {
throw new IllegalArgumentException("Invalid input stream");
}
if (length < 1 && length != UNKNOWN) {
throw new IllegalArgumentException("Invalid input stream length " + length);
}
inputWasSet = doSetInput(input, length);
// Reset object. Use stream.
inputObject = null;
inputStream = input;
inputStreamLength = length;
if(isRealizable())
notifyRealized();
}
}
/**
* Sets the input of the media processor as an Image.
* <p>
* Setting the input as an Image allows use of raw image data in a convenient way. It also
* allows converting Images to image files.
* <code>image</code> is an UI Image of the implementing platform. For example, in MIDP
* <code>image</code> is <code>javax.microedition.lcdui.Image</code> object.
* </p>
* <p>
* Mutable Image is allowed as an input but the behavior is unspecified if the Image
* is changed during processing.
* </p>
* @param image The <code>Image</code> object to be used as input.
* @throws IllegalStateException if the <code>MediaProcessor</code> was not in <i>UNREALIZED</i> or <i>REALIZED</i> state.
* @throws javax.microedition.media.MediaException if input can not be given as an image.
*
* @throws IllegalArgumentException if the image is not an Image object.
*
*/
public synchronized void setInput(Object image)
throws javax.microedition.media.MediaException {
inputWasSet = false;
synchronized (stateLock) {
if (state != UNREALIZED && state != REALIZED)
throw new IllegalStateException("Invalid state " + state);
inputWasSet = doSetInput(image);
// Reset stream. Use object.
if (inputStream != null) {
//try {inputStream.close();} catch();
inputStream = null;
}
inputObject = image;
if(isRealizable())
notifyRealized();
}
}
/**
* Sets the output of the media processor.
* @param output The <code>OutputStream</code> to be used as output.
* @throws IllegalArgumentException if output is null.
* @throws IllegalStateException if the <code>MediaProcessor</code> was not in <i>UNREALIZED</i> or <i>REALIZED</i> state.
*/
public void setOutput(OutputStream output) {
synchronized (stateLock) {
if (state != UNREALIZED && state != REALIZED) {
throw new IllegalStateException("Invalid state " + state);
}
if (output == null) {
throw new IllegalArgumentException("Invalid output stream");
}
outputStream = output;
if(isRealizable()) {
notifyRealized();
}
}
}
/**
* checks if the media processor can be transitioned
* from UNREALIZED to REALIZED state.
*/
private boolean isRealizable() {
return ( ((inputStream != null) || (inputObject != null))
&& (outputStream != null) && (state == UNREALIZED));
}
/**
* Starts processing. If the <code>MediaProcessor</code> is in
* STARTED state, the call is ignored. Upon calling this method,
* the <code>MediaProcessor</code> either throws a
* <code>MediaException</code> or moves to <i>STARTED</i> state and posts
* <code>PROCESSING_STARTED</code> event to <code>MediaProcessorListener</code>s.
*
* <p>After the processing has been completed, a <code>PROCESSING_COMPLETED</code>
* event will be delivered and the <code>MediaProcessor</code>
* will move into the <i>UNREALIZED</i> state.</p>
* @throws IllegalStateException if the <code>MediaProcessor</code>
* was in <i>UNREALIZED</i> state.
* @throws MediaException if the <code>MediaProcessor</code>
* could not be started.
*/
public final void start() throws MediaException {
if (state == STARTED) {
return;
}
synchronized (stateLock) {
/* do nothing if already in STARTED state */
if (state == STARTED) {
return;
}
/* valid states are only REALIZED and STOPPED */
if (state == UNREALIZED)
throw new IllegalStateException("Invalid state " + state);
if (!inputWasSet)
throw new MediaException("Incorrect or unsupported input data");
boolean isStarted = false;
if (state == STOPPED)
isStarted = doContinue();
else
isStarted = doStart();
if (isStarted) {
state = STARTED;
/** requestStart & notification is done inside stateLock. So
* in any case PROCESSING_STARTED will be send early than
* PROCESSING_COMPLETED or PROCESSING_EROR
*/
notifyListeners(MediaProcessorListener.PROCESSING_STARTED,
new Integer(getProgressInTenths()));
}
else throw new MediaException("Failed to start operation");
}
}
/**
* Stops processing temporarily. If the
* <code>MediaProcessor</code> is in a <i>UNREALIZED</i>, <i>REALIZED</i> or <i>STOPPED</i> state, the
* call is ignored. Otherwise, the <code>MediaProcessor</code>
* either throws a <code>MediaException</code> or moves to
* <i>STOPPED</i> state and posts <code>PROCESSING_STOPPED</code> event to <code>MediaProcessorListener</code>s.
*
* @throws MediaException if the <code>MediaProcessor</code>
* could not be stopped.
*/
public final void stop() throws MediaException {
/* do nothing if not in STARTED state */
if (state != STARTED) {
return;
}
synchronized (stateLock) {
if (state != STARTED) {
return;
}
if (doStop()) {
notifyStopped();
} else {
throw new MediaException("Failed to stop operation");
}
}
}
/**
* Waits until the processing has been completed. If
* the <code>MediaProcessor</code> is not in <i>STARTED</i> state, calls
* <code>start</code> implicitly causing <code>PROCESSING_STARTED</code> event to be posted
* to <code>MediaProcessorListener</code>s. Otherwise, waits until either
* a <code>MediaException</code> is thrown and <code>PROCESSING_ERROR</code> is posted
* or a <code>PROCESSING_COMPLETED</code>
* event has been posted. After this method returns, the
* <code>MediaProcessor</code> is in <i>UNREALIZED</i> state if the processing was succesful
* or in <i>REALIZED</i> state if the processing failed.
* @throws IllegalStateException if the <code>MediaProcessor</code>
* was in <i>UNREALIZED</i> state
* @throws MediaException if completing the processing failed either because the processing couldn't be started
* or because an error occured during processing.
*/
public final void complete() throws MediaException {
/*
* need to do same checks as start() method does ...
* need to be inlined if there is a risk that start() method in derived
* classes will be inlined !
*/
synchronized(stateLock) {
if (state == UNREALIZED)
throw new IllegalStateException("Invalid state " + state);
if (state != STARTED) /// If not started start
start();
}
String event = mpWait.Complete();
if (event != MediaProcessorListener.PROCESSING_COMPLETED)
throw new MediaException("Media processing was interrupted: " + event);
}
/**
* Aborts the processing even if the processing was not
* complete.
* Any bytes that were written to output may not be
* reasonable and should be discarded. A <code>PROCESSING_ABORTED</code>
* event is posted and the <code>MediaProcessor</code> is
* moved into <i>UNREALIZED</i> state.
* <p>
* Ignored if the
* <code>MediaProcessor</code> was in <i>REALIZED</i> or <i>UNREALIZED</i> state.
*/
public synchronized final void abort() {
/* do nothing of not in STARTED or STOPPED state - nothing to abort */
if (state != STARTED && state != STOPPED) {
return;
}
// close input & output streams before callback
synchronized (stateLock) {
if (state != STARTED && state != STOPPED) {
return;
}
if (doAbort()) {
synchronized (stateLock) {
closeAllStreams();
state = UNREALIZED;
notifyListeners(MediaProcessorListener.PROCESSING_ABORTED,
new Integer(getProgressInTenths()));
}
} else {
/// Strange state. Abort doesn't throw exceptions, so what do with
/// unsuccessful result ?
}
}
}
public final void addMediaProcessorListener(MediaProcessorListener listener) {
if (listener != null) {
/*
* Explicit "sync" is needed to raise "modified" flag.
* Implicit "sync" is already inside addElement() method,
* so second sync from the same thread will do nothing ...
*/
synchronized (listeners) {
listenersModified = true;
listeners.addElement(listener);
}
}
}
public final void removeMediaProcessorListener(MediaProcessorListener listener) {
if (listener != null) {
/*
* Explicit "sync" is needed to raise "modified" flag.
* Implicit "sync" is already inside removeElemet() method,
* so second sync from the same thread will do nothing ...
*/
synchronized (listeners) {
listenersModified = true;
listeners.removeElement(listener);
}
}
}
/**
* Get an estimated percentage of work that has been done.
*
* @return
* <ul>
* <li>0, if the <code>MediaProcessor</code> is in <i>UNREALIZED</i> or <i>REALIZED</i> state
* <li>amount of work completed (0 - 100%) if <code>MediaProcessor</code> is in <i>STARTED</i> or <i>STOPPED</i> states
* <li><code>UNKNOWN</code>, if the estimation cannot be calculated.
* </ul>
*/
public int getProgress() {
return ((state == UNREALIZED) || (state == REALIZED))
? 0 : progress;
}
/**
* Get the current MediaProcessor state.
*
* @return
* <ul>
* <li><i>UNREALIZED</i>
* <li><i>REALIZED</i>
* <li><i>STOPPED</i>
* <li><i>STARTED</i>
* </ul>
*/
public int getState() {
return state;
}
/**
* Called to notify about processing completed (or processing error)
*/
protected void notifyCompleted(boolean processingSuccess) {
if (processingSuccess) {
processingSuccess = doOutput();
synchronized (stateLock) {
// close input & output streams before callback
closeAllStreams();
state = UNREALIZED;
notifyListeners(MediaProcessorListener.PROCESSING_COMPLETED,
new Boolean(processingSuccess));
}
} else {
synchronized (stateLock) {
state = REALIZED;
notifyListeners(MediaProcessorListener.PROCESSING_ERROR,
"");
}
}
}
protected void notifyStopped() {
synchronized (stateLock) {
state = STOPPED;
notifyListeners(MediaProcessorListener.PROCESSING_STOPPED,
new Integer(getProgressInTenths()));
}
}
/**
* Called from setInput() & setOutput() methods
* to notify that processor wants to move to REALIZED state.
*/
private void notifyRealized() {
synchronized (stateLock) {
state = REALIZED;
notifyListeners(MediaProcessorListener.PROCESSOR_REALIZED,
new Integer(getProgressInTenths()));
}
}
private void notifyListeners(String message, Object obj) {
Object copy[];
synchronized (listeners) {
copy = new Object[listeners.size()];
listeners.copyInto(copy);
listenersModified = false;
}
for (int i = 0; i < copy.length; i++) {
MediaProcessorListener listener = (MediaProcessorListener)copy[i];
listener.mediaProcessorUpdate(this, message, obj);
}
mpWait.mediaProcessorUpdate(this, message, obj);
/*
* need to check for "listenersModified == true",
* this means that one of callbacks updated listeners ->
* need some actions ...
*/
}
private int getProgressInTenths() {
return ((progress > 0) && (progress <= 100)
? (progress * 10)
: progress);
}
private boolean closeAllStreams() {
boolean result;
try {
if (inputStream != null)
inputStream.close();
if (outputStream != null)
outputStream.close();
/*
* Reset handles to avoid false transition to REALIZED state after
* next input setup
*/
inputStream = null;
outputStream = null;
inputObject = null;
result = true;
} catch (java.io.IOException ioex) {
result = false;
}
return result;
}
private boolean waitProcessing() {
return false;
}
/**
* For processors management
*
* @param pid Description of the Parameter
* @return Description of the Return Value
*/
public static BasicMediaProcessor get(int mpid) {
return (BasicMediaProcessor) (mprocessors.get(new Integer(mpid)));
}
}
class MPListenerWait implements MediaProcessorListener{
boolean isWait = true;
String event = MediaProcessorListener.PROCESSING_ERROR;
public void mediaProcessorUpdate( MediaProcessor processor, String event, Object eventData ) {
this.event = event;
isWait = (event == MediaProcessorListener.PROCESSING_STARTED);
if (!isWait) {
synchronized(this) {
this.notifyAll();
}
}
}
public String Complete() {
synchronized(this) {
while (isWait)
try { this.wait(); } catch(Exception e) {};
}
return event;
}
}

Просмотреть файл

@ -0,0 +1,195 @@
/*
* Copyright 1990-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 only, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is
* included at /legal/license.txt).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 or visit www.sun.com if you need additional
* information or have any questions.
*/
package com.sun.amms;
import javax.microedition.amms.SoundSource3D;
import javax.microedition.media.Player;
import javax.microedition.media.MediaException;
import com.sun.mmedia.DirectPlayer;
import com.sun.mmedia.PlayerImpl;
import com.sun.mmedia.PlayerStateSubscriber;
public class DirectSoundSource3D extends BasicDirectModule
implements SoundSource3D, PlayerStateSubscriber
{
private int _peer = 0;
private int _managerPeer; // needed for the native finalizer
private DirectSoundSource3D() {}
public DirectSoundSource3D( int managerPeer, int peer )
{
_peer = peer;
_managerPeer = managerPeer;
}
private native int nGetControlPeer( byte[] typeName );
protected int getControlPeer( String controlType )
{
return nGetControlPeer( controlType.getBytes() );
}
private native int nGetNumOfSupportedControls();
private native void nGetSupportedControlNames( String [] names );
protected String [] getSupportedControlNames()
{
int number = nGetNumOfSupportedControls();
if( number <= 0 )
{
return new String [0];
}
String [] names = new String [ number ];
nGetSupportedControlNames( names );
return names;
}
private native void nAddMIDIChannel( int player_handle, int channel )
throws MediaException;
private PlayerImpl getPlayerImpl(Player player) throws MediaException
{
PlayerImpl pimpl;
try {
pimpl = (PlayerImpl)player;
} catch (ClassCastException cce) {
throw new MediaException("This Player type is not supported");
}
return pimpl;
}
private DirectPlayer getDirectPlayer( Player player ) throws MediaException
{
PlayerImpl pimpl;
DirectPlayer dp;
try {
pimpl = (PlayerImpl)player;
dp = (DirectPlayer)( pimpl.getPlayerInst() );
if (null == dp) {
throw new MediaException("Player is not completely created");
}
} catch( ClassCastException cce ) {
throw new MediaException("This Player type is not supported");
}
return dp;
}
public void doAddMIDIChannel( Player player, int channel )
throws MediaException
{
DirectPlayer dp = getDirectPlayer( player );
nAddMIDIChannel( dp.getNativeHandle() , channel );
}
private native void nAddPlayer( int player_handle ) throws MediaException;
private native void nCheckSupported( int player_handle ) throws MediaException;
public void doAddPlayer( Player player ) throws MediaException
{
PlayerImpl pimpl = getPlayerImpl(player);
if (pimpl.getState() != Player.CLOSED) {
pimpl.state_subscriber = this;
if (pimpl.getState() >= Player.REALIZED) {
PlayerRealized(player);
}
}
}
public void PlayerRealized(Player player) throws MediaException {
DirectPlayer dp = getDirectPlayer(player);
nCheckSupported(dp.getNativeHandle());
}
public void PlayerPrefetched(Player player) throws MediaException
{
if( isAddedWholly( player ) )
{
DirectPlayer dp = getDirectPlayer(player);
nAddPlayer(dp.getNativeHandle());
}
}
public void PlayerDeallocated( Player player )
{
if( isAddedWholly( player ) )
{
try{
DirectPlayer dp = getDirectPlayer(player);
nRemovePlayer(dp.getNativeHandle());
} catch ( MediaException me ) {}
}
}
private native void nRemoveMIDIChannel( int player_handle, int channel );
public void doRemoveMIDIChannel( Player player, int channel )
{
try
{
DirectPlayer dp = getDirectPlayer(player);
int hNative = dp.getNativeHandle();
if (0 != hNative) nRemoveMIDIChannel(hNative, channel);
}
catch (MediaException e)
{
// do nothing.
// We won't get here, if player wasn't sucessfully added,
// and if it was, it's right type of Player.
}
}
private native void nRemovePlayer( int player_handle );
public void doRemovePlayer( Player player )
{
try
{
/* no need to perform native removal here because only
* the following two situations are possible
* 1) it has already been done in PlayerDeallocated()
* 2) The Player is closed and the removal has been performed in
* the native close procedure.
*/
PlayerImpl pimpl = getPlayerImpl(player);
if ( pimpl != null ) {
pimpl.state_subscriber = null;
}
}
catch (MediaException e)
{
// do nothing.
// We won't get here, if player wasn't sucessfully added,
// and if it was, it's right type of Player.
}
}
// #ifdef ENABLE_CDC [
protected native void finalize();
// #else ][
private native void finalize();
// #endif ]
}

Просмотреть файл

@ -0,0 +1,60 @@
/*
* Copyright 1990-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 only, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is
* included at /legal/license.txt).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 or visit www.sun.com if you need additional
* information or have any questions.
*/
package com.sun.amms;
import javax.microedition.amms.Spectator;
public class DirectSpectatorImpl extends AbstractDirectControllable
{
private int _peer = 0;
private DirectSpectatorImpl() {}
DirectSpectatorImpl( int peer )
{
_peer = peer;
}
private native int nGetControlPeer( byte[] typeName );
protected int getControlPeer( String controlType )
{
return nGetControlPeer( controlType.getBytes() );
}
private native int nGetNumOfSupportedControls();
private native void nGetSupportedControlNames( String [] names );
protected String [] getSupportedControlNames()
{
int number = nGetNumOfSupportedControls();
if( number <= 0 )
{
return new String [0];
}
String [] names = new String [ number ];
nGetSupportedControlNames( names );
return names;
}
}

Просмотреть файл

@ -0,0 +1,188 @@
/*
* Copyright 1990-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 only, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is
* included at /legal/license.txt).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 or visit www.sun.com if you need additional
* information or have any questions.
*/
package com.sun.amms;
import java.util.Hashtable;
import javax.microedition.amms.Spectator;
import javax.microedition.amms.SoundSource3D;
import javax.microedition.amms.MediaProcessor;
import javax.microedition.media.MediaException;
import javax.microedition.media.Control;
import javax.microedition.media.Controllable;
import com.sun.mmedia.Configuration;
// implements Singleton pattern
public class GlobalMgrImpl extends AbstractDirectControllable
{
private static GlobalMgrImpl _instance; // singleton instance
private static Hashtable _processors; // mapping of mime types to media processor implementations
public static GlobalMgrImpl getInstance()
{
if( null == _processors )
{
_processors = new Hashtable( 3 );
_processors.put( Configuration.MIME_IMAGE_RAW, "com.sun.amms.imageprocessor.ObjectImageProcessor" );
_processors.put( Configuration.MIME_IMAGE_JPEG, "com.sun.amms.imageprocessor.StreamImageProcessor" );
_processors.put( Configuration.MIME_IMAGE_PNG, "com.sun.amms.imageprocessor.StreamImageProcessor" );
}
if( _instance == null )
{
_instance = new GlobalMgrImpl();
}
return _instance;
}
// constructor can be called only from static method getInstance()
private GlobalMgrImpl()
{
_peer = nCreatePeer();
_mp_listener = AMMSMPEventListener.getInstance();
}
private int _peer = 0;
private DirectSpectatorImpl _spectator_impl;
private AMMSMPEventListener _mp_listener;
private native int nCreatePeer();
private native int nGetControlPeer( byte[] typeName );
protected int getControlPeer(String controlType)
{
return nGetControlPeer( controlType.getBytes() );
}
private native int nGetNumOfSupportedControls();
private native void nGetSupportedControlNames( String [] names );
protected String [] getSupportedControlNames()
{
int number = nGetNumOfSupportedControls();
if( number <= 0 )
{
return new String [0];
}
String [] names = new String [ number ];
nGetSupportedControlNames( names );
return names;
}
public Controllable getSpectatorImpl() throws MediaException
{
if( _spectator_impl == null )
{
_spectator_impl = createSpectatorImpl();
}
return _spectator_impl;
}
private DirectSpectatorImpl createSpectatorImpl() throws MediaException
{
int native_spectator_peer = nGetSpectatorPeer();
if( native_spectator_peer == 0 )
{
throw new MediaException( "Spectator is not supported" );
}
return new DirectSpectatorImpl( native_spectator_peer );
}
private native int nGetSpectatorPeer();
public SoundSource3D createSoundSource3D() throws MediaException
{
int source3d_native_peer = nCreateSoundSource3D();
if( source3d_native_peer == 0 )
{
throw new MediaException( "SoundSource3D is not supported" );
}
return new DirectSoundSource3D( _peer, source3d_native_peer );
}
private native int nCreateSoundSource3D();
public String [] getSupportedSoundSource3DPlayerTypes()
{
int n = nGetNumOf3DPlayerTypes();
if ( n <= 0 )
{
return new String [0];
}
String [] types = new String [ n ];
nGetSupportedSoundSource3DPlayerTypes( types );
return types;
}
private native int nGetNumOf3DPlayerTypes();
private native void nGetSupportedSoundSource3DPlayerTypes(
String [] types );
public String [] getSupportedMediaProcessorInputTypes()
{
// IMPL_NOTE: this call should be forwarded to javacall,
// in the same manner as getSupportedSoundSource3DPlayerTypes()
return new String[] { Configuration.MIME_IMAGE_PNG,
Configuration.MIME_IMAGE_JPEG,
Configuration.MIME_IMAGE_RAW };
}
public MediaProcessor createMediaProcessor(String inputType) throws MediaException
{
if( null == inputType )
{
throw new MediaException( "Null input type" );
}
String mpName = (String)_processors.get(inputType);
if( null == mpName )
{
throw new MediaException( "Input type '" + inputType + "' is not supported" );
}
MediaProcessor mp;
try
{
mp = (MediaProcessor)Class.forName( mpName ).newInstance();
}
catch( Exception e )
{
throw new MediaException( "Creation of '" + mpName + "' failed:" + e.getMessage() );
}
return mp;
}
// #ifdef ENABLE_CDC [
protected native void finalize();
// #else ][
private native void finalize();
// #endif ]
}

Просмотреть файл

@ -0,0 +1,86 @@
/*
* Copyright 1990-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 only, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is
* included at /legal/license.txt).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 or visit www.sun.com if you need additional
* information or have any questions.
*/
package com.sun.amms.directcontrol;
import javax.microedition.media.Control;
public class DirectAMMSControl implements
Control
{
private int _peer;
protected DirectAMMSControl() {}
private static String getDirectControlClassName( String controlType )
{
int idx = -1;
while( controlType.indexOf( '.', idx + 1 ) >= 0 )
{
idx = controlType.indexOf( '.', idx + 1 );
}
String name = "com.sun.amms.directcontrol.Direct" +
controlType.substring( idx + 1 );
return name;
}
public static DirectAMMSControl createDirectAMMSControl( String controlType,
int peer)
{
Class c = null;
DirectAMMSControl ctr = null;
try
{
c = Class.forName( getDirectControlClassName( controlType ) );
}
catch( ClassNotFoundException e )
{
return null;
}
try
{
ctr = ( DirectAMMSControl )c.newInstance();
}
catch( InstantiationException ie )
{
return null;
}
catch( IllegalAccessException iae )
{
return null;
}
ctr.setNativePtr( peer );
return ctr;
}
protected void setNativePtr( int peer )
{
_peer = peer;
}
}

Просмотреть файл

@ -0,0 +1,56 @@
/*
* Copyright 1990-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 only, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is
* included at /legal/license.txt).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 or visit www.sun.com if you need additional
* information or have any questions.
*/
package com.sun.amms.directcontrol;
import javax.microedition.media.control.*;
class DirectVolumeControl extends DirectAMMSControl implements VolumeControl
{
private native void nSetMute(boolean mute);
public void setMute(boolean mute)
{
nSetMute(mute);
}
private native boolean nIsMuted();
public boolean isMuted()
{
return nIsMuted();
}
private native int nSetLevel(int level);
public int setLevel(int level)
{
return nSetLevel(level);
}
private native int nGetLevel();
public int getLevel()
{
return nGetLevel();
}
//throw new IllegalArgumentException(
// "Negative radius passed to setSpherical()" );
}

Просмотреть файл

@ -0,0 +1,35 @@
/*
* Copyright 1990-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 only, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is
* included at /legal/license.txt).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 or visit www.sun.com if you need additional
* information or have any questions.
*/
package javax.microedition.amms;
/**
* This class is defined by the JSR-234 specification
* <em>Advanced Multimedia Supplements API
* for Java&trade; Platform, Micro Edition</em>
*/
// JAVADOC COMMENT ELIDED
public interface EffectModule extends Module {
}

Просмотреть файл

@ -0,0 +1,90 @@
/*
* Copyright 1990-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 only, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is
* included at /legal/license.txt).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 or visit www.sun.com if you need additional
* information or have any questions.
*/
package javax.microedition.amms;
import javax.microedition.media.Control;
import javax.microedition.media.MediaException;
import com.sun.amms.GlobalMgrImpl;
/**
* This class is defined by the JSR-234 specification
* <em>Advanced Multimedia Supplements API
* for Java&trade; Platform, Micro Edition</em>
*/
// JAVADOC COMMENT ELIDED
public class GlobalManager {
private GlobalManager() {} // Must be hidden
private static Spectator _spectator;
// JAVADOC COMMENT ELIDED
public static Control[] getControls() {
return GlobalMgrImpl.getInstance().getControls();
}
// JAVADOC COMMENT ELIDED
public static Control getControl(String controlType) {
return GlobalMgrImpl.getInstance().getControl( controlType );
}
// JAVADOC COMMENT ELIDED
public static Spectator getSpectator() throws MediaException {
if( null == _spectator ) {
_spectator = new Spectator( GlobalMgrImpl.getInstance().getSpectatorImpl() );
}
return _spectator;
}
// JAVADOC COMMENT ELIDED
public static EffectModule createEffectModule() throws MediaException {
throw new MediaException("EffectModule is not supported");
}
// JAVADOC COMMENT ELIDED
public static SoundSource3D createSoundSource3D() throws MediaException {
return GlobalMgrImpl.getInstance().createSoundSource3D();
}
// JAVADOC COMMENT ELIDED
public static String[] getSupportedSoundSource3DPlayerTypes() {
return
GlobalMgrImpl.getInstance().getSupportedSoundSource3DPlayerTypes();
}
// JAVADOC COMMENT ELIDED
public static MediaProcessor createMediaProcessor(String inputType)
throws MediaException {
return
GlobalMgrImpl.getInstance().createMediaProcessor(inputType);
}
// JAVADOC COMMENT ELIDED
public static String[] getSupportedMediaProcessorInputTypes() {
return
GlobalMgrImpl.getInstance().getSupportedMediaProcessorInputTypes();
}
}

Просмотреть файл

@ -0,0 +1,89 @@
/*
* Copyright 1990-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 only, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is
* included at /legal/license.txt).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 or visit www.sun.com if you need additional
* information or have any questions.
*/
package javax.microedition.amms;
import javax.microedition.media.*;
import java.io.InputStream;
import java.io.OutputStream;
/**
* This class is defined by the JSR-234 specification
* <em>Advanced Multimedia Supplements API
* for Java&trade; Platform, Micro Edition</em>
*/
// JAVADOC COMMENT ELIDED
public interface MediaProcessor extends Controllable {
// JAVADOC COMMENT ELIDED
public static final int UNKNOWN = -1;
// JAVADOC COMMENT ELIDED
public static final int UNREALIZED = 100;
// JAVADOC COMMENT ELIDED
public static final int REALIZED = 200;
// JAVADOC COMMENT ELIDED
public static final int STARTED = 400;
// JAVADOC COMMENT ELIDED
public static final int STOPPED = 300;
// JAVADOC COMMENT ELIDED
public void setInput( InputStream input, int length ) throws javax.microedition.media.MediaException;
// JAVADOC COMMENT ELIDED
public void setInput( Object image ) throws javax.microedition.media.MediaException;
// JAVADOC COMMENT ELIDED
public void setOutput( OutputStream output );
// JAVADOC COMMENT ELIDED
public void start() throws MediaException;
// JAVADOC COMMENT ELIDED
public void stop() throws MediaException;
// JAVADOC COMMENT ELIDED
public void complete() throws MediaException;
// JAVADOC COMMENT ELIDED
public void abort();
// JAVADOC COMMENT ELIDED
public void addMediaProcessorListener( MediaProcessorListener mediaProcessorListener );
// JAVADOC COMMENT ELIDED
public void removeMediaProcessorListener( MediaProcessorListener mediaProcessorListener );
// JAVADOC COMMENT ELIDED
public int getProgress();
// JAVADOC COMMENT ELIDED
public int getState();
}

Просмотреть файл

@ -0,0 +1,57 @@
/*
* Copyright 1990-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 only, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is
* included at /legal/license.txt).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 or visit www.sun.com if you need additional
* information or have any questions.
*/
package javax.microedition.amms;
/**
* This class is defined by the JSR-234 specification
* <em>Advanced Multimedia Supplements API
* for Java&trade; Platform, Micro Edition</em>
*/
// JAVADOC COMMENT ELIDED
public interface MediaProcessorListener {
// JAVADOC COMMENT ELIDED
public static final String PROCESSOR_REALIZED = "processRealized";
// JAVADOC COMMENT ELIDED
public static final String PROCESSING_STARTED = "processingStarted";
// JAVADOC COMMENT ELIDED
public static final String PROCESSING_STOPPED = "processingStopped";
// JAVADOC COMMENT ELIDED
public static final String PROCESSING_ABORTED = "processingAborted";
// JAVADOC COMMENT ELIDED
public static final String PROCESSING_COMPLETED = "processingCompleted";
// JAVADOC COMMENT ELIDED
public static final String PROCESSING_ERROR = "processingError";
// JAVADOC COMMENT ELIDED
public void mediaProcessorUpdate( MediaProcessor processor, String event, Object eventData );
}

Просмотреть файл

@ -0,0 +1,50 @@
/*
* Copyright 1990-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 only, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is
* included at /legal/license.txt).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 or visit www.sun.com if you need additional
* information or have any questions.
*/
package javax.microedition.amms;
import javax.microedition.media.*;
/**
* This class is defined by the JSR-234 specification
* <em>Advanced Multimedia Supplements API
* for Java&trade; Platform, Micro Edition</em>
*/
// JAVADOC COMMENT ELIDED
public interface Module extends Controllable {
// JAVADOC COMMENT ELIDED
public void addMIDIChannel( Player player, int channel )
throws MediaException;
// JAVADOC COMMENT ELIDED
public void removeMIDIChannel( Player player, int channel );
// JAVADOC COMMENT ELIDED
public void addPlayer( Player player ) throws MediaException;
// JAVADOC COMMENT ELIDED
public void removePlayer( Player player );
}

Просмотреть файл

@ -0,0 +1,35 @@
/*
* Copyright 1990-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 only, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is
* included at /legal/license.txt).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 or visit www.sun.com if you need additional
* information or have any questions.
*/
package javax.microedition.amms;
/**
* This class is defined by the JSR-234 specification
* <em>Advanced Multimedia Supplements API
* for Java&trade; Platform, Micro Edition</em>
*/
// JAVADOC COMMENT ELIDED
public interface SoundSource3D extends Module {
}

Просмотреть файл

@ -0,0 +1,52 @@
/*
* Copyright 1990-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 only, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is
* included at /legal/license.txt).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 or visit www.sun.com if you need additional
* information or have any questions.
*/
package javax.microedition.amms;
import javax.microedition.media.Control;
import javax.microedition.media.Controllable;
/**
* This class is defined by the JSR-234 specification
* <em>Advanced Multimedia Supplements API
* for Java&trade; Platform, Micro Edition</em>
*/
// JAVADOC COMMENT ELIDED
/*final*/ public class Spectator implements Controllable {
private Controllable _impl;
Spectator( Controllable impl ) {
_impl = impl;
}
public Control getControl(String controlType) {
return _impl.getControl( controlType );
}
public Control[] getControls() {
return _impl.getControls();
}
}

Просмотреть файл

@ -0,0 +1,81 @@
/*
* Copyright 1990-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 only, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is
* included at /legal/license.txt).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 or visit www.sun.com if you need additional
* information or have any questions.
*/
package javax.microedition.amms.control.camera;
import javax.microedition.media.MediaException;
import javax.microedition.media.Control;
/**
* This class is defined by the JSR-234 specification
* <em>Advanced Multimedia Supplements API
* for Java&trade; Platform, Micro Edition</em>
*/
// JAVADOC COMMENT ELIDED
public interface SnapshotControl extends Control {
// JAVADOC COMMENT ELIDED
String SHOOTING_STOPPED = "SHOOTING_STOPPED";
// JAVADOC COMMENT ELIDED
String STORAGE_ERROR = "STORAGE_ERROR";
// JAVADOC COMMENT ELIDED
String WAITING_UNFREEZE = "WAITING_UNFREEZE";
// JAVADOC COMMENT ELIDED
public final static int FREEZE = -2;
// JAVADOC COMMENT ELIDED
public final static int FREEZE_AND_CONFIRM = -1;
// JAVADOC COMMENT ELIDED
void setDirectory(String directory);
// JAVADOC COMMENT ELIDED
String getDirectory();
// JAVADOC COMMENT ELIDED
void setFilePrefix(String prefix);
// JAVADOC COMMENT ELIDED
String getFilePrefix();
// JAVADOC COMMENT ELIDED
void setFileSuffix(String suffix);
// JAVADOC COMMENT ELIDED
String getFileSuffix();
// JAVADOC COMMENT ELIDED
void start(int maxShots) throws SecurityException;
// JAVADOC COMMENT ELIDED
void stop();
// JAVADOC COMMENT ELIDED
void unfreeze(boolean save);
}

Просмотреть файл

@ -0,0 +1,108 @@
/*
* Copyright 1990-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 only, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is
* included at /legal/license.txt).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 or visit www.sun.com if you need additional
* information or have any questions.
*/
package javax.microedition.amms.control.tuner;
import javax.microedition.media.*;
import java.util.Date;
/**
* This class is defined by the JSR-234 specification
* <em>Advanced Multimedia Supplements API
* for Java&trade; Platform, Micro Edition</em>
*/
// JAVADOC COMMENT ELIDED
public interface RDSControl extends javax.microedition.media.Control {
// JAVADOC COMMENT ELIDED
String RDS_NEW_DATA = "RDS_NEW_DATA";
// JAVADOC COMMENT ELIDED
String RDS_NEW_ALARM = "RDS_ALARM";
// JAVADOC COMMENT ELIDED
String RADIO_CHANGED = "radio_changed";
// JAVADOC COMMENT ELIDED
boolean isRDSSignal();
// JAVADOC COMMENT ELIDED
String getPS();
// JAVADOC COMMENT ELIDED
String getRT();
// JAVADOC COMMENT ELIDED
short getPTY();
// JAVADOC COMMENT ELIDED
String getPTYString(boolean longer);
// JAVADOC COMMENT ELIDED
short getPI();
// JAVADOC COMMENT ELIDED
int[] getFreqsByPTY(short PTY);
// JAVADOC COMMENT ELIDED
int[][] getFreqsByTA(boolean TA);
// JAVADOC COMMENT ELIDED
String[] getPSByPTY(short PTY);
// JAVADOC COMMENT ELIDED
String[] getPSByTA(boolean TA);
// JAVADOC COMMENT ELIDED
Date getCT();
// JAVADOC COMMENT ELIDED
boolean getTA();
// JAVADOC COMMENT ELIDED
boolean getTP();
/**
* Gets the current Traffic Message Channel's (TMC) message.
*
* @return TBD based on CEN standard ENV 12313-1
*/
//Object getTMC();
// JAVADOC COMMENT ELIDED
void setAutomaticSwitching(boolean automatic)
throws MediaException;
// JAVADOC COMMENT ELIDED
boolean getAutomaticSwitching();
// JAVADOC COMMENT ELIDED
void setAutomaticTA(boolean automatic) throws MediaException;
// JAVADOC COMMENT ELIDED
boolean getAutomaticTA();
}