summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorTeng-Hui Zhu <ztenghui@google.com>2012-08-06 17:24:10 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-08-21 14:17:02 -0700
commit2253eeab6c0c20e0b03f144c5bc23ae13e8ab234 (patch)
tree07c555b02e8ed9d9a991e82970171618318cd3b0 /media
parent02df84a3b1b4f68044d981bb345515ae9419d0c1 (diff)
downloadframeworks_base-2253eeab6c0c20e0b03f144c5bc23ae13e8ab234.zip
frameworks_base-2253eeab6c0c20e0b03f144c5bc23ae13e8ab234.tar.gz
frameworks_base-2253eeab6c0c20e0b03f144c5bc23ae13e8ab234.tar.bz2
Add context support into the filter framework.
Basically we need the context to pass the content URI into MediaPlayer. bug:6837809 Change-Id: I9390b57baff06f80246584fb3a4b746e1a308ff2
Diffstat (limited to 'media')
-rw-r--r--media/mca/filterpacks/java/android/filterpacks/videosrc/MediaSource.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/media/mca/filterpacks/java/android/filterpacks/videosrc/MediaSource.java b/media/mca/filterpacks/java/android/filterpacks/videosrc/MediaSource.java
index 9c40cec..0be6c62 100644
--- a/media/mca/filterpacks/java/android/filterpacks/videosrc/MediaSource.java
+++ b/media/mca/filterpacks/java/android/filterpacks/videosrc/MediaSource.java
@@ -35,6 +35,7 @@ import android.filterfw.core.ShaderProgram;
import android.filterfw.format.ImageFormat;
import android.graphics.SurfaceTexture;
import android.media.MediaPlayer;
+import android.net.Uri;
import android.os.ConditionVariable;
import android.opengl.Matrix;
import android.view.Surface;
@@ -64,6 +65,12 @@ public class MediaSource extends Filter {
@GenerateFieldPort(name = "sourceAsset", hasDefault = true)
private AssetFileDescriptor mSourceAsset = null;
+ /** The context for the MediaPlayer to resolve the sourceUrl.
+ * Make sure this is set before the sourceUrl to avoid unexpected result.
+ * If the sourceUrl is not a content URI, it is OK to keep this as null. */
+ @GenerateFieldPort(name = "context", hasDefault = true)
+ private Context mContext = null;
+
/** Whether the media source is a URL or an asset file descriptor. Defaults
* to false.
*/
@@ -459,7 +466,11 @@ public class MediaSource extends Filter {
try {
if (useUrl) {
if (mLogVerbose) Log.v(TAG, "Setting MediaPlayer source to URI " + mSourceUrl);
- mMediaPlayer.setDataSource(mSourceUrl);
+ if (mContext == null) {
+ mMediaPlayer.setDataSource(mSourceUrl);
+ } else {
+ mMediaPlayer.setDataSource(mContext, Uri.parse(mSourceUrl.toString()));
+ }
} else {
if (mLogVerbose) Log.v(TAG, "Setting MediaPlayer source to asset " + mSourceAsset);
mMediaPlayer.setDataSource(mSourceAsset.getFileDescriptor(), mSourceAsset.getStartOffset(), mSourceAsset.getLength());