summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/AmrInputStream.java12
-rw-r--r--media/java/android/media/AudioRecord.java4
-rw-r--r--media/java/android/media/AudioTrack.java4
-rw-r--r--media/java/android/media/FaceDetector.java6
-rw-r--r--media/java/android/media/JetPlayer.java2
-rw-r--r--media/java/android/media/MediaCodec.java2
-rw-r--r--media/java/android/media/MediaCrypto.java2
-rw-r--r--media/java/android/media/MediaDrm.java186
-rw-r--r--media/java/android/media/MediaExtractor.java2
-rw-r--r--media/java/android/media/MediaMetadataRetriever.java2
-rw-r--r--media/java/android/media/MediaMuxer.java20
-rw-r--r--media/java/android/media/MediaPlayer.java4
-rw-r--r--media/java/android/media/MediaRecorder.java2
-rw-r--r--media/java/android/media/MediaRouter.java7
-rw-r--r--media/java/android/media/MediaScanner.java2
-rw-r--r--media/java/android/media/RemoteDisplay.java10
-rw-r--r--media/java/android/media/Ringtone.java6
-rw-r--r--media/java/android/media/SoundPool.java2
-rw-r--r--media/java/android/media/ToneGenerator.java2
-rw-r--r--media/java/android/media/audiofx/AudioEffect.java4
-rw-r--r--media/java/android/media/audiofx/Visualizer.java4
-rw-r--r--media/java/android/media/videoeditor/MediaArtistNativeHelper.java2
-rwxr-xr-xmedia/java/android/mtp/MtpDatabase.java2
-rw-r--r--media/java/android/mtp/MtpDevice.java2
-rw-r--r--media/java/android/mtp/MtpServer.java2
-rw-r--r--media/jni/android_media_AmrInputStream.cpp28
-rw-r--r--media/jni/android_media_MediaCodec.cpp12
-rw-r--r--media/jni/android_media_MediaCrypto.cpp20
-rw-r--r--media/jni/android_media_MediaDrm.cpp135
-rw-r--r--media/jni/android_media_MediaExtractor.cpp70
-rw-r--r--media/jni/android_media_MediaMetadataRetriever.cpp22
-rw-r--r--media/jni/android_media_MediaMuxer.cpp35
-rw-r--r--media/jni/android_media_MediaPlayer.cpp85
-rw-r--r--media/jni/android_media_MediaProfiles.cpp16
-rw-r--r--media/jni/android_media_MediaRecorder.cpp12
-rw-r--r--media/jni/android_media_MediaScanner.cpp8
-rw-r--r--media/jni/android_mtp_MtpDatabase.cpp10
-rw-r--r--media/jni/android_mtp_MtpDevice.cpp31
-rw-r--r--media/jni/android_mtp_MtpServer.cpp8
-rw-r--r--media/jni/audioeffect/android_media_AudioEffect.cpp64
-rw-r--r--media/jni/audioeffect/android_media_Visualizer.cpp50
-rw-r--r--media/jni/mediaeditor/VideoEditorClasses.cpp16
-rw-r--r--media/jni/mediaeditor/VideoEditorMain.cpp56
-rw-r--r--media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp38
-rw-r--r--media/lib/remotedisplay/Android.mk (renamed from media/lib/Android.mk)4
-rw-r--r--media/lib/remotedisplay/README.txt (renamed from media/lib/README.txt)1
-rw-r--r--media/lib/remotedisplay/com.android.media.remotedisplay.xml (renamed from media/lib/com.android.media.remotedisplay.xml)0
-rw-r--r--media/lib/remotedisplay/java/com/android/media/remotedisplay/RemoteDisplay.java (renamed from media/lib/java/com/android/media/remotedisplay/RemoteDisplay.java)8
-rw-r--r--media/lib/remotedisplay/java/com/android/media/remotedisplay/RemoteDisplayProvider.java (renamed from media/lib/java/com/android/media/remotedisplay/RemoteDisplayProvider.java)0
-rw-r--r--media/lib/signer/Android.mk45
-rw-r--r--media/lib/signer/README.txt28
-rw-r--r--media/lib/signer/com.android.mediadrm.signer.xml20
-rw-r--r--media/lib/signer/java/com/android/mediadrm/signer/MediaDrmSigner.java137
-rw-r--r--media/mca/filterfw/jni/jni_gl_environment.cpp4
54 files changed, 861 insertions, 395 deletions
diff --git a/media/java/android/media/AmrInputStream.java b/media/java/android/media/AmrInputStream.java
index 8b7eee2..e2115e4 100644
--- a/media/java/android/media/AmrInputStream.java
+++ b/media/java/android/media/AmrInputStream.java
@@ -41,7 +41,7 @@ public final class AmrInputStream extends InputStream
private InputStream mInputStream;
// native handle
- private int mGae;
+ private long mGae;
// result amr stream
private final byte[] mBuf = new byte[SAMPLES_PER_FRAME * 2];
@@ -130,11 +130,11 @@ public final class AmrInputStream extends InputStream
//
// AudioRecord JNI interface
//
- private static native int GsmAmrEncoderNew();
- private static native void GsmAmrEncoderInitialize(int gae);
- private static native int GsmAmrEncoderEncode(int gae,
+ private static native long GsmAmrEncoderNew();
+ private static native void GsmAmrEncoderInitialize(long gae);
+ private static native int GsmAmrEncoderEncode(long gae,
byte[] pcm, int pcmOffset, byte[] amr, int amrOffset) throws IOException;
- private static native void GsmAmrEncoderCleanup(int gae);
- private static native void GsmAmrEncoderDelete(int gae);
+ private static native void GsmAmrEncoderCleanup(long gae);
+ private static native void GsmAmrEncoderDelete(long gae);
}
diff --git a/media/java/android/media/AudioRecord.java b/media/java/android/media/AudioRecord.java
index f49ef2e..461b52f 100644
--- a/media/java/android/media/AudioRecord.java
+++ b/media/java/android/media/AudioRecord.java
@@ -107,13 +107,13 @@ public class AudioRecord
* Accessed by native methods: provides access to C++ AudioRecord object
*/
@SuppressWarnings("unused")
- private int mNativeRecorderInJavaObj;
+ private long mNativeRecorderInJavaObj;
/**
* Accessed by native methods: provides access to the callback data.
*/
@SuppressWarnings("unused")
- private int mNativeCallbackCookie;
+ private long mNativeCallbackCookie;
//---------------------------------------------------------
diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java
index 78a37c5..01a6fc2 100644
--- a/media/java/android/media/AudioTrack.java
+++ b/media/java/android/media/AudioTrack.java
@@ -221,13 +221,13 @@ public class AudioTrack
* Accessed by native methods: provides access to C++ AudioTrack object.
*/
@SuppressWarnings("unused")
- private int mNativeTrackInJavaObj;
+ private long mNativeTrackInJavaObj;
/**
* Accessed by native methods: provides access to the JNI data (i.e. resources used by
* the native AudioTrack object, but not stored in it).
*/
@SuppressWarnings("unused")
- private int mJniData;
+ private long mJniData;
//--------------------------------------------------------------------------
diff --git a/media/java/android/media/FaceDetector.java b/media/java/android/media/FaceDetector.java
index cf900ce..61991e3 100644
--- a/media/java/android/media/FaceDetector.java
+++ b/media/java/android/media/FaceDetector.java
@@ -191,9 +191,9 @@ public class FaceDetector {
native private void fft_get_face(Face face, int i);
native private void fft_destroy();
- private int mFD;
- private int mSDK;
- private int mDCR;
+ private long mFD;
+ private long mSDK;
+ private long mDCR;
private int mWidth;
private int mHeight;
private int mMaxFaces;
diff --git a/media/java/android/media/JetPlayer.java b/media/java/android/media/JetPlayer.java
index 06cda34..bd91fc5 100644
--- a/media/java/android/media/JetPlayer.java
+++ b/media/java/android/media/JetPlayer.java
@@ -127,7 +127,7 @@ public class JetPlayer
* Accessed by native methods: provides access to C++ JetPlayer object
*/
@SuppressWarnings("unused")
- private int mNativePlayerInJavaObj;
+ private long mNativePlayerInJavaObj;
//--------------------------------------------
diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java
index 5175830..ddf88df 100644
--- a/media/java/android/media/MediaCodec.java
+++ b/media/java/android/media/MediaCodec.java
@@ -644,5 +644,5 @@ final public class MediaCodec {
native_init();
}
- private int mNativeContext;
+ private long mNativeContext;
}
diff --git a/media/java/android/media/MediaCrypto.java b/media/java/android/media/MediaCrypto.java
index 40a1326..c7c3fc2 100644
--- a/media/java/android/media/MediaCrypto.java
+++ b/media/java/android/media/MediaCrypto.java
@@ -88,5 +88,5 @@ public final class MediaCrypto {
native_init();
}
- private int mNativeContext;
+ private long mNativeContext;
}
diff --git a/media/java/android/media/MediaDrm.java b/media/java/android/media/MediaDrm.java
index 6b278d4..532e39a 100644
--- a/media/java/android/media/MediaDrm.java
+++ b/media/java/android/media/MediaDrm.java
@@ -21,6 +21,8 @@ import java.lang.ref.WeakReference;
import java.util.UUID;
import java.util.HashMap;
import java.util.List;
+import android.os.Binder;
+import android.os.Debug;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -97,10 +99,26 @@ public final class MediaDrm {
private final static String TAG = "MediaDrm";
+ private static final String PERMISSION = android.Manifest.permission.ACCESS_DRM_CERTIFICATES;
+
private EventHandler mEventHandler;
private OnEventListener mOnEventListener;
- private int mNativeContext;
+ private long mNativeContext;
+
+ /**
+ * Specify no certificate type
+ *
+ * @hide - not part of the public API at this time
+ */
+ public static final int CERTIFICATE_TYPE_NONE = 0;
+
+ /**
+ * Specify X.509 certificate type
+ *
+ * @hide - not part of the public API at this time
+ */
+ public static final int CERTIFICATE_TYPE_X509 = 1;
/**
* Query if the given scheme identified by its UUID is supported on
@@ -137,7 +155,7 @@ public final class MediaDrm {
}
private static final native boolean isCryptoSchemeSupportedNative(byte[] uuid,
- String mimeType);
+ String mimeType);
/**
* Instantiate a MediaDrm object
@@ -161,7 +179,7 @@ public final class MediaDrm {
* It's easier to create it here than in C++.
*/
native_setup(new WeakReference<MediaDrm>(this),
- getByteArrayFromUUID(uuid));
+ getByteArrayFromUUID(uuid));
}
/**
@@ -270,7 +288,7 @@ public final class MediaDrm {
* the cookie passed to native_setup().)
*/
private static void postEventFromNative(Object mediadrm_ref,
- int eventType, int extra, Object obj)
+ int eventType, int extra, Object obj)
{
MediaDrm md = (MediaDrm)((WeakReference)mediadrm_ref).get();
if (md == null) {
@@ -318,6 +336,9 @@ public final class MediaDrm {
* Contains the opaque data an app uses to request keys from a license server
*/
public final static class KeyRequest {
+ private byte[] mData;
+ private String mDefaultUrl;
+
KeyRequest() {}
/**
@@ -331,9 +352,6 @@ public final class MediaDrm {
* server URL from other sources.
*/
public String getDefaultUrl() { return mDefaultUrl; }
-
- private byte[] mData;
- private String mDefaultUrl;
};
/**
@@ -370,9 +388,8 @@ public final class MediaDrm {
* problem with the certifcate
*/
public native KeyRequest getKeyRequest(byte[] scope, byte[] init,
- String mimeType, int keyType,
- HashMap<String, String> optionalParameters)
- throws NotProvisionedException;
+ String mimeType, int keyType, HashMap<String, String> optionalParameters)
+ throws NotProvisionedException;
/**
@@ -396,7 +413,7 @@ public final class MediaDrm {
* @throws ResourceBusyException if required resources are in use
*/
public native byte[] provideKeyResponse(byte[] scope, byte[] response)
- throws NotProvisionedException, DeniedByServerException;
+ throws NotProvisionedException, DeniedByServerException;
/**
@@ -458,7 +475,12 @@ public final class MediaDrm {
* is returned in ProvisionRequest.data. The recommended URL to deliver the provision
* request to is returned in ProvisionRequest.defaultUrl.
*/
- public native ProvisionRequest getProvisionRequest();
+ public ProvisionRequest getProvisionRequest() {
+ return getProvisionRequestNative(CERTIFICATE_TYPE_NONE, "");
+ }
+
+ private native ProvisionRequest getProvisionRequestNative(int certType,
+ String certAuthority);
/**
* After a provision response is received by the app, it is provided to the DRM
@@ -470,8 +492,13 @@ public final class MediaDrm {
* @throws DeniedByServerException if the response indicates that the
* server rejected the request
*/
- public native void provideProvisionResponse(byte[] response)
- throws DeniedByServerException;
+ public void provideProvisionResponse(byte[] response)
+ throws DeniedByServerException {
+ provideProvisionResponseNative(response);
+ }
+
+ private native Certificate provideProvisionResponseNative(byte[] response)
+ throws DeniedByServerException;
/**
* A means of enforcing limits on the number of concurrent streams per subscriber
@@ -558,23 +585,22 @@ public final class MediaDrm {
private static final native void setCipherAlgorithmNative(MediaDrm drm, byte[] sessionId,
- String algorithm);
+ String algorithm);
private static final native void setMacAlgorithmNative(MediaDrm drm, byte[] sessionId,
- String algorithm);
+ String algorithm);
private static final native byte[] encryptNative(MediaDrm drm, byte[] sessionId,
- byte[] keyId, byte[] input, byte[] iv);
+ byte[] keyId, byte[] input, byte[] iv);
private static final native byte[] decryptNative(MediaDrm drm, byte[] sessionId,
- byte[] keyId, byte[] input, byte[] iv);
+ byte[] keyId, byte[] input, byte[] iv);
private static final native byte[] signNative(MediaDrm drm, byte[] sessionId,
- byte[] keyId, byte[] message);
+ byte[] keyId, byte[] message);
private static final native boolean verifyNative(MediaDrm drm, byte[] sessionId,
- byte[] keyId, byte[] message,
- byte[] signature);
+ byte[] keyId, byte[] message, byte[] signature);
/**
* In addition to supporting decryption of DASH Common Encrypted Media, the
@@ -604,7 +630,7 @@ public final class MediaDrm {
private byte[] mSessionId;
CryptoSession(MediaDrm drm, byte[] sessionId,
- String cipherAlgorithm, String macAlgorithm)
+ String cipherAlgorithm, String macAlgorithm)
{
mSessionId = sessionId;
mDrm = drm;
@@ -679,12 +705,124 @@ public final class MediaDrm {
* "algorithms".
*/
public CryptoSession getCryptoSession(byte[] sessionId,
- String cipherAlgorithm,
- String macAlgorithm)
+ String cipherAlgorithm, String macAlgorithm)
{
return new CryptoSession(this, sessionId, cipherAlgorithm, macAlgorithm);
}
+ /**
+ * Contains the opaque data an app uses to request a certificate from a provisioning
+ * server
+ *
+ * @hide - not part of the public API at this time
+ */
+ public final static class CertificateRequest {
+ private byte[] mData;
+ private String mDefaultUrl;
+
+ CertificateRequest(byte[] data, String defaultUrl) {
+ mData = data;
+ mDefaultUrl = defaultUrl;
+ }
+
+ /**
+ * Get the opaque message data
+ */
+ public byte[] getData() { return mData; }
+
+ /**
+ * Get the default URL to use when sending the certificate request
+ * message to a server, if known. The app may prefer to use a different
+ * certificate server URL obtained from other sources.
+ */
+ public String getDefaultUrl() { return mDefaultUrl; }
+ }
+
+ /**
+ * Generate a certificate request, specifying the certificate type
+ * and authority. The response received should be passed to
+ * provideCertificateResponse.
+ *
+ * @param certType Specifies the certificate type.
+ *
+ * @param certAuthority is passed to the certificate server to specify
+ * the chain of authority.
+ *
+ * @hide - not part of the public API at this time
+ */
+ public CertificateRequest getCertificateRequest(int certType,
+ String certAuthority)
+ {
+ ProvisionRequest provisionRequest = getProvisionRequestNative(certType, certAuthority);
+ return new CertificateRequest(provisionRequest.getData(),
+ provisionRequest.getDefaultUrl());
+ }
+
+ /**
+ * Contains the wrapped private key and public certificate data associated
+ * with a certificate.
+ *
+ * @hide - not part of the public API at this time
+ */
+ public final static class Certificate {
+ Certificate() {}
+
+ /**
+ * Get the wrapped private key data
+ */
+ public byte[] getWrappedPrivateKey() { return mWrappedKey; }
+
+ /**
+ * Get the PEM-encoded certificate chain
+ */
+ public byte[] getContent() { return mCertificateData; }
+
+ private byte[] mWrappedKey;
+ private byte[] mCertificateData;
+ }
+
+
+ /**
+ * Process a response from the certificate server. The response
+ * is obtained from an HTTP Post to the url provided by getCertificateRequest.
+ * <p>
+ * The public X509 certificate chain and wrapped private key are returned
+ * in the returned Certificate objec. The certificate chain is in PEM format.
+ * The wrapped private key should be stored in application private
+ * storage, and used when invoking the signRSA method.
+ *
+ * @param response the opaque certificate response byte array to provide to the
+ * DRM engine plugin.
+ *
+ * @throws DeniedByServerException if the response indicates that the
+ * server rejected the request
+ *
+ * @hide - not part of the public API at this time
+ */
+ public Certificate provideCertificateResponse(byte[] response)
+ throws DeniedByServerException {
+ return provideProvisionResponseNative(response);
+ }
+
+ private static final native byte[] signRSANative(MediaDrm drm, byte[] sessionId,
+ String algorithm, byte[] wrappedKey, byte[] message);
+
+ /**
+ * Sign data using an RSA key
+ *
+ * @param sessionId a sessionId obtained from openSession on the MediaDrm object
+ * @param algorithm the signing algorithm to use, e.g. "PKCS1-BlockType1"
+ * @param wrappedKey - the wrapped (encrypted) RSA private key obtained
+ * from provideCertificateResponse
+ * @param message the data for which a signature is to be computed
+ *
+ * @hide - not part of the public API at this time
+ */
+ public byte[] signRSA(byte[] sessionId, String algorithm,
+ byte[] wrappedKey, byte[] message) {
+ return signRSANative(this, sessionId, algorithm, wrappedKey, message);
+ }
+
@Override
protected void finalize() {
native_finalize();
diff --git a/media/java/android/media/MediaExtractor.java b/media/java/android/media/MediaExtractor.java
index e558c07..c3e5035 100644
--- a/media/java/android/media/MediaExtractor.java
+++ b/media/java/android/media/MediaExtractor.java
@@ -352,5 +352,5 @@ final public class MediaExtractor {
native_init();
}
- private int mNativeContext;
+ private long mNativeContext;
}
diff --git a/media/java/android/media/MediaMetadataRetriever.java b/media/java/android/media/MediaMetadataRetriever.java
index 9014453..db27d09 100644
--- a/media/java/android/media/MediaMetadataRetriever.java
+++ b/media/java/android/media/MediaMetadataRetriever.java
@@ -42,7 +42,7 @@ public class MediaMetadataRetriever
// The field below is accessed by native methods
@SuppressWarnings("unused")
- private int mNativeContext;
+ private long mNativeContext;
private static final int EMBEDDED_PICTURE_TYPE_ANY = 0xFFFF;
diff --git a/media/java/android/media/MediaMuxer.java b/media/java/android/media/MediaMuxer.java
index 65a9308..e5c97e7 100644
--- a/media/java/android/media/MediaMuxer.java
+++ b/media/java/android/media/MediaMuxer.java
@@ -65,8 +65,6 @@ import java.util.Map;
final public class MediaMuxer {
- private int mNativeContext;
-
static {
System.loadLibrary("media_jni");
}
@@ -84,16 +82,16 @@ final public class MediaMuxer {
};
// All the native functions are listed here.
- private static native int nativeSetup(FileDescriptor fd, int format);
- private static native void nativeRelease(int nativeObject);
- private static native void nativeStart(int nativeObject);
- private static native void nativeStop(int nativeObject);
- private static native int nativeAddTrack(int nativeObject, String[] keys,
+ private static native long nativeSetup(FileDescriptor fd, int format);
+ private static native void nativeRelease(long nativeObject);
+ private static native void nativeStart(long nativeObject);
+ private static native void nativeStop(long nativeObject);
+ private static native int nativeAddTrack(long nativeObject, String[] keys,
Object[] values);
- private static native void nativeSetOrientationHint(int nativeObject,
+ private static native void nativeSetOrientationHint(long nativeObject,
int degrees);
- private static native void nativeSetLocation(int nativeObject, int latitude, int longitude);
- private static native void nativeWriteSampleData(int nativeObject,
+ private static native void nativeSetLocation(long nativeObject, int latitude, int longitude);
+ private static native void nativeWriteSampleData(long nativeObject,
int trackIndex, ByteBuffer byteBuf,
int offset, int size, long presentationTimeUs, int flags);
@@ -108,7 +106,7 @@ final public class MediaMuxer {
private final CloseGuard mCloseGuard = CloseGuard.get();
private int mLastTrackIndex = -1;
- private int mNativeObject;
+ private long mNativeObject;
/**
* Constructor.
diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java
index 2c16b5e..41ba5d6 100644
--- a/media/java/android/media/MediaPlayer.java
+++ b/media/java/android/media/MediaPlayer.java
@@ -572,8 +572,8 @@ public class MediaPlayer implements SubtitleController.Listener
// macro invocation in IMediaPlayer.cpp
private final static String IMEDIA_PLAYER = "android.media.IMediaPlayer";
- private int mNativeContext; // accessed by native methods
- private int mNativeSurfaceTexture; // accessed by native methods
+ private long mNativeContext; // accessed by native methods
+ private long mNativeSurfaceTexture; // accessed by native methods
private int mListenerContext; // accessed by native methods
private SurfaceHolder mSurfaceHolder;
private EventHandler mEventHandler;
diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java
index 8dcbd6b..5a9d577 100644
--- a/media/java/android/media/MediaRecorder.java
+++ b/media/java/android/media/MediaRecorder.java
@@ -81,7 +81,7 @@ public class MediaRecorder
// The two fields below are accessed by native methods
@SuppressWarnings("unused")
- private int mNativeContext;
+ private long mNativeContext;
@SuppressWarnings("unused")
private Surface mSurface;
diff --git a/media/java/android/media/MediaRouter.java b/media/java/android/media/MediaRouter.java
index de20227..a4d491d8 100644
--- a/media/java/android/media/MediaRouter.java
+++ b/media/java/android/media/MediaRouter.java
@@ -16,8 +16,6 @@
package android.media;
-import com.android.internal.util.Objects;
-
import android.Manifest;
import android.app.ActivityThread;
import android.content.BroadcastReceiver;
@@ -43,6 +41,7 @@ import android.view.Display;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.Objects;
import java.util.concurrent.CopyOnWriteArrayList;
/**
@@ -493,11 +492,11 @@ public class MediaRouter {
boolean volumeChanged = false;
boolean presentationDisplayChanged = false;
- if (!Objects.equal(route.mName, globalRoute.name)) {
+ if (!Objects.equals(route.mName, globalRoute.name)) {
route.mName = globalRoute.name;
changed = true;
}
- if (!Objects.equal(route.mDescription, globalRoute.description)) {
+ if (!Objects.equals(route.mDescription, globalRoute.description)) {
route.mDescription = globalRoute.description;
changed = true;
}
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java
index de3041e..53835e2 100644
--- a/media/java/android/media/MediaScanner.java
+++ b/media/java/android/media/MediaScanner.java
@@ -301,7 +301,7 @@ public class MediaScanner
// 148 and up don't seem to have been defined yet.
};
- private int mNativeContext;
+ private long mNativeContext;
private Context mContext;
private String mPackageName;
private IContentProvider mMediaProvider;
diff --git a/media/java/android/media/RemoteDisplay.java b/media/java/android/media/RemoteDisplay.java
index 7afce1a..4e937a5 100644
--- a/media/java/android/media/RemoteDisplay.java
+++ b/media/java/android/media/RemoteDisplay.java
@@ -38,12 +38,12 @@ public final class RemoteDisplay {
private final Listener mListener;
private final Handler mHandler;
- private int mPtr;
+ private long mPtr;
- private native int nativeListen(String iface);
- private native void nativeDispose(int ptr);
- private native void nativePause(int ptr);
- private native void nativeResume(int ptr);
+ private native long nativeListen(String iface);
+ private native void nativeDispose(long ptr);
+ private native void nativePause(long ptr);
+ private native void nativeResume(long ptr);
private RemoteDisplay(Listener listener, Handler handler) {
mListener = listener;
diff --git a/media/java/android/media/Ringtone.java b/media/java/android/media/Ringtone.java
index 1283e9b..2616b6c 100644
--- a/media/java/android/media/Ringtone.java
+++ b/media/java/android/media/Ringtone.java
@@ -217,7 +217,7 @@ public class Ringtone {
if (mAudioManager.getStreamVolume(mStreamType) != 0) {
mLocalPlayer.start();
}
- } else if (mAllowRemote) {
+ } else if (mAllowRemote && (mRemotePlayer != null)) {
final Uri canonicalUri = mUri.getCanonicalUri();
try {
mRemotePlayer.play(mRemoteToken, canonicalUri, mStreamType);
@@ -239,7 +239,7 @@ public class Ringtone {
public void stop() {
if (mLocalPlayer != null) {
destroyLocalPlayer();
- } else if (mAllowRemote) {
+ } else if (mAllowRemote && (mRemotePlayer != null)) {
try {
mRemotePlayer.stop(mRemoteToken);
} catch (RemoteException e) {
@@ -264,7 +264,7 @@ public class Ringtone {
public boolean isPlaying() {
if (mLocalPlayer != null) {
return mLocalPlayer.isPlaying();
- } else if (mAllowRemote) {
+ } else if (mAllowRemote && (mRemotePlayer != null)) {
try {
return mRemotePlayer.isPlaying(mRemoteToken);
} catch (RemoteException e) {
diff --git a/media/java/android/media/SoundPool.java b/media/java/android/media/SoundPool.java
index 06af5de..fbfc574 100644
--- a/media/java/android/media/SoundPool.java
+++ b/media/java/android/media/SoundPool.java
@@ -443,7 +443,7 @@ public class SoundPool {
private final static String TAG = "SoundPool";
private final static boolean DEBUG = false;
- private int mNativeContext; // accessed by native methods
+ private long mNativeContext; // accessed by native methods
private EventHandler mEventHandler;
private SoundPool.OnLoadCompleteListener mOnLoadCompleteListener;
diff --git a/media/java/android/media/ToneGenerator.java b/media/java/android/media/ToneGenerator.java
index 5592105..713f147 100644
--- a/media/java/android/media/ToneGenerator.java
+++ b/media/java/android/media/ToneGenerator.java
@@ -887,5 +887,5 @@ public class ToneGenerator
protected void finalize() { native_finalize(); }
@SuppressWarnings("unused")
- private int mNativeContext; // accessed by native methods
+ private long mNativeContext; // accessed by native methods
}
diff --git a/media/java/android/media/audiofx/AudioEffect.java b/media/java/android/media/audiofx/AudioEffect.java
index 1e1ef8c..cc121a3 100644
--- a/media/java/android/media/audiofx/AudioEffect.java
+++ b/media/java/android/media/audiofx/AudioEffect.java
@@ -315,8 +315,8 @@ public class AudioEffect {
private int mId;
// accessed by native methods
- private int mNativeAudioEffect;
- private int mJniData;
+ private long mNativeAudioEffect;
+ private long mJniData;
/**
* Effect descriptor
diff --git a/media/java/android/media/audiofx/Visualizer.java b/media/java/android/media/audiofx/Visualizer.java
index fb7f718..ff04201 100644
--- a/media/java/android/media/audiofx/Visualizer.java
+++ b/media/java/android/media/audiofx/Visualizer.java
@@ -184,8 +184,8 @@ public class Visualizer {
private OnServerDiedListener mServerDiedListener = null;
// accessed by native methods
- private int mNativeVisualizer;
- private int mJniData;
+ private long mNativeVisualizer;
+ private long mJniData;
//--------------------------------------------------------------------------
// Constructor, Finalize
diff --git a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
index f4fccbe..2b0b3e2 100644
--- a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
+++ b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
@@ -118,7 +118,7 @@ class MediaArtistNativeHelper {
private boolean mErrorFlagSet = false;
@SuppressWarnings("unused")
- private int mManualEditContext;
+ private long mManualEditContext;
/* Listeners */
diff --git a/media/java/android/mtp/MtpDatabase.java b/media/java/android/mtp/MtpDatabase.java
index cf1238a..9ceefc3 100755
--- a/media/java/android/mtp/MtpDatabase.java
+++ b/media/java/android/mtp/MtpDatabase.java
@@ -1036,7 +1036,7 @@ public class MtpDatabase {
}
// used by the JNI code
- private int mNativeContext;
+ private long mNativeContext;
private native final void native_setup();
private native final void native_finalize();
diff --git a/media/java/android/mtp/MtpDevice.java b/media/java/android/mtp/MtpDevice.java
index 3272fed..8310579 100644
--- a/media/java/android/mtp/MtpDevice.java
+++ b/media/java/android/mtp/MtpDevice.java
@@ -237,7 +237,7 @@ public final class MtpDevice {
}
// used by the JNI code
- private int mNativeContext;
+ private long mNativeContext;
private native boolean native_open(String deviceName, int fd);
private native void native_close();
diff --git a/media/java/android/mtp/MtpServer.java b/media/java/android/mtp/MtpServer.java
index f561cc0..266f78e 100644
--- a/media/java/android/mtp/MtpServer.java
+++ b/media/java/android/mtp/MtpServer.java
@@ -22,7 +22,7 @@ package android.mtp;
*/
public class MtpServer implements Runnable {
- private int mNativeContext; // accessed by native methods
+ private long mNativeContext; // accessed by native methods
static {
System.loadLibrary("media_jni");
diff --git a/media/jni/android_media_AmrInputStream.cpp b/media/jni/android_media_AmrInputStream.cpp
index b5220fe..3df6530 100644
--- a/media/jni/android_media_AmrInputStream.cpp
+++ b/media/jni/android_media_AmrInputStream.cpp
@@ -49,17 +49,17 @@ struct GsmAmrEncoderState {
int32_t mLastModeUsed;
};
-static jint android_media_AmrInputStream_GsmAmrEncoderNew
+static jlong android_media_AmrInputStream_GsmAmrEncoderNew
(JNIEnv *env, jclass clazz) {
GsmAmrEncoderState* gae = new GsmAmrEncoderState();
if (gae == NULL) {
jniThrowRuntimeException(env, "Out of memory");
}
- return (jint)gae;
+ return (jlong)gae;
}
static void android_media_AmrInputStream_GsmAmrEncoderInitialize
- (JNIEnv *env, jclass clazz, jint gae) {
+ (JNIEnv *env, jclass clazz, jlong gae) {
GsmAmrEncoderState *state = (GsmAmrEncoderState *) gae;
int32_t nResult = AMREncodeInit(&state->mEncState, &state->mSidState, false);
if (nResult != OK) {
@@ -70,7 +70,7 @@ static void android_media_AmrInputStream_GsmAmrEncoderInitialize
static jint android_media_AmrInputStream_GsmAmrEncoderEncode
(JNIEnv *env, jclass clazz,
- jint gae, jbyteArray pcm, jint pcmOffset, jbyteArray amr, jint amrOffset) {
+ jlong gae, jbyteArray pcm, jint pcmOffset, jbyteArray amr, jint amrOffset) {
jbyte inBuf[BYTES_PER_FRAME];
jbyte outBuf[MAX_OUTPUT_BUFFER_SIZE];
@@ -86,7 +86,7 @@ static jint android_media_AmrInputStream_GsmAmrEncoderEncode
if (length < 0) {
jniThrowExceptionFmt(env, "java/io/IOException",
"Failed to encode a frame with error code: %d", length);
- return -1;
+ return (jint)-1;
}
// The 1st byte of PV AMR frames are WMF (Wireless Multimedia Forum)
@@ -101,30 +101,30 @@ static jint android_media_AmrInputStream_GsmAmrEncoderEncode
env->SetByteArrayRegion(amr, amrOffset, length, outBuf);
- return length;
+ return (jint)length;
}
static void android_media_AmrInputStream_GsmAmrEncoderCleanup
- (JNIEnv *env, jclass clazz, jint gae) {
- GsmAmrEncoderState *state = (GsmAmrEncoderState *)gae;
+ (JNIEnv *env, jclass clazz, jlong gae) {
+ GsmAmrEncoderState *state = (GsmAmrEncoderState *) gae;
AMREncodeExit(&state->mEncState, &state->mSidState);
state->mEncState = NULL;
state->mSidState = NULL;
}
static void android_media_AmrInputStream_GsmAmrEncoderDelete
- (JNIEnv *env, jclass clazz, jint gae) {
+ (JNIEnv *env, jclass clazz, jlong gae) {
delete (GsmAmrEncoderState*)gae;
}
// ----------------------------------------------------------------------------
static JNINativeMethod gMethods[] = {
- {"GsmAmrEncoderNew", "()I", (void*)android_media_AmrInputStream_GsmAmrEncoderNew},
- {"GsmAmrEncoderInitialize", "(I)V", (void*)android_media_AmrInputStream_GsmAmrEncoderInitialize},
- {"GsmAmrEncoderEncode", "(I[BI[BI)I", (void*)android_media_AmrInputStream_GsmAmrEncoderEncode},
- {"GsmAmrEncoderCleanup", "(I)V", (void*)android_media_AmrInputStream_GsmAmrEncoderCleanup},
- {"GsmAmrEncoderDelete", "(I)V", (void*)android_media_AmrInputStream_GsmAmrEncoderDelete},
+ {"GsmAmrEncoderNew", "()J", (void*)android_media_AmrInputStream_GsmAmrEncoderNew},
+ {"GsmAmrEncoderInitialize", "(J)V", (void*)android_media_AmrInputStream_GsmAmrEncoderInitialize},
+ {"GsmAmrEncoderEncode", "(J[BI[BI)I", (void*)android_media_AmrInputStream_GsmAmrEncoderEncode},
+ {"GsmAmrEncoderCleanup", "(J)V", (void*)android_media_AmrInputStream_GsmAmrEncoderCleanup},
+ {"GsmAmrEncoderDelete", "(J)V", (void*)android_media_AmrInputStream_GsmAmrEncoderDelete},
};
diff --git a/media/jni/android_media_MediaCodec.cpp b/media/jni/android_media_MediaCodec.cpp
index b8d437c..221ea57 100644
--- a/media/jni/android_media_MediaCodec.cpp
+++ b/media/jni/android_media_MediaCodec.cpp
@@ -328,20 +328,20 @@ using namespace android;
static sp<JMediaCodec> setMediaCodec(
JNIEnv *env, jobject thiz, const sp<JMediaCodec> &codec) {
- sp<JMediaCodec> old = (JMediaCodec *)env->GetIntField(thiz, gFields.context);
+ sp<JMediaCodec> old = (JMediaCodec *)env->GetLongField(thiz, gFields.context);
if (codec != NULL) {
codec->incStrong(thiz);
}
if (old != NULL) {
old->decStrong(thiz);
}
- env->SetIntField(thiz, gFields.context, (int)codec.get());
+ env->SetLongField(thiz, gFields.context, (jlong)codec.get());
return old;
}
static sp<JMediaCodec> getMediaCodec(JNIEnv *env, jobject thiz) {
- return (JMediaCodec *)env->GetIntField(thiz, gFields.context);
+ return (JMediaCodec *)env->GetLongField(thiz, gFields.context);
}
static void android_media_MediaCodec_release(JNIEnv *env, jobject thiz) {
@@ -710,7 +710,7 @@ static jint android_media_MediaCodec_dequeueInputBuffer(
status_t err = codec->dequeueInputBuffer(&index, timeoutUs);
if (err == OK) {
- return index;
+ return (jint) index;
}
return throwExceptionAsNecessary(env, err);
@@ -732,7 +732,7 @@ static jint android_media_MediaCodec_dequeueOutputBuffer(
env, bufferInfo, &index, timeoutUs);
if (err == OK) {
- return index;
+ return (jint) index;
}
return throwExceptionAsNecessary(env, err);
@@ -885,7 +885,7 @@ static void android_media_MediaCodec_native_init(JNIEnv *env) {
env, env->FindClass("android/media/MediaCodec"));
CHECK(clazz.get() != NULL);
- gFields.context = env->GetFieldID(clazz.get(), "mNativeContext", "I");
+ gFields.context = env->GetFieldID(clazz.get(), "mNativeContext", "J");
CHECK(gFields.context != NULL);
clazz.reset(env->FindClass("android/media/MediaCodec$CryptoInfo"));
diff --git a/media/jni/android_media_MediaCrypto.cpp b/media/jni/android_media_MediaCrypto.cpp
index d0f56ea..a6f8dcd 100644
--- a/media/jni/android_media_MediaCrypto.cpp
+++ b/media/jni/android_media_MediaCrypto.cpp
@@ -38,7 +38,7 @@ struct fields_t {
static fields_t gFields;
static sp<JCrypto> getCrypto(JNIEnv *env, jobject thiz) {
- return (JCrypto *)env->GetIntField(thiz, gFields.context);
+ return (JCrypto *)env->GetLongField(thiz, gFields.context);
}
JCrypto::JCrypto(
@@ -146,14 +146,14 @@ using namespace android;
static sp<JCrypto> setCrypto(
JNIEnv *env, jobject thiz, const sp<JCrypto> &crypto) {
- sp<JCrypto> old = (JCrypto *)env->GetIntField(thiz, gFields.context);
+ sp<JCrypto> old = (JCrypto *)env->GetLongField(thiz, gFields.context);
if (crypto != NULL) {
crypto->incStrong(thiz);
}
if (old != NULL) {
old->decStrong(thiz);
}
- env->SetIntField(thiz, gFields.context, (int)crypto.get());
+ env->SetLongField(thiz, gFields.context, (jlong)crypto.get());
return old;
}
@@ -166,7 +166,7 @@ static void android_media_MediaCrypto_native_init(JNIEnv *env) {
jclass clazz = env->FindClass("android/media/MediaCrypto");
CHECK(clazz != NULL);
- gFields.context = env->GetFieldID(clazz, "mNativeContext", "I");
+ gFields.context = env->GetFieldID(clazz, "mNativeContext", "J");
CHECK(gFields.context != NULL);
}
@@ -232,7 +232,7 @@ static jboolean android_media_MediaCrypto_isCryptoSchemeSupportedNative(
env,
"java/lang/IllegalArgumentException",
NULL);
- return false;
+ return JNI_FALSE;
}
jboolean isCopy;
@@ -243,27 +243,27 @@ static jboolean android_media_MediaCrypto_isCryptoSchemeSupportedNative(
env->ReleaseByteArrayElements(uuidObj, uuid, 0);
uuid = NULL;
- return result;
+ return result ? JNI_TRUE : JNI_FALSE;
}
static jboolean android_media_MediaCrypto_requiresSecureDecoderComponent(
JNIEnv *env, jobject thiz, jstring mimeObj) {
if (mimeObj == NULL) {
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
- return false;
+ return JNI_FALSE;
}
sp<JCrypto> crypto = getCrypto(env, thiz);
if (crypto == NULL) {
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
- return false;
+ return JNI_FALSE;
}
const char *mime = env->GetStringUTFChars(mimeObj, NULL);
if (mime == NULL) {
- return false;
+ return JNI_FALSE;
}
bool result = crypto->requiresSecureDecoderComponent(mime);
@@ -271,7 +271,7 @@ static jboolean android_media_MediaCrypto_requiresSecureDecoderComponent(
env->ReleaseStringUTFChars(mimeObj, mime);
mime = NULL;
- return result;
+ return result ? JNI_TRUE : JNI_FALSE;
}
static JNINativeMethod gMethods[] = {
diff --git a/media/jni/android_media_MediaDrm.cpp b/media/jni/android_media_MediaDrm.cpp
index bbb74d2..7c45682 100644
--- a/media/jni/android_media_MediaDrm.cpp
+++ b/media/jni/android_media_MediaDrm.cpp
@@ -100,6 +100,16 @@ struct KeyTypes {
jint kKeyTypeRelease;
} gKeyTypes;
+struct CertificateTypes {
+ jint kCertificateTypeNone;
+ jint kCertificateTypeX509;
+} gCertificateTypes;
+
+struct CertificateFields {
+ jfieldID wrappedPrivateKey;
+ jfieldID certificateData;
+};
+
struct fields_t {
jfieldID context;
jmethodID post_event;
@@ -110,6 +120,11 @@ struct fields_t {
SetFields set;
IteratorFields iterator;
EntryFields entry;
+ CertificateFields certificate;
+ jclass certificateClassId;
+ jclass hashmapClassId;
+ jclass arraylistClassId;
+ jclass stringClassId;
};
static fields_t gFields;
@@ -186,6 +201,7 @@ void JNIDrmListener::notify(DrmPlugin::EventType eventType, int extra,
nativeParcel->setData(obj->data(), obj->dataSize());
env->CallStaticVoidMethod(mClass, gFields.post_event, mObject,
jeventType, extra, jParcel);
+ env->DeleteLocalRef(jParcel);
}
}
@@ -267,7 +283,7 @@ static bool throwExceptionAsNecessary(
}
static sp<IDrm> GetDrm(JNIEnv *env, jobject thiz) {
- JDrm *jdrm = (JDrm *)env->GetIntField(thiz, gFields.context);
+ JDrm *jdrm = (JDrm *)env->GetLongField(thiz, gFields.context);
return jdrm ? jdrm->getDrm() : NULL;
}
@@ -405,8 +421,7 @@ static String8 JStringToString8(JNIEnv *env, jstring const &jstr) {
*/
static KeyedVector<String8, String8> HashMapToKeyedVector(JNIEnv *env, jobject &hashMap) {
- jclass clazz;
- FIND_CLASS(clazz, "java/lang/String");
+ jclass clazz = gFields.stringClassId;
KeyedVector<String8, String8> keyedVector;
jobject entrySet = env->CallObjectMethod(hashMap, gFields.hashmap.entrySet);
@@ -449,8 +464,7 @@ static KeyedVector<String8, String8> HashMapToKeyedVector(JNIEnv *env, jobject &
}
static jobject KeyedVectorToHashMap (JNIEnv *env, KeyedVector<String8, String8> const &map) {
- jclass clazz;
- FIND_CLASS(clazz, "java/util/HashMap");
+ jclass clazz = gFields.hashmapClassId;
jobject hashMap = env->NewObject(clazz, gFields.hashmap.init);
for (size_t i = 0; i < map.size(); ++i) {
jstring jkey = env->NewStringUTF(map.keyAt(i).string());
@@ -464,8 +478,7 @@ static jobject KeyedVectorToHashMap (JNIEnv *env, KeyedVector<String8, String8>
static jobject ListOfVectorsToArrayListOfByteArray(JNIEnv *env,
List<Vector<uint8_t> > list) {
- jclass clazz;
- FIND_CLASS(clazz, "java/util/ArrayList");
+ jclass clazz = gFields.arraylistClassId;
jobject arrayList = env->NewObject(clazz, gFields.arraylist.init);
List<Vector<uint8_t> >::iterator iter = list.begin();
while (iter != list.end()) {
@@ -484,14 +497,14 @@ using namespace android;
static sp<JDrm> setDrm(
JNIEnv *env, jobject thiz, const sp<JDrm> &drm) {
- sp<JDrm> old = (JDrm *)env->GetIntField(thiz, gFields.context);
+ sp<JDrm> old = (JDrm *)env->GetLongField(thiz, gFields.context);
if (drm != NULL) {
drm->incStrong(thiz);
}
if (old != NULL) {
old->decStrong(thiz);
}
- env->SetIntField(thiz, gFields.context, (int)drm.get());
+ env->SetLongField(thiz, gFields.context, reinterpret_cast<jlong>(drm.get()));
return old;
}
@@ -520,7 +533,7 @@ static void android_media_MediaDrm_release(JNIEnv *env, jobject thiz) {
static void android_media_MediaDrm_native_init(JNIEnv *env) {
jclass clazz;
FIND_CLASS(clazz, "android/media/MediaDrm");
- GET_FIELD_ID(gFields.context, clazz, "mNativeContext", "I");
+ GET_FIELD_ID(gFields.context, clazz, "mNativeContext", "J");
GET_STATIC_METHOD_ID(gFields.post_event, clazz, "postEventFromNative",
"(Ljava/lang/Object;IILjava/lang/Object;)V");
@@ -541,6 +554,11 @@ static void android_media_MediaDrm_native_init(JNIEnv *env) {
GET_STATIC_FIELD_ID(field, clazz, "KEY_TYPE_RELEASE", "I");
gKeyTypes.kKeyTypeRelease = env->GetStaticIntField(clazz, field);
+ GET_STATIC_FIELD_ID(field, clazz, "CERTIFICATE_TYPE_NONE", "I");
+ gCertificateTypes.kCertificateTypeNone = env->GetStaticIntField(clazz, field);
+ GET_STATIC_FIELD_ID(field, clazz, "CERTIFICATE_TYPE_X509", "I");
+ gCertificateTypes.kCertificateTypeX509 = env->GetStaticIntField(clazz, field);
+
FIND_CLASS(clazz, "android/media/MediaDrm$KeyRequest");
GET_FIELD_ID(gFields.keyRequest.data, clazz, "mData", "[B");
GET_FIELD_ID(gFields.keyRequest.defaultUrl, clazz, "mDefaultUrl", "Ljava/lang/String;");
@@ -549,6 +567,11 @@ static void android_media_MediaDrm_native_init(JNIEnv *env) {
GET_FIELD_ID(gFields.provisionRequest.data, clazz, "mData", "[B");
GET_FIELD_ID(gFields.provisionRequest.defaultUrl, clazz, "mDefaultUrl", "Ljava/lang/String;");
+ FIND_CLASS(clazz, "android/media/MediaDrm$Certificate");
+ GET_FIELD_ID(gFields.certificate.wrappedPrivateKey, clazz, "mWrappedKey", "[B");
+ GET_FIELD_ID(gFields.certificate.certificateData, clazz, "mCertificateData", "[B");
+ gFields.certificateClassId = static_cast<jclass>(env->NewGlobalRef(clazz));
+
FIND_CLASS(clazz, "java/util/ArrayList");
GET_METHOD_ID(gFields.arraylist.init, clazz, "<init>", "()V");
GET_METHOD_ID(gFields.arraylist.add, clazz, "add", "(Ljava/lang/Object;)Z");
@@ -570,6 +593,15 @@ static void android_media_MediaDrm_native_init(JNIEnv *env) {
FIND_CLASS(clazz, "java/util/Map$Entry");
GET_METHOD_ID(gFields.entry.getKey, clazz, "getKey", "()Ljava/lang/Object;");
GET_METHOD_ID(gFields.entry.getValue, clazz, "getValue", "()Ljava/lang/Object;");
+
+ FIND_CLASS(clazz, "java/util/HashMap");
+ gFields.hashmapClassId = static_cast<jclass>(env->NewGlobalRef(clazz));
+
+ FIND_CLASS(clazz, "java/lang/String");
+ gFields.stringClassId = static_cast<jclass>(env->NewGlobalRef(clazz));
+
+ FIND_CLASS(clazz, "java/util/ArrayList");
+ gFields.arraylistClassId = static_cast<jclass>(env->NewGlobalRef(clazz));
}
static void android_media_MediaDrm_native_setup(
@@ -825,8 +857,8 @@ static jobject android_media_MediaDrm_queryKeyStatus(
return KeyedVectorToHashMap(env, infoMap);
}
-static jobject android_media_MediaDrm_getProvisionRequest(
- JNIEnv *env, jobject thiz) {
+static jobject android_media_MediaDrm_getProvisionRequestNative(
+ JNIEnv *env, jobject thiz, jint jcertType, jstring jcertAuthority) {
sp<IDrm> drm = GetDrm(env, thiz);
if (drm == NULL) {
@@ -838,7 +870,17 @@ static jobject android_media_MediaDrm_getProvisionRequest(
Vector<uint8_t> request;
String8 defaultUrl;
- status_t err = drm->getProvisionRequest(request, defaultUrl);
+ String8 certType;
+ if (jcertType == gCertificateTypes.kCertificateTypeX509) {
+ certType = "X.509";
+ } else if (jcertType == gCertificateTypes.kCertificateTypeNone) {
+ certType = "none";
+ } else {
+ certType = "invalid";
+ }
+
+ String8 certAuthority = JStringToString8(env, jcertAuthority);
+ status_t err = drm->getProvisionRequest(certType, certAuthority, request, defaultUrl);
if (throwExceptionAsNecessary(env, err, "Failed to get provision request")) {
return NULL;
@@ -862,27 +904,43 @@ static jobject android_media_MediaDrm_getProvisionRequest(
return provisionObj;
}
-static void android_media_MediaDrm_provideProvisionResponse(
+static jobject android_media_MediaDrm_provideProvisionResponseNative(
JNIEnv *env, jobject thiz, jbyteArray jresponse) {
sp<IDrm> drm = GetDrm(env, thiz);
if (drm == NULL) {
jniThrowException(env, "java/lang/IllegalStateException",
"MediaDrm obj is null");
- return;
+ return NULL;
}
if (jresponse == NULL) {
jniThrowException(env, "java/lang/IllegalArgumentException",
"provision response is null");
- return;
+ return NULL;
}
Vector<uint8_t> response(JByteArrayToVector(env, jresponse));
+ Vector<uint8_t> certificate, wrappedKey;
+
+ status_t err = drm->provideProvisionResponse(response, certificate, wrappedKey);
+
+ // Fill out return obj
+ jclass clazz = gFields.certificateClassId;
+
+ jobject certificateObj = NULL;
+
+ if (clazz && certificate.size() && wrappedKey.size()) {
+ certificateObj = env->AllocObject(clazz);
+ jbyteArray jcertificate = VectorToJByteArray(env, certificate);
+ env->SetObjectField(certificateObj, gFields.certificate.certificateData, jcertificate);
- status_t err = drm->provideProvisionResponse(response);
+ jbyteArray jwrappedKey = VectorToJByteArray(env, wrappedKey);
+ env->SetObjectField(certificateObj, gFields.certificate.wrappedPrivateKey, jwrappedKey);
+ }
throwExceptionAsNecessary(env, err, "Failed to handle provision response");
+ return certificateObj;
}
static jobject android_media_MediaDrm_getSecureStops(
@@ -1208,6 +1266,38 @@ static jboolean android_media_MediaDrm_verifyNative(
}
+static jbyteArray android_media_MediaDrm_signRSANative(
+ JNIEnv *env, jobject thiz, jobject jdrm, jbyteArray jsessionId,
+ jstring jalgorithm, jbyteArray jwrappedKey, jbyteArray jmessage) {
+
+ sp<IDrm> drm = GetDrm(env, jdrm);
+
+ if (!CheckSession(env, drm, jsessionId)) {
+ return NULL;
+ }
+
+ if (jalgorithm == NULL || jwrappedKey == NULL || jmessage == NULL) {
+ jniThrowException(env, "java/lang/IllegalArgumentException",
+ "required argument is null");
+ return NULL;
+ }
+
+ Vector<uint8_t> sessionId(JByteArrayToVector(env, jsessionId));
+ String8 algorithm = JStringToString8(env, jalgorithm);
+ Vector<uint8_t> wrappedKey(JByteArrayToVector(env, jwrappedKey));
+ Vector<uint8_t> message(JByteArrayToVector(env, jmessage));
+ Vector<uint8_t> signature;
+
+ status_t err = drm->signRSA(sessionId, algorithm, message, wrappedKey, signature);
+
+ if (throwExceptionAsNecessary(env, err, "Failed to sign")) {
+ return NULL;
+ }
+
+ return VectorToJByteArray(env, signature);
+}
+
+
static JNINativeMethod gMethods[] = {
{ "release", "()V", (void *)android_media_MediaDrm_release },
{ "native_init", "()V", (void *)android_media_MediaDrm_native_init },
@@ -1243,11 +1333,11 @@ static JNINativeMethod gMethods[] = {
{ "queryKeyStatus", "([B)Ljava/util/HashMap;",
(void *)android_media_MediaDrm_queryKeyStatus },
- { "getProvisionRequest", "()Landroid/media/MediaDrm$ProvisionRequest;",
- (void *)android_media_MediaDrm_getProvisionRequest },
+ { "getProvisionRequestNative", "(ILjava/lang/String;)Landroid/media/MediaDrm$ProvisionRequest;",
+ (void *)android_media_MediaDrm_getProvisionRequestNative },
- { "provideProvisionResponse", "([B)V",
- (void *)android_media_MediaDrm_provideProvisionResponse },
+ { "provideProvisionResponseNative", "([B)Landroid/media/MediaDrm$Certificate;",
+ (void *)android_media_MediaDrm_provideProvisionResponseNative },
{ "getSecureStops", "()Ljava/util/List;",
(void *)android_media_MediaDrm_getSecureStops },
@@ -1286,6 +1376,9 @@ static JNINativeMethod gMethods[] = {
{ "verifyNative", "(Landroid/media/MediaDrm;[B[B[B[B)Z",
(void *)android_media_MediaDrm_verifyNative },
+
+ { "signRSANative", "(Landroid/media/MediaDrm;[BLjava/lang/String;[B[B)[B",
+ (void *)android_media_MediaDrm_signRSANative },
};
int register_android_media_Drm(JNIEnv *env) {
diff --git a/media/jni/android_media_MediaExtractor.cpp b/media/jni/android_media_MediaExtractor.cpp
index 1ac45d4..705de88 100644
--- a/media/jni/android_media_MediaExtractor.cpp
+++ b/media/jni/android_media_MediaExtractor.cpp
@@ -88,7 +88,7 @@ class JavaDataSourceBridge : public DataSource {
env->GetByteArrayRegion(byteArrayObj, 0, size, (jbyte*) buffer);
env->DeleteLocalRef(byteArrayObj);
if (env->ExceptionCheck()) {
- ALOGW("Exception occurred while reading %d at %lld", size, offset);
+ ALOGW("Exception occurred while reading %zu at %lld", size, offset);
LOGW_EX(env);
env->ExceptionClear();
return -1;
@@ -198,7 +198,7 @@ status_t JMediaExtractor::readSampleData(
void *dst = env->GetDirectBufferAddress(byteBuf);
- jlong dstSize;
+ size_t dstSize;
jbyteArray byteArray = NULL;
if (dst == NULL) {
@@ -219,9 +219,9 @@ status_t JMediaExtractor::readSampleData(
jboolean isCopy;
dst = env->GetByteArrayElements(byteArray, &isCopy);
- dstSize = env->GetArrayLength(byteArray);
+ dstSize = (size_t) env->GetArrayLength(byteArray);
} else {
- dstSize = env->GetDirectBufferCapacity(byteBuf);
+ dstSize = (size_t) env->GetDirectBufferCapacity(byteBuf);
}
if (dstSize < offset) {
@@ -299,7 +299,7 @@ using namespace android;
static sp<JMediaExtractor> setMediaExtractor(
JNIEnv *env, jobject thiz, const sp<JMediaExtractor> &extractor) {
sp<JMediaExtractor> old =
- (JMediaExtractor *)env->GetIntField(thiz, gFields.context);
+ (JMediaExtractor *)env->GetLongField(thiz, gFields.context);
if (extractor != NULL) {
extractor->incStrong(thiz);
@@ -307,13 +307,13 @@ static sp<JMediaExtractor> setMediaExtractor(
if (old != NULL) {
old->decStrong(thiz);
}
- env->SetIntField(thiz, gFields.context, (int)extractor.get());
+ env->SetLongField(thiz, gFields.context, (jlong)extractor.get());
return old;
}
static sp<JMediaExtractor> getMediaExtractor(JNIEnv *env, jobject thiz) {
- return (JMediaExtractor *)env->GetIntField(thiz, gFields.context);
+ return (JMediaExtractor *)env->GetLongField(thiz, gFields.context);
}
static void android_media_MediaExtractor_release(JNIEnv *env, jobject thiz) {
@@ -329,7 +329,7 @@ static jint android_media_MediaExtractor_getTrackCount(
return -1;
}
- return extractor->countTracks();
+ return (jint) extractor->countTracks();
}
static jobject android_media_MediaExtractor_getTrackFormatNative(
@@ -430,19 +430,19 @@ static jboolean android_media_MediaExtractor_advance(
if (extractor == NULL) {
jniThrowException(env, "java/lang/IllegalStateException", NULL);
- return false;
+ return JNI_FALSE;
}
status_t err = extractor->advance();
if (err == ERROR_END_OF_STREAM) {
- return false;
+ return JNI_FALSE;
} else if (err != OK) {
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
- return false;
+ return JNI_FALSE;
}
- return true;
+ return JNI_TRUE;
}
static jint android_media_MediaExtractor_readSampleData(
@@ -461,10 +461,10 @@ static jint android_media_MediaExtractor_readSampleData(
return -1;
} else if (err != OK) {
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
- return false;
+ return -1;
}
- return sampleSize;
+ return (jint) sampleSize;
}
static jint android_media_MediaExtractor_getSampleTrackIndex(
@@ -483,10 +483,10 @@ static jint android_media_MediaExtractor_getSampleTrackIndex(
return -1;
} else if (err != OK) {
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
- return false;
+ return -1;
}
- return trackIndex;
+ return (jint) trackIndex;
}
static jlong android_media_MediaExtractor_getSampleTime(
@@ -505,10 +505,10 @@ static jlong android_media_MediaExtractor_getSampleTime(
return -1ll;
} else if (err != OK) {
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
- return false;
+ return -1ll;
}
- return sampleTimeUs;
+ return (jlong) sampleTimeUs;
}
static jint android_media_MediaExtractor_getSampleFlags(
@@ -517,20 +517,20 @@ static jint android_media_MediaExtractor_getSampleFlags(
if (extractor == NULL) {
jniThrowException(env, "java/lang/IllegalStateException", NULL);
- return -1ll;
+ return -1;
}
uint32_t sampleFlags;
status_t err = extractor->getSampleFlags(&sampleFlags);
if (err == ERROR_END_OF_STREAM) {
- return -1ll;
+ return -1;
} else if (err != OK) {
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
- return false;
+ return -1;
}
- return sampleFlags;
+ return (jint) sampleFlags;
}
static jboolean android_media_MediaExtractor_getSampleCryptoInfo(
@@ -539,27 +539,27 @@ static jboolean android_media_MediaExtractor_getSampleCryptoInfo(
if (extractor == NULL) {
jniThrowException(env, "java/lang/IllegalStateException", NULL);
- return -1ll;
+ return JNI_FALSE;
}
sp<MetaData> meta;
status_t err = extractor->getSampleMeta(&meta);
if (err != OK) {
- return false;
+ return JNI_FALSE;
}
uint32_t type;
const void *data;
size_t size;
if (!meta->findData(kKeyEncryptedSizes, &type, &data, &size)) {
- return false;
+ return JNI_FALSE;
}
size_t numSubSamples = size / sizeof(size_t);
if (numSubSamples == 0) {
- return false;
+ return JNI_FALSE;
}
jintArray numBytesOfEncryptedDataObj = env->NewIntArray(numSubSamples);
@@ -576,7 +576,7 @@ static jboolean android_media_MediaExtractor_getSampleCryptoInfo(
if (meta->findData(kKeyPlainSizes, &type, &data, &size)) {
if (size != encSize) {
// The two must be of the same length.
- return false;
+ return JNI_FALSE;
}
numBytesOfPlainDataObj = env->NewIntArray(numSubSamples);
@@ -593,7 +593,7 @@ static jboolean android_media_MediaExtractor_getSampleCryptoInfo(
if (meta->findData(kKeyCryptoKey, &type, &data, &size)) {
if (size != 16) {
// Keys must be 16 bytes in length.
- return false;
+ return JNI_FALSE;
}
keyObj = env->NewByteArray(size);
@@ -608,7 +608,7 @@ static jboolean android_media_MediaExtractor_getSampleCryptoInfo(
if (meta->findData(kKeyCryptoIV, &type, &data, &size)) {
if (size != 16) {
// IVs must be 16 bytes in length.
- return false;
+ return JNI_FALSE;
}
ivObj = env->NewByteArray(size);
@@ -634,14 +634,14 @@ static jboolean android_media_MediaExtractor_getSampleCryptoInfo(
ivObj,
mode);
- return true;
+ return JNI_TRUE;
}
static void android_media_MediaExtractor_native_init(JNIEnv *env) {
jclass clazz = env->FindClass("android/media/MediaExtractor");
CHECK(clazz != NULL);
- gFields.context = env->GetFieldID(clazz, "mNativeContext", "I");
+ gFields.context = env->GetFieldID(clazz, "mNativeContext", "J");
CHECK(gFields.context != NULL);
clazz = env->FindClass("android/media/MediaCodec$CryptoInfo");
@@ -770,7 +770,7 @@ static jlong android_media_MediaExtractor_getCachedDurationUs(
return -1ll;
}
- return cachedDurationUs;
+ return (jlong) cachedDurationUs;
}
static jboolean android_media_MediaExtractor_hasCacheReachedEOS(
@@ -779,16 +779,16 @@ static jboolean android_media_MediaExtractor_hasCacheReachedEOS(
if (extractor == NULL) {
jniThrowException(env, "java/lang/IllegalStateException", NULL);
- return true;
+ return JNI_TRUE;
}
int64_t cachedDurationUs;
bool eos;
if (!extractor->getCachedDuration(&cachedDurationUs, &eos)) {
- return true;
+ return JNI_TRUE;
}
- return eos;
+ return eos ? JNI_TRUE : JNI_FALSE;
}
static void android_media_MediaExtractor_native_finalize(
diff --git a/media/jni/android_media_MediaMetadataRetriever.cpp b/media/jni/android_media_MediaMetadataRetriever.cpp
index 297dadf..a52b24d 100644
--- a/media/jni/android_media_MediaMetadataRetriever.cpp
+++ b/media/jni/android_media_MediaMetadataRetriever.cpp
@@ -67,15 +67,15 @@ static void process_media_retriever_call(JNIEnv *env, status_t opStatus, const c
static MediaMetadataRetriever* getRetriever(JNIEnv* env, jobject thiz)
{
// No lock is needed, since it is called internally by other methods that are protected
- MediaMetadataRetriever* retriever = (MediaMetadataRetriever*) env->GetIntField(thiz, fields.context);
+ MediaMetadataRetriever* retriever = (MediaMetadataRetriever*) env->GetLongField(thiz, fields.context);
return retriever;
}
-static void setRetriever(JNIEnv* env, jobject thiz, int retriever)
+static void setRetriever(JNIEnv* env, jobject thiz, MediaMetadataRetriever* retriever)
{
// No lock is needed, since it is called internally by other methods that are protected
- MediaMetadataRetriever *old = (MediaMetadataRetriever*) env->GetIntField(thiz, fields.context);
- env->SetIntField(thiz, fields.context, retriever);
+ MediaMetadataRetriever *old = (MediaMetadataRetriever*) env->GetLongField(thiz, fields.context);
+ env->SetLongField(thiz, fields.context, (jlong) retriever);
}
static void
@@ -146,10 +146,10 @@ static void android_media_MediaMetadataRetriever_setDataSourceFD(JNIEnv *env, jo
int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
if (offset < 0 || length < 0 || fd < 0) {
if (offset < 0) {
- ALOGE("negative offset (%lld)", offset);
+ ALOGE("negative offset (%lld)", (long long)offset);
}
if (length < 0) {
- ALOGE("negative length (%lld)", length);
+ ALOGE("negative length (%lld)", (long long)length);
}
if (fd < 0) {
ALOGE("invalid file descriptor");
@@ -264,7 +264,7 @@ static jobject android_media_MediaMetadataRetriever_getFrameAtTime(JNIEnv *env,
config);
SkBitmap *bitmap =
- (SkBitmap *) env->GetIntField(jBitmap, fields.nativeBitmap);
+ (SkBitmap *) env->GetLongField(jBitmap, fields.nativeBitmap);
bitmap->lockPixels();
rotate((uint16_t*)bitmap->getPixels(),
@@ -359,7 +359,7 @@ static void android_media_MediaMetadataRetriever_release(JNIEnv *env, jobject th
Mutex::Autolock lock(sLock);
MediaMetadataRetriever* retriever = getRetriever(env, thiz);
delete retriever;
- setRetriever(env, thiz, 0);
+ setRetriever(env, thiz, (MediaMetadataRetriever*) 0);
}
static void android_media_MediaMetadataRetriever_native_finalize(JNIEnv *env, jobject thiz)
@@ -379,7 +379,7 @@ static void android_media_MediaMetadataRetriever_native_init(JNIEnv *env)
return;
}
- fields.context = env->GetFieldID(clazz, "mNativeContext", "I");
+ fields.context = env->GetFieldID(clazz, "mNativeContext", "J");
if (fields.context == NULL) {
return;
}
@@ -406,7 +406,7 @@ static void android_media_MediaMetadataRetriever_native_init(JNIEnv *env)
if (fields.createScaledBitmapMethod == NULL) {
return;
}
- fields.nativeBitmap = env->GetFieldID(fields.bitmapClazz, "mNativeBitmap", "I");
+ fields.nativeBitmap = env->GetFieldID(fields.bitmapClazz, "mNativeBitmap", "J");
if (fields.nativeBitmap == NULL) {
return;
}
@@ -435,7 +435,7 @@ static void android_media_MediaMetadataRetriever_native_setup(JNIEnv *env, jobje
jniThrowException(env, "java/lang/RuntimeException", "Out of memory");
return;
}
- setRetriever(env, thiz, (int)retriever);
+ setRetriever(env, thiz, retriever);
}
// JNI mapping between Java methods and native methods
diff --git a/media/jni/android_media_MediaMuxer.cpp b/media/jni/android_media_MediaMuxer.cpp
index 457b956..2c16a05 100644
--- a/media/jni/android_media_MediaMuxer.cpp
+++ b/media/jni/android_media_MediaMuxer.cpp
@@ -31,7 +31,6 @@
namespace android {
struct fields_t {
- jfieldID context;
jmethodID arrayID;
};
@@ -42,7 +41,7 @@ static fields_t gFields;
using namespace android;
static jint android_media_MediaMuxer_addTrack(
- JNIEnv *env, jclass clazz, jint nativeObject, jobjectArray keys,
+ JNIEnv *env, jclass clazz, jlong nativeObject, jobjectArray keys,
jobjectArray values) {
sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject));
if (muxer == NULL) {
@@ -72,7 +71,7 @@ static jint android_media_MediaMuxer_addTrack(
}
static void android_media_MediaMuxer_writeSampleData(
- JNIEnv *env, jclass clazz, jint nativeObject, jint trackIndex,
+ JNIEnv *env, jclass clazz, jlong nativeObject, jint trackIndex,
jobject byteBuf, jint offset, jint size, jlong timeUs, jint flags) {
sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject));
if (muxer == NULL) {
@@ -147,7 +146,7 @@ static jint android_media_MediaMuxer_native_setup(
}
static void android_media_MediaMuxer_setOrientationHint(
- JNIEnv *env, jclass clazz, jint nativeObject, jint degrees) {
+ JNIEnv *env, jclass clazz, jlong nativeObject, jint degrees) {
sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject));
if (muxer == NULL) {
jniThrowException(env, "java/lang/IllegalStateException",
@@ -177,7 +176,7 @@ static void android_media_MediaMuxer_setLocation(
}
static void android_media_MediaMuxer_start(JNIEnv *env, jclass clazz,
- jint nativeObject) {
+ jlong nativeObject) {
sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject));
if (muxer == NULL) {
jniThrowException(env, "java/lang/IllegalStateException",
@@ -195,7 +194,7 @@ static void android_media_MediaMuxer_start(JNIEnv *env, jclass clazz,
}
static void android_media_MediaMuxer_stop(JNIEnv *env, jclass clazz,
- jint nativeObject) {
+ jlong nativeObject) {
sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject));
if (muxer == NULL) {
jniThrowException(env, "java/lang/IllegalStateException",
@@ -213,7 +212,7 @@ static void android_media_MediaMuxer_stop(JNIEnv *env, jclass clazz,
}
static void android_media_MediaMuxer_native_release(
- JNIEnv *env, jclass clazz, jint nativeObject) {
+ JNIEnv *env, jclass clazz, jlong nativeObject) {
sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject));
if (muxer != NULL) {
muxer->decStrong(clazz);
@@ -222,26 +221,26 @@ static void android_media_MediaMuxer_native_release(
static JNINativeMethod gMethods[] = {
- { "nativeAddTrack", "(I[Ljava/lang/String;[Ljava/lang/Object;)I",
+ { "nativeAddTrack", "(J[Ljava/lang/String;[Ljava/lang/Object;)I",
(void *)android_media_MediaMuxer_addTrack },
- { "nativeSetOrientationHint", "(II)V",
+ { "nativeSetOrientationHint", "(JI)V",
(void *)android_media_MediaMuxer_setOrientationHint},
- { "nativeSetLocation", "(III)V",
+ { "nativeSetLocation", "(JII)V",
(void *)android_media_MediaMuxer_setLocation},
- { "nativeStart", "(I)V", (void *)android_media_MediaMuxer_start},
+ { "nativeStart", "(J)V", (void *)android_media_MediaMuxer_start},
- { "nativeWriteSampleData", "(IILjava/nio/ByteBuffer;IIJI)V",
+ { "nativeWriteSampleData", "(JILjava/nio/ByteBuffer;IIJI)V",
(void *)android_media_MediaMuxer_writeSampleData },
- { "nativeStop", "(I)V", (void *)android_media_MediaMuxer_stop},
+ { "nativeStop", "(J)V", (void *)android_media_MediaMuxer_stop},
- { "nativeSetup", "(Ljava/io/FileDescriptor;I)I",
+ { "nativeSetup", "(Ljava/io/FileDescriptor;I)J",
(void *)android_media_MediaMuxer_native_setup },
- { "nativeRelease", "(I)V",
+ { "nativeRelease", "(J)V",
(void *)android_media_MediaMuxer_native_release },
};
@@ -252,12 +251,6 @@ int register_android_media_MediaMuxer(JNIEnv *env) {
int err = AndroidRuntime::registerNativeMethods(env,
"android/media/MediaMuxer", gMethods, NELEM(gMethods));
- jclass clazz = env->FindClass("android/media/MediaMuxer");
- CHECK(clazz != NULL);
-
- gFields.context = env->GetFieldID(clazz, "mNativeContext", "I");
- CHECK(gFields.context != NULL);
-
jclass byteBufClass = env->FindClass("java/nio/ByteBuffer");
CHECK(byteBufClass != NULL);
diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp
index 4be9cd6..9d0d5a6 100644
--- a/media/jni/android_media_MediaPlayer.cpp
+++ b/media/jni/android_media_MediaPlayer.cpp
@@ -133,21 +133,21 @@ void JNIMediaPlayerListener::notify(int msg, int ext1, int ext2, const Parcel *o
static sp<MediaPlayer> getMediaPlayer(JNIEnv* env, jobject thiz)
{
Mutex::Autolock l(sLock);
- MediaPlayer* const p = (MediaPlayer*)env->GetIntField(thiz, fields.context);
+ MediaPlayer* const p = (MediaPlayer*)env->GetLongField(thiz, fields.context);
return sp<MediaPlayer>(p);
}
static sp<MediaPlayer> setMediaPlayer(JNIEnv* env, jobject thiz, const sp<MediaPlayer>& player)
{
Mutex::Autolock l(sLock);
- sp<MediaPlayer> old = (MediaPlayer*)env->GetIntField(thiz, fields.context);
+ sp<MediaPlayer> old = (MediaPlayer*)env->GetLongField(thiz, fields.context);
if (player.get()) {
player->incStrong((void*)setMediaPlayer);
}
if (old != 0) {
old->decStrong((void*)setMediaPlayer);
}
- env->SetIntField(thiz, fields.context, (int)player.get());
+ env->SetLongField(thiz, fields.context, (jlong)player.get());
return old;
}
@@ -244,7 +244,7 @@ android_media_MediaPlayer_setDataSourceFD(JNIEnv *env, jobject thiz, jobject fil
static sp<IGraphicBufferProducer>
getVideoSurfaceTexture(JNIEnv* env, jobject thiz) {
- IGraphicBufferProducer * const p = (IGraphicBufferProducer*)env->GetIntField(thiz, fields.surface_texture);
+ IGraphicBufferProducer * const p = (IGraphicBufferProducer*)env->GetLongField(thiz, fields.surface_texture);
return sp<IGraphicBufferProducer>(p);
}
@@ -293,7 +293,7 @@ setVideoSurface(JNIEnv *env, jobject thiz, jobject jsurface, jboolean mediaPlaye
}
}
- env->SetIntField(thiz, fields.surface_texture, (int)new_st.get());
+ env->SetLongField(thiz, fields.surface_texture, (jlong)new_st.get());
// This will fail if the media player has not been initialized yet. This
// can be the case if setDisplay() on MediaPlayer.java has been called
@@ -384,7 +384,7 @@ android_media_MediaPlayer_isPlaying(JNIEnv *env, jobject thiz)
sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
if (mp == NULL ) {
jniThrowException(env, "java/lang/IllegalStateException", NULL);
- return false;
+ return JNI_FALSE;
}
const jboolean is_playing = mp->isPlaying();
@@ -393,7 +393,7 @@ android_media_MediaPlayer_isPlaying(JNIEnv *env, jobject thiz)
}
static void
-android_media_MediaPlayer_seekTo(JNIEnv *env, jobject thiz, int msec)
+android_media_MediaPlayer_seekTo(JNIEnv *env, jobject thiz, jint msec)
{
sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
if (mp == NULL ) {
@@ -404,7 +404,7 @@ android_media_MediaPlayer_seekTo(JNIEnv *env, jobject thiz, int msec)
process_media_player_call( env, thiz, mp->seekTo(msec), NULL, NULL );
}
-static int
+static jint
android_media_MediaPlayer_getVideoWidth(JNIEnv *env, jobject thiz)
{
sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
@@ -418,10 +418,10 @@ android_media_MediaPlayer_getVideoWidth(JNIEnv *env, jobject thiz)
w = 0;
}
ALOGV("getVideoWidth: %d", w);
- return w;
+ return (jint) w;
}
-static int
+static jint
android_media_MediaPlayer_getVideoHeight(JNIEnv *env, jobject thiz)
{
sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
@@ -435,11 +435,11 @@ android_media_MediaPlayer_getVideoHeight(JNIEnv *env, jobject thiz)
h = 0;
}
ALOGV("getVideoHeight: %d", h);
- return h;
+ return (jint) h;
}
-static int
+static jint
android_media_MediaPlayer_getCurrentPosition(JNIEnv *env, jobject thiz)
{
sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
@@ -450,10 +450,10 @@ android_media_MediaPlayer_getCurrentPosition(JNIEnv *env, jobject thiz)
int msec;
process_media_player_call( env, thiz, mp->getCurrentPosition(&msec), NULL, NULL );
ALOGV("getCurrentPosition: %d (msec)", msec);
- return msec;
+ return (jint) msec;
}
-static int
+static jint
android_media_MediaPlayer_getDuration(JNIEnv *env, jobject thiz)
{
sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
@@ -464,7 +464,7 @@ android_media_MediaPlayer_getDuration(JNIEnv *env, jobject thiz)
int msec;
process_media_player_call( env, thiz, mp->getDuration(&msec), NULL, NULL );
ALOGV("getDuration: %d (msec)", msec);
- return msec;
+ return (jint) msec;
}
static void
@@ -480,7 +480,7 @@ android_media_MediaPlayer_reset(JNIEnv *env, jobject thiz)
}
static void
-android_media_MediaPlayer_setAudioStreamType(JNIEnv *env, jobject thiz, int streamtype)
+android_media_MediaPlayer_setAudioStreamType(JNIEnv *env, jobject thiz, jint streamtype)
{
ALOGV("setAudioStreamType: %d", streamtype);
sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
@@ -510,21 +510,21 @@ android_media_MediaPlayer_isLooping(JNIEnv *env, jobject thiz)
sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
if (mp == NULL ) {
jniThrowException(env, "java/lang/IllegalStateException", NULL);
- return false;
+ return JNI_FALSE;
}
- return mp->isLooping();
+ return mp->isLooping() ? JNI_TRUE : JNI_FALSE;
}
static void
-android_media_MediaPlayer_setVolume(JNIEnv *env, jobject thiz, float leftVolume, float rightVolume)
+android_media_MediaPlayer_setVolume(JNIEnv *env, jobject thiz, jfloat leftVolume, jfloat rightVolume)
{
- ALOGV("setVolume: left %f right %f", leftVolume, rightVolume);
+ ALOGV("setVolume: left %f right %f", (float) leftVolume, (float) rightVolume);
sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
if (mp == NULL ) {
jniThrowException(env, "java/lang/IllegalStateException", NULL);
return;
}
- process_media_player_call( env, thiz, mp->setVolume(leftVolume, rightVolume), NULL, NULL );
+ process_media_player_call( env, thiz, mp->setVolume((float) leftVolume, (float) rightVolume), NULL, NULL );
}
// Sends the request and reply parcels to the media player via the
@@ -544,7 +544,7 @@ android_media_MediaPlayer_invoke(JNIEnv *env, jobject thiz,
// Don't use process_media_player_call which use the async loop to
// report errors, instead returns the status.
- return media_player->invoke(*request, reply);
+ return (jint) media_player->invoke(*request, reply);
}
// Sends the new filter to the client.
@@ -564,7 +564,7 @@ android_media_MediaPlayer_setMetadataFilter(JNIEnv *env, jobject thiz, jobject r
return UNKNOWN_ERROR;
}
- return media_player->setMetadataFilter(*filter);
+ return (jint) media_player->setMetadataFilter(*filter);
}
static jboolean
@@ -574,14 +574,14 @@ android_media_MediaPlayer_getMetadata(JNIEnv *env, jobject thiz, jboolean update
sp<MediaPlayer> media_player = getMediaPlayer(env, thiz);
if (media_player == NULL ) {
jniThrowException(env, "java/lang/IllegalStateException", NULL);
- return false;
+ return JNI_FALSE;
}
Parcel *metadata = parcelForJavaObject(env, reply);
if (metadata == NULL ) {
jniThrowException(env, "java/lang/RuntimeException", "Reply parcel is null");
- return false;
+ return JNI_FALSE;
}
metadata->freeData();
@@ -589,7 +589,11 @@ android_media_MediaPlayer_getMetadata(JNIEnv *env, jobject thiz, jboolean update
// metadata. Note however that the parcel actually starts with the
// return code so you should not rewind the parcel using
// setDataPosition(0).
- return media_player->getMetadata(update_only, apply_filter, metadata) == OK;
+ if (media_player->getMetadata(update_only, apply_filter, metadata) == OK) {
+ return JNI_TRUE;
+ } else {
+ return JNI_FALSE;
+ }
}
// This function gets some field IDs, which in turn causes class initialization.
@@ -605,7 +609,7 @@ android_media_MediaPlayer_native_init(JNIEnv *env)
return;
}
- fields.context = env->GetFieldID(clazz, "mNativeContext", "I");
+ fields.context = env->GetFieldID(clazz, "mNativeContext", "J");
if (fields.context == NULL) {
return;
}
@@ -616,7 +620,7 @@ android_media_MediaPlayer_native_init(JNIEnv *env)
return;
}
- fields.surface_texture = env->GetFieldID(clazz, "mNativeSurfaceTexture", "I");
+ fields.surface_texture = env->GetFieldID(clazz, "mNativeSurfaceTexture", "J");
if (fields.surface_texture == NULL) {
return;
}
@@ -696,7 +700,7 @@ static jint android_media_MediaPlayer_get_audio_session_id(JNIEnv *env, jobject
return 0;
}
- return mp->getAudioSessionId();
+ return (jint) mp->getAudioSessionId();
}
static void
@@ -733,7 +737,7 @@ android_media_MediaPlayer_pullBatteryData(JNIEnv *env, jobject thiz, jobject jav
Parcel *reply = parcelForJavaObject(env, java_reply);
- return service->pullBatteryData(reply);
+ return (jint) service->pullBatteryData(reply);
}
static jint
@@ -772,7 +776,7 @@ android_media_MediaPlayer_setRetransmitEndpoint(JNIEnv *env, jobject thiz,
jniThrowException(env, "java/lang/IllegalStateException", NULL);
}
- return ret;
+ return (jint) ret;
}
static void
@@ -826,16 +830,19 @@ android_media_MediaPlayer_updateProxyConfig(
jstring exclusionListObj = (jstring)env->CallObjectMethod(
proxyProps, fields.proxyConfigGetExclusionList);
- const char *exclusionList =
- env->GetStringUTFChars(exclusionListObj, NULL);
-
if (host != NULL && exclusionListObj != NULL) {
- thisplayer->updateProxyConfig(host, port, exclusionList);
- }
+ const char *exclusionList = env->GetStringUTFChars(exclusionListObj, NULL);
+
+ if (exclusionList != NULL) {
+ thisplayer->updateProxyConfig(host, port, exclusionList);
- if (exclusionList != NULL) {
- env->ReleaseStringUTFChars(exclusionListObj, exclusionList);
- exclusionList = NULL;
+ env->ReleaseStringUTFChars(exclusionListObj, exclusionList);
+ exclusionList = NULL;
+ } else {
+ thisplayer->updateProxyConfig(host, port, "");
+ }
+ } else if (host != NULL) {
+ thisplayer->updateProxyConfig(host, port, "");
}
if (host != NULL) {
diff --git a/media/jni/android_media_MediaProfiles.cpp b/media/jni/android_media_MediaProfiles.cpp
index 3fbb8ba..48a9132 100644
--- a/media/jni/android_media_MediaProfiles.cpp
+++ b/media/jni/android_media_MediaProfiles.cpp
@@ -48,7 +48,7 @@ static jint
android_media_MediaProfiles_native_get_num_file_formats(JNIEnv *env, jobject thiz)
{
ALOGV("native_get_num_file_formats");
- return sProfiles->getOutputFileFormats().size();
+ return (jint) sProfiles->getOutputFileFormats().size();
}
static jint
@@ -119,7 +119,7 @@ static jint
android_media_MediaProfiles_native_get_num_audio_encoders(JNIEnv *env, jobject thiz)
{
ALOGV("native_get_num_audio_encoders");
- return sProfiles->getAudioEncoders().size();
+ return (jint) sProfiles->getAudioEncoders().size();
}
static jobject
@@ -223,18 +223,18 @@ android_media_MediaProfiles_native_has_camcorder_profile(JNIEnv *env, jobject th
{
ALOGV("native_has_camcorder_profile: %d %d", id, quality);
if (!isCamcorderQualityKnown(quality)) {
- return false;
+ return JNI_FALSE;
}
camcorder_quality q = static_cast<camcorder_quality>(quality);
- return sProfiles->hasCamcorderProfile(id, q);
+ return sProfiles->hasCamcorderProfile(id, q) ? JNI_TRUE : JNI_FALSE;
}
static jint
android_media_MediaProfiles_native_get_num_video_decoders(JNIEnv *env, jobject thiz)
{
ALOGV("native_get_num_video_decoders");
- return sProfiles->getVideoDecoders().size();
+ return (jint) sProfiles->getVideoDecoders().size();
}
static jint
@@ -255,7 +255,7 @@ static jint
android_media_MediaProfiles_native_get_num_audio_decoders(JNIEnv *env, jobject thiz)
{
ALOGV("native_get_num_audio_decoders");
- return sProfiles->getAudioDecoders().size();
+ return (jint) sProfiles->getAudioDecoders().size();
}
static jint
@@ -276,7 +276,7 @@ static jint
android_media_MediaProfiles_native_get_num_image_encoding_quality_levels(JNIEnv *env, jobject thiz, jint cameraId)
{
ALOGV("native_get_num_image_encoding_quality_levels");
- return sProfiles->getImageEncodingQualityLevels(cameraId).size();
+ return (jint) sProfiles->getImageEncodingQualityLevels(cameraId).size();
}
static jint
@@ -284,7 +284,7 @@ android_media_MediaProfiles_native_get_image_encoding_quality_level(JNIEnv *env,
{
ALOGV("native_get_image_encoding_quality_level");
Vector<int> levels = sProfiles->getImageEncodingQualityLevels(cameraId);
- if (index < 0 || index >= levels.size()) {
+ if (index < 0 || index >= (jint) levels.size()) {
jniThrowException(env, "java/lang/IllegalArgumentException", "out of array boundary");
return -1;
}
diff --git a/media/jni/android_media_MediaRecorder.cpp b/media/jni/android_media_MediaRecorder.cpp
index 9888591..0cfd2ff 100644
--- a/media/jni/android_media_MediaRecorder.cpp
+++ b/media/jni/android_media_MediaRecorder.cpp
@@ -128,21 +128,21 @@ static bool process_media_recorder_call(JNIEnv *env, status_t opStatus, const ch
static sp<MediaRecorder> getMediaRecorder(JNIEnv* env, jobject thiz)
{
Mutex::Autolock l(sLock);
- MediaRecorder* const p = (MediaRecorder*)env->GetIntField(thiz, fields.context);
+ MediaRecorder* const p = (MediaRecorder*)env->GetLongField(thiz, fields.context);
return sp<MediaRecorder>(p);
}
static sp<MediaRecorder> setMediaRecorder(JNIEnv* env, jobject thiz, const sp<MediaRecorder>& recorder)
{
Mutex::Autolock l(sLock);
- sp<MediaRecorder> old = (MediaRecorder*)env->GetIntField(thiz, fields.context);
+ sp<MediaRecorder> old = (MediaRecorder*)env->GetLongField(thiz, fields.context);
if (recorder.get()) {
recorder->incStrong(thiz);
}
if (old != 0) {
old->decStrong(thiz);
}
- env->SetIntField(thiz, fields.context, (int)recorder.get());
+ env->SetLongField(thiz, fields.context, (jlong)recorder.get());
return old;
}
@@ -334,14 +334,14 @@ android_media_MediaRecorder_prepare(JNIEnv *env, jobject thiz)
process_media_recorder_call(env, mr->prepare(), "java/io/IOException", "prepare failed.");
}
-static int
+static jint
android_media_MediaRecorder_native_getMaxAmplitude(JNIEnv *env, jobject thiz)
{
ALOGV("getMaxAmplitude");
sp<MediaRecorder> mr = getMediaRecorder(env, thiz);
int result = 0;
process_media_recorder_call(env, mr->getMaxAmplitude(&result), "java/lang/RuntimeException", "getMaxAmplitude failed.");
- return result;
+ return (jint) result;
}
static void
@@ -392,7 +392,7 @@ android_media_MediaRecorder_native_init(JNIEnv *env)
return;
}
- fields.context = env->GetFieldID(clazz, "mNativeContext", "I");
+ fields.context = env->GetFieldID(clazz, "mNativeContext", "J");
if (fields.context == NULL) {
return;
}
diff --git a/media/jni/android_media_MediaScanner.cpp b/media/jni/android_media_MediaScanner.cpp
index 4e3d14e..84028b7 100644
--- a/media/jni/android_media_MediaScanner.cpp
+++ b/media/jni/android_media_MediaScanner.cpp
@@ -226,12 +226,12 @@ private:
static MediaScanner *getNativeScanner_l(JNIEnv* env, jobject thiz)
{
- return (MediaScanner *) env->GetIntField(thiz, fields.context);
+ return (MediaScanner *) env->GetLongField(thiz, fields.context);
}
static void setNativeScanner_l(JNIEnv* env, jobject thiz, MediaScanner *s)
{
- env->SetIntField(thiz, fields.context, (int)s);
+ env->SetLongField(thiz, fields.context, (jlong)s);
}
static void
@@ -381,7 +381,7 @@ android_media_MediaScanner_native_init(JNIEnv *env)
return;
}
- fields.context = env->GetFieldID(clazz, "mNativeContext", "I");
+ fields.context = env->GetFieldID(clazz, "mNativeContext", "J");
if (fields.context == NULL) {
return;
}
@@ -398,7 +398,7 @@ android_media_MediaScanner_native_setup(JNIEnv *env, jobject thiz)
return;
}
- env->SetIntField(thiz, fields.context, (int)mp);
+ env->SetLongField(thiz, fields.context, (jlong)mp);
}
static void
diff --git a/media/jni/android_mtp_MtpDatabase.cpp b/media/jni/android_mtp_MtpDatabase.cpp
index f8fb144..4689867e 100644
--- a/media/jni/android_mtp_MtpDatabase.cpp
+++ b/media/jni/android_mtp_MtpDatabase.cpp
@@ -80,7 +80,7 @@ static jfieldID field_mStringValues;
MtpDatabase* getMtpDatabase(JNIEnv *env, jobject database) {
- return (MtpDatabase *)env->GetIntField(database, field_context);
+ return (MtpDatabase *)env->GetLongField(database, field_context);
}
// ----------------------------------------------------------------------------
@@ -1088,17 +1088,17 @@ static void
android_mtp_MtpDatabase_setup(JNIEnv *env, jobject thiz)
{
MyMtpDatabase* database = new MyMtpDatabase(env, thiz);
- env->SetIntField(thiz, field_context, (int)database);
+ env->SetLongField(thiz, field_context, (jlong)database);
checkAndClearExceptionFromCallback(env, __FUNCTION__);
}
static void
android_mtp_MtpDatabase_finalize(JNIEnv *env, jobject thiz)
{
- MyMtpDatabase* database = (MyMtpDatabase *)env->GetIntField(thiz, field_context);
+ MyMtpDatabase* database = (MyMtpDatabase *)env->GetLongField(thiz, field_context);
database->cleanup(env);
delete database;
- env->SetIntField(thiz, field_context, 0);
+ env->SetLongField(thiz, field_context, 0);
checkAndClearExceptionFromCallback(env, __FUNCTION__);
}
@@ -1230,7 +1230,7 @@ int register_android_mtp_MtpDatabase(JNIEnv *env)
return -1;
}
- field_context = env->GetFieldID(clazz, "mNativeContext", "I");
+ field_context = env->GetFieldID(clazz, "mNativeContext", "J");
if (field_context == NULL) {
ALOGE("Can't find MtpDatabase.mNativeContext");
return -1;
diff --git a/media/jni/android_mtp_MtpDevice.cpp b/media/jni/android_mtp_MtpDevice.cpp
index b61b66c..8e013a0 100644
--- a/media/jni/android_mtp_MtpDevice.cpp
+++ b/media/jni/android_mtp_MtpDevice.cpp
@@ -88,7 +88,7 @@ static jfieldID field_objectInfo_keywords;
MtpDevice* get_device_from_object(JNIEnv* env, jobject javaDevice)
{
- return (MtpDevice*)env->GetIntField(javaDevice, field_context);
+ return (MtpDevice*)env->GetLongField(javaDevice, field_context);
}
static void checkAndClearExceptionFromCallback(JNIEnv* env, const char* methodName) {
@@ -106,15 +106,15 @@ android_mtp_MtpDevice_open(JNIEnv *env, jobject thiz, jstring deviceName, jint f
{
const char *deviceNameStr = env->GetStringUTFChars(deviceName, NULL);
if (deviceNameStr == NULL) {
- return false;
+ return JNI_FALSE;
}
MtpDevice* device = MtpDevice::open(deviceNameStr, fd);
env->ReleaseStringUTFChars(deviceName, deviceNameStr);
if (device)
- env->SetIntField(thiz, field_context, (int)device);
- return (device != NULL);
+ env->SetLongField(thiz, field_context, (jlong)device);
+ return (jboolean)(device != NULL);
}
static void
@@ -124,7 +124,7 @@ android_mtp_MtpDevice_close(JNIEnv *env, jobject thiz)
if (device) {
device->close();
delete device;
- env->SetIntField(thiz, field_context, 0);
+ env->SetLongField(thiz, field_context, 0);
}
}
@@ -356,10 +356,11 @@ static jboolean
android_mtp_MtpDevice_delete_object(JNIEnv *env, jobject thiz, jint object_id)
{
MtpDevice* device = get_device_from_object(env, thiz);
- if (device)
- return device->deleteObject(object_id);
- else
- return NULL;
+ if (device && device->deleteObject(object_id)) {
+ return JNI_TRUE;
+ } else {
+ return JNI_FALSE;
+ }
}
static jlong
@@ -367,7 +368,7 @@ android_mtp_MtpDevice_get_parent(JNIEnv *env, jobject thiz, jint object_id)
{
MtpDevice* device = get_device_from_object(env, thiz);
if (device)
- return device->getParent(object_id);
+ return (jlong)device->getParent(object_id);
else
return -1;
}
@@ -377,7 +378,7 @@ android_mtp_MtpDevice_get_storage_id(JNIEnv *env, jobject thiz, jint object_id)
{
MtpDevice* device = get_device_from_object(env, thiz);
if (device)
- return device->getStorageID(object_id);
+ return (jlong)device->getStorageID(object_id);
else
return -1;
}
@@ -389,15 +390,15 @@ android_mtp_MtpDevice_import_file(JNIEnv *env, jobject thiz, jint object_id, jst
if (device) {
const char *destPathStr = env->GetStringUTFChars(dest_path, NULL);
if (destPathStr == NULL) {
- return false;
+ return JNI_FALSE;
}
- bool result = device->readObject(object_id, destPathStr, AID_SDCARD_RW, 0664);
+ jboolean result = device->readObject(object_id, destPathStr, AID_SDCARD_RW, 0664);
env->ReleaseStringUTFChars(dest_path, destPathStr);
return result;
}
- return false;
+ return JNI_FALSE;
}
// ----------------------------------------------------------------------------
@@ -618,7 +619,7 @@ int register_android_mtp_MtpDevice(JNIEnv *env)
ALOGE("Can't find android/mtp/MtpDevice");
return -1;
}
- field_context = env->GetFieldID(clazz, "mNativeContext", "I");
+ field_context = env->GetFieldID(clazz, "mNativeContext", "J");
if (field_context == NULL) {
ALOGE("Can't find MtpDevice.mNativeContext");
return -1;
diff --git a/media/jni/android_mtp_MtpServer.cpp b/media/jni/android_mtp_MtpServer.cpp
index 5252a3a..9d7f1c2 100644
--- a/media/jni/android_mtp_MtpServer.cpp
+++ b/media/jni/android_mtp_MtpServer.cpp
@@ -53,7 +53,7 @@ static Mutex sMutex;
extern MtpDatabase* getMtpDatabase(JNIEnv *env, jobject database);
static inline MtpServer* getMtpServer(JNIEnv *env, jobject thiz) {
- return (MtpServer*)env->GetIntField(thiz, field_MtpServer_nativeContext);
+ return (MtpServer*)env->GetLongField(thiz, field_MtpServer_nativeContext);
}
static void
@@ -63,7 +63,7 @@ android_mtp_MtpServer_setup(JNIEnv *env, jobject thiz, jobject javaDatabase, jbo
if (fd >= 0) {
MtpServer* server = new MtpServer(fd, getMtpDatabase(env, javaDatabase),
usePtp, AID_MEDIA_RW, 0664, 0775);
- env->SetIntField(thiz, field_MtpServer_nativeContext, (int)server);
+ env->SetLongField(thiz, field_MtpServer_nativeContext, (jlong)server);
} else {
ALOGE("could not open MTP driver, errno: %d", errno);
}
@@ -87,7 +87,7 @@ android_mtp_MtpServer_cleanup(JNIEnv *env, jobject thiz)
MtpServer* server = getMtpServer(env, thiz);
if (server) {
delete server;
- env->SetIntField(thiz, field_MtpServer_nativeContext, 0);
+ env->SetLongField(thiz, field_MtpServer_nativeContext, 0);
} else {
ALOGE("server is null in cleanup");
}
@@ -226,7 +226,7 @@ int register_android_mtp_MtpServer(JNIEnv *env)
ALOGE("Can't find android/mtp/MtpServer");
return -1;
}
- field_MtpServer_nativeContext = env->GetFieldID(clazz, "mNativeContext", "I");
+ field_MtpServer_nativeContext = env->GetFieldID(clazz, "mNativeContext", "J");
if (field_MtpServer_nativeContext == NULL) {
ALOGE("Can't find MtpServer.mNativeContext");
return -1;
diff --git a/media/jni/audioeffect/android_media_AudioEffect.cpp b/media/jni/audioeffect/android_media_AudioEffect.cpp
index bcab4f3..be37aa8 100644
--- a/media/jni/audioeffect/android_media_AudioEffect.cpp
+++ b/media/jni/audioeffect/android_media_AudioEffect.cpp
@@ -214,7 +214,7 @@ android_media_AudioEffect_native_init(JNIEnv *env)
// nativeTrackInJavaObj
fields.fidNativeAudioEffect = env->GetFieldID(
fields.clazzEffect,
- "mNativeAudioEffect", "I");
+ "mNativeAudioEffect", "J");
if (fields.fidNativeAudioEffect == NULL) {
ALOGE("Can't find AudioEffect.%s", "mNativeAudioEffect");
return;
@@ -222,7 +222,7 @@ android_media_AudioEffect_native_init(JNIEnv *env)
// fidJniData;
fields.fidJniData = env->GetFieldID(
fields.clazzEffect,
- "mJniData", "I");
+ "mJniData", "J");
if (fields.fidJniData == NULL) {
ALOGE("Can't find AudioEffect.%s", "mJniData");
return;
@@ -388,11 +388,11 @@ android_media_AudioEffect_native_setup(JNIEnv *env, jobject thiz, jobject weak_t
env->SetObjectArrayElement(javadesc, 0, jdesc);
- env->SetIntField(thiz, fields.fidNativeAudioEffect, (int)lpAudioEffect);
+ env->SetLongField(thiz, fields.fidNativeAudioEffect, (jlong)lpAudioEffect);
- env->SetIntField(thiz, fields.fidJniData, (int)lpJniStorage);
+ env->SetLongField(thiz, fields.fidJniData, (jlong)lpJniStorage);
- return AUDIOEFFECT_SUCCESS;
+ return (jint) AUDIOEFFECT_SUCCESS;
// failures:
setup_failure:
@@ -404,12 +404,12 @@ setup_failure:
if (lpAudioEffect) {
delete lpAudioEffect;
}
- env->SetIntField(thiz, fields.fidNativeAudioEffect, 0);
+ env->SetLongField(thiz, fields.fidNativeAudioEffect, 0);
if (lpJniStorage) {
delete lpJniStorage;
}
- env->SetIntField(thiz, fields.fidJniData, 0);
+ env->SetLongField(thiz, fields.fidJniData, 0);
if (uuidStr != NULL) {
env->ReleaseStringUTFChars(uuid, uuidStr);
@@ -419,27 +419,27 @@ setup_failure:
env->ReleaseStringUTFChars(type, typeStr);
}
- return lStatus;
+ return (jint)lStatus;
}
// ----------------------------------------------------------------------------
static void android_media_AudioEffect_native_finalize(JNIEnv *env, jobject thiz) {
- ALOGV("android_media_AudioEffect_native_finalize jobject: %x\n", (int)thiz);
+ ALOGV("android_media_AudioEffect_native_finalize jobject: %p\n", thiz);
// delete the AudioEffect object
- AudioEffect* lpAudioEffect = (AudioEffect *)env->GetIntField(
+ AudioEffect* lpAudioEffect = (AudioEffect *)env->GetLongField(
thiz, fields.fidNativeAudioEffect);
if (lpAudioEffect) {
- ALOGV("deleting AudioEffect: %x\n", (int)lpAudioEffect);
+ ALOGV("deleting AudioEffect: %p\n", lpAudioEffect);
delete lpAudioEffect;
}
// delete the JNI data
- AudioEffectJniStorage* lpJniStorage = (AudioEffectJniStorage *)env->GetIntField(
+ AudioEffectJniStorage* lpJniStorage = (AudioEffectJniStorage *)env->GetLongField(
thiz, fields.fidJniData);
if (lpJniStorage) {
- ALOGV("deleting pJniStorage: %x\n", (int)lpJniStorage);
+ ALOGV("deleting pJniStorage: %p\n", lpJniStorage);
delete lpJniStorage;
}
}
@@ -451,15 +451,15 @@ static void android_media_AudioEffect_native_release(JNIEnv *env, jobject thiz)
android_media_AudioEffect_native_finalize(env, thiz);
// + reset the native resources in the Java object so any attempt to access
// them after a call to release fails.
- env->SetIntField(thiz, fields.fidNativeAudioEffect, 0);
- env->SetIntField(thiz, fields.fidJniData, 0);
+ env->SetLongField(thiz, fields.fidNativeAudioEffect, 0);
+ env->SetLongField(thiz, fields.fidJniData, 0);
}
static jint
android_media_AudioEffect_native_setEnabled(JNIEnv *env, jobject thiz, jboolean enabled)
{
// retrieve the AudioEffect object
- AudioEffect* lpAudioEffect = (AudioEffect *)env->GetIntField(
+ AudioEffect* lpAudioEffect = (AudioEffect *)env->GetLongField(
thiz, fields.fidNativeAudioEffect);
if (lpAudioEffect == NULL) {
@@ -468,23 +468,27 @@ android_media_AudioEffect_native_setEnabled(JNIEnv *env, jobject thiz, jboolean
return AUDIOEFFECT_ERROR_NO_INIT;
}
- return translateError(lpAudioEffect->setEnabled(enabled));
+ return (jint) translateError(lpAudioEffect->setEnabled(enabled));
}
static jboolean
android_media_AudioEffect_native_getEnabled(JNIEnv *env, jobject thiz)
{
// retrieve the AudioEffect object
- AudioEffect* lpAudioEffect = (AudioEffect *)env->GetIntField(
+ AudioEffect* lpAudioEffect = (AudioEffect *)env->GetLongField(
thiz, fields.fidNativeAudioEffect);
if (lpAudioEffect == NULL) {
jniThrowException(env, "java/lang/IllegalStateException",
"Unable to retrieve AudioEffect pointer for getEnabled()");
- return false;
+ return JNI_FALSE;
}
- return (jboolean)lpAudioEffect->getEnabled();
+ if (lpAudioEffect->getEnabled()) {
+ return JNI_TRUE;
+ } else {
+ return JNI_FALSE;
+ }
}
@@ -492,24 +496,24 @@ static jboolean
android_media_AudioEffect_native_hasControl(JNIEnv *env, jobject thiz)
{
// retrieve the AudioEffect object
- AudioEffect* lpAudioEffect = (AudioEffect *)env->GetIntField(
+ AudioEffect* lpAudioEffect = (AudioEffect *)env->GetLongField(
thiz, fields.fidNativeAudioEffect);
if (lpAudioEffect == NULL) {
jniThrowException(env, "java/lang/IllegalStateException",
"Unable to retrieve AudioEffect pointer for hasControl()");
- return false;
+ return JNI_FALSE;
}
if (lpAudioEffect->initCheck() == NO_ERROR) {
- return true;
+ return JNI_TRUE;
} else {
- return false;
+ return JNI_FALSE;
}
}
static jint android_media_AudioEffect_native_setParameter(JNIEnv *env,
- jobject thiz, int psize, jbyteArray pJavaParam, int vsize,
+ jobject thiz, jint psize, jbyteArray pJavaParam, jint vsize,
jbyteArray pJavaValue) {
// retrieve the AudioEffect object
jbyte* lpValue = NULL;
@@ -518,7 +522,7 @@ static jint android_media_AudioEffect_native_setParameter(JNIEnv *env,
effect_param_t *p;
int voffset;
- AudioEffect* lpAudioEffect = (AudioEffect *) env->GetIntField(thiz,
+ AudioEffect* lpAudioEffect = (AudioEffect *) env->GetLongField(thiz,
fields.fidNativeAudioEffect);
if (lpAudioEffect == NULL) {
@@ -567,7 +571,7 @@ setParameter_Exit:
if (lpValue != NULL) {
env->ReleasePrimitiveArrayCritical(pJavaValue, lpValue, 0);
}
- return translateError(lStatus);
+ return (jint) translateError(lStatus);
}
static jint
@@ -581,7 +585,7 @@ android_media_AudioEffect_native_getParameter(JNIEnv *env,
effect_param_t *p;
int voffset;
- AudioEffect* lpAudioEffect = (AudioEffect *) env->GetIntField(thiz,
+ AudioEffect* lpAudioEffect = (AudioEffect *) env->GetLongField(thiz,
fields.fidNativeAudioEffect);
if (lpAudioEffect == NULL) {
@@ -637,7 +641,7 @@ getParameter_Exit:
if (lStatus == NO_ERROR) {
return vsize;
}
- return translateError(lStatus);
+ return (jint) translateError(lStatus);
}
static jint android_media_AudioEffect_native_command(JNIEnv *env, jobject thiz,
@@ -648,7 +652,7 @@ static jint android_media_AudioEffect_native_command(JNIEnv *env, jobject thiz,
jint lStatus = AUDIOEFFECT_ERROR_BAD_VALUE;
// retrieve the AudioEffect object
- AudioEffect* lpAudioEffect = (AudioEffect *) env->GetIntField(thiz,
+ AudioEffect* lpAudioEffect = (AudioEffect *) env->GetLongField(thiz,
fields.fidNativeAudioEffect);
if (lpAudioEffect == NULL) {
diff --git a/media/jni/audioeffect/android_media_Visualizer.cpp b/media/jni/audioeffect/android_media_Visualizer.cpp
index 40cd06b..8463d94 100644
--- a/media/jni/audioeffect/android_media_Visualizer.cpp
+++ b/media/jni/audioeffect/android_media_Visualizer.cpp
@@ -231,7 +231,7 @@ static void captureCallback(void* user,
static Visualizer *getVisualizer(JNIEnv* env, jobject thiz)
{
- Visualizer *v = (Visualizer *)env->GetIntField(
+ Visualizer *v = (Visualizer *)env->GetLongField(
thiz, fields.fidNativeVisualizer);
if (v == NULL) {
jniThrowException(env, "java/lang/IllegalStateException",
@@ -282,7 +282,7 @@ android_media_visualizer_native_init(JNIEnv *env)
// nativeTrackInJavaObj
fields.fidNativeVisualizer = env->GetFieldID(
fields.clazzEffect,
- "mNativeVisualizer", "I");
+ "mNativeVisualizer", "J");
if (fields.fidNativeVisualizer == NULL) {
ALOGE("Can't find Visualizer.%s", "mNativeVisualizer");
return;
@@ -290,7 +290,7 @@ android_media_visualizer_native_init(JNIEnv *env)
// fidJniData;
fields.fidJniData = env->GetFieldID(
fields.clazzEffect,
- "mJniData", "I");
+ "mJniData", "J");
if (fields.fidJniData == NULL) {
ALOGE("Can't find Visualizer.%s", "mJniData");
return;
@@ -391,9 +391,9 @@ android_media_visualizer_native_setup(JNIEnv *env, jobject thiz, jobject weak_th
env->ReleasePrimitiveArrayCritical(jId, nId, 0);
nId = NULL;
- env->SetIntField(thiz, fields.fidNativeVisualizer, (int)lpVisualizer);
+ env->SetLongField(thiz, fields.fidNativeVisualizer, (jlong)lpVisualizer);
- env->SetIntField(thiz, fields.fidJniData, (int)lpJniStorage);
+ env->SetLongField(thiz, fields.fidJniData, (jlong)lpJniStorage);
return VISUALIZER_SUCCESS;
@@ -407,33 +407,33 @@ setup_failure:
if (lpVisualizer) {
delete lpVisualizer;
}
- env->SetIntField(thiz, fields.fidNativeVisualizer, 0);
+ env->SetLongField(thiz, fields.fidNativeVisualizer, 0);
if (lpJniStorage) {
delete lpJniStorage;
}
- env->SetIntField(thiz, fields.fidJniData, 0);
+ env->SetLongField(thiz, fields.fidJniData, 0);
- return lStatus;
+ return (jint) lStatus;
}
// ----------------------------------------------------------------------------
static void android_media_visualizer_native_finalize(JNIEnv *env, jobject thiz) {
- ALOGV("android_media_visualizer_native_finalize jobject: %x\n", (int)thiz);
+ ALOGV("android_media_visualizer_native_finalize jobject: %p\n", thiz);
// delete the Visualizer object
- Visualizer* lpVisualizer = (Visualizer *)env->GetIntField(
+ Visualizer* lpVisualizer = (Visualizer *)env->GetLongField(
thiz, fields.fidNativeVisualizer);
if (lpVisualizer) {
- ALOGV("deleting Visualizer: %x\n", (int)lpVisualizer);
+ ALOGV("deleting Visualizer: %p\n", lpVisualizer);
delete lpVisualizer;
}
// delete the JNI data
- visualizerJniStorage* lpJniStorage = (visualizerJniStorage *)env->GetIntField(
+ visualizerJniStorage* lpJniStorage = (visualizerJniStorage *)env->GetLongField(
thiz, fields.fidJniData);
if (lpJniStorage) {
- ALOGV("deleting pJniStorage: %x\n", (int)lpJniStorage);
+ ALOGV("deleting pJniStorage: %p\n", lpJniStorage);
delete lpJniStorage;
}
}
@@ -445,8 +445,8 @@ static void android_media_visualizer_native_release(JNIEnv *env, jobject thiz)
android_media_visualizer_native_finalize(env, thiz);
// + reset the native resources in the Java object so any attempt to access
// them after a call to release fails.
- env->SetIntField(thiz, fields.fidNativeVisualizer, 0);
- env->SetIntField(thiz, fields.fidJniData, 0);
+ env->SetLongField(thiz, fields.fidNativeVisualizer, 0);
+ env->SetLongField(thiz, fields.fidJniData, 0);
}
static jint
@@ -460,7 +460,7 @@ android_media_visualizer_native_setEnabled(JNIEnv *env, jobject thiz, jboolean e
jint retVal = translateError(lpVisualizer->setEnabled(enabled));
if (!enabled) {
- visualizerJniStorage* lpJniStorage = (visualizerJniStorage *)env->GetIntField(
+ visualizerJniStorage* lpJniStorage = (visualizerJniStorage *)env->GetLongField(
thiz, fields.fidJniData);
if (NULL != lpJniStorage)
@@ -475,10 +475,14 @@ android_media_visualizer_native_getEnabled(JNIEnv *env, jobject thiz)
{
Visualizer* lpVisualizer = getVisualizer(env, thiz);
if (lpVisualizer == NULL) {
- return false;
+ return JNI_FALSE;
}
- return (jboolean)lpVisualizer->getEnabled();
+ if (lpVisualizer->getEnabled()) {
+ return JNI_TRUE;
+ } else {
+ return JNI_FALSE;
+ }
}
static jintArray
@@ -496,7 +500,7 @@ android_media_visualizer_native_getCaptureSizeRange(JNIEnv *env, jobject thiz)
static jint
android_media_visualizer_native_getMaxCaptureRate(JNIEnv *env, jobject thiz)
{
- return Visualizer::getMaxCaptureRate();
+ return (jint) Visualizer::getMaxCaptureRate();
}
static jint
@@ -517,7 +521,7 @@ android_media_visualizer_native_getCaptureSize(JNIEnv *env, jobject thiz)
if (lpVisualizer == NULL) {
return -1;
}
- return lpVisualizer->getCaptureSize();
+ return (jint) lpVisualizer->getCaptureSize();
}
static jint
@@ -538,7 +542,7 @@ android_media_visualizer_native_getScalingMode(JNIEnv *env, jobject thiz)
if (lpVisualizer == NULL) {
return -1;
}
- return lpVisualizer->getScalingMode();
+ return (jint)lpVisualizer->getScalingMode();
}
static jint
@@ -568,7 +572,7 @@ android_media_visualizer_native_getSamplingRate(JNIEnv *env, jobject thiz)
if (lpVisualizer == NULL) {
return -1;
}
- return lpVisualizer->getSamplingRate();
+ return (jint) lpVisualizer->getSamplingRate();
}
static jint
@@ -634,7 +638,7 @@ android_media_setPeriodicCapture(JNIEnv *env, jobject thiz, jint rate, jboolean
if (lpVisualizer == NULL) {
return VISUALIZER_ERROR_NO_INIT;
}
- visualizerJniStorage* lpJniStorage = (visualizerJniStorage *)env->GetIntField(thiz,
+ visualizerJniStorage* lpJniStorage = (visualizerJniStorage *)env->GetLongField(thiz,
fields.fidJniData);
if (lpJniStorage == NULL) {
return VISUALIZER_ERROR_NO_INIT;
diff --git a/media/jni/mediaeditor/VideoEditorClasses.cpp b/media/jni/mediaeditor/VideoEditorClasses.cpp
index d8099dd..d29fad3 100644
--- a/media/jni/mediaeditor/VideoEditorClasses.cpp
+++ b/media/jni/mediaeditor/VideoEditorClasses.cpp
@@ -609,7 +609,7 @@ VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(EffectSettings, EFFECT_SETTINGS_CLASS_NAME)
VIDEOEDIT_JAVA_DEFINE_FIELDS(Engine)
{
- VIDEOEDIT_JAVA_FIELD_INIT("mManualEditContext", "I")
+ VIDEOEDIT_JAVA_FIELD_INIT("mManualEditContext", "J")
};
VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(Engine, MANUAL_EDIT_ENGINE_CLASS_NAME)
@@ -3096,7 +3096,7 @@ videoEditClasses_getContext(
if (*pResult)
{
// Retrieve the context pointer.
- pContext = (void *)pEnv->GetIntField(object, fieldIds.context);
+ pContext = (void *)pEnv->GetLongField(object, fieldIds.context);
}
// Return the context pointer.
@@ -3132,15 +3132,15 @@ videoEditClasses_setContext(
{
// Set the context field.
VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
- "The context value from JAVA before setting is = 0x%x",
- pEnv->GetIntField(object, fieldIds.context));
+ "The context value from JAVA before setting is = %p",
+ (void *)pEnv->GetLongField(object, fieldIds.context));
- pEnv->SetIntField(object, fieldIds.context, (int)pContext);
- M4OSA_TRACE1_1("The context value in JNI is = 0x%x",pContext);
+ pEnv->SetLongField(object, fieldIds.context, (jlong)pContext);
+ M4OSA_TRACE1_1("The context value in JNI is = %p",pContext);
VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
- "The context value from JAVA after setting is = 0x%x",
- pEnv->GetIntField(object, fieldIds.context));
+ "The context value from JAVA after setting is = %p",
+ (void *)pEnv->GetLongField(object, fieldIds.context));
}
}
diff --git a/media/jni/mediaeditor/VideoEditorMain.cpp b/media/jni/mediaeditor/VideoEditorMain.cpp
index c1ad516..058012b 100644
--- a/media/jni/mediaeditor/VideoEditorMain.cpp
+++ b/media/jni/mediaeditor/VideoEditorMain.cpp
@@ -170,7 +170,7 @@ static void videoEditor_stopEncoding(
static void videoEditor_release(
JNIEnv* pEnv,
jobject thiz);
-static int videoEditor_getPixels(
+static jint videoEditor_getPixels(
JNIEnv* env,
jobject thiz,
jstring path,
@@ -178,7 +178,7 @@ static int videoEditor_getPixels(
M4OSA_UInt32 width,
M4OSA_UInt32 height,
M4OSA_UInt32 timeMS);
-static int videoEditor_getPixelsList(
+static jint videoEditor_getPixelsList(
JNIEnv* env,
jobject thiz,
jstring path,
@@ -209,7 +209,7 @@ videoEditor_populateSettings(
jobject object,
jobject audioSettingObject);
-static int videoEditor_stopPreview(JNIEnv* pEnv,
+static jint videoEditor_stopPreview(JNIEnv* pEnv,
jobject thiz);
static jobject
@@ -218,7 +218,7 @@ videoEditor_getProperties(
jobject thiz,
jstring file);
-static int videoEditor_renderPreviewFrame(JNIEnv* pEnv,
+static jint videoEditor_renderPreviewFrame(JNIEnv* pEnv,
jobject thiz,
jobject mSurface,
jlong fromMs,
@@ -231,7 +231,7 @@ static int videoEditor_registerManualEditMethods(
static void jniPreviewProgressCallback(void* cookie, M4OSA_UInt32 msgType,
void *argc);
-static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv,
+static jint videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv,
jobject thiz,
jobject mSurface,
jstring filePath,
@@ -241,7 +241,7 @@ static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv,
jint surfaceHeight,
jlong fromMs);
-static int videoEditor_generateAudioWaveFormSync ( JNIEnv* pEnv,
+static jint videoEditor_generateAudioWaveFormSync ( JNIEnv* pEnv,
jobject thiz,
jstring pcmfilePath,
jstring outGraphfilePath,
@@ -258,7 +258,7 @@ M4OSA_ERR videoEditor_generateAudio(JNIEnv* pEnv,ManualEditContext* pContext,
M4OSA_Char* infilePath,
M4OSA_Char* pcmfilePath );
-static int
+static jint
videoEditor_generateClip(
JNIEnv* pEnv,
jobject thiz,
@@ -572,7 +572,7 @@ static M4OSA_ERR checkClipVideoProfileAndLevel(M4DECODER_VideoDecoders *pDecoder
return result;
}
-static int videoEditor_stopPreview(JNIEnv* pEnv,
+static jint videoEditor_stopPreview(JNIEnv* pEnv,
jobject thiz)
{
ManualEditContext* pContext = M4OSA_NULL;
@@ -594,7 +594,7 @@ static int videoEditor_stopPreview(JNIEnv* pEnv,
pContext->mOverlayFileName = NULL;
}
- return lastProgressTimeMs;
+ return (jint)lastProgressTimeMs;
}
static void videoEditor_clearSurface(JNIEnv* pEnv,
@@ -654,7 +654,7 @@ static void videoEditor_clearSurface(JNIEnv* pEnv,
}
-static int videoEditor_renderPreviewFrame(JNIEnv* pEnv,
+static jint videoEditor_renderPreviewFrame(JNIEnv* pEnv,
jobject thiz,
jobject mSurface,
jlong fromMs,
@@ -976,10 +976,10 @@ static int videoEditor_renderPreviewFrame(JNIEnv* pEnv,
free(yuvPlane);
}
- return tnTimeMs;
+ return (jint)tnTimeMs;
}
-static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv,
+static jint videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv,
jobject thiz,
jobject mSurface,
jstring filePath,
@@ -1033,7 +1033,7 @@ static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv,
/* get thumbnail*/
result = ThumbnailOpen(&tnContext,(const M4OSA_Char*)pString, M4OSA_TRUE);
if (result != M4NO_ERROR || tnContext == M4OSA_NULL) {
- return timeMs;
+ return (jint)timeMs;
}
framesizeYuv = ((frameWidth)*(frameHeight)*1.5);
@@ -1046,7 +1046,7 @@ static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv,
ThumbnailClose(tnContext);
pMessage = videoEditJava_getErrorName(M4ERR_ALLOC);
jniThrowException(pEnv, "java/lang/RuntimeException", pMessage);
- return timeMs;
+ return (jint)timeMs;
}
result = ThumbnailGetPixels16(tnContext, (M4OSA_Int16 *)pixelArray,
@@ -1055,7 +1055,7 @@ static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv,
if (result != M4NO_ERROR) {
free(pixelArray);
ThumbnailClose(tnContext);
- return fromMs;
+ return (jint)fromMs;
}
#ifdef DUMPTOFILESYSTEM
@@ -1131,10 +1131,10 @@ static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv,
pEnv->ReleaseStringUTFChars(filePath, pString);
}
- return timeMs;
+ return (jint)timeMs;
}
-int videoEditor_generateAudioRawFile( JNIEnv* pEnv,
+jint videoEditor_generateAudioRawFile( JNIEnv* pEnv,
jobject thiz,
jstring infilePath,
jstring pcmfilePath)
@@ -1178,7 +1178,7 @@ int videoEditor_generateAudioRawFile( JNIEnv* pEnv,
pEnv->ReleaseStringUTFChars(pcmfilePath, pStringOutPCMFilePath);
}
- return result;
+ return (jint)result;
}
M4OSA_ERR videoEditor_generateAudio(JNIEnv* pEnv,ManualEditContext* pContext,
@@ -2182,7 +2182,7 @@ videoEditor_getProperties(
return object;
}
-static int videoEditor_getPixels(
+static jint videoEditor_getPixels(
JNIEnv* env,
jobject thiz,
jstring path,
@@ -2234,10 +2234,10 @@ static int videoEditor_getPixels(
env->ReleaseStringUTFChars(path, pString);
}
- return timeMS;
+ return (jint)timeMS;
}
-static int videoEditor_getPixelsList(
+static jint videoEditor_getPixelsList(
JNIEnv* env,
jobject thiz,
jstring path,
@@ -2257,7 +2257,7 @@ static int videoEditor_getPixelsList(
const char *pString = env->GetStringUTFChars(path, NULL);
if (pString == M4OSA_NULL) {
jniThrowException(env, "java/lang/RuntimeException", "Input string null");
- return M4ERR_ALLOC;
+ return (jint)M4ERR_ALLOC;
}
err = ThumbnailOpen(&mContext,(const M4OSA_Char*)pString, M4OSA_FALSE);
@@ -2266,7 +2266,7 @@ static int videoEditor_getPixelsList(
if (pString != NULL) {
env->ReleaseStringUTFChars(path, pString);
}
- return err;
+ return (jint)err;
}
jlong duration = (endTime - startTime);
@@ -2307,7 +2307,7 @@ static int videoEditor_getPixelsList(
"ThumbnailGetPixels32 failed");
}
- return err;
+ return (jint)err;
}
static M4OSA_ERR
@@ -2892,7 +2892,7 @@ M4OSA_ERR videoEditor_processClip(
}
/*+ PROGRESS CB */
-static int
+static jint
videoEditor_generateClip(
JNIEnv* pEnv,
jobject thiz,
@@ -2934,7 +2934,7 @@ videoEditor_generateClip(
}
ALOGV("videoEditor_generateClip END 0x%x", (unsigned int) result);
- return result;
+ return (jint)result;
}
static void
@@ -3556,7 +3556,7 @@ M4OSA_ERR M4MA_generateAudioGraphFile(JNIEnv* pEnv, M4OSA_Char* pInputFileURL,
return err;
}
-static int videoEditor_generateAudioWaveFormSync (JNIEnv* pEnv, jobject thiz,
+static jint videoEditor_generateAudioWaveFormSync (JNIEnv* pEnv, jobject thiz,
jstring pcmfilePath,
jstring outGraphfilePath,
jint frameDuration, jint channels,
@@ -3619,7 +3619,7 @@ out:
VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR",
"videoEditor_generateAudioWaveFormSync pContext->bSkipState ");
- return result;
+ return (jint)result;
}
/******** End Audio Graph *******/
diff --git a/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp b/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp
index 2604850..9cc55ab 100644
--- a/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp
+++ b/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp
@@ -34,11 +34,11 @@ static struct fields_t {
} fields;
static inline SoundPool* MusterSoundPool(JNIEnv *env, jobject thiz) {
- return (SoundPool*)env->GetIntField(thiz, fields.mNativeContext);
+ return (SoundPool*)env->GetLongField(thiz, fields.mNativeContext);
}
// ----------------------------------------------------------------------------
-static int
+static jint
android_media_SoundPool_SoundPoolImpl_load_URL(JNIEnv *env, jobject thiz, jstring path, jint priority)
{
ALOGV("android_media_SoundPool_SoundPoolImpl_load_URL");
@@ -50,29 +50,29 @@ android_media_SoundPool_SoundPoolImpl_load_URL(JNIEnv *env, jobject thiz, jstrin
const char* s = env->GetStringUTFChars(path, NULL);
int id = ap->load(s, priority);
env->ReleaseStringUTFChars(path, s);
- return id;
+ return (jint) id;
}
-static int
+static jint
android_media_SoundPool_SoundPoolImpl_load_FD(JNIEnv *env, jobject thiz, jobject fileDescriptor,
jlong offset, jlong length, jint priority)
{
ALOGV("android_media_SoundPool_SoundPoolImpl_load_FD");
SoundPool *ap = MusterSoundPool(env, thiz);
if (ap == NULL) return 0;
- return ap->load(jniGetFDFromFileDescriptor(env, fileDescriptor),
+ return (jint) ap->load(jniGetFDFromFileDescriptor(env, fileDescriptor),
int64_t(offset), int64_t(length), int(priority));
}
-static bool
+static jboolean
android_media_SoundPool_SoundPoolImpl_unload(JNIEnv *env, jobject thiz, jint sampleID) {
ALOGV("android_media_SoundPool_SoundPoolImpl_unload\n");
SoundPool *ap = MusterSoundPool(env, thiz);
- if (ap == NULL) return 0;
- return ap->unload(sampleID);
+ if (ap == NULL) return JNI_FALSE;
+ return ap->unload(sampleID) ? JNI_TRUE : JNI_FALSE;
}
-static int
+static jint
android_media_SoundPool_SoundPoolImpl_play(JNIEnv *env, jobject thiz, jint sampleID,
jfloat leftVolume, jfloat rightVolume, jint priority, jint loop,
jfloat rate)
@@ -80,7 +80,7 @@ android_media_SoundPool_SoundPoolImpl_play(JNIEnv *env, jobject thiz, jint sampl
ALOGV("android_media_SoundPool_SoundPoolImpl_play\n");
SoundPool *ap = MusterSoundPool(env, thiz);
if (ap == NULL) return 0;
- return ap->play(sampleID, leftVolume, rightVolume, priority, loop, rate);
+ return (jint) ap->play(sampleID, leftVolume, rightVolume, priority, loop, rate);
}
static void
@@ -130,22 +130,22 @@ android_media_SoundPool_SoundPoolImpl_stop(JNIEnv *env, jobject thiz, jint chann
static void
android_media_SoundPool_SoundPoolImpl_setVolume(JNIEnv *env, jobject thiz, jint channelID,
- float leftVolume, float rightVolume)
+ jfloat leftVolume, jfloat rightVolume)
{
ALOGV("android_media_SoundPool_SoundPoolImpl_setVolume");
SoundPool *ap = MusterSoundPool(env, thiz);
if (ap == NULL) return;
- ap->setVolume(channelID, leftVolume, rightVolume);
+ ap->setVolume(channelID, (float) leftVolume, (float) rightVolume);
}
static void
android_media_SoundPool_SoundPoolImpl_setPriority(JNIEnv *env, jobject thiz, jint channelID,
- int priority)
+ jint priority)
{
ALOGV("android_media_SoundPool_SoundPoolImpl_setPriority");
SoundPool *ap = MusterSoundPool(env, thiz);
if (ap == NULL) return;
- ap->setPriority(channelID, priority);
+ ap->setPriority(channelID, (int) priority);
}
static void
@@ -160,12 +160,12 @@ android_media_SoundPool_SoundPoolImpl_setLoop(JNIEnv *env, jobject thiz, jint ch
static void
android_media_SoundPool_SoundPoolImpl_setRate(JNIEnv *env, jobject thiz, jint channelID,
- float rate)
+ jfloat rate)
{
ALOGV("android_media_SoundPool_SoundPoolImpl_setRate");
SoundPool *ap = MusterSoundPool(env, thiz);
if (ap == NULL) return;
- ap->setRate(channelID, rate);
+ ap->setRate(channelID, (float) rate);
}
static void android_media_callback(SoundPoolEvent event, SoundPool* soundPool, void* user)
@@ -185,7 +185,7 @@ android_media_SoundPool_SoundPoolImpl_native_setup(JNIEnv *env, jobject thiz, jo
}
// save pointer to SoundPool C++ object in opaque field in Java object
- env->SetIntField(thiz, fields.mNativeContext, (int)ap);
+ env->SetLongField(thiz, fields.mNativeContext, (jlong) ap);
// set callback with weak reference
jobject globalWeakRef = env->NewGlobalRef(weakRef);
@@ -208,7 +208,7 @@ android_media_SoundPool_SoundPoolImpl_release(JNIEnv *env, jobject thiz)
// clear callback and native context
ap->setCallback(NULL, NULL);
- env->SetIntField(thiz, fields.mNativeContext, 0);
+ env->SetLongField(thiz, fields.mNativeContext, 0);
delete ap;
}
}
@@ -299,7 +299,7 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
goto bail;
}
- fields.mNativeContext = env->GetFieldID(clazz, "mNativeContext", "I");
+ fields.mNativeContext = env->GetFieldID(clazz, "mNativeContext", "J");
if (fields.mNativeContext == NULL) {
ALOGE("Can't find SoundPoolImpl.mNativeContext");
goto bail;
diff --git a/media/lib/Android.mk b/media/lib/remotedisplay/Android.mk
index 50799a6..ea1ac2b 100644
--- a/media/lib/Android.mk
+++ b/media/lib/remotedisplay/Android.mk
@@ -15,7 +15,7 @@
#
LOCAL_PATH := $(call my-dir)
-# the library
+# the remotedisplay library
# ============================================================
include $(CLEAR_VARS)
@@ -23,7 +23,7 @@ LOCAL_MODULE:= com.android.media.remotedisplay
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := \
- $(call all-subdir-java-files) \
+ $(call all-java-files-under, java) \
$(call all-aidl-files-under, java)
include $(BUILD_JAVA_LIBRARY)
diff --git a/media/lib/README.txt b/media/lib/remotedisplay/README.txt
index cade3df..5738dbe 100644
--- a/media/lib/README.txt
+++ b/media/lib/remotedisplay/README.txt
@@ -25,4 +25,3 @@ with the framework in a new API. That API isn't ready yet so this
library is a compromise to make new capabilities available to the system
without exposing the full surface area of the support library media
route provider protocol.
-
diff --git a/media/lib/com.android.media.remotedisplay.xml b/media/lib/remotedisplay/com.android.media.remotedisplay.xml
index 77a91d2..77a91d2 100644
--- a/media/lib/com.android.media.remotedisplay.xml
+++ b/media/lib/remotedisplay/com.android.media.remotedisplay.xml
diff --git a/media/lib/java/com/android/media/remotedisplay/RemoteDisplay.java b/media/lib/remotedisplay/java/com/android/media/remotedisplay/RemoteDisplay.java
index 5e15702..6cfc0e8 100644
--- a/media/lib/java/com/android/media/remotedisplay/RemoteDisplay.java
+++ b/media/lib/remotedisplay/java/com/android/media/remotedisplay/RemoteDisplay.java
@@ -16,12 +16,12 @@
package com.android.media.remotedisplay;
-import com.android.internal.util.Objects;
-
import android.media.MediaRouter;
import android.media.RemoteDisplayState.RemoteDisplayInfo;
import android.text.TextUtils;
+import java.util.Objects;
+
/**
* Represents a remote display that has been discovered.
*/
@@ -87,7 +87,7 @@ public class RemoteDisplay {
}
public void setName(String name) {
- if (!Objects.equal(mMutableInfo.name, name)) {
+ if (!Objects.equals(mMutableInfo.name, name)) {
mMutableInfo.name = name;
mImmutableInfo = null;
}
@@ -98,7 +98,7 @@ public class RemoteDisplay {
}
public void setDescription(String description) {
- if (!Objects.equal(mMutableInfo.description, description)) {
+ if (!Objects.equals(mMutableInfo.description, description)) {
mMutableInfo.description = description;
mImmutableInfo = null;
}
diff --git a/media/lib/java/com/android/media/remotedisplay/RemoteDisplayProvider.java b/media/lib/remotedisplay/java/com/android/media/remotedisplay/RemoteDisplayProvider.java
index e2df77c..e2df77c 100644
--- a/media/lib/java/com/android/media/remotedisplay/RemoteDisplayProvider.java
+++ b/media/lib/remotedisplay/java/com/android/media/remotedisplay/RemoteDisplayProvider.java
diff --git a/media/lib/signer/Android.mk b/media/lib/signer/Android.mk
new file mode 100644
index 0000000..4c3772f
--- /dev/null
+++ b/media/lib/signer/Android.mk
@@ -0,0 +1,45 @@
+#
+# Copyright (C) 2013 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+LOCAL_PATH := $(call my-dir)
+
+# the mediadrm signer library
+# ============================================================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE:= com.android.mediadrm.signer
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := \
+ $(call all-java-files-under, java)
+
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+
+# ==== com.android.mediadrm.signer.xml lib def ========================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := com.android.mediadrm.signer.xml
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_CLASS := ETC
+
+# This will install the file in /system/etc/permissions
+#
+LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/permissions
+
+LOCAL_SRC_FILES := $(LOCAL_MODULE)
+
+include $(BUILD_PREBUILT)
diff --git a/media/lib/signer/README.txt b/media/lib/signer/README.txt
new file mode 100644
index 0000000..362ab8e
--- /dev/null
+++ b/media/lib/signer/README.txt
@@ -0,0 +1,28 @@
+This library (com.android.mediadrm.signer.jar) is a shared java library
+containing classes required by unbundled apps running on devices that use
+the certficate provisioning and private key signing capabilities provided
+by the MediaDrm API.
+
+--- Rules of this library ---
+o This library is effectively a PUBLIC API for unbundled CAST receivers
+ that may be distributed outside the system image. So it MUST BE API STABLE.
+ You can add but not remove. The rules are the same as for the
+ public platform SDK API.
+o This library can see and instantiate internal platform classes, but it must not
+ expose them in any public method (or by extending them via inheritance). This would
+ break clients of the library because they cannot see the internal platform classes.
+
+This library is distributed in the system image, and loaded as
+a shared library. So you can change the implementation, but not
+the interface. In this way it is like framework.jar.
+
+--- Why does this library exist? ---
+
+Unbundled apps cannot use internal platform classes.
+
+This library will eventually be replaced when the provisioned certificate-
+based signing infrastructure that is currently defined in the support library
+is reintegrated with the framework in a new API. That API isn't ready yet so
+this library is a compromise to make new capabilities available to the system
+without exposing the full surface area of the support library.
+
diff --git a/media/lib/signer/com.android.mediadrm.signer.xml b/media/lib/signer/com.android.mediadrm.signer.xml
new file mode 100644
index 0000000..b5b1f09
--- /dev/null
+++ b/media/lib/signer/com.android.mediadrm.signer.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<permissions>
+ <library name="com.android.media.drm.signer"
+ file="/system/framework/com.android.media.drm.signer.jar" />
+</permissions>
diff --git a/media/lib/signer/java/com/android/mediadrm/signer/MediaDrmSigner.java b/media/lib/signer/java/com/android/mediadrm/signer/MediaDrmSigner.java
new file mode 100644
index 0000000..0a2897f
--- /dev/null
+++ b/media/lib/signer/java/com/android/mediadrm/signer/MediaDrmSigner.java
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.mediadrm.signer;
+
+import android.media.MediaDrm;
+import android.media.DeniedByServerException;
+
+/**
+ * Provides certificate request generation, response handling and
+ * signing APIs
+ */
+public final class MediaDrmSigner {
+ private MediaDrmSigner() {}
+
+ /**
+ * Specify X.509 certificate type
+ */
+ public static final int CERTIFICATE_TYPE_X509 = MediaDrm.CERTIFICATE_TYPE_X509;
+
+ /**
+ * Contains the opaque data an app uses to request a certificate from a provisioning
+ * server
+ */
+ public final static class CertificateRequest {
+ private final MediaDrm.CertificateRequest mCertRequest;
+
+ CertificateRequest(MediaDrm.CertificateRequest certRequest) {
+ mCertRequest = certRequest;
+ }
+
+ /**
+ * Get the opaque message data
+ */
+ public byte[] getData() {
+ return mCertRequest.getData();
+ }
+
+ /**
+ * Get the default URL to use when sending the certificate request
+ * message to a server, if known. The app may prefer to use a different
+ * certificate server URL obtained from other sources.
+ */
+ public String getDefaultUrl() {
+ return mCertRequest.getDefaultUrl();
+ }
+ }
+
+ /**
+ * Contains the wrapped private key and public certificate data associated
+ * with a certificate.
+ */
+ public final static class Certificate {
+ private final MediaDrm.Certificate mCertificate;
+
+ Certificate(MediaDrm.Certificate certificate) {
+ mCertificate = certificate;
+ }
+
+ /**
+ * Get the wrapped private key data
+ */
+ public byte[] getWrappedPrivateKey() {
+ return mCertificate.getWrappedPrivateKey();
+ }
+
+ /**
+ * Get the PEM-encoded public certificate chain
+ */
+ public byte[] getContent() {
+ return mCertificate.getContent();
+ }
+ }
+
+ /**
+ * Generate a certificate request, specifying the certificate type
+ * and authority. The response received should be passed to
+ * provideCertificateResponse.
+ *
+ * @param drm the MediaDrm object
+ * @param certType Specifies the certificate type.
+ * @param certAuthority is passed to the certificate server to specify
+ * the chain of authority.
+ */
+ public static CertificateRequest getCertificateRequest(MediaDrm drm, int certType,
+ String certAuthority) {
+ return new CertificateRequest(drm.getCertificateRequest(certType, certAuthority));
+ }
+
+ /**
+ * Process a response from the provisioning server. The response
+ * is obtained from an HTTP Post to the url provided by getCertificateRequest.
+ *
+ * The public X509 certificate chain and wrapped private key are returned
+ * in the returned Certificate objec. The certificate chain is in BIO serialized
+ * PEM format. The wrapped private key should be stored in application private
+ * storage, and used when invoking the signRSA method.
+ *
+ * @param drm the MediaDrm object
+ * @param response the opaque certificate response byte array to provide to the
+ * DRM engine plugin.
+ * @throws android.media.DeniedByServerException if the response indicates that the
+ * server rejected the request
+ */
+ public static Certificate provideCertificateResponse(MediaDrm drm, byte[] response)
+ throws DeniedByServerException {
+ return new Certificate(drm.provideCertificateResponse(response));
+ }
+
+ /**
+ * Sign data using an RSA key
+ *
+ * @param drm the MediaDrm object
+ * @param sessionId a sessionId obtained from openSession on the MediaDrm object
+ * @param algorithm the signing algorithm to use, e.g. "PKCS1-BlockType1"
+ * @param wrappedKey - the wrapped (encrypted) RSA private key obtained
+ * from provideCertificateResponse
+ * @param message the data for which a signature is to be computed
+ */
+ public static byte[] signRSA(MediaDrm drm, byte[] sessionId,
+ String algorithm, byte[] wrappedKey, byte[] message) {
+ return drm.signRSA(sessionId, algorithm, wrappedKey, message);
+ }
+}
diff --git a/media/mca/filterfw/jni/jni_gl_environment.cpp b/media/mca/filterfw/jni/jni_gl_environment.cpp
index 9abf191..6da7b7c 100644
--- a/media/mca/filterfw/jni/jni_gl_environment.cpp
+++ b/media/mca/filterfw/jni/jni_gl_environment.cpp
@@ -119,12 +119,12 @@ static sp<MediaRecorder> getMediaRecorder(JNIEnv* env, jobject jmediarecorder) {
return NULL;
}
- jfieldID context = env->GetFieldID(clazz, "mNativeContext", "I");
+ jfieldID context = env->GetFieldID(clazz, "mNativeContext", "J");
if (context == NULL) {
return NULL;
}
- MediaRecorder* const p = (MediaRecorder*)env->GetIntField(jmediarecorder, context);
+ MediaRecorder* const p = (MediaRecorder*)env->GetLongField(jmediarecorder, context);
env->DeleteLocalRef(clazz);
return sp<MediaRecorder>(p);
}