diff options
author | Andreas Huber <andih@google.com> | 2010-12-06 10:36:06 -0800 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2010-12-06 12:45:50 -0800 |
commit | 14acc736e336cbd6026df781d4f411e908831815 (patch) | |
tree | ed12a1452bb0e9a7bc9d9a3b4deb00458e90c852 /media/libstagefright/foundation | |
parent | a44153c1a57202fb538659eb50706e60454d6273 (diff) | |
download | frameworks_av-14acc736e336cbd6026df781d4f411e908831815.zip frameworks_av-14acc736e336cbd6026df781d4f411e908831815.tar.gz frameworks_av-14acc736e336cbd6026df781d4f411e908831815.tar.bz2 |
API Support for both synchronous and queued commands, optionally associated metadata.
Change-Id: Idb90d64cb638942210c5822b3cba2f05b087d601
Diffstat (limited to 'media/libstagefright/foundation')
-rw-r--r-- | media/libstagefright/foundation/AMessage.cpp | 134 | ||||
-rw-r--r-- | media/libstagefright/foundation/Android.mk | 7 |
2 files changed, 134 insertions, 7 deletions
diff --git a/media/libstagefright/foundation/AMessage.cpp b/media/libstagefright/foundation/AMessage.cpp index 26c6d42..7da9cb8 100644 --- a/media/libstagefright/foundation/AMessage.cpp +++ b/media/libstagefright/foundation/AMessage.cpp @@ -23,6 +23,8 @@ #include "ALooperRoster.h" #include "AString.h" +#include <binder/Parcel.h> + namespace android { AMessage::AMessage(uint32_t what, ALooper::handler_id target) @@ -341,4 +343,136 @@ AString AMessage::debugString(int32_t indent) const { return s; } +// static +sp<AMessage> AMessage::FromParcel(const Parcel &parcel) { + int32_t what = parcel.readInt32(); + sp<AMessage> msg = new AMessage(what); + + msg->mNumItems = static_cast<size_t>(parcel.readInt32()); + + for (size_t i = 0; i < msg->mNumItems; ++i) { + Item *item = &msg->mItems[i]; + + item->mName = AAtomizer::Atomize(parcel.readCString()); + item->mType = static_cast<Type>(parcel.readInt32()); + + switch (item->mType) { + case kTypeInt32: + { + item->u.int32Value = parcel.readInt32(); + break; + } + + case kTypeInt64: + { + item->u.int64Value = parcel.readInt64(); + break; + } + + case kTypeSize: + { + item->u.sizeValue = static_cast<size_t>(parcel.readInt32()); + break; + } + + case kTypeFloat: + { + item->u.floatValue = parcel.readFloat(); + break; + } + + case kTypeDouble: + { + item->u.doubleValue = parcel.readDouble(); + break; + } + + case kTypeString: + { + item->u.stringValue = new AString(parcel.readCString()); + break; + } + + case kTypeMessage: + { + sp<AMessage> subMsg = AMessage::FromParcel(parcel); + subMsg->incStrong(msg.get()); + + item->u.refValue = subMsg.get(); + break; + } + + default: + { + LOGE("This type of object cannot cross process boundaries."); + TRESPASS(); + } + } + } + + return msg; +} + +void AMessage::writeToParcel(Parcel *parcel) const { + parcel->writeInt32(static_cast<int32_t>(mWhat)); + parcel->writeInt32(static_cast<int32_t>(mNumItems)); + + for (size_t i = 0; i < mNumItems; ++i) { + const Item &item = mItems[i]; + + parcel->writeCString(item.mName); + parcel->writeInt32(static_cast<int32_t>(item.mType)); + + switch (item.mType) { + case kTypeInt32: + { + parcel->writeInt32(item.u.int32Value); + break; + } + + case kTypeInt64: + { + parcel->writeInt64(item.u.int64Value); + break; + } + + case kTypeSize: + { + parcel->writeInt32(static_cast<int32_t>(item.u.sizeValue)); + break; + } + + case kTypeFloat: + { + parcel->writeFloat(item.u.floatValue); + break; + } + + case kTypeDouble: + { + parcel->writeDouble(item.u.doubleValue); + break; + } + + case kTypeString: + { + parcel->writeCString(item.u.stringValue->c_str()); + break; + } + + case kTypeMessage: + { + static_cast<AMessage *>(item.u.refValue)->writeToParcel(parcel); + break; + } + + default: + { + LOGE("This type of object cannot cross process boundaries."); + TRESPASS(); + } + } + } +} + } // namespace android diff --git a/media/libstagefright/foundation/Android.mk b/media/libstagefright/foundation/Android.mk index ffa7db0..a4d4809 100644 --- a/media/libstagefright/foundation/Android.mk +++ b/media/libstagefright/foundation/Android.mk @@ -18,14 +18,7 @@ LOCAL_C_INCLUDES:= \ LOCAL_SHARED_LIBRARIES := \ libbinder \ - libmedia \ libutils \ - libcutils \ - libui \ - libsonivox \ - libvorbisidec \ - libsurfaceflinger_client \ - libcamera_client LOCAL_CFLAGS += -Wno-multichar |