summaryrefslogtreecommitdiff
path: root/media/libstagefright/ACodec.cpp
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2012-08-29 11:41:50 -0700
committerAndreas Huber <andih@google.com>2012-08-29 15:06:57 -0700
commitd7bee3a9d2ad76d073d91f0ee36d5ac5f9df480c (patch)
tree3c4c7a83313d169b13c79c9660afeb804d27b975 /media/libstagefright/ACodec.cpp
parenteb941f9a0c8474324732a99387cc6d8cb4ab01ef (diff)
Initial checkin of support for acting as a wifi display source
Change-Id: I08f17efa0c7d007e17408feb7d4fbef0a19f531a
Diffstat (limited to 'media/libstagefright/ACodec.cpp')
-rw-r--r--media/libstagefright/ACodec.cpp67
1 files changed, 62 insertions, 5 deletions
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index c37d2cae..3dd5d60f 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -861,6 +861,20 @@ status_t ACodec::configureCodec(
return INVALID_OPERATION;
}
+ int32_t storeMeta;
+ if (encoder
+ && msg->findInt32("store-metadata-in-buffers", &storeMeta)
+ && storeMeta != 0) {
+ err = mOMX->storeMetaDataInBuffers(mNode, kPortIndexInput, OMX_TRUE);
+
+ if (err != OK) {
+ ALOGE("[%s] storeMetaDataInBuffers failed w/ err %d",
+ mComponentName.c_str(), err);
+
+ return err;
+ }
+ }
+
if (!strncasecmp(mime, "video/", 6)) {
if (encoder) {
err = setupVideoEncoder(mime, msg);
@@ -2424,6 +2438,21 @@ bool ACodec::BaseState::onOMXEmptyBufferDone(IOMX::buffer_id bufferID) {
CHECK_EQ((int)info->mStatus, (int)BufferInfo::OWNED_BY_COMPONENT);
info->mStatus = BufferInfo::OWNED_BY_US;
+ const sp<AMessage> &bufferMeta = info->mData->meta();
+ void *mediaBuffer;
+ if (bufferMeta->findPointer("mediaBuffer", &mediaBuffer)
+ && mediaBuffer != NULL) {
+ // We're in "store-metadata-in-buffers" mode, the underlying
+ // OMX component had access to data that's implicitly refcounted
+ // by this "mediaBuffer" object. Now that the OMX component has
+ // told us that it's done with the input buffer, we can decrement
+ // the mediaBuffer's reference count.
+ ((MediaBuffer *)mediaBuffer)->release();
+ mediaBuffer = NULL;
+
+ bufferMeta->setPointer("mediaBuffer", NULL);
+ }
+
PortMode mode = getPortMode(kPortIndexInput);
switch (mode) {
@@ -2531,10 +2560,10 @@ void ACodec::BaseState::onInputBufferFilled(const sp<AMessage> &msg) {
}
if (buffer != info->mData) {
- if (0 && !(flags & OMX_BUFFERFLAG_CODECCONFIG)) {
- ALOGV("[%s] Needs to copy input data.",
- mCodec->mComponentName.c_str());
- }
+ ALOGV("[%s] Needs to copy input data for buffer %p. (%p != %p)",
+ mCodec->mComponentName.c_str(),
+ bufferID,
+ buffer.get(), info->mData.get());
CHECK_LE(buffer->size(), info->mData->capacity());
memcpy(info->mData->data(), buffer->data(), buffer->size());
@@ -2547,10 +2576,22 @@ void ACodec::BaseState::onInputBufferFilled(const sp<AMessage> &msg) {
ALOGV("[%s] calling emptyBuffer %p w/ EOS",
mCodec->mComponentName.c_str(), bufferID);
} else {
+#if TRACK_BUFFER_TIMING
+ ALOGI("[%s] calling emptyBuffer %p w/ time %lld us",
+ mCodec->mComponentName.c_str(), bufferID, timeUs);
+#else
ALOGV("[%s] calling emptyBuffer %p w/ time %lld us",
mCodec->mComponentName.c_str(), bufferID, timeUs);
+#endif
}
+#if TRACK_BUFFER_TIMING
+ ACodec::BufferStats stats;
+ stats.mEmptyBufferTimeUs = ALooper::GetNowUs();
+ stats.mFillBufferDoneTimeUs = -1ll;
+ mCodec->mBufferStats.add(timeUs, stats);
+#endif
+
CHECK_EQ(mCodec->mOMX->emptyBuffer(
mCodec->mNode,
bufferID,
@@ -2647,6 +2688,22 @@ bool ACodec::BaseState::onOMXFillBufferDone(
mCodec->mComponentName.c_str(), bufferID, timeUs, flags);
ssize_t index;
+
+#if TRACK_BUFFER_TIMING
+ index = mCodec->mBufferStats.indexOfKey(timeUs);
+ if (index >= 0) {
+ ACodec::BufferStats *stats = &mCodec->mBufferStats.editValueAt(index);
+ stats->mFillBufferDoneTimeUs = ALooper::GetNowUs();
+
+ ALOGI("frame PTS %lld: %lld",
+ timeUs,
+ stats->mFillBufferDoneTimeUs - stats->mEmptyBufferTimeUs);
+
+ mCodec->mBufferStats.removeItemsAt(index);
+ stats = NULL;
+ }
+#endif
+
BufferInfo *info =
mCodec->findBufferByID(kPortIndexOutput, bufferID, &index);
@@ -2891,7 +2948,7 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp<AMessage> &msg) {
AString mime;
AString componentName;
- uint32_t quirks;
+ uint32_t quirks = 0;
if (msg->findString("componentName", &componentName)) {
ssize_t index = matchingCodecs.add();
OMXCodec::CodecNameAndQuirks *entry = &matchingCodecs.editItemAt(index);