summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2014-05-07 16:03:54 -0700
committerMarco Nelissen <marcone@google.com>2014-05-08 09:36:08 -0700
commit86aa02ce274826dc80ffa00766b16172c47503fd (patch)
tree99aab102e4a44533c645b8a074759548e7f7fcf8
parentcdedf74e34117f9834055973880ee728f11d97cd (diff)
downloadframeworks_av-86aa02ce274826dc80ffa00766b16172c47503fd.zip
frameworks_av-86aa02ce274826dc80ffa00766b16172c47503fd.tar.gz
frameworks_av-86aa02ce274826dc80ffa00766b16172c47503fd.tar.bz2
Make AMediaCodec_create* APIs more like their Java counterparts
and add configure flags. Change-Id: Ibfb7f8cad724fa1db2320966828104d40b5e6590
-rw-r--r--include/ndk/NdkMediaCodec.h14
-rw-r--r--media/ndk/NdkMediaCodec.cpp13
2 files changed, 16 insertions, 11 deletions
diff --git a/include/ndk/NdkMediaCodec.h b/include/ndk/NdkMediaCodec.h
index 73ece1b..2af88d0 100644
--- a/include/ndk/NdkMediaCodec.h
+++ b/include/ndk/NdkMediaCodec.h
@@ -49,6 +49,7 @@ typedef struct AMediaCodecBufferInfo AMediaCodecBufferInfo;
enum {
AMEDIACODEC_BUFFER_FLAG_END_OF_STREAM = 4,
+ AMEDIACODEC_CONFIGURE_FLAG_ENCODE = 1,
AMEDIACODEC_INFO_OUTPUT_BUFFERS_CHANGED = -3,
AMEDIACODEC_INFO_OUTPUT_FORMAT_CHANGED = -2,
AMEDIACODEC_INFO_TRY_AGAIN_LATER = -1
@@ -56,20 +57,22 @@ enum {
/**
- * Create decoder by name. Use this if you know the exact codec you want to use.
+ * Create codec by name. Use this if you know the exact codec you want to use.
+ * When configuring, you will need to specify whether to use the codec as an
+ * encoder or decoder.
*/
-AMediaCodec* AMediaCodec_createByCodecName(const char *name);
+AMediaCodec* AMediaCodec_createCodecByName(const char *name);
/**
* Create codec by mime type. Most applications will use this, specifying a
* mime type obtained from media extractor.
*/
-AMediaCodec* AMediaCodec_createByCodecType(const char *mime_type);
+AMediaCodec* AMediaCodec_createDecoderByType(const char *mime_type);
/**
* Create encoder by name.
*/
-AMediaCodec* AMediaCodec_createEncoderByName(const char *name);
+AMediaCodec* AMediaCodec_createEncoderByType(const char *mime_type);
/**
* delete the codec and free its resources
@@ -79,7 +82,8 @@ int AMediaCodec_delete(AMediaCodec*);
/**
* Configure the codec. For decoding you would typically get the format from an extractor.
*/
-int AMediaCodec_configure(AMediaCodec*, const AMediaFormat* format, ANativeWindow* surface); // TODO: other args
+int AMediaCodec_configure(AMediaCodec*, const AMediaFormat* format,
+ ANativeWindow* surface, uint32_t flags); // TODO: other args
/**
* Start the codec. A codec must be configured before it can be started, and must be started
diff --git a/media/ndk/NdkMediaCodec.cpp b/media/ndk/NdkMediaCodec.cpp
index e7f009e..9592af8 100644
--- a/media/ndk/NdkMediaCodec.cpp
+++ b/media/ndk/NdkMediaCodec.cpp
@@ -88,16 +88,16 @@ static AMediaCodec * createAMediaCodec(const char *name, bool name_is_type, bool
}
-AMediaCodec* AMediaCodec_createByCodecName(const char *name) {
+AMediaCodec* AMediaCodec_createCodecByName(const char *name) {
return createAMediaCodec(name, false, false);
}
-AMediaCodec* AMediaCodec_createByCodecType(const char *mime_type) {
+AMediaCodec* AMediaCodec_createDecoderByType(const char *mime_type) {
return createAMediaCodec(mime_type, true, false);
}
-AMediaCodec* AMediaCodec_createEncoderByName(const char *name) {
- return createAMediaCodec(name, false, true);
+AMediaCodec* AMediaCodec_createEncoderByType(const char *name) {
+ return createAMediaCodec(name, true, true);
}
int AMediaCodec_delete(AMediaCodec *mData) {
@@ -115,7 +115,8 @@ int AMediaCodec_delete(AMediaCodec *mData) {
return OK;
}
-int AMediaCodec_configure(AMediaCodec *mData, const AMediaFormat* format, ANativeWindow* window) {
+int AMediaCodec_configure(
+ AMediaCodec *mData, const AMediaFormat* format, ANativeWindow* window, uint32_t flags) {
sp<AMessage> nativeFormat;
AMediaFormat_getFormat(format, &nativeFormat);
ALOGV("configure with format: %s", nativeFormat->debugString(0).c_str());
@@ -124,7 +125,7 @@ int AMediaCodec_configure(AMediaCodec *mData, const AMediaFormat* format, ANativ
surface = (Surface*) window;
}
- return translate_error(mData->mCodec->configure(nativeFormat, surface, NULL, 0));
+ return translate_error(mData->mCodec->configure(nativeFormat, surface, NULL, flags));
}
int AMediaCodec_start(AMediaCodec *mData) {