diff options
Diffstat (limited to 'media/java')
-rw-r--r-- | media/java/android/media/AudioRecord.java | 14 | ||||
-rw-r--r-- | media/java/android/media/AudioService.java | 61 | ||||
-rw-r--r-- | media/java/android/media/AudioTrack.java | 21 | ||||
-rw-r--r-- | media/java/android/media/MediaPlayer.java | 369 | ||||
-rw-r--r-- | media/java/android/media/MediaRecorder.java | 91 | ||||
-rw-r--r-- | media/java/android/media/MediaScanner.java | 45 | ||||
-rw-r--r-- | media/java/android/media/RingtoneManager.java | 11 | ||||
-rw-r--r-- | media/java/android/media/ToneGenerator.java | 628 |
8 files changed, 959 insertions, 281 deletions
diff --git a/media/java/android/media/AudioRecord.java b/media/java/android/media/AudioRecord.java index 3346bed..4d1535f 100644 --- a/media/java/android/media/AudioRecord.java +++ b/media/java/android/media/AudioRecord.java @@ -88,7 +88,7 @@ public class AudioRecord private static final int AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT = -16; private static final int AUDIORECORD_ERROR_SETUP_INVALIDCHANNELCOUNT = -17; private static final int AUDIORECORD_ERROR_SETUP_INVALIDFORMAT = -18; - private static final int AUDIORECORD_ERROR_SETUP_INVALIDSTREAMTYPE = -19; + private static final int AUDIORECORD_ERROR_SETUP_INVALIDSOURCE = -19; private static final int AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED = -20; // Events: @@ -113,13 +113,7 @@ public class AudioRecord */ @SuppressWarnings("unused") private int mNativeRecorderInJavaObj; - /** - * Accessed by native methods: provides access to record source constants - */ - @SuppressWarnings("unused") - private final static int SOURCE_DEFAULT = MediaRecorder.AudioSource.DEFAULT; - @SuppressWarnings("unused") - private final static int SOURCE_MIC = MediaRecorder.AudioSource.MIC; + /** * Accessed by native methods: provides access to the callback data. */ @@ -252,8 +246,8 @@ public class AudioRecord //-------------- // audio source - if ( (audioSource != MediaRecorder.AudioSource.DEFAULT) - && (audioSource != MediaRecorder.AudioSource.MIC) ) { + if ( (audioSource < MediaRecorder.AudioSource.DEFAULT) || + (audioSource > MediaRecorder.getAudioSourceMax()) ) { throw (new IllegalArgumentException("Invalid audio source.")); } else { mRecordSource = audioSource; diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index 881de4d..937baad 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -163,6 +163,9 @@ public class AudioService extends IAudioService.Stub { */ private int mRingerMode; + /** @see System#MODE_RINGER_STREAMS_AFFECTED */ + private int mRingerModeAffectedStreams; + /** @see System#MUTE_STREAMS_AFFECTED */ private int mMuteAffectedStreams; @@ -286,6 +289,10 @@ public class AudioService extends IAudioService.Stub { mVibrateSetting = System.getInt(cr, System.VIBRATE_ON, 0); + mRingerModeAffectedStreams = Settings.System.getInt(cr, + Settings.System.MODE_RINGER_STREAMS_AFFECTED, + ((1 << AudioManager.STREAM_RING)|(1 << AudioManager.STREAM_NOTIFICATION)|(1 << AudioManager.STREAM_SYSTEM))); + mMuteAffectedStreams = System.getInt(cr, System.MUTE_STREAMS_AFFECTED, ((1 << AudioSystem.STREAM_MUSIC)|(1 << AudioSystem.STREAM_RING)|(1 << AudioSystem.STREAM_SYSTEM))); @@ -399,7 +406,7 @@ public class AudioService extends IAudioService.Stub { ensureValidStreamType(streamType); syncRingerAndNotificationStreamVolume(streamType, index, false); - setStreamVolumeInt(streamType, index, false); + setStreamVolumeInt(streamType, index, false, true); // UI, etc. mVolumePanel.postVolumeChanged(streamType, flags); @@ -437,7 +444,7 @@ public class AudioService extends IAudioService.Stub { } if (streamType == AudioManager.STREAM_RING) { // One-off to sync notification volume to ringer volume - setStreamVolumeInt(AudioManager.STREAM_NOTIFICATION, index, force); + setStreamVolumeInt(AudioManager.STREAM_NOTIFICATION, index, force, true); } } } @@ -451,10 +458,11 @@ public class AudioService extends IAudioService.Stub { * @param index Desired volume index of the stream * @param force If true, set the volume even if the desired volume is same * as the current volume. + * @param lastAudible If true, stores new index as last audible one */ - private void setStreamVolumeInt(int streamType, int index, boolean force) { + private void setStreamVolumeInt(int streamType, int index, boolean force, boolean lastAudible) { VolumeStreamState streamState = mStreamStates[streamType]; - if (streamState.setIndex(index) || force) { + if (streamState.setIndex(index, lastAudible) || force) { // Post message to set system volume (it in turn will post a message // to persist). Do not change volume if stream is muted. if (streamState.muteCount() == 0) { @@ -517,13 +525,20 @@ public class AudioService extends IAudioService.Stub { if (!isStreamAffectedByRingerMode(streamType)) continue; // Bring back last audible volume setStreamVolumeInt(streamType, mStreamStates[streamType].mLastAudibleIndex, - false); + false, false); } } else { for (int streamType = numStreamTypes - 1; streamType >= 0; streamType--) { - if (!isStreamAffectedByRingerMode(streamType)) continue; - // Either silent or vibrate, either way volume is 0 - setStreamVolumeInt(streamType, 0, false); + if (isStreamAffectedByRingerMode(streamType)) { + // Either silent or vibrate, either way volume is 0 + setStreamVolumeInt(streamType, 0, false, false); + } else { + // restore stream volume in the case the stream changed from affected + // to non affected by ringer mode. Does not arm to do it for streams that + // are not affected as well. + setStreamVolumeInt(streamType, mStreamStates[streamType].mLastAudibleIndex, + false, false); + } } } @@ -621,7 +636,7 @@ public class AudioService extends IAudioService.Stub { int streamType = getActiveStreamType(AudioManager.USE_DEFAULT_STREAM_TYPE); int index = mStreamStates[streamType].mIndex; syncRingerAndNotificationStreamVolume(streamType, index, true); - setStreamVolumeInt(streamType, index, true); + setStreamVolumeInt(streamType, index, true, true); } } @@ -653,7 +668,7 @@ public class AudioService extends IAudioService.Stub { mSpeakerIsOn = true; mRoutes[AudioSystem.MODE_IN_CALL] = AudioSystem.ROUTE_SPEAKER; incallMask = AudioSystem.ROUTE_ALL; - } else if (mSpeakerIsOn) { + } else if (routes == 0 && mSpeakerIsOn) { mSpeakerIsOn = false; if (mBluetoothScoIsConnected) { mRoutes[AudioSystem.MODE_IN_CALL] = AudioSystem.ROUTE_BLUETOOTH_SCO; @@ -680,7 +695,7 @@ public class AudioService extends IAudioService.Stub { // should not affect A2DP routing ringtoneMask = AudioSystem.ROUTE_ALL & ~AudioSystem.ROUTE_BLUETOOTH_A2DP; normalMask = AudioSystem.ROUTE_ALL & ~AudioSystem.ROUTE_BLUETOOTH_A2DP; - } else if (mBluetoothScoIsConnected) { + } else if (routes == 0 && mBluetoothScoIsConnected) { mBluetoothScoIsConnected = false; if (mHeadsetIsConnected) { mRoutes[AudioSystem.MODE_IN_CALL] = AudioSystem.ROUTE_HEADSET; @@ -724,7 +739,7 @@ public class AudioService extends IAudioService.Stub { ringtoneMask = AudioSystem.ROUTE_ALL & ~AudioSystem.ROUTE_BLUETOOTH_A2DP; normalMask = AudioSystem.ROUTE_ALL & ~AudioSystem.ROUTE_BLUETOOTH_A2DP; } - } else if (mHeadsetIsConnected) { + } else if (routes == 0 && mHeadsetIsConnected) { mHeadsetIsConnected = false; // do not act upon headset disconnection if bluetooth SCO is connected to match phone app behavior if (!mBluetoothScoIsConnected) { @@ -757,7 +772,7 @@ public class AudioService extends IAudioService.Stub { // so there is no need to disable other routes. ringtoneMask = AudioSystem.ROUTE_BLUETOOTH_A2DP; normalMask = AudioSystem.ROUTE_BLUETOOTH_A2DP; - } else if (mBluetoothA2dpIsConnected) { + } else if (routes == 0 && mBluetoothA2dpIsConnected) { mBluetoothA2dpIsConnected = false; mRoutes[AudioSystem.MODE_RINGTONE] &= ~AudioSystem.ROUTE_BLUETOOTH_A2DP; mRoutes[AudioSystem.MODE_NORMAL] &= ~AudioSystem.ROUTE_BLUETOOTH_A2DP; @@ -791,7 +806,7 @@ public class AudioService extends IAudioService.Stub { int streamType = getActiveStreamType(AudioManager.USE_DEFAULT_STREAM_TYPE); int index = mStreamStates[streamType].mIndex; syncRingerAndNotificationStreamVolume(streamType, index, true); - setStreamVolumeInt(streamType, index, true); + setStreamVolumeInt(streamType, index, true, true); } } } @@ -941,9 +956,7 @@ public class AudioService extends IAudioService.Stub { } public boolean isStreamAffectedByRingerMode(int streamType) { - int ringerModeAffectedStreams = Settings.System.getInt(mContentResolver, - Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0); - return (ringerModeAffectedStreams & (1 << streamType)) != 0; + return (mRingerModeAffectedStreams & (1 << streamType)) != 0; } public boolean isStreamAffectedByMute(int streamType) { @@ -1095,15 +1108,15 @@ public class AudioService extends IAudioService.Stub { } public boolean adjustIndex(int deltaIndex) { - return setIndex(mIndex + deltaIndex); + return setIndex(mIndex + deltaIndex, true); } - public boolean setIndex(int index) { + public boolean setIndex(int index, boolean lastAudible) { int oldIndex = mIndex; mIndex = getValidIndex(index); if (oldIndex != mIndex) { - if (mIndex > 0) { + if (lastAudible) { mLastAudibleIndex = mIndex; } return true; @@ -1153,7 +1166,7 @@ public class AudioService extends IAudioService.Stub { mDeathHandlers.add(this); // If the stream is not yet muted by any client, set lvel to 0 if (muteCount() == 0) { - setIndex(0); + setIndex(0, false); sendMsg(mAudioHandler, MSG_SET_SYSTEM_VOLUME, mStreamType, SENDMSG_NOOP, 0, 0, VolumeStreamState.this, 0); } @@ -1180,7 +1193,7 @@ public class AudioService extends IAudioService.Stub { // If the stream is not mut any more, restore it's volume if // ringer mode allows it if (!isStreamAffectedByRingerMode(mStreamType) || mRingerMode == AudioManager.RINGER_MODE_NORMAL) { - setIndex(mLastAudibleIndex); + setIndex(mLastAudibleIndex, false); sendMsg(mAudioHandler, MSG_SET_SYSTEM_VOLUME, mStreamType, SENDMSG_NOOP, 0, 0, VolumeStreamState.this, 0); } @@ -1405,6 +1418,10 @@ public class AudioService extends IAudioService.Stub { public void onChange(boolean selfChange) { super.onChange(selfChange); + mRingerModeAffectedStreams = Settings.System.getInt(mContentResolver, + Settings.System.MODE_RINGER_STREAMS_AFFECTED, + 0); + /* * Ensure all stream types that should be affected by ringer mode * are in the proper state. diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java index 3cd841d..5f1be9d 100644 --- a/media/java/android/media/AudioTrack.java +++ b/media/java/android/media/AudioTrack.java @@ -425,8 +425,7 @@ public class AudioTrack } /** - * Returns the current playback rate in Hz. Note that this rate may differ from the one set - * with {@link #setPlaybackRate(int)} as the value effectively used is implementation-dependent. + * Returns the current playback rate in Hz. */ public int getPlaybackRate() { return native_get_playback_rate(); @@ -651,18 +650,13 @@ public class AudioTrack * Sets the playback sample rate for this track. This sets the sampling rate at which * the audio data will be consumed and played back, not the original sampling rate of the * content. Setting it to half the sample rate of the content will cause the playback to - * last twice as long, but will also result result in a negative pitch shift. - * The current implementation supports a maximum sample rate of 64kHz. - * Use {@link #getSampleRate()} to check the rate actually used in hardware after - * potential clamping. + * last twice as long, but will also result in a negative pitch shift. + * The valid sample rate range if from 1Hz to twice the value returned by + * {@link #getNativeOutputSampleRate(int)}. * @param sampleRateInHz the sample rate expressed in Hz * @return error code or success, see {@link #SUCCESS}, {@link #ERROR_BAD_VALUE}, * {@link #ERROR_INVALID_OPERATION} */ - // FIXME: the implementation should support twice the hardware output sample rate - // (see {@link #getNativeOutputSampleRate(int)}), but currently - // due to the representation of the sample rate in the native layer, the sample rate - // is limited to 65535Hz public int setPlaybackRate(int sampleRateInHz) { if (mState != STATE_INITIALIZED) { return ERROR_INVALID_OPERATION; @@ -670,8 +664,7 @@ public class AudioTrack if (sampleRateInHz <= 0) { return ERROR_BAD_VALUE; } - native_set_playback_rate(sampleRateInHz); - return SUCCESS; + return native_set_playback_rate(sampleRateInHz); } @@ -1031,8 +1024,8 @@ public class AudioTrack private native final void native_setVolume(float leftVolume, float rightVolume); - private native final void native_set_playback_rate(int sampleRateInHz); - private native final int native_get_playback_rate(); + private native final int native_set_playback_rate(int sampleRateInHz); + private native final int native_get_playback_rate(); private native final int native_set_marker_pos(int marker); private native final int native_get_marker_pos(); diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java index 19ab0ad..3b46d69 100644 --- a/media/java/android/media/MediaPlayer.java +++ b/media/java/android/media/MediaPlayer.java @@ -58,7 +58,7 @@ import java.lang.ref.WeakReference; * MediaPlayer object driven by the supported playback control operations. * The ovals represent the states a MediaPlayer object may reside * in. The arcs represent the playback control operations that drive the object - * state transition. There are two types of arcs. The arcs with a single arrow + * state transition. There are two types of arcs. The arcs with a single arrow * head represent synchronous method calls, while those with * a double arrow head represent asynchronous method calls.</p> * @@ -69,42 +69,42 @@ import java.lang.ref.WeakReference; * <p>From this state diagram, one can see that a MediaPlayer object has the * following states:</p> * <ul> - * <li>When a MediaPlayer object is just created using <code>new</code> or - * after {@link #reset()} is called, it is in the <em>Idle</em> state; and after - * {@link #release()} is called, it is in the <em>End</em> state. Between these - * two states is the life cycle of the MediaPlayer object. + * <li>When a MediaPlayer object is just created using <code>new</code> or + * after {@link #reset()} is called, it is in the <em>Idle</em> state; and after + * {@link #release()} is called, it is in the <em>End</em> state. Between these + * two states is the life cycle of the MediaPlayer object. * <ul> - * <li>There is a subtle but important difference between a newly constructed - * MediaPlayer object and the MediaPlayer object after {@link #reset()} - * is called. It is a programming error to invoke methods such - * as {@link #getCurrentPosition()}, - * {@link #getDuration()}, {@link #getVideoHeight()}, + * <li>There is a subtle but important difference between a newly constructed + * MediaPlayer object and the MediaPlayer object after {@link #reset()} + * is called. It is a programming error to invoke methods such + * as {@link #getCurrentPosition()}, + * {@link #getDuration()}, {@link #getVideoHeight()}, * {@link #getVideoWidth()}, {@link #setAudioStreamType(int)}, * {@link #setLooping(boolean)}, - * {@link #setVolume(float, float)}, {@link #pause()}, {@link #start()}, - * {@link #stop()}, {@link #seekTo(int)}, {@link #prepare()} or - * {@link #prepareAsync()} in the <em>Idle</em> state for both cases. If any of these - * methods is called right after a MediaPlayer object is constructed, - * the user supplied callback method OnErrorListener.onError() won't be + * {@link #setVolume(float, float)}, {@link #pause()}, {@link #start()}, + * {@link #stop()}, {@link #seekTo(int)}, {@link #prepare()} or + * {@link #prepareAsync()} in the <em>Idle</em> state for both cases. If any of these + * methods is called right after a MediaPlayer object is constructed, + * the user supplied callback method OnErrorListener.onError() won't be * called by the internal player engine and the object state remains - * unchanged; but if these methods are called right after {@link #reset()}, + * unchanged; but if these methods are called right after {@link #reset()}, * the user supplied callback method OnErrorListener.onError() will be - * invoked by the internal player engine and the object will be + * invoked by the internal player engine and the object will be * transfered to the <em>Error</em> state. </li> - * <li>It is also recommended that once - * a MediaPlayer object is no longer being used, call {@link #release()} immediately - * so that resources used by the internal player engine associated with the + * <li>It is also recommended that once + * a MediaPlayer object is no longer being used, call {@link #release()} immediately + * so that resources used by the internal player engine associated with the * MediaPlayer object can be released immediately. Resource may include - * singleton resources such as hardware acceleration components and + * singleton resources such as hardware acceleration components and * failure to call {@link #release()} may cause subsequent instances of * MediaPlayer objects to fallback to software implementations or fail * altogether. Once the MediaPlayer - * object is in the <em>End</em> state, it can no longer be used and + * object is in the <em>End</em> state, it can no longer be used and * there is no way to bring it back to any other state. </li> - * <li>Furthermore, - * the MediaPlayer objects created using <code>new</code> is in the - * <em>Idle</em> state, while those created with one - * of the overloaded convenient <code>create</code> methods are <em>NOT</em> + * <li>Furthermore, + * the MediaPlayer objects created using <code>new</code> is in the + * <em>Idle</em> state, while those created with one + * of the overloaded convenient <code>create</code> methods are <em>NOT</em> * in the <em>Idle</em> state. In fact, the objects are in the <em>Prepared</em> * state if the creation using <code>create</code> method is successful. * </li> @@ -114,23 +114,23 @@ import java.lang.ref.WeakReference; * reasons, such as unsupported audio/video format, poorly interleaved * audio/video, resolution too high, streaming timeout, and the like. * Thus, error reporting and recovery is an important concern under - * these circumstances. Sometimes, due to programming errors, invoking a playback + * these circumstances. Sometimes, due to programming errors, invoking a playback * control operation in an invalid state may also occur. Under all these * error conditions, the internal player engine invokes a user supplied * OnErrorListener.onError() method if an OnErrorListener has been * registered beforehand via * {@link #setOnErrorListener(android.media.MediaPlayer.OnErrorListener)}. * <ul> - * <li>It is important to note that once an error occurs, the - * MediaPlayer object enters the <em>Error</em> state (except as noted + * <li>It is important to note that once an error occurs, the + * MediaPlayer object enters the <em>Error</em> state (except as noted * above), even if an error listener has not been registered by the application.</li> * <li>In order to reuse a MediaPlayer object that is in the <em> - * Error</em> state and recover from the error, + * Error</em> state and recover from the error, * {@link #reset()} can be called to restore the object to its <em>Idle</em> * state.</li> - * <li>It is good programming practice to have your application - * register a OnErrorListener to look out for error notifications from - * the internal player engine.</li> + * <li>It is good programming practice to have your application + * register a OnErrorListener to look out for error notifications from + * the internal player engine.</li> * <li>IlleglStateException is * thrown to prevent programming errors such as calling {@link #prepare()}, * {@link #prepareAsync()}, or one of the overloaded <code>setDataSource @@ -141,28 +141,28 @@ import java.lang.ref.WeakReference; * {@link #setDataSource(FileDescriptor)}, or * {@link #setDataSource(String)}, or * {@link #setDataSource(Context, Uri)}, or - * {@link #setDataSource(FileDescriptor, long, long)} transfers a + * {@link #setDataSource(FileDescriptor, long, long)} transfers a * MediaPlayer object in the <em>Idle</em> state to the * <em>Initialized</em> state. * <ul> - * <li>An IllegalStateException is thrown if + * <li>An IllegalStateException is thrown if * setDataSource() is called in any other state.</li> - * <li>It is good programming - * practice to always look out for <code>IllegalArgumentException</code> + * <li>It is good programming + * practice to always look out for <code>IllegalArgumentException</code> * and <code>IOException</code> that may be thrown from the overloaded * <code>setDataSource</code> methods.</li> * </ul> * </li> * <li>A MediaPlayer object must first enter the <em>Prepared</em> state - * before playback can be started. + * before playback can be started. * <ul> * <li>There are two ways (synchronous vs. * asynchronous) that the <em>Prepared</em> state can be reached: * either a call to {@link #prepare()} (synchronous) which * transfers the object to the <em>Prepared</em> state once the method call * returns, or a call to {@link #prepareAsync()} (asynchronous) which - * first transfers the object to the <em>Preparing</em> state after the - * call returns (which occurs almost right way) while the internal + * first transfers the object to the <em>Preparing</em> state after the + * call returns (which occurs almost right way) while the internal * player engine continues working on the rest of preparation work * until the preparation work completes. When the preparation completes or when {@link #prepare()} call returns, * the internal player engine then calls a user supplied callback method, @@ -173,22 +173,22 @@ import java.lang.ref.WeakReference; * the <em>Preparing</em> state is a transient state, and the behavior * of calling any method with side effect while a MediaPlayer object is * in the <em>Preparing</em> state is undefined.</li> - * <li>An IllegalStateException is - * thrown if {@link #prepare()} or {@link #prepareAsync()} is called in - * any other state.</li> - * <li>While in the <em>Prepared</em> state, properties - * such as audio/sound volume, screenOnWhilePlaying, looping can be + * <li>An IllegalStateException is + * thrown if {@link #prepare()} or {@link #prepareAsync()} is called in + * any other state.</li> + * <li>While in the <em>Prepared</em> state, properties + * such as audio/sound volume, screenOnWhilePlaying, looping can be * adjusted by invoking the corresponding set methods.</li> * </ul> * </li> - * <li>To start the playback, {@link #start()} must be called. After + * <li>To start the playback, {@link #start()} must be called. After * {@link #start()} returns successfully, the MediaPlayer object is in the - * <em>Started</em> state. {@link #isPlaying()} can be called to test + * <em>Started</em> state. {@link #isPlaying()} can be called to test * whether the MediaPlayer object is in the <em>Started</em> state. * <ul> * <li>While in the <em>Started</em> state, the internal player engine calls * a user supplied OnBufferingUpdateListener.onBufferingUpdate() callback - * method if a OnBufferingUpdateListener has been registered beforehand + * method if a OnBufferingUpdateListener has been registered beforehand * via {@link #setOnBufferingUpdateListener(OnBufferingUpdateListener)}. * This callback allows applications to keep track of the buffering status * while streaming audio/video.</li> @@ -197,44 +197,44 @@ import java.lang.ref.WeakReference; * </ul> * </li> * <li>Playback can be paused and stopped, and the current playback position - * can be adjusted. Playback can be paused via {@link #pause()}. When the call to + * can be adjusted. Playback can be paused via {@link #pause()}. When the call to * {@link #pause()} returns, the MediaPlayer object enters the - * <em>Paused</em> state. Note that the transition from the <em>Started</em> - * state to the <em>Paused</em> state and vice versa happens - * asynchronously in the player engine. It may take some time before - * the state is updated in calls to {@link #isPlaying()}, and it can be + * <em>Paused</em> state. Note that the transition from the <em>Started</em> + * state to the <em>Paused</em> state and vice versa happens + * asynchronously in the player engine. It may take some time before + * the state is updated in calls to {@link #isPlaying()}, and it can be * a number of seconds in the case of streamed content. * <ul> - * <li>Calling {@link #start()} to resume playback for a paused + * <li>Calling {@link #start()} to resume playback for a paused * MediaPlayer object, and the resumed playback - * position is the same as where it was paused. When the call to + * position is the same as where it was paused. When the call to * {@link #start()} returns, the paused MediaPlayer object goes back to * the <em>Started</em> state.</li> * <li>Calling {@link #pause()} has no effect on * a MediaPlayer object that is already in the <em>Paused</em> state.</li> * </ul> * </li> - * <li>Calling {@link #stop()} stops playback and causes a + * <li>Calling {@link #stop()} stops playback and causes a * MediaPlayer in the <em>Started</em>, <em>Paused</em>, <em>Prepared - * </em> or <em>PlaybackCompleted</em> state to enter the + * </em> or <em>PlaybackCompleted</em> state to enter the * <em>Stopped</em> state. * <ul> - * <li>Once in the <em>Stopped</em> state, playback cannot be started + * <li>Once in the <em>Stopped</em> state, playback cannot be started * until {@link #prepare()} or {@link #prepareAsync()} are called to set * the MediaPlayer object to the <em>Prepared</em> state again.</li> - * <li>Calling {@link #stop()} has no effect on a MediaPlayer + * <li>Calling {@link #stop()} has no effect on a MediaPlayer * object that is already in the <em>Stopped</em> state.</li> * </ul> * </li> - * <li>The playback position can be adjusted with a call to - * {@link #seekTo(int)}. + * <li>The playback position can be adjusted with a call to + * {@link #seekTo(int)}. * <ul> * <li>Although the asynchronuous {@link #seekTo(int)} * call returns right way, the actual seek operation may take a while to - * finish, especially for audio/video being streamed. When the actual - * seek operation completes, the internal player engine calls a user + * finish, especially for audio/video being streamed. When the actual + * seek operation completes, the internal player engine calls a user * supplied OnSeekComplete.onSeekComplete() if an OnSeekCompleteListener - * has been registered beforehand via + * has been registered beforehand via * {@link #setOnSeekCompleteListener(OnSeekCompleteListener)}.</li> * <li>Please * note that {@link #seekTo(int)} can also be called in the other states, @@ -242,7 +242,7 @@ import java.lang.ref.WeakReference; * </em> state.</li> * <li>Furthermore, the actual current playback position * can be retrieved with a call to {@link #getCurrentPosition()}, which - * is helpful for applications such as a Music player that need to keep + * is helpful for applications such as a Music player that need to keep * track of the playback progress.</li> * </ul> * </li> @@ -272,7 +272,7 @@ import java.lang.ref.WeakReference; * <td>Invalid States </p></td> * <td>Comments </p></td></tr> * <tr><td>getCurrentPosition </p></td> - * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, + * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, * PlaybackCompleted} </p></td> * <td>{Error}</p></td> * <td>Successful invoke of this method in a valid state does not change the @@ -282,45 +282,45 @@ import java.lang.ref.WeakReference; * <td>{Prepared, Started, Paused, Stopped, PlaybackCompleted} </p></td> * <td>{Idle, Initialized, Error} </p></td> * <td>Successful invoke of this method in a valid state does not change the - * state. Calling this method in an invalid state transfers the object + * state. Calling this method in an invalid state transfers the object * to the <em>Error</em> state. </p></td></tr> * <tr><td>getVideoHeight </p></td> - * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, + * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, * PlaybackCompleted}</p></td> * <td>{Error}</p></td> * <td>Successful invoke of this method in a valid state does not change the - * state. Calling this method in an invalid state transfers the object + * state. Calling this method in an invalid state transfers the object * to the <em>Error</em> state. </p></td></tr> * <tr><td>getVideoWidth </p></td> * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, * PlaybackCompleted}</p></td> * <td>{Error}</p></td> - * <td>Successful invoke of this method in a valid state does not change - * the state. Calling this method in an invalid state transfers the + * <td>Successful invoke of this method in a valid state does not change + * the state. Calling this method in an invalid state transfers the * object to the <em>Error</em> state. </p></td></tr> * <tr><td>isPlaying </p></td> - * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, + * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, * PlaybackCompleted}</p></td> * <td>{Error}</p></td> * <td>Successful invoke of this method in a valid state does not change - * the state. Calling this method in an invalid state transfers the + * the state. Calling this method in an invalid state transfers the * object to the <em>Error</em> state. </p></td></tr> * <tr><td>pause </p></td> * <td>{Started, Paused}</p></td> * <td>{Idle, Initialized, Prepared, Stopped, PlaybackCompleted, Error}</p></td> - * <td>Successful invoke of this method in a valid state transfers the - * object to the <em>Paused</em> state. Calling this method in an + * <td>Successful invoke of this method in a valid state transfers the + * object to the <em>Paused</em> state. Calling this method in an * invalid state transfers the object to the <em>Error</em> state.</p></td></tr> * <tr><td>prepare </p></td> * <td>{Initialized, Stopped} </p></td> * <td>{Idle, Prepared, Started, Paused, PlaybackCompleted, Error} </p></td> - * <td>Successful invoke of this method in a valid state transfers the - * object to the <em>Prepared</em> state. Calling this method in an + * <td>Successful invoke of this method in a valid state transfers the + * object to the <em>Prepared</em> state. Calling this method in an * invalid state throws an IllegalStateException.</p></td></tr> * <tr><td>prepareAsync </p></td> * <td>{Initialized, Stopped} </p></td> * <td>{Idle, Prepared, Started, Paused, PlaybackCompleted, Error} </p></td> - * <td>Successful invoke of this method in a valid state transfers the + * <td>Successful invoke of this method in a valid state transfers the * object to the <em>Preparing</em> state. Calling this method in an * invalid state throws an IllegalStateException.</p></td></tr> * <tr><td>release </p></td> @@ -328,18 +328,18 @@ import java.lang.ref.WeakReference; * <td>{} </p></td> * <td>After {@link #release()}, the object is no longer available. </p></td></tr> * <tr><td>reset </p></td> - * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, + * <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, * PlaybackCompleted, Error}</p></td> * <td>{}</p></td> * <td>After {@link #reset()}, the object is like being just created.</p></td></tr> * <tr><td>seekTo </p></td> * <td>{Prepared, Started, Paused, PlaybackCompleted} </p></td> * <td>{Idle, Initialized, Stopped, Error}</p></td> - * <td>Successful invoke of this method in a valid state does not change - * the state. Calling this method in an invalid state transfers the + * <td>Successful invoke of this method in a valid state does not change + * the state. Calling this method in an invalid state transfers the * object to the <em>Error</em> state. </p></td></tr> * <tr><td>setAudioStreamType </p></td> - * <td>{Idle, Initialized, Stopped, Prepared, Started, Paused, + * <td>{Idle, Initialized, Stopped, Prepared, Started, Paused, * PlaybackCompleted}</p></td> * <td>{Error}</p></td> * <td>Successful invoke of this method does not change the state.</p></td></tr> @@ -347,8 +347,8 @@ import java.lang.ref.WeakReference; * <td>{Idle} </p></td> * <td>{Initialized, Prepared, Started, Paused, Stopped, PlaybackCompleted, * Error} </p></td> - * <td>Successful invoke of this method in a valid state transfers the - * object to the <em>Initialized</em> state. Calling this method in an + * <td>Successful invoke of this method in a valid state transfers the + * object to the <em>Initialized</em> state. Calling this method in an * invalid state throws an IllegalStateException.</p></td></tr> * <tr><td>setDisplay </p></td> * <td>any </p></td> @@ -356,11 +356,11 @@ import java.lang.ref.WeakReference; * <td>This method can be called in any state and calling it does not change * the object state. </p></td></tr> * <tr><td>setLooping </p></td> - * <td>{Idle, Initialized, Stopped, Prepared, Started, Paused, + * <td>{Idle, Initialized, Stopped, Prepared, Started, Paused, * PlaybackCompleted}</p></td> * <td>{Error}</p></td> - * <td>Successful invoke of this method in a valid state does not change - * the state. Calling this method in an + * <td>Successful invoke of this method in a valid state does not change + * the state. Calling this method in an * invalid state transfers the object to the <em>Error</em> state.</p></td></tr> * <tr><td>isLooping </p></td> * <td>any </p></td> @@ -398,7 +398,7 @@ import java.lang.ref.WeakReference; * <td>This method can be called in any state and calling it does not change * the object state. </p></td></tr> * <tr><td>setVolume </p></td> - * <td>{Idle, Initialized, Stopped, Prepared, Started, Paused, + * <td>{Idle, Initialized, Stopped, Prepared, Started, Paused, * PlaybackCompleted}</p></td> * <td>{Error}</p></td> * <td>Successful invoke of this method does not change the state. @@ -410,14 +410,14 @@ import java.lang.ref.WeakReference; * <tr><td>start </p></td> * <td>{Prepared, Started, Paused, PlaybackCompleted}</p></td> * <td>{Idle, Initialized, Stopped, Error}</p></td> - * <td>Successful invoke of this method in a valid state transfers the - * object to the <em>Started</em> state. Calling this method in an + * <td>Successful invoke of this method in a valid state transfers the + * object to the <em>Started</em> state. Calling this method in an * invalid state transfers the object to the <em>Error</em> state.</p></td></tr> * <tr><td>stop </p></td> * <td>{Prepared, Started, Stopped, Paused, PlaybackCompleted}</p></td> * <td>{Idle, Initialized, Error}</p></td> - * <td>Successful invoke of this method in a valid state transfers the - * object to the <em>Stopped</em> state. Calling this method in an + * <td>Successful invoke of this method in a valid state transfers the + * object to the <em>Stopped</em> state. Calling this method in an * invalid state transfers the object to the <em>Error</em> state.</p></td></tr> * </table> * @@ -429,13 +429,13 @@ import java.lang.ref.WeakReference; * */ public class MediaPlayer -{ +{ static { System.loadLibrary("media_jni"); } - + private final static String TAG = "MediaPlayer"; - + private int mNativeContext; // accessed by native methods private int mListenerContext; // accessed by native methods private Surface mSurface; // accessed by native methods @@ -444,16 +444,16 @@ public class MediaPlayer private PowerManager.WakeLock mWakeLock = null; private boolean mScreenOnWhilePlaying; private boolean mStayAwake; - + /** - * Default constructor. Consider using one of the create() methods for + * Default constructor. Consider using one of the create() methods for * synchronously instantiating a MediaPlayer from a Uri or resource. * <p>When done with the MediaPlayer, you should call {@link #release()}, * to free the resources. If not released, too many MediaPlayer instances may * result in an exception.</p> */ public MediaPlayer() { - + Looper looper; if ((looper = Looper.myLooper()) != null) { mEventHandler = new EventHandler(this, looper); @@ -468,17 +468,27 @@ public class MediaPlayer */ native_setup(new WeakReference<MediaPlayer>(this)); } - + + /* + * Update the MediaPlayer ISurface. Call after updating mSurface. + */ + private native void _setVideoSurface(); + /** * Sets the SurfaceHolder to use for displaying the video portion of the media. * This call is optional. Not calling it when playing back a video will * result in only the audio track being played. - * + * * @param sh the SurfaceHolder to use for video display */ public void setDisplay(SurfaceHolder sh) { mSurfaceHolder = sh; - mSurface = sh.getSurface(); + if (sh != null) { + mSurface = sh.getSurface(); + } else { + mSurface = null; + } + _setVideoSurface(); updateSurfaceScreenOn(); } @@ -488,29 +498,29 @@ public class MediaPlayer * <p>When done with the MediaPlayer, you should call {@link #release()}, * to free the resources. If not released, too many MediaPlayer instances will * result in an exception.</p> - * - * @param context the Context to use + * + * @param context the Context to use * @param uri the Uri from which to get the datasource * @return a MediaPlayer object, or null if creation failed */ public static MediaPlayer create(Context context, Uri uri) { return create (context, uri, null); } - + /** * Convenience method to create a MediaPlayer for a given Uri. * On success, {@link #prepare()} will already have been called and must not be called again. * <p>When done with the MediaPlayer, you should call {@link #release()}, * to free the resources. If not released, too many MediaPlayer instances will * result in an exception.</p> - * - * @param context the Context to use + * + * @param context the Context to use * @param uri the Uri from which to get the datasource * @param holder the SurfaceHolder to use for displaying the video * @return a MediaPlayer object, or null if creation failed */ public static MediaPlayer create(Context context, Uri uri, SurfaceHolder holder) { - + try { MediaPlayer mp = new MediaPlayer(); mp.setDataSource(context, uri); @@ -539,9 +549,9 @@ public class MediaPlayer * <p>When done with the MediaPlayer, you should call {@link #release()}, * to free the resources. If not released, too many MediaPlayer instances will * result in an exception.</p> - * - * @param context the Context to use - * @param resid the raw resource id (<var>R.raw.<something></var>) for + * + * @param context the Context to use + * @param resid the raw resource id (<var>R.raw.<something></var>) for * the resource to use as the datasource * @return a MediaPlayer object, or null if creation failed */ @@ -567,17 +577,17 @@ public class MediaPlayer } return null; } - + /** * Sets the data source as a content Uri. - * + * * @param context the Context to use when resolving the Uri * @param uri the Content URI of the data you want to play * @throws IllegalStateException if it is called in an invalid state */ public void setDataSource(Context context, Uri uri) throws IOException, IllegalArgumentException, SecurityException, IllegalStateException { - + String scheme = uri.getScheme(); if(scheme == null || scheme.equals("file")) { setDataSource(uri.getPath()); @@ -607,13 +617,14 @@ public class MediaPlayer fd.close(); } } + Log.d(TAG, "Couldn't open file on client side, trying server side"); setDataSource(uri.toString()); return; } /** * Sets the data source (file-path or http/rtsp URL) to use. - * + * * @param path the path of the file, or the http/rtsp URL of the stream you want to play * @throws IllegalStateException if it is called in an invalid state */ @@ -622,57 +633,57 @@ public class MediaPlayer /** * Sets the data source (FileDescriptor) to use. It is the caller's responsibility * to close the file descriptor. It is safe to do so as soon as this call returns. - * + * * @param fd the FileDescriptor for the file you want to play * @throws IllegalStateException if it is called in an invalid state */ - public void setDataSource(FileDescriptor fd) + public void setDataSource(FileDescriptor fd) throws IOException, IllegalArgumentException, IllegalStateException { // intentionally less than LONG_MAX setDataSource(fd, 0, 0x7ffffffffffffffL); } - + /** * Sets the data source (FileDescriptor) to use. It is the caller's responsibility * to close the file descriptor. It is safe to do so as soon as this call returns. - * + * * @param fd the FileDescriptor for the file you want to play * @param offset the offset into the file where the data to be played starts, in bytes * @param length the length in bytes of the data to be played * @throws IllegalStateException if it is called in an invalid state */ - public native void setDataSource(FileDescriptor fd, long offset, long length) + public native void setDataSource(FileDescriptor fd, long offset, long length) throws IOException, IllegalArgumentException, IllegalStateException; /** * Prepares the player for playback, synchronously. - * + * * After setting the datasource and the display surface, you need to either * call prepare() or prepareAsync(). For files, it is OK to call prepare(), * which blocks until MediaPlayer is ready for playback. - * + * * @throws IllegalStateException if it is called in an invalid state */ public native void prepare() throws IOException, IllegalStateException; - + /** * Prepares the player for playback, asynchronously. - * + * * After setting the datasource and the display surface, you need to either * call prepare() or prepareAsync(). For streams, you should call prepareAsync(), * which returns immediately, rather than blocking until enough data has been * buffered. - * + * * @throws IllegalStateException if it is called in an invalid state */ public native void prepareAsync() throws IllegalStateException; - + /** * Starts or resumes playback. If playback had previously been paused, * playback will continue from where it was paused. If playback had * been stopped, or never started before, playback will start at the * beginning. - * + * * @throws IllegalStateException if it is called in an invalid state */ public void start() throws IllegalStateException { @@ -681,10 +692,10 @@ public class MediaPlayer } private native void _start() throws IllegalStateException; - + /** - * Stops playback after playback has been stopped or paused. - * + * Stops playback after playback has been stopped or paused. + * * @throws IllegalStateException if the internal player engine has not been * initialized. */ @@ -694,10 +705,10 @@ public class MediaPlayer } private native void _stop() throws IllegalStateException; - + /** * Pauses playback. Call start() to resume. - * + * * @throws IllegalStateException if the internal player engine has not been * initialized. */ @@ -707,20 +718,20 @@ public class MediaPlayer } private native void _pause() throws IllegalStateException; - + /** * Set the low-level power management behavior for this MediaPlayer. This * can be used when the MediaPlayer is not playing through a SurfaceHolder * set with {@link #setDisplay(SurfaceHolder)} and thus can use the * high-level {@link #setScreenOnWhilePlaying(boolean)} feature. - * + * * <p>This function has the MediaPlayer access the low-level power manager * service to control the device's power usage while playing is occurring. * The parameter is a combination of {@link android.os.PowerManager} wake flags. * Use of this method requires {@link android.Manifest.permission#WAKE_LOCK} * permission. * By default, no attempt is made to keep the device awake during playback. - * + * * @param context the Context to use * @param mode the power/wake mode to set * @see android.os.PowerManager @@ -742,14 +753,14 @@ public class MediaPlayer mWakeLock.acquire(); } } - + /** * Control whether we should use the attached SurfaceHolder to keep the * screen on while video playback is occurring. This is the preferred * method over {@link #setWakeMode} where possible, since it doesn't * require that the application have permission for low-level wake lock * access. - * + * * @param screenOn Supply true to keep the screen on, false to allow it * to turn off. */ @@ -759,7 +770,7 @@ public class MediaPlayer updateSurfaceScreenOn(); } } - + private void stayAwake(boolean awake) { if (mWakeLock != null) { if (awake && !mWakeLock.isHeld()) { @@ -771,61 +782,61 @@ public class MediaPlayer mStayAwake = awake; updateSurfaceScreenOn(); } - + private void updateSurfaceScreenOn() { if (mSurfaceHolder != null) { mSurfaceHolder.setKeepScreenOn(mScreenOnWhilePlaying && mStayAwake); } } - + /** * Returns the width of the video. - * + * * @return the width of the video, or 0 if there is no video, * no display surface was set, or prepare()/prepareAsync() * have not completed yet */ public native int getVideoWidth(); - + /** * Returns the height of the video. - * + * * @return the height of the video, or 0 if there is no video, * no display surface was set, or prepare()/prepareAsync() * have not completed yet */ public native int getVideoHeight(); - + /** * Checks whether the MediaPlayer is playing. - * + * * @return true if currently playing, false otherwise */ public native boolean isPlaying(); - + /** * Seeks to specified time position. - * + * * @param msec the offset in milliseconds from the start to seek to * @throws IllegalStateException if the internal player engine has not been * initialized */ public native void seekTo(int msec) throws IllegalStateException; - + /** * Gets the current playback position. - * + * * @return the current position in milliseconds */ public native int getCurrentPosition(); - + /** * Gets the duration of the file. - * + * * @return the duration in milliseconds */ public native int getDuration(); - + /** * Releases resources associated with this MediaPlayer object. * It is considered good practice to call this method when you're @@ -845,7 +856,7 @@ public class MediaPlayer } private native void _release(); - + /** * Resets the MediaPlayer to its uninitialized state. After calling * this method, you will have to initialize it again by setting the @@ -857,13 +868,13 @@ public class MediaPlayer // make sure none of the listeners get called anymore mEventHandler.removeCallbacksAndMessages(null); } - + private native void _reset(); - + /** * Sets the audio stream type for this MediaPlayer. See {@link AudioManager} * for a list of stream types. - * + * * @param streamtype the audio stream type * @see android.media.AudioManager */ @@ -871,20 +882,20 @@ public class MediaPlayer /** * Sets the player to be looping or non-looping. - * + * * @param looping whether to loop or not */ public native void setLooping(boolean looping); /** * Checks whether the MediaPlayer is looping or non-looping. - * + * * @return true if the MediaPlayer is currently looping, false otherwise */ public native boolean isLooping(); /** - * Sets the volume on this player. + * Sets the volume on this player. * This API is recommended for balancing the output of audio streams * within an application. Unless you are writing an application to * control user settings, this API should be used in preference to @@ -903,7 +914,7 @@ public class MediaPlayer * @hide */ public native Bitmap getFrameAt(int msec) throws IllegalStateException; - + private native final void native_setup(Object mediaplayer_this); private native final void native_finalize(); @Override @@ -1026,7 +1037,7 @@ public class MediaPlayer { /** * Called when the media file is ready for playback. - * + * * @param mp the MediaPlayer that is ready for playback */ void onPrepared(MediaPlayer mp); @@ -1053,7 +1064,7 @@ public class MediaPlayer { /** * Called when the end of a media source is reached during playback. - * + * * @param mp the MediaPlayer that reached the end of the file */ void onCompletion(MediaPlayer mp); @@ -1080,14 +1091,14 @@ public class MediaPlayer { /** * Called to update status in buffering a media stream. - * + * * @param mp the MediaPlayer the update pertains to * @param percent the percentage (0-100) of the buffer * that has been filled thus far */ void onBufferingUpdate(MediaPlayer mp, int percent); } - + /** * Register a callback to be invoked when the status of a network * stream's buffer has changed. @@ -1100,7 +1111,7 @@ public class MediaPlayer } private OnBufferingUpdateListener mOnBufferingUpdateListener; - + /** * Interface definition of a callback to be invoked indicating * the completion of a seek operation. @@ -1109,23 +1120,23 @@ public class MediaPlayer { /** * Called to indicate the completion of a seek operation. - * + * * @param mp the MediaPlayer that issued the seek operation */ public void onSeekComplete(MediaPlayer mp); } - + /** * Register a callback to be invoked when a seek operation has been * completed. - * + * * @param listener the callback that will be run */ public void setOnSeekCompleteListener(OnSeekCompleteListener listener) { mOnSeekCompleteListener = listener; } - + private OnSeekCompleteListener mOnSeekCompleteListener; /** @@ -1136,25 +1147,25 @@ public class MediaPlayer { /** * Called to indicate the video size - * + * * @param mp the MediaPlayer associated with this callback * @param width the width of the video * @param height the height of the video */ public void onVideoSizeChanged(MediaPlayer mp, int width, int height); } - + /** * Register a callback to be invoked when the video size is * known or updated. - * + * * @param listener the callback that will be run */ public void setOnVideoSizeChangedListener(OnVideoSizeChangedListener listener) { mOnVideoSizeChangedListener = listener; } - + private OnVideoSizeChangedListener mOnVideoSizeChangedListener; /* Do not change these values without updating their counterparts @@ -1166,11 +1177,11 @@ public class MediaPlayer public static final int MEDIA_ERROR_UNKNOWN = 1; /** Media server died. In this case, the application must release the - * MediaPlayer object and instantiate a new one. + * MediaPlayer object and instantiate a new one. * @see android.media.MediaPlayer.OnErrorListener */ public static final int MEDIA_ERROR_SERVER_DIED = 100; - + /** The video is streamed and its container is not valid for progressive * playback i.e the video's index (e.g moov atom) is not at the start of the * file. @@ -1187,7 +1198,7 @@ public class MediaPlayer { /** * Called to indicate an error. - * + * * @param mp the MediaPlayer the error pertains to * @param what the type of error that has occurred: * <ul> @@ -1202,11 +1213,11 @@ public class MediaPlayer */ boolean onError(MediaPlayer mp, int what, int extra); } - + /** * Register a callback to be invoked when an error has happened * during an asynchronous operation. - * + * * @param listener the callback that will be run */ public void setOnErrorListener(OnErrorListener listener) @@ -1251,7 +1262,7 @@ public class MediaPlayer { /** * Called to indicate an info or a warning. - * + * * @param mp the MediaPlayer the info pertains to. * @param what the type of info or warning. * <ul> @@ -1271,7 +1282,7 @@ public class MediaPlayer /** * Register a callback to be invoked when an info/warning is available. - * + * * @param listener the callback that will be run */ public void setOnInfoListener(OnInfoListener listener) diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java index 5d90e62..be4b489 100644 --- a/media/java/android/media/MediaRecorder.java +++ b/media/java/android/media/MediaRecorder.java @@ -125,6 +125,15 @@ public class MediaRecorder public static final int DEFAULT = 0; /** Microphone audio source */ public static final int MIC = 1; + + /** Voice call uplink (Tx) audio source */ + public static final int VOICE_UPLINK = 2; + + /** Voice call downlink (Rx) audio source */ + public static final int VOICE_DOWNLINK = 3; + + /** Voice call uplink + downlink audio source */ + public static final int VOICE_CALL = 4; } /** @@ -155,8 +164,19 @@ public class MediaRecorder public static final int THREE_GPP = 1; /** MPEG4 media file format*/ public static final int MPEG_4 = 2; - /** Raw AMR file format */ + + /** The following formats are audio only .aac or .amr formats **/ + /** @deprecated Deprecated in favor of AMR_NB */ + /** @todo change link when AMR_NB is exposed. Deprecated in favor of {@link MediaRecorder.OutputFormat#AMR_NB} */ public static final int RAW_AMR = 3; + /** @hide AMR NB file format */ + public static final int AMR_NB = 3; + /** @hide AMR WB file format */ + public static final int AMR_WB = 4; + /** @hide AAC ADIF file format */ + public static final int AAC_ADIF = 5; + /** @hide AAC ADTS file format */ + public static final int AAC_ADTS = 6; }; /** @@ -171,7 +191,14 @@ public class MediaRecorder public static final int DEFAULT = 0; /** AMR (Narrowband) audio codec */ public static final int AMR_NB = 1; - //public static final AAC = 2; currently unsupported + /** @hide AMR (Wideband) audio codec */ + public static final int AMR_WB = 2; + /** @hide AAC audio codec */ + public static final int AAC = 3; + /** @hide enhanced AAC audio codec */ + public static final int AAC_PLUS = 4; + /** @hide enhanced AAC plus audio codec */ + public static final int EAAC_PLUS = 5; } /** @@ -189,6 +216,46 @@ public class MediaRecorder public static final int MPEG_4_SP = 3; } + + /** + * @hide Defines the audio sampling rate. This must be set before + * setAudioEncoder() or it will be ignored. + * This parameter is used with + * {@link MediaRecorder#setParameters(String)}. + */ + public final class AudioParamSamplingRate { + /* Do not change these values without updating their counterparts + * in include/media/mediarecorder.h! + */ + private AudioParamSamplingRate() {} + public static final String AUDIO_PARAM_SAMPLING_RATE_KEY = "audio-param-sampling-rate="; + } + + /** + * @hide Defines the audio number of channels. This must be set before + * setAudioEncoder() or it will be ignored. + * This parameter is used with + * {@link MediaRecorder#setParameters(String)}. + */ + public final class AudioParamChannels { + /* Do not change these values without updating their counterparts + * in include/media/mediarecorder.h! + */ + private AudioParamChannels() {} + public static final String AUDIO_PARAM_NUMBER_OF_CHANNELS = "audio-param-number-of-channels="; + } + + /** + * @hide Defines the audio encoding bitrate. This must be set before + * setAudioEncoder() or it will be ignored. + * This parameter is used with + * {@link MediaRecorder#setParameters(String)}. + */ + public final class AudioParamEncodingBitrate{ + private AudioParamEncodingBitrate() {} + public static final String AUDIO_PARAM_ENCODING_BITRATE = "audio-param-encoding-bitrate="; + } + /** * Sets the audio source to be used for recording. If this method is not * called, the output file will not contain an audio track. The source needs @@ -203,6 +270,12 @@ public class MediaRecorder throws IllegalStateException; /** + * Gets the maximum value for audio sources. + * @see android.media.MediaRecorder.AudioSource + */ + public static final int getAudioSourceMax() { return AudioSource.VOICE_CALL; } + + /** * Sets the video source to be used for recording. If this method is not * called, the output file will not contain an video track. The source needs * to be specified before setting recording-parameters or encoders. Call @@ -317,6 +390,16 @@ public class MediaRecorder throws IllegalStateException; /** + * @hide Sets a parameter in the author engine. + * + * @param params the parameter to set. + * @see android.media.MediaRecorder.AudioParamSamplingRate + * @see android.media.MediaRecorder.AudioParamChannels + * @see android.media.MediaRecorder.AudioParamEncodingBitrate + */ + public native void setParameters(String params); + + /** * Pass in the file descriptor of the file to be written. Call this after * setOutputFormat() but before prepare(). * @@ -433,7 +516,7 @@ public class MediaRecorder { /** * Called when an error occurs while recording. - * + * * @param mr the MediaRecorder that encountered the error * @param what the type of error that has occurred: * <ul> @@ -479,7 +562,7 @@ public class MediaRecorder { /** * Called when an error occurs while recording. - * + * * @param mr the MediaRecorder that encountered the error * @param what the type of error that has occurred: * <ul> diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java index ae3e181..cccc0fc 100644 --- a/media/java/android/media/MediaScanner.java +++ b/media/java/android/media/MediaScanner.java @@ -53,7 +53,45 @@ import java.util.HashSet; import java.util.Iterator; /** - * Internal service that no-one should use directly. + * Internal service helper that no-one should use directly. + * + * The way the scan currently works is: + * - The Java MediaScannerService creates a MediaScanner (this class), and calls + * MediaScanner.scanDirectories on it. + * - scanDirectories() calls the native processDirectory() for each of the specified directories. + * - the processDirectory() JNI method wraps the provided mediascanner client in a native + * 'MyMediaScannerClient' class, then calls processDirectory() on the native MediaScanner + * object (which got created when the Java MediaScanner was created). + * - native MediaScanner.processDirectory() (currently part of opencore) calls + * doProcessDirectory(), which recurses over the folder, and calls + * native MyMediaScannerClient.scanFile() for every file whose extension matches. + * - native MyMediaScannerClient.scanFile() calls back on Java MediaScannerClient.scanFile, + * which calls doScanFile, which after some setup calls back down to native code, calling + * MediaScanner.processFile(). + * - MediaScanner.processFile() calls one of several methods, depending on the type of the + * file: parseMP3, parseMP4, parseMidi, parseOgg or parseWMA. + * - each of these methods gets metadata key/value pairs from the file, and repeatedly + * calls native MyMediaScannerClient.handleStringTag, which calls back up to its Java + * counterparts in this file. + * - Java handleStringTag() gathers the key/value pairs that it's interested in. + * - once processFile returns and we're back in Java code in doScanFile(), it calls + * Java MyMediaScannerClient.endFile(), which takes all the data that's been + * gathered and inserts an entry in to the database. + * + * In summary: + * Java MediaScannerService calls + * Java MediaScanner scanDirectories, which calls + * Java MediaScanner processDirectory (native method), which calls + * native MediaScanner processDirectory, which calls + * native MyMediaScannerClient scanFile, which calls + * Java MyMediaScannerClient scanFile, which calls + * Java MediaScannerClient doScanFile, which calls + * Java MediaScanner processFile (native method), which calls + * native MediaScanner processFile, which calls + * native parseMP3, parseMP4, parseMidi, parseOgg or parseWMA, which calls + * native MyMediaScanner handleStringTag, which calls + * Java MyMediaScanner handleStringTag. + * Once MediaScanner processFile returns, an entry is inserted in to the database. * * {@hide} */ @@ -506,7 +544,10 @@ public class MediaScanner public void handleStringTag(String name, String value) { if (name.equalsIgnoreCase("title") || name.startsWith("title;")) { - mTitle = value.trim(); + // Don't trim() here, to preserve the special \001 character + // used to force sorting. The media provider will trim() before + // inserting the title in to the database. + mTitle = value; } else if (name.equalsIgnoreCase("artist") || name.startsWith("artist;")) { mArtist = value.trim(); } else if (name.equalsIgnoreCase("albumartist") || name.startsWith("albumartist;")) { diff --git a/media/java/android/media/RingtoneManager.java b/media/java/android/media/RingtoneManager.java index 8f05cec..42edae6 100644 --- a/media/java/android/media/RingtoneManager.java +++ b/media/java/android/media/RingtoneManager.java @@ -176,17 +176,20 @@ public class RingtoneManager { private static final String[] INTERNAL_COLUMNS = new String[] { MediaStore.Audio.Media._ID, MediaStore.Audio.Media.TITLE, - "\"" + MediaStore.Audio.Media.INTERNAL_CONTENT_URI + "\"" + "\"" + MediaStore.Audio.Media.INTERNAL_CONTENT_URI + "\"", + MediaStore.Audio.Media.TITLE_KEY }; private static final String[] DRM_COLUMNS = new String[] { DrmStore.Audio._ID, DrmStore.Audio.TITLE, - "\"" + DrmStore.Audio.CONTENT_URI + "\"" + "\"" + DrmStore.Audio.CONTENT_URI + "\"", + DrmStore.Audio.TITLE + " AS " + MediaStore.Audio.Media.TITLE_KEY }; private static final String[] MEDIA_COLUMNS = new String[] { MediaStore.Audio.Media._ID, MediaStore.Audio.Media.TITLE, - "\"" + MediaStore.Audio.Media.EXTERNAL_CONTENT_URI + "\"" + "\"" + MediaStore.Audio.Media.EXTERNAL_CONTENT_URI + "\"", + MediaStore.Audio.Media.TITLE_KEY }; /** @@ -361,7 +364,7 @@ public class RingtoneManager { final Cursor mediaCursor = getMediaRingtones(); return mCursor = new SortCursor(new Cursor[] { internalCursor, drmCursor, mediaCursor }, - MediaStore.MediaColumns.TITLE); + MediaStore.Audio.Media.DEFAULT_SORT_ORDER); } /** diff --git a/media/java/android/media/ToneGenerator.java b/media/java/android/media/ToneGenerator.java index 4b53756..e5ee9a3 100644 --- a/media/java/android/media/ToneGenerator.java +++ b/media/java/android/media/ToneGenerator.java @@ -19,11 +19,11 @@ package android.media; /** - * This class provides methods to play DTMF tones (ITU-T Recommendation Q.23), - * call supervisory tones (3GPP TS 22.001, CEPT) and proprietary tones (3GPP TS 31.111). + * This class provides methods to play DTMF tones (ITU-T Recommendation Q.23), + * call supervisory tones (3GPP TS 22.001, CEPT) and proprietary tones (3GPP TS 31.111). * Depending on call state and routing options, tones are mixed to the downlink audio - * or output to the speaker phone or headset. - * This API is not for generating tones over the uplink audio path. + * or output to the speaker phone or headset. + * This API is not for generating tones over the uplink audio path. */ public class ToneGenerator { @@ -33,99 +33,99 @@ public class ToneGenerator * List of all available tones: These constants must be kept consistant with * the enum in ToneGenerator C++ class. */ - /** + /** * DTMF tone for key 0: 1336Hz, 941Hz, continuous</p> - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_0 = 0; /** * DTMF tone for key 1: 1209Hz, 697Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_1 = 1; /** * DTMF tone for key 2: 1336Hz, 697Hz, continuous - * + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_DTMF_2 = 2; + /** + * DTMF tone for key 3: 1477Hz, 697Hz, continuous + * * @see #ToneGenerator(int, int) */ - public static final int TONE_DTMF_2 = 2; - /** - * DTMF tone for key 3: 1477Hz, 697Hz, continuous - * - * @see #ToneGenerator(int, int) - */ public static final int TONE_DTMF_3 = 3; /** * DTMF tone for key 4: 1209Hz, 770Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_4 = 4; /** * DTMF tone for key 5: 1336Hz, 770Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_5 = 5; /** * DTMF tone for key 6: 1477Hz, 770Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_6 = 6; /** * DTMF tone for key 7: 1209Hz, 852Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_7 = 7; /** * DTMF tone for key 8: 1336Hz, 852Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_8 = 8; /** * DTMF tone for key 9: 1477Hz, 852Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_9 = 9; /** * DTMF tone for key *: 1209Hz, 941Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_S = 10; /** * DTMF tone for key #: 1477Hz, 941Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_P = 11; /** * DTMF tone for key A: 1633Hz, 697Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_A = 12; /** * DTMF tone for key B: 1633Hz, 770Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_B = 13; /** * DTMF tone for key C: 1633Hz, 852Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_C = 14; /** * DTMF tone for key D: 1633Hz, 941Hz, continuous - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_DTMF_D = 15; @@ -151,7 +151,7 @@ public class ToneGenerator * Call supervisory tone, Congestion: * CEPT, JAPAN: 425Hz, 200ms ON, 200ms OFF... * ANSI (IS-95): 480Hz+620Hz, 250ms ON, 250ms OFF... - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_SUP_CONGESTION = 18; @@ -159,27 +159,28 @@ public class ToneGenerator * Call supervisory tone, Radio path acknowlegment : * CEPT, ANSI: 425Hz, 200ms ON * JAPAN: 400Hz, 1s ON, 2s OFF... - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_SUP_RADIO_ACK = 19; /** * Call supervisory tone, Radio path not available: 425Hz, 200ms ON, 200 OFF 3 bursts - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_SUP_RADIO_NOTAVAIL = 20; /** * Call supervisory tone, Error/Special info: 950Hz+1400Hz+1800Hz, 330ms ON, 1s OFF... - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_SUP_ERROR = 21; /** * Call supervisory tone, Call Waiting: * CEPT, JAPAN: 425Hz, 200ms ON, 600ms OFF, 200ms ON, 3s OFF... - * ANSI (IS-95): 440 Hz, 300 ms ON, 9.7 s OFF, (100 ms ON, 100 ms OFF, 100 ms ON, 9.7s OFF ...) - * + * ANSI (IS-95): 440 Hz, 300 ms ON, 9.7 s OFF, + * (100 ms ON, 100 ms OFF, 100 ms ON, 9.7s OFF ...) + * * @see #ToneGenerator(int, int) */ public static final int TONE_SUP_CALL_WAITING = 22; @@ -187,42 +188,43 @@ public class ToneGenerator * Call supervisory tone, Ring Tone: * CEPT, JAPAN: 425Hz, 1s ON, 4s OFF... * ANSI (IS-95): 440Hz + 480Hz, 2s ON, 4s OFF... - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_SUP_RINGTONE = 23; /** * Proprietary tone, general beep: 400Hz+1200Hz, 35ms ON - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_PROP_BEEP = 24; /** * Proprietary tone, positive acknowlegement: 1200Hz, 100ms ON, 100ms OFF 2 bursts - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_PROP_ACK = 25; /** * Proprietary tone, negative acknowlegement: 300Hz+400Hz+500Hz, 400ms ON - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_PROP_NACK = 26; /** * Proprietary tone, prompt tone: 400Hz+1200Hz, 200ms ON - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_PROP_PROMPT = 27; /** * Proprietary tone, general double beep: twice 400Hz+1200Hz, 35ms ON, 200ms OFF, 35ms ON - * + * * @see #ToneGenerator(int, int) */ public static final int TONE_PROP_BEEP2 = 28; /** - * Call supervisory tone (IS-95), intercept tone: alternating 440 Hz and 620 Hz tones, each on for 250 ms + * Call supervisory tone (IS-95), intercept tone: alternating 440 Hz and 620 Hz tones, + * each on for 250 ms * * @see #ToneGenerator(int, int) */ @@ -240,7 +242,8 @@ public class ToneGenerator */ public static final int TONE_SUP_CONGESTION_ABBREV = 31; /** - * Call supervisory tone (IS-95), confirm tone: a 350 Hz tone added to a 440 Hz tone repeated 3 times in a 100 ms on, 100 ms off cycle + * Call supervisory tone (IS-95), confirm tone: a 350 Hz tone added to a 440 Hz tone + * repeated 3 times in a 100 ms on, 100 ms off cycle * * @see #ToneGenerator(int, int) */ @@ -251,7 +254,474 @@ public class ToneGenerator * @see #ToneGenerator(int, int) */ public static final int TONE_SUP_PIP = 33; - + /** + * CDMA Dial tone : 425Hz continuous + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_DIAL_TONE_LITE = 34; + /** + * CDMA USA Ringback: 440Hz+480Hz 2s ON, 4000 OFF ... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_NETWORK_USA_RINGBACK = 35; + /** + * CDMA Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON ... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_INTERCEPT = 36; + /** + * CDMA Abbr Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_ABBR_INTERCEPT = 37; + /** + * CDMA Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_REORDER = 38; + /** + * + * CDMA Abbr Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF repeated for 8 times + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_ABBR_REORDER = 39; + /** + * CDMA Network Busy tone: 480Hz+620Hz 500ms ON, 500ms OFF continuous + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_NETWORK_BUSY = 40; + /** + * CDMA Confirm tone: 350Hz+440Hz 100ms ON, 100ms OFF repeated for 3 times + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_CONFIRM = 41; + /** + * + * CDMA answer tone: silent tone - defintion Frequency 0, 0ms ON, 0ms OFF + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_ANSWER = 42; + /** + * + * CDMA Network Callwaiting tone: 440Hz 300ms ON + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_NETWORK_CALLWAITING = 43; + /** + * CDMA PIP tone: 480Hz 100ms ON, 100ms OFF repeated for 4 times + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_PIP = 44; + /** + * ISDN Call Signal Normal tone: {2091Hz 32ms ON, 2556 64ms ON} 20 times, + * 2091 32ms ON, 2556 48ms ON, 4s OFF + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_CALL_SIGNAL_ISDN_NORMAL = 45; + /** + * ISDN Call Signal Intergroup tone: {2091Hz 32ms ON, 2556 64ms ON} 8 times, + * 2091Hz 32ms ON, 400ms OFF, {2091Hz 32ms ON, 2556Hz 64ms ON} times, + * 2091Hz 32ms ON, 4s OFF. + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_CALL_SIGNAL_ISDN_INTERGROUP = 46; + /** + * ISDN Call Signal SP PRI tone:{2091Hz 32ms ON, 2556 64ms ON} 4 times + * 2091Hz 16ms ON, 200ms OFF, {2091Hz 32ms ON, 2556Hz 64ms ON} 4 times, + * 2091Hz 16ms ON, 200ms OFF + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_CALL_SIGNAL_ISDN_SP_PRI = 47; + /** + * ISDN Call sign PAT3 tone: silent tone + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_CALL_SIGNAL_ISDN_PAT3 = 48; + /** + * ISDN Ping Ring tone: {2091Hz 32ms ON, 2556Hz 64ms ON} 5 times + * 2091Hz 20ms ON + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_CALL_SIGNAL_ISDN_PING_RING = 49; + /** + * + * ISDN Pat5 tone: silent tone + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_CALL_SIGNAL_ISDN_PAT5 = 50; + /** + * + * ISDN Pat6 tone: silent tone + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_CALL_SIGNAL_ISDN_PAT6 = 51; + /** + * ISDN Pat7 tone: silent tone + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_CALL_SIGNAL_ISDN_PAT7 = 52; + /** + * TONE_CDMA_HIGH_L tone: {3700Hz 25ms, 4000Hz 25ms} 40 times + * 4000ms OFF, Repeat .... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_HIGH_L = 53; + /** + * TONE_CDMA_MED_L tone: {2600Hz 25ms, 2900Hz 25ms} 40 times + * 4000ms OFF, Repeat .... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_MED_L = 54; + /** + * TONE_CDMA_LOW_L tone: {1300Hz 25ms, 1450Hz 25ms} 40 times, + * 4000ms OFF, Repeat .... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_LOW_L = 55; + /** + * CDMA HIGH SS tone: {3700Hz 25ms, 4000Hz 25ms} repeat 16 times, + * 400ms OFF, repeat .... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_HIGH_SS = 56; + /** + * CDMA MED SS tone: {2600Hz 25ms, 2900Hz 25ms} repeat 16 times, + * 400ms OFF, repeat .... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_MED_SS = 57; + /** + * CDMA LOW SS tone: {1300z 25ms, 1450Hz 25ms} repeat 16 times, + * 400ms OFF, repeat .... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_LOW_SS = 58; + /** + * CDMA HIGH SSL tone: {3700Hz 25ms, 4000Hz 25ms} 8 times, + * 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} repeat 8 times, + * 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} repeat 16 times, + * 4000ms OFF, repeat ... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_HIGH_SSL = 59; + /** + * CDMA MED SSL tone: {2600Hz 25ms, 2900Hz 25ms} 8 times, + * 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} repeat 8 times, + * 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} repeat 16 times, + * 4000ms OFF, repeat ... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_MED_SSL = 60; + /** + * CDMA LOW SSL tone: {1300Hz 25ms, 1450Hz 25ms} 8 times, + * 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} repeat 8 times, + * 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} repeat 16 times, + * 4000ms OFF, repeat ... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_LOW_SSL = 61; + /** + * CDMA HIGH SS2 tone: {3700Hz 25ms, 4000Hz 25ms} 20 times, + * 1000ms OFF, {3700Hz 25ms, 4000Hz 25ms} 20 times, + * 3000ms OFF, repeat .... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_HIGH_SS_2 = 62; + /** + * CDMA MED SS2 tone: {2600Hz 25ms, 2900Hz 25ms} 20 times, + * 1000ms OFF, {2600Hz 25ms, 2900Hz 25ms} 20 times, + * 3000ms OFF, repeat .... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_MED_SS_2 = 63; + /** + * CDMA LOW SS2 tone: {1300Hz 25ms, 1450Hz 25ms} 20 times, + * 1000ms OFF, {1300Hz 25ms, 1450Hz 25ms} 20 times, + * 3000ms OFF, repeat .... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_LOW_SS_2 = 64; + /** + * CDMA HIGH SLS tone: {3700Hz 25ms, 4000Hz 25ms} 10 times, + * 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 20 times, 500ms OFF, + * {3700Hz 25ms, 4000Hz 25ms} 10 times, 3000ms OFF, REPEAT + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_HIGH_SLS = 65; + /** + * CDMA MED SLS tone: {2600Hz 25ms, 2900Hz 25ms} 10 times, + * 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 20 times, 500ms OFF, + * {2600Hz 25ms, 2900Hz 25ms} 10 times, 3000ms OFF, REPEAT + * + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_MED_SLS = 66; + /** + * CDMA LOW SLS tone: {1300Hz 25ms, 1450Hz 25ms} 10 times, + * 500ms OFF, {1300Hz 25ms, 1450Hz 25ms} 20 times, 500ms OFF, + * {1300Hz 25ms, 1450Hz 25ms} 10 times, 3000ms OFF, REPEAT + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_LOW_SLS = 67; + /** + * CDMA HIGH S X4 tone: {3700Hz 25ms, 4000Hz 25ms} 10 times, + * 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, + * {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, + * {3700Hz 25ms, 4000Hz 25ms} 10 times, 2500ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_HIGH_S_X4 = 68; + /** + * CDMA MED S X4 tone: {2600Hz 25ms, 2900Hz 25ms} 10 times, + * 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, + * {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, + * {2600Hz 25ms, 2900Hz 25ms} 10 times, 2500ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_MED_S_X4 = 69; + /** + * CDMA LOW S X4 tone: {2600Hz 25ms, 2900Hz 25ms} 10 times, + * 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, + * {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, + * {2600Hz 25ms, 2900Hz 25ms} 10 times, 2500ms OFF, REPEAT.... + * + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_LOW_S_X4 = 70; + /** + * CDMA HIGH PBX L: {3700Hz 25ms, 4000Hz 25ms}20 times, + * 2000ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_HIGH_PBX_L = 71; + /** + * CDMA MED PBX L: {2600Hz 25ms, 2900Hz 25ms}20 times, + * 2000ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_MED_PBX_L = 72; + /** + * CDMA LOW PBX L: {1300Hz 25ms,1450Hz 25ms}20 times, + * 2000ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_LOW_PBX_L = 73; + /** + * CDMA HIGH PBX SS tone: {3700Hz 25ms, 4000Hz 25ms} 8 times + * 200 ms OFF, {3700Hz 25ms 4000Hz 25ms}8 times, + * 2000ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_HIGH_PBX_SS = 74; + /** + * CDMA MED PBX SS tone: {2600Hz 25ms, 2900Hz 25ms} 8 times + * 200 ms OFF, {2600Hz 25ms 2900Hz 25ms}8 times, + * 2000ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_MED_PBX_SS = 75; + /** + * CDMA LOW PBX SS tone: {1300Hz 25ms, 1450Hz 25ms} 8 times + * 200 ms OFF, {1300Hz 25ms 1450Hz 25ms}8 times, + * 2000ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_LOW_PBX_SS = 76; + /** + * CDMA HIGH PBX SSL tone:{3700Hz 25ms, 4000Hz 25ms} 8 times + * 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 8 times, 200ms OFF, + * {3700Hz 25ms, 4000Hz 25ms} 16 times, 1000ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_HIGH_PBX_SSL = 77; + /** + * CDMA MED PBX SSL tone:{2600Hz 25ms, 2900Hz 25ms} 8 times + * 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 8 times, 200ms OFF, + * {2600Hz 25ms, 2900Hz 25ms} 16 times, 1000ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_MED_PBX_SSL = 78; + /** + * CDMA LOW PBX SSL tone:{1300Hz 25ms, 1450Hz 25ms} 8 times + * 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 8 times, 200ms OFF, + * {1300Hz 25ms, 1450Hz 25ms} 16 times, 1000ms OFF, REPEAT.... + * + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_LOW_PBX_SSL = 79; + /** + * CDMA HIGH PBX SSL tone:{3700Hz 25ms, 4000Hz 25ms} 8 times + * 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 16 times, 200ms OFF, + * {3700Hz 25ms, 4000Hz 25ms} 8 times, 1000ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_HIGH_PBX_SLS = 80; + /** + * CDMA HIGH PBX SLS tone:{2600Hz 25ms, 2900Hz 25ms} 8 times + * 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 16 times, 200ms OFF, + * {2600Hz 25ms, 2900Hz 25ms} 8 times, 1000ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_MED_PBX_SLS = 81; + /** + * CDMA HIGH PBX SLS tone:{1300Hz 25ms, 1450Hz 25ms} 8 times + * 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 16 times, 200ms OFF, + * {1300Hz 25ms, 1450Hz 25ms} 8 times, 1000ms OFF, REPEAT.... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_LOW_PBX_SLS = 82; + /** + * CDMA HIGH PBX X S4 tone: {3700Hz 25ms 4000Hz 25ms} 8 times, + * 200ms OFF, {3700Hz 25ms 4000Hz 25ms} 8 times, 200ms OFF, + * {3700Hz 25ms 4000Hz 25ms} 8 times, 200ms OFF, + * {3700Hz 25ms 4000Hz 25ms} 8 times, 800ms OFF, REPEAT... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_HIGH_PBX_S_X4 = 83; + /** + * CDMA MED PBX X S4 tone: {2600Hz 25ms 2900Hz 25ms} 8 times, + * 200ms OFF, {2600Hz 25ms 2900Hz 25ms} 8 times, 200ms OFF, + * {2600Hz 25ms 2900Hz 25ms} 8 times, 200ms OFF, + * {2600Hz 25ms 2900Hz 25ms} 8 times, 800ms OFF, REPEAT... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_MED_PBX_S_X4 = 84; + /** + * CDMA LOW PBX X S4 tone: {1300Hz 25ms 1450Hz 25ms} 8 times, + * 200ms OFF, {1300Hz 25ms 1450Hz 25ms} 8 times, 200ms OFF, + * {1300Hz 25ms 1450Hz 25ms} 8 times, 200ms OFF, + * {1300Hz 25ms 1450Hz 25ms} 8 times, 800ms OFF, REPEAT... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_LOW_PBX_S_X4 = 85; + /** + * CDMA Alert Network Lite tone: 1109Hz 62ms ON, 784Hz 62ms ON, 740Hz 62ms ON + * 622Hz 62ms ON, 1109Hz 62ms ON + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_ALERT_NETWORK_LITE = 86; + /** + * CDMA Alert Auto Redial tone: {1245Hz 62ms ON, 659Hz 62ms ON} 3 times, + * 1245 62ms ON + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_ALERT_AUTOREDIAL_LITE = 87; + /** + * CDMA One Min Beep tone: 1150Hz+770Hz 400ms ON + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_ONE_MIN_BEEP = 88; + /** + * + * CDMA KEYPAD Volume key lite tone: 941Hz+1477Hz 120ms ON + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_KEYPAD_VOLUME_KEY_LITE = 89; + /** + * CDMA PRESSHOLDKEY LITE tone: 587Hz 375ms ON, 1175Hz 125ms ON + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_PRESSHOLDKEY_LITE = 90; + /** + * CDMA ALERT INCALL LITE tone: 587Hz 62ms, 784 62ms, 831Hz 62ms, + * 784Hz 62ms, 1109 62ms, 784Hz 62ms, 831Hz 62ms, 784Hz 62ms + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_ALERT_INCALL_LITE = 91; + /** + * CDMA EMERGENCY RINGBACK tone: {941Hz 125ms ON, 10ms OFF} 3times + * 4990ms OFF, REPEAT... + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_EMERGENCY_RINGBACK = 92; + /** + * CDMA ALERT CALL GUARD tone: {1319Hz 125ms ON, 125ms OFF} 3 times + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_ALERT_CALL_GUARD = 93; + /** + * CDMA SOFT ERROR LITE tone: 1047Hz 125ms ON, 370Hz 125ms + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_SOFT_ERROR_LITE = 94; + /** + * CDMA CALLDROP LITE tone: 1480Hz 125ms, 1397Hz 125ms, 784Hz 125ms + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_CALLDROP_LITE = 95; + /** + * CDMA_NETWORK_BUSY_ONE_SHOT tone: 425Hz 500ms ON, 500ms OFF. + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_NETWORK_BUSY_ONE_SHOT = 96; + /** + * CDMA_ABBR_ALERT tone: 1150Hz+770Hz 400ms ON + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_ABBR_ALERT = 97; + /** + * CDMA_SIGNAL_OFF - silent tone + * + * @see #ToneGenerator(int, int) + */ + public static final int TONE_CDMA_SIGNAL_OFF = 98; /** Maximum volume, for use with {@link #ToneGenerator(int,int)} */ public static final int MAX_VOLUME = AudioSystem.MAX_VOLUME; @@ -261,10 +731,10 @@ public class ToneGenerator /** * ToneGenerator class contructor specifying output stream type and volume. - * + * * @param streamType The streame type used for tone playback (e.g. STREAM_MUSIC). * @param volume The volume of the tone, given in percentage of maximum volume (from 0-100). - * + * */ public ToneGenerator(int streamType, int volume) { native_setup(streamType, volume); @@ -272,7 +742,7 @@ public class ToneGenerator /** * This method starts the playback of a tone of the specified type. - * only one tone can play at a time: if a tone is playing while this method is called, + * only one tone can play at a time: if a tone is playing while this method is called, * this tone is stopped and replaced by the one requested. * @param toneType The type of tone generate chosen from the following list: * <ul> @@ -308,6 +778,71 @@ public class ToneGenerator * <li>{@link #TONE_SUP_CONGESTION_ABBREV} * <li>{@link #TONE_SUP_CONFIRM} * <li>{@link #TONE_SUP_PIP} + * <li>{@link #TONE_CDMA_DIAL_TONE_LITE} + * <li>{@link #TONE_CDMA_NETWORK_USA_RINGBACK} + * <li>{@link #TONE_CDMA_INTERCEPT} + * <li>{@link #TONE_CDMA_ABBR_INTERCEPT} + * <li>{@link #TONE_CDMA_REORDER} + * <li>{@link #TONE_CDMA_ABBR_REORDER} + * <li>{@link #TONE_CDMA_NETWORK_BUSY} + * <li>{@link #TONE_CDMA_CONFIRM} + * <li>{@link #TONE_CDMA_ANSWER} + * <li>{@link #TONE_CDMA_NETWORK_CALLWAITING} + * <li>{@link #TONE_CDMA_PIP} + * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_NORMAL} + * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_INTERGROUP} + * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_SP_PRI} + * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_PAT3} + * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_PING_RING} + * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_PAT5} + * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_PAT6} + * <li>{@link #TONE_CDMA_CALL_SIGNAL_ISDN_PAT7} + * <li>{@link #TONE_CDMA_HIGH_L} + * <li>{@link #TONE_CDMA_MED_L} + * <li>{@link #TONE_CDMA_LOW_L} + * <li>{@link #TONE_CDMA_HIGH_SS} + * <li>{@link #TONE_CDMA_MED_SS} + * <li>{@link #TONE_CDMA_LOW_SS} + * <li>{@link #TONE_CDMA_HIGH_SSL} + * <li>{@link #TONE_CDMA_MED_SSL} + * <li>{@link #TONE_CDMA_LOW_SSL} + * <li>{@link #TONE_CDMA_HIGH_SS_2} + * <li>{@link #TONE_CDMA_MED_SS_2} + * <li>{@link #TONE_CDMA_LOW_SS_2} + * <li>{@link #TONE_CDMA_HIGH_SLS} + * <li>{@link #TONE_CDMA_MED_SLS} + * <li>{@link #TONE_CDMA_LOW_SLS} + * <li>{@link #TONE_CDMA_HIGH_S_X4} + * <li>{@link #TONE_CDMA_MED_S_X4} + * <li>{@link #TONE_CDMA_LOW_S_X4} + * <li>{@link #TONE_CDMA_HIGH_PBX_L} + * <li>{@link #TONE_CDMA_MED_PBX_L} + * <li>{@link #TONE_CDMA_LOW_PBX_L} + * <li>{@link #TONE_CDMA_HIGH_PBX_SS} + * <li>{@link #TONE_CDMA_MED_PBX_SS} + * <li>{@link #TONE_CDMA_LOW_PBX_SS} + * <li>{@link #TONE_CDMA_HIGH_PBX_SSL} + * <li>{@link #TONE_CDMA_MED_PBX_SSL} + * <li>{@link #TONE_CDMA_LOW_PBX_SSL} + * <li>{@link #TONE_CDMA_HIGH_PBX_SLS} + * <li>{@link #TONE_CDMA_MED_PBX_SLS} + * <li>{@link #TONE_CDMA_LOW_PBX_SLS} + * <li>{@link #TONE_CDMA_HIGH_PBX_S_X4} + * <li>{@link #TONE_CDMA_MED_PBX_S_X4} + * <li>{@link #TONE_CDMA_LOW_PBX_S_X4} + * <li>{@link #TONE_CDMA_ALERT_NETWORK_LITE} + * <li>{@link #TONE_CDMA_ALERT_AUTOREDIAL_LITE} + * <li>{@link #TONE_CDMA_ONE_MIN_BEEP} + * <li>{@link #TONE_CDMA_KEYPAD_VOLUME_KEY_LITE} + * <li>{@link #TONE_CDMA_PRESSHOLDKEY_LITE} + * <li>{@link #TONE_CDMA_ALERT_INCALL_LITE} + * <li>{@link #TONE_CDMA_EMERGENCY_RINGBACK} + * <li>{@link #TONE_CDMA_ALERT_CALL_GUARD} + * <li>{@link #TONE_CDMA_SOFT_ERROR_LITE} + * <li>{@link #TONE_CDMA_CALLDROP_LITE} + * <li>{@link #TONE_CDMA_NETWORK_BUSY_ONE_SHOT} + * <li>{@link #TONE_CDMA_ABBR_ALERT} + * <li>{@link #TONE_CDMA_SIGNAL_OFF} * </ul> * @see #ToneGenerator(int, int) */ @@ -328,9 +863,10 @@ public class ToneGenerator private native final void native_setup(int streamType, int volume); private native final void native_finalize(); + + @Override protected void finalize() { native_finalize(); } + @SuppressWarnings("unused") private int mNativeContext; // accessed by native methods - - } |