OSDN Git Service

am 11b14e39: (-s ours) LayoutLib: Use ICU\'s line break algo. [DO NOT MERGE]
[android-x86/frameworks-base.git] / media / jni / android_media_MediaCodec.h
index 2fbbd72..9f2785a 100644 (file)
 
 #include <media/hardware/CryptoAPI.h>
 #include <media/stagefright/foundation/ABase.h>
+#include <media/stagefright/foundation/AHandler.h>
 #include <utils/Errors.h>
-#include <utils/RefBase.h>
 
 namespace android {
 
+struct ABuffer;
 struct ALooper;
 struct AMessage;
 struct AString;
@@ -34,13 +35,18 @@ struct IGraphicBufferProducer;
 struct MediaCodec;
 class Surface;
 
-struct JMediaCodec : public RefBase {
+struct JMediaCodec : public AHandler {
     JMediaCodec(
             JNIEnv *env, jobject thiz,
             const char *name, bool nameIsType, bool encoder);
 
     status_t initCheck() const;
 
+    void registerSelf();
+    void release();
+
+    status_t setCallback(jobject cb);
+
     status_t configure(
             const sp<AMessage> &format,
             const sp<IGraphicBufferProducer> &bufferProducer,
@@ -51,6 +57,7 @@ struct JMediaCodec : public RefBase {
 
     status_t start();
     status_t stop();
+    status_t reset();
 
     status_t flush();
 
@@ -76,15 +83,24 @@ struct JMediaCodec : public RefBase {
     status_t dequeueOutputBuffer(
             JNIEnv *env, jobject bufferInfo, size_t *index, int64_t timeoutUs);
 
-    status_t releaseOutputBuffer(size_t index, bool render);
+    status_t releaseOutputBuffer(
+            size_t index, bool render, bool updatePTS, int64_t timestampNs);
 
     status_t signalEndOfInputStream();
 
-    status_t getOutputFormat(JNIEnv *env, jobject *format) const;
+    status_t getFormat(JNIEnv *env, bool input, jobject *format) const;
+
+    status_t getOutputFormat(JNIEnv *env, size_t index, jobject *format) const;
 
     status_t getBuffers(
             JNIEnv *env, bool input, jobjectArray *bufArray) const;
 
+    status_t getBuffer(
+            JNIEnv *env, bool input, size_t index, jobject *buf) const;
+
+    status_t getImage(
+            JNIEnv *env, bool input, size_t index, jobject *image) const;
+
     status_t getName(JNIEnv *env, jstring *name) const;
 
     status_t setParameters(const sp<AMessage> &params);
@@ -94,14 +110,40 @@ struct JMediaCodec : public RefBase {
 protected:
     virtual ~JMediaCodec();
 
+    virtual void onMessageReceived(const sp<AMessage> &msg);
+    void handleCallback(const sp<AMessage> &msg);
+
 private:
+    enum {
+        kWhatCallbackNotify,
+    };
+
     jclass mClass;
     jweak mObject;
     sp<Surface> mSurfaceTextureClient;
 
+    // java objects cached
+    jclass mByteBufferClass;
+    jobject mNativeByteOrderObj;
+    jmethodID mByteBufferOrderMethodID;
+    jmethodID mByteBufferPositionMethodID;
+    jmethodID mByteBufferLimitMethodID;
+    jmethodID mByteBufferAsReadOnlyBufferMethodID;
+
     sp<ALooper> mLooper;
     sp<MediaCodec> mCodec;
 
+    sp<AMessage> mCallbackNotification;
+
+    status_t mInitStatus;
+
+    status_t createByteBufferFromABuffer(
+            JNIEnv *env, bool readOnly, bool clearBuffer, const sp<ABuffer> &buffer,
+            jobject *buf) const;
+
+    void cacheJavaObjects(JNIEnv *env);
+    void deleteJavaObjects(JNIEnv *env);
+
     DISALLOW_EVIL_CONSTRUCTORS(JMediaCodec);
 };