stagefright: untangle metadata-mode handling
- specify requested metadata mode from producers to OMX
- (pass requested metadata in IOMX::storeMetadataInBuffers)
- use correct logic for native handle source
- use native handle source for encoded meta buffers
Bug: 22775369
Change-Id: I58b03acd3e9a5367d5010d7f87b7af5cae23362c
diff --git a/include/media/IOMX.h b/include/media/IOMX.h
index 8caf72d..673c56a 100644
--- a/include/media/IOMX.h
+++ b/include/media/IOMX.h
@@ -276,17 +276,18 @@
OMX_U32 mLevel;
};
-} // namespace android
-
-inline static const char *asString(android::MetadataBufferType i, const char *def = "??") {
+inline static const char *asString(MetadataBufferType i, const char *def = "??") {
using namespace android;
switch (i) {
case kMetadataBufferTypeCameraSource: return "CameraSource";
case kMetadataBufferTypeGrallocSource: return "GrallocSource";
case kMetadataBufferTypeANWBuffer: return "ANWBuffer";
+ case kMetadataBufferTypeNativeHandleSource: return "NativeHandleSource";
case kMetadataBufferTypeInvalid: return "Invalid";
default: return def;
}
}
+} // namespace android
+
#endif // ANDROID_IOMX_H_
diff --git a/include/media/stagefright/CameraSource.h b/include/media/stagefright/CameraSource.h
index 399f363..c2e75a6 100644
--- a/include/media/stagefright/CameraSource.h
+++ b/include/media/stagefright/CameraSource.h
@@ -28,6 +28,7 @@
#include <utils/List.h>
#include <utils/RefBase.h>
#include <utils/String16.h>
+#include <MetadataBufferType.h>
namespace android {
@@ -118,11 +119,11 @@
* Tell whether this camera source stores meta data or real YUV
* frame data in video buffers.
*
- * @return true if meta data is stored in the video
- * buffers; false if real YUV data is stored in
+ * @return a valid type if meta data is stored in the video
+ * buffers; kMetadataBufferTypeInvalid if real YUV data is stored in
* the video buffers.
*/
- bool isMetaDataStoredInVideoBuffers() const;
+ MetadataBufferType metaDataStoredInVideoBuffers() const;
virtual void signalBufferReturned(MediaBuffer* buffer);
diff --git a/include/media/stagefright/MediaCodecSource.h b/include/media/stagefright/MediaCodecSource.h
index 035e8ae..cc62786 100644
--- a/include/media/stagefright/MediaCodecSource.h
+++ b/include/media/stagefright/MediaCodecSource.h
@@ -37,7 +37,6 @@
public MediaBufferObserver {
enum FlagBits {
FLAG_USE_SURFACE_INPUT = 1,
- FLAG_USE_METADATA_INPUT = 2,
FLAG_PREFER_SOFTWARE_CODEC = 4, // used for testing only
};
diff --git a/include/media/stagefright/SurfaceMediaSource.h b/include/media/stagefright/SurfaceMediaSource.h
index 2177c00..ca3a3bf 100644
--- a/include/media/stagefright/SurfaceMediaSource.h
+++ b/include/media/stagefright/SurfaceMediaSource.h
@@ -25,6 +25,8 @@
#include <media/stagefright/MediaSource.h>
#include <media/stagefright/MediaBuffer.h>
+#include <MetadataBufferType.h>
+
#include "foundation/ABase.h"
namespace android {
@@ -109,9 +111,9 @@
void dump(String8& result, const char* prefix, char* buffer,
size_t SIZE) const;
- // isMetaDataStoredInVideoBuffers tells the encoder whether we will
- // pass metadata through the buffers. Currently, it is force set to true
- bool isMetaDataStoredInVideoBuffers() const;
+ // metaDataStoredInVideoBuffers tells the encoder what kind of metadata
+ // is passed through the buffers. Currently, it is set to ANWBuffer
+ MetadataBufferType metaDataStoredInVideoBuffers() const;
sp<IGraphicBufferProducer> getProducer() const { return mProducer; }
@@ -234,6 +236,9 @@
Condition mMediaBuffersAvailableCondition;
+ // Allocate and return a new MediaBuffer and pass the ANW buffer as metadata into it.
+ void passMetadataBuffer_l(MediaBuffer **buffer, ANativeWindowBuffer *bufferHandle) const;
+
// Avoid copying and equating and default constructor
DISALLOW_EVIL_CONSTRUCTORS(SurfaceMediaSource);
};