diff options
Diffstat (limited to 'media/libstagefright')
-rw-r--r-- | media/libstagefright/foundation/AMessage.cpp | 16 | ||||
-rw-r--r-- | media/libstagefright/foundation/hexdump.cpp | 21 |
2 files changed, 33 insertions, 4 deletions
diff --git a/media/libstagefright/foundation/AMessage.cpp b/media/libstagefright/foundation/AMessage.cpp index 8b01ac6..dc42f91 100644 --- a/media/libstagefright/foundation/AMessage.cpp +++ b/media/libstagefright/foundation/AMessage.cpp @@ -25,6 +25,7 @@ #include "AString.h" #include <binder/Parcel.h> +#include <media/stagefright/foundation/hexdump.h> namespace android { @@ -399,9 +400,20 @@ AString AMessage::debugString(int32_t indent) const { "RefBase *%s = %p", item.mName, item.u.refValue); break; case kTypeBuffer: - tmp = StringPrintf( - "ABuffer *%s = %p", item.mName, item.u.refValue); + { + sp<ABuffer> buffer = static_cast<ABuffer *>(item.u.refValue); + + if (buffer != NULL && buffer->size() <= 64) { + tmp = StringPrintf("Buffer %s = {\n", item.mName); + hexdump(buffer->data(), buffer->size(), indent + 4, &tmp); + appendIndent(&tmp, indent + 2); + tmp.append("}"); + } else { + tmp = StringPrintf( + "Buffer *%s = %p", item.mName, buffer.get()); + } break; + } case kTypeMessage: tmp = StringPrintf( "AMessage %s = %s", diff --git a/media/libstagefright/foundation/hexdump.cpp b/media/libstagefright/foundation/hexdump.cpp index 16c1ca5..a44d832 100644 --- a/media/libstagefright/foundation/hexdump.cpp +++ b/media/libstagefright/foundation/hexdump.cpp @@ -29,13 +29,25 @@ namespace android { -void hexdump(const void *_data, size_t size) { +static void appendIndent(AString *s, int32_t indent) { + static const char kWhitespace[] = + " " + " "; + + CHECK_LT((size_t)indent, sizeof(kWhitespace)); + + s->append(kWhitespace, indent); +} + +void hexdump(const void *_data, size_t size, size_t indent, AString *appendTo) { const uint8_t *data = (const uint8_t *)_data; size_t offset = 0; while (offset < size) { AString line; + appendIndent(&line, indent); + char tmp[32]; sprintf(tmp, "%08lx: ", (unsigned long)offset); @@ -67,7 +79,12 @@ void hexdump(const void *_data, size_t size) { } } - ALOGI("%s", line.c_str()); + if (appendTo != NULL) { + appendTo->append(line); + appendTo->append("\n"); + } else { + ALOGI("%s", line.c_str()); + } offset += 16; } |