android_media_MediaCodec.h revision 8240d9239d9aabed75c49f9d4d69fd8a5fe4c899
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/stagefright/foundation/ABase.h> 23#include <utils/Errors.h> 24#include <utils/RefBase.h> 25 26namespace android { 27 28struct ALooper; 29struct AMessage; 30struct ICrypto; 31struct ISurfaceTexture; 32struct MediaCodec; 33 34struct JMediaCodec : public RefBase { 35 JMediaCodec( 36 JNIEnv *env, jobject thiz, 37 const char *name, bool nameIsType, bool encoder); 38 39 status_t initCheck() const; 40 41 status_t configure( 42 const sp<AMessage> &format, 43 const sp<ISurfaceTexture> &surfaceTexture, 44 const sp<ICrypto> &crypto, 45 int flags); 46 47 status_t start(); 48 status_t stop(); 49 50 status_t flush(); 51 52 status_t queueInputBuffer( 53 size_t index, 54 size_t offset, size_t size, int64_t timeUs, uint32_t flags); 55 56 status_t dequeueInputBuffer(size_t *index, int64_t timeoutUs); 57 58 status_t dequeueOutputBuffer( 59 JNIEnv *env, jobject bufferInfo, size_t *index, int64_t timeoutUs); 60 61 status_t releaseOutputBuffer(size_t index, bool render); 62 63 status_t getOutputFormat(JNIEnv *env, jobject *format) const; 64 65 status_t getBuffers( 66 JNIEnv *env, bool input, jobjectArray *bufArray) const; 67 68protected: 69 virtual ~JMediaCodec(); 70 71private: 72 jclass mClass; 73 jweak mObject; 74 75 sp<ALooper> mLooper; 76 sp<MediaCodec> mCodec; 77 78 DISALLOW_EVIL_CONSTRUCTORS(JMediaCodec); 79}; 80 81} // namespace android 82 83#endif // _ANDROID_MEDIA_MEDIACODEC_H_ 84