OSDN Git Service

am 8bc68f96: am 52ee9b99: am ffd0e8bf: am a6f32d7f: am 64d4ef8c: am 63889480: am...
[android-x86/frameworks-base.git] / media / jni / android_media_MediaCodec.h
1 /*
2  * Copyright 2012, The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef _ANDROID_MEDIA_MEDIACODEC_H_
18 #define _ANDROID_MEDIA_MEDIACODEC_H_
19
20 #include "jni.h"
21
22 #include <media/hardware/CryptoAPI.h>
23 #include <media/stagefright/foundation/ABase.h>
24 #include <utils/Errors.h>
25 #include <utils/RefBase.h>
26
27 namespace android {
28
29 struct ALooper;
30 struct AMessage;
31 struct AString;
32 struct ICrypto;
33 struct ISurfaceTexture;
34 struct MediaCodec;
35 struct SurfaceTextureClient;
36
37 struct JMediaCodec : public RefBase {
38     JMediaCodec(
39             JNIEnv *env, jobject thiz,
40             const char *name, bool nameIsType, bool encoder);
41
42     status_t initCheck() const;
43
44     status_t configure(
45             const sp<AMessage> &format,
46             const sp<ISurfaceTexture> &surfaceTexture,
47             const sp<ICrypto> &crypto,
48             int flags);
49
50     status_t start();
51     status_t stop();
52
53     status_t flush();
54
55     status_t queueInputBuffer(
56             size_t index,
57             size_t offset, size_t size, int64_t timeUs, uint32_t flags,
58             AString *errorDetailMsg);
59
60     status_t queueSecureInputBuffer(
61             size_t index,
62             size_t offset,
63             const CryptoPlugin::SubSample *subSamples,
64             size_t numSubSamples,
65             const uint8_t key[16],
66             const uint8_t iv[16],
67             CryptoPlugin::Mode mode,
68             int64_t presentationTimeUs,
69             uint32_t flags,
70             AString *errorDetailMsg);
71
72     status_t dequeueInputBuffer(size_t *index, int64_t timeoutUs);
73
74     status_t dequeueOutputBuffer(
75             JNIEnv *env, jobject bufferInfo, size_t *index, int64_t timeoutUs);
76
77     status_t releaseOutputBuffer(size_t index, bool render);
78
79     status_t getOutputFormat(JNIEnv *env, jobject *format) const;
80
81     status_t getBuffers(
82             JNIEnv *env, bool input, jobjectArray *bufArray) const;
83
84     status_t getName(JNIEnv *env, jstring *name) const;
85
86     void setVideoScalingMode(int mode);
87
88 protected:
89     virtual ~JMediaCodec();
90
91 private:
92     jclass mClass;
93     jweak mObject;
94     sp<SurfaceTextureClient> mSurfaceTextureClient;
95
96     sp<ALooper> mLooper;
97     sp<MediaCodec> mCodec;
98
99     DISALLOW_EVIL_CONSTRUCTORS(JMediaCodec);
100 };
101
102 }  // namespace android
103
104 #endif  // _ANDROID_MEDIA_MEDIACODEC_H_