android_media_MediaCodec.h revision 9e6bcce17d13bd4f7bba5f8fbcc2e6a0d695274b
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 27namespace android { 28 29struct ALooper; 30struct AMessage; 31struct ICrypto; 32struct ISurfaceTexture; 33struct MediaCodec; 34 35struct JMediaCodec : public RefBase { 36 JMediaCodec( 37 JNIEnv *env, jobject thiz, 38 const char *name, bool nameIsType, bool encoder); 39 40 status_t initCheck() const; 41 42 status_t configure( 43 const sp<AMessage> &format, 44 const sp<ISurfaceTexture> &surfaceTexture, 45 const sp<ICrypto> &crypto, 46 int flags); 47 48 status_t start(); 49 status_t stop(); 50 51 status_t flush(); 52 53 status_t queueInputBuffer( 54 size_t index, 55 size_t offset, size_t size, int64_t timeUs, uint32_t flags); 56 57 status_t queueSecureInputBuffer( 58 size_t index, 59 size_t offset, 60 const CryptoPlugin::SubSample *subSamples, 61 size_t numSubSamples, 62 const uint8_t key[16], 63 const uint8_t iv[16], 64 CryptoPlugin::Mode mode, 65 int64_t presentationTimeUs, 66 uint32_t flags); 67 68 status_t dequeueInputBuffer(size_t *index, int64_t timeoutUs); 69 70 status_t dequeueOutputBuffer( 71 JNIEnv *env, jobject bufferInfo, size_t *index, int64_t timeoutUs); 72 73 status_t releaseOutputBuffer(size_t index, bool render); 74 75 status_t getOutputFormat(JNIEnv *env, jobject *format) const; 76 77 status_t getBuffers( 78 JNIEnv *env, bool input, jobjectArray *bufArray) const; 79 80protected: 81 virtual ~JMediaCodec(); 82 83private: 84 jclass mClass; 85 jweak mObject; 86 87 sp<ALooper> mLooper; 88 sp<MediaCodec> mCodec; 89 90 DISALLOW_EVIL_CONSTRUCTORS(JMediaCodec); 91}; 92 93} // namespace android 94 95#endif // _ANDROID_MEDIA_MEDIACODEC_H_ 96