From 14acc736e336cbd6026df781d4f411e908831815 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Mon, 6 Dec 2010 10:36:06 -0800 Subject: API Support for both synchronous and queued commands, optionally associated metadata. Change-Id: Idb90d64cb638942210c5822b3cba2f05b087d601 --- media/libstagefright/foundation/AMessage.cpp | 134 +++++++++++++++++++++++++++ media/libstagefright/foundation/Android.mk | 7 -- 2 files changed, 134 insertions(+), 7 deletions(-) (limited to 'media/libstagefright/foundation') 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 + 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::FromParcel(const Parcel &parcel) { + int32_t what = parcel.readInt32(); + sp msg = new AMessage(what); + + msg->mNumItems = static_cast(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(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(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 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(mWhat)); + parcel->writeInt32(static_cast(mNumItems)); + + for (size_t i = 0; i < mNumItems; ++i) { + const Item &item = mItems[i]; + + parcel->writeCString(item.mName); + parcel->writeInt32(static_cast(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(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(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 -- cgit v1.1