summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-11 12:11:56 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-11 12:11:56 -0700
commitc39a6e0c51e182338deb8b63d07933b585134929 (patch)
treee55fc5bd38b1eb8fb4851a0fe1cc264a7fe2f245 /media
parentb2a3dd88a53cc8c6d19f6dc8ec4f3d6c4abd9b54 (diff)
downloadframeworks_base-c39a6e0c51e182338deb8b63d07933b585134929.zip
frameworks_base-c39a6e0c51e182338deb8b63d07933b585134929.tar.gz
frameworks_base-c39a6e0c51e182338deb8b63d07933b585134929.tar.bz2
auto import from //branches/cupcake/...@137873
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/MediaPlayer.java114
-rw-r--r--media/libmedia/mediaplayer.cpp13
-rw-r--r--media/libmedia/mediarecorder.cpp5
3 files changed, 115 insertions, 17 deletions
diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java
index 369af3b..202d0ae 100644
--- a/media/java/android/media/MediaPlayer.java
+++ b/media/java/android/media/MediaPlayer.java
@@ -839,6 +839,7 @@ public class MediaPlayer
mOnCompletionListener = null;
mOnSeekCompleteListener = null;
mOnErrorListener = null;
+ mOnInfoListener = null;
mOnVideoSizeChangedListener = null;
_release();
}
@@ -918,18 +919,7 @@ public class MediaPlayer
private static final int MEDIA_SEEK_COMPLETE = 4;
private static final int MEDIA_SET_VIDEO_SIZE = 5;
private static final int MEDIA_ERROR = 100;
-
- // error codes from framework that indicate content issues
- // contained in arg1 of error message
-
- // Seek not supported - live stream
- private static final int ERROR_SEEK_NOT_SUPPORTED = 42;
-
- // A/V interleave exceeds the progressive streaming buffer
- private static final int ERROR_CONTENT_IS_POORLY_INTERLEAVED = 43;
-
- // video decoder is falling behind - content is too complex
- private static final int ERROR_VIDEO_TRACK_IS_FALLING_BEHIND = 44;
+ private static final int MEDIA_INFO = 200;
private class EventHandler extends Handler
{
@@ -974,6 +964,8 @@ public class MediaPlayer
return;
case MEDIA_ERROR:
+ // For PV specific error values (msg.arg2) look in
+ // opencore/pvmi/pvmf/include/pvmf_return_codes.h
Log.e(TAG, "Error (" + msg.arg1 + "," + msg.arg2 + ")");
boolean error_was_handled = false;
if (mOnErrorListener != null) {
@@ -984,6 +976,17 @@ public class MediaPlayer
}
stayAwake(false);
return;
+
+ case MEDIA_INFO:
+ // For PV specific code values (msg.arg2) look in
+ // opencore/pvmi/pvmf/include/pvmf_return_codes.h
+ Log.i(TAG, "Info (" + msg.arg1 + "," + msg.arg2 + ")");
+ if (mOnInfoListener != null) {
+ mOnInfoListener.onInfo(mMediaPlayer, msg.arg1, msg.arg2);
+ }
+ // No real default action so far.
+ return;
+
case MEDIA_NOP: // interface test message - ignore
break;
@@ -1165,12 +1168,19 @@ public class MediaPlayer
* @see android.media.MediaPlayer.OnErrorListener
*/
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.
* @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.
+ * @hide pending API council approval. Replace with @see tag after.
+ */
+ public static final int MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK = 200;
/**
* Interface definition of a callback to be invoked when there
@@ -1188,7 +1198,8 @@ public class MediaPlayer
* <li>{@link #MEDIA_ERROR_UNKNOWN}
* <li>{@link #MEDIA_ERROR_SERVER_DIED}
* </ul>
- * @param extra an extra code, specific to the error type
+ * @param extra an extra code, specific to the error. Typically
+ * implementation dependant.
* @return True if the method handled the error, false if it didn't.
* Returning false, or not having an OnErrorListener at all, will
* cause the OnCompletionListener to be called.
@@ -1200,12 +1211,83 @@ public class MediaPlayer
* Register a callback to be invoked when an error has happened
* during an asynchronous operation.
*
- * @param l the callback that will be run
+ * @param listener the callback that will be run
*/
- public void setOnErrorListener(OnErrorListener l)
+ public void setOnErrorListener(OnErrorListener listener)
{
- mOnErrorListener = l;
+ mOnErrorListener = listener;
}
private OnErrorListener mOnErrorListener;
+
+
+ /* Do not change these values without updating their counterparts
+ * in include/media/mediaplayer.h!
+ */
+ /** Unspecified media player info.
+ * @see android.media.MediaPlayer.OnInfoListener
+ * @hide pending API council approval.
+ */
+ public static final int MEDIA_INFO_UNKNOWN = 1;
+
+ /** The video is too complex for the decoder: it can't decode frames fast
+ * enough. Possibly only the audio plays fine at this stage.
+ * @see android.media.MediaPlayer.OnInfoListener
+ * @hide pending API council approval.
+ */
+ public static final int MEDIA_INFO_VIDEO_TRACK_LAGGING = 700;
+
+ /** Bad interleaving means that a media has been improperly interleaved or
+ * not interleaved at all, e.g has all the video samples first then all the
+ * audio ones. Video is playing but a lot of disk seeks may be happening.
+ * @see android.media.MediaPlayer.OnInfoListener
+ * @hide pending API council approval.
+ */
+ public static final int MEDIA_INFO_BAD_INTERLEAVING = 800;
+
+ /** The media cannot be seeked (e.g live stream)
+ * @see android.media.MediaPlayer.OnInfoListener
+ * @hide pending API council approval.
+ */
+ public static final int MEDIA_INFO_NOT_SEEKABLE = 801;
+
+ /**
+ * Interface definition of a callback to be invoked to communicate some
+ * info and/or warning about the media or its playback.
+ * @hide pending API council approval.
+ */
+ public interface OnInfoListener
+ {
+ /**
+ * 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>
+ * <li>{@link #MEDIA_INFO_UNKNOWN}
+ * <li>{@link #MEDIA_INFO_VIDEO_TRACK_LAGGING}
+ * <li>{@link #MEDIA_INFO_BAD_INTERLEAVING}
+ * <li>{@link #MEDIA_INFO_NOT_SEEKABLE}
+ * </ul>
+ * @param extra an extra code, specific to the info. Typically
+ * implementation dependant.
+ * @return True if the method handled the info, false if it didn't.
+ * Returning false, or not having an OnErrorListener at all, will
+ * cause the info to be discarded.
+ */
+ boolean onInfo(MediaPlayer mp, int what, int extra);
+ }
+
+ /**
+ * Register a callback to be invoked when an info/warning is available.
+ *
+ * @param listener the callback that will be run
+ * @hide pending API council approval.
+ */
+ public void setOnInfoListener(OnInfoListener listener)
+ {
+ mOnInfoListener = listener;
+ }
+
+ private OnInfoListener mOnInfoListener;
}
diff --git a/media/libmedia/mediaplayer.cpp b/media/libmedia/mediaplayer.cpp
index bd8579c..6b40412 100644
--- a/media/libmedia/mediaplayer.cpp
+++ b/media/libmedia/mediaplayer.cpp
@@ -215,6 +215,10 @@ status_t MediaPlayer::prepareAsync_l()
return INVALID_OPERATION;
}
+// TODO: In case of error, prepareAsync provides the caller with 2 error codes,
+// one defined in the Android framework and one provided by the implementation
+// that generated the error. The sync version of prepare returns only 1 error
+// code.
status_t MediaPlayer::prepare()
{
LOGV("prepare");
@@ -512,7 +516,9 @@ void MediaPlayer::notify(int msg, int ext1, int ext2)
}
break;
case MEDIA_ERROR:
- // Always log errors
+ // Always log errors.
+ // ext1: Media framework error code.
+ // ext2: Implementation dependant error code.
LOGE("error (%d, %d)", ext1, ext2);
mCurrentState = MEDIA_PLAYER_STATE_ERROR;
if (mPrepareSync)
@@ -524,6 +530,11 @@ void MediaPlayer::notify(int msg, int ext1, int ext2)
send = false;
}
break;
+ case MEDIA_INFO:
+ // ext1: Media framework error code.
+ // ext2: Implementation dependant error code.
+ LOGW("info/warning (%d, %d)", ext1, ext2);
+ break;
case MEDIA_SEEK_COMPLETE:
LOGV("Received seek complete");
if (mSeekPosition != mCurrentPosition) {
diff --git a/media/libmedia/mediarecorder.cpp b/media/libmedia/mediarecorder.cpp
index 5eba0ef..572b1e7 100644
--- a/media/libmedia/mediarecorder.cpp
+++ b/media/libmedia/mediarecorder.cpp
@@ -456,6 +456,11 @@ status_t MediaRecorder::stop()
mCurrentState = MEDIA_RECORDER_ERROR;
return ret;
}
+
+ // FIXME:
+ // stop and reset are semantically different.
+ // We treat them the same for now, and will change this in the future.
+ doCleanUp();
mCurrentState = MEDIA_RECORDER_IDLE;
return ret;
}