diff options
author | Marco Nelissen <marcone@google.com> | 2014-05-07 12:55:18 -0700 |
---|---|---|
committer | Marco Nelissen <marcone@google.com> | 2014-05-07 12:55:18 -0700 |
commit | 34d497283c66b5ef0f8855c007eaa20d7ac8b96d (patch) | |
tree | 5f3cc71c9454f4081dd82eb9d42f47261ae11bc1 /media/ndk | |
parent | 08aaabe87960c04ecac180db1fe88b5a7bc2ed3b (diff) | |
download | frameworks_av-34d497283c66b5ef0f8855c007eaa20d7ac8b96d.zip frameworks_av-34d497283c66b5ef0f8855c007eaa20d7ac8b96d.tar.gz frameworks_av-34d497283c66b5ef0f8855c007eaa20d7ac8b96d.tar.bz2 |
Expand AMediaFormat
Remove getDouble and getSize methods, since these are not used and/or
not present in the corresponding Java MediaFormat API.
Add setBuffer/getBuffer, needed for making formats for encoding, and
add other setters.
Change-Id: I528d51b4ed571d852b949637f7ae3a95d31da7c1
Diffstat (limited to 'media/ndk')
-rw-r--r-- | media/ndk/NdkMediaFormat.cpp | 54 |
1 files changed, 44 insertions, 10 deletions
diff --git a/media/ndk/NdkMediaFormat.cpp b/media/ndk/NdkMediaFormat.cpp index 32acf59..c08814f 100644 --- a/media/ndk/NdkMediaFormat.cpp +++ b/media/ndk/NdkMediaFormat.cpp @@ -141,24 +141,30 @@ const char* AMediaFormat_toString(AMediaFormat *mData) { return mData->mDebug.string(); } -bool AMediaFormat_getInt32(AMediaFormat* mData, const char *name, int32_t *out) { - return mData->mFormat->findInt32(name, out); +bool AMediaFormat_getInt32(AMediaFormat* format, const char *name, int32_t *out) { + return format->mFormat->findInt32(name, out); } -bool AMediaFormat_getInt64(AMediaFormat* mData, const char *name, int64_t *out) { - return mData->mFormat->findInt64(name, out); +bool AMediaFormat_getInt64(AMediaFormat* format, const char *name, int64_t *out) { + return format->mFormat->findInt64(name, out); } -bool AMediaFormat_getFloat(AMediaFormat* mData, const char *name, float *out) { - return mData->mFormat->findFloat(name, out); +bool AMediaFormat_getFloat(AMediaFormat* format, const char *name, float *out) { + return format->mFormat->findFloat(name, out); } -bool AMediaFormat_getDouble(AMediaFormat* mData, const char *name, double *out) { - return mData->mFormat->findDouble(name, out); +bool AMediaFormat_getSize(AMediaFormat* format, const char *name, size_t *out) { + return format->mFormat->findSize(name, out); } -bool AMediaFormat_getSize(AMediaFormat* mData, const char *name, size_t *out) { - return mData->mFormat->findSize(name, out); +bool AMediaFormat_getBuffer(AMediaFormat* format, const char *name, void** data, size_t *outsize) { + sp<ABuffer> buf; + if (format->mFormat->findBuffer(name, &buf)) { + *data = buf->data() + buf->offset(); + *outsize = buf->size(); + return true; + } + return false; } bool AMediaFormat_getString(AMediaFormat* mData, const char *name, const char **out) { @@ -180,6 +186,34 @@ bool AMediaFormat_getString(AMediaFormat* mData, const char *name, const char ** return false; } +void AMediaFormat_setInt32(AMediaFormat* format, const char *name, int32_t value) { + format->mFormat->setInt32(name, value); +} + +void AMediaFormat_setInt64(AMediaFormat* format, const char *name, int64_t value) { + format->mFormat->setInt64(name, value); +} + +void AMediaFormat_setFloat(AMediaFormat* format, const char* name, float value) { + format->mFormat->setFloat(name, value); +} + +void AMediaFormat_setString(AMediaFormat* format, const char* name, const char* value) { + // AMessage::setString() makes a copy of the string + format->mFormat->setString(name, value, strlen(value)); +} + +void AMediaFormat_setBuffer(AMediaFormat* format, const char* name, void* data, size_t size) { + // the ABuffer(void*, size_t) constructor doesn't take ownership of the data, so create + // a new buffer and copy the data into it + sp<ABuffer> buf = new ABuffer(size); + memcpy(buf->data(), data, size); + buf->setRange(0, size); + // AMessage::setBuffer() increases the refcount of the buffer + format->mFormat->setBuffer(name, buf); +} + + const char* AMEDIAFORMAT_KEY_AAC_PROFILE = "aac-profile"; const char* AMEDIAFORMAT_KEY_BIT_RATE = "bitrate"; const char* AMEDIAFORMAT_KEY_CHANNEL_COUNT = "channel-count"; |