2 * Copyright 2012, The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef _ANDROID_MEDIA_MEDIACODEC_H_
18 #define _ANDROID_MEDIA_MEDIACODEC_H_
22 #include <media/hardware/CryptoAPI.h>
23 #include <media/stagefright/foundation/ABase.h>
24 #include <utils/Errors.h>
25 #include <utils/RefBase.h>
33 struct ISurfaceTexture;
35 struct SurfaceTextureClient;
37 struct JMediaCodec : public RefBase {
39 JNIEnv *env, jobject thiz,
40 const char *name, bool nameIsType, bool encoder);
42 status_t initCheck() const;
45 const sp<AMessage> &format,
46 const sp<ISurfaceTexture> &surfaceTexture,
47 const sp<ICrypto> &crypto,
55 status_t queueInputBuffer(
57 size_t offset, size_t size, int64_t timeUs, uint32_t flags,
58 AString *errorDetailMsg);
60 status_t queueSecureInputBuffer(
63 const CryptoPlugin::SubSample *subSamples,
65 const uint8_t key[16],
67 CryptoPlugin::Mode mode,
68 int64_t presentationTimeUs,
70 AString *errorDetailMsg);
72 status_t dequeueInputBuffer(size_t *index, int64_t timeoutUs);
74 status_t dequeueOutputBuffer(
75 JNIEnv *env, jobject bufferInfo, size_t *index, int64_t timeoutUs);
77 status_t releaseOutputBuffer(size_t index, bool render);
79 status_t getOutputFormat(JNIEnv *env, jobject *format) const;
82 JNIEnv *env, bool input, jobjectArray *bufArray) const;
84 status_t getName(JNIEnv *env, jstring *name) const;
86 void setVideoScalingMode(int mode);
89 virtual ~JMediaCodec();
94 sp<SurfaceTextureClient> mSurfaceTextureClient;
97 sp<MediaCodec> mCodec;
99 DISALLOW_EVIL_CONSTRUCTORS(JMediaCodec);
102 } // namespace android
104 #endif // _ANDROID_MEDIA_MEDIACODEC_H_