media.c2 aidl: add C2AidlNode
Bug: 322870482
Test: m libsfplugin_ccodec
Merged-In: I717de624c3c10fb2c84456e110b7513d078fd6a0
Change-Id: I717de624c3c10fb2c84456e110b7513d078fd6a0
diff --git a/media/codec2/sfplugin/Android.bp b/media/codec2/sfplugin/Android.bp
index 1dc91f9..362373e 100644
--- a/media/codec2/sfplugin/Android.bp
+++ b/media/codec2/sfplugin/Android.bp
@@ -19,6 +19,8 @@
export_include_dirs: ["include"],
srcs: [
+ "C2AidlNode.cpp",
+ "C2OMXNode.cpp",
"C2NodeImpl.cpp",
"CCodec.cpp",
"CCodecBufferChannel.cpp",
@@ -54,8 +56,11 @@
"android.hardware.drm@1.0",
"android.hardware.media.c2@1.0",
"android.hardware.media.omx@1.0",
+ "android.hardware.graphics.common-V5-ndk",
+ "graphicbuffersource-aidl-ndk",
"libbase",
"libbinder",
+ "libbinder_ndk",
"libcodec2",
"libcodec2_client",
"libcodec2_vndk",
@@ -67,9 +72,11 @@
"liblog",
"libmedia_codeclist",
"libmedia_omx",
+ "libnativewindow",
"libsfplugin_ccodec_utils",
"libstagefright_bufferqueue_helper",
"libstagefright_codecbase",
+ "libstagefright_graphicbuffersource_aidl",
"libstagefright_foundation",
"libstagefright_omx",
"libstagefright_surface_utils",
diff --git a/media/codec2/sfplugin/C2AidlNode.cpp b/media/codec2/sfplugin/C2AidlNode.cpp
new file mode 100644
index 0000000..c20f50d
--- /dev/null
+++ b/media/codec2/sfplugin/C2AidlNode.cpp
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2024, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//#define LOG_NDEBUG 0
+#define LOG_TAG "C2AidlNode"
+#include <log/log.h>
+#include <private/android/AHardwareBufferHelpers.h>
+
+#include <media/stagefright/MediaErrors.h>
+#include <media/stagefright/aidlpersistentsurface/wrapper/Conversion.h>
+
+#include "C2NodeImpl.h"
+#include "C2AidlNode.h"
+
+namespace android {
+
+using ::aidl::android::media::IAidlBufferSource;
+using ::aidl::android::media::IAidlNode;
+
+using ::android::media::CommandStateSet;
+using ::android::media::NodeStatusLoaded;
+
+// Conversion
+using ::android::media::aidl_conversion::toAidlStatus;
+
+C2AidlNode::C2AidlNode(const std::shared_ptr<Codec2Client::Component> &comp)
+ : mImpl(new C2NodeImpl(comp, true)) {}
+
+// aidl ndk interfaces
+::ndk::ScopedAStatus C2AidlNode::freeNode() {
+ return toAidlStatus(mImpl->freeNode());
+}
+
+::ndk::ScopedAStatus C2AidlNode::sendCommand(int32_t cmd, int32_t param) {
+ if (cmd == CommandStateSet && param == NodeStatusLoaded) {
+ mImpl->onFirstInputFrame();
+ }
+ return toAidlStatus(ERROR_UNSUPPORTED);
+}
+
+::ndk::ScopedAStatus C2AidlNode::getConsumerUsage(int64_t* _aidl_return) {
+ uint64_t usage;
+ mImpl->getConsumerUsageBits(&usage);
+ *_aidl_return = usage;
+ return ::ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus C2AidlNode::getInputBufferParams(IAidlNode::InputBufferParams* _aidl_return) {
+ mImpl->getInputBufferParams(_aidl_return);
+ return ::ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus C2AidlNode::setConsumerUsage(int64_t usage) {
+ mImpl->setConsumerUsageBits(static_cast<uint64_t>(usage));
+ return ::ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus C2AidlNode::setAdjustTimestampGapUs(int32_t gapUs) {
+ mImpl->setAdjustTimestampGapUs(gapUs);
+ return ::ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus C2AidlNode::setInputSurface(
+ const std::shared_ptr<IAidlBufferSource>& bufferSource) {
+ return toAidlStatus(mImpl->setAidlInputSurface(bufferSource));
+}
+
+::ndk::ScopedAStatus C2AidlNode::submitBuffer(
+ int32_t buffer, const ::aidl::android::hardware::HardwareBuffer& hBuffer,
+ int32_t flags, int64_t timestamp, const ::ndk::ScopedFileDescriptor& fence) {
+ sp<GraphicBuffer> gBuf;
+ AHardwareBuffer *ahwb = hBuffer.get();
+ if (ahwb) {
+ gBuf = AHardwareBuffer_to_GraphicBuffer(ahwb);
+ }
+ return toAidlStatus(mImpl->submitBuffer(
+ buffer, gBuf, flags, timestamp, ::dup(fence.get())));
+}
+
+::ndk::ScopedAStatus C2AidlNode::onDataSpaceChanged(
+ int32_t dataSpace,
+ int32_t aspects,
+ int32_t pixelFormat) {
+ // NOTE: legacy codes passed aspects, but they didn't used.
+ (void)aspects;
+
+ return toAidlStatus(mImpl->onDataspaceChanged(
+ static_cast<uint32_t>(dataSpace),
+ static_cast<uint32_t>(pixelFormat)));
+}
+
+// cpp interface
+
+std::shared_ptr<IAidlBufferSource> C2AidlNode::getSource() {
+ return mImpl->getAidlSource();
+}
+
+void C2AidlNode::setFrameSize(uint32_t width, uint32_t height) {
+ return mImpl->setFrameSize(width, height);
+}
+
+void C2AidlNode::onInputBufferDone(c2_cntr64_t index) {
+ return mImpl->onInputBufferDone(index);
+}
+
+android_dataspace C2AidlNode::getDataspace() {
+ return mImpl->getDataspace();
+}
+
+uint32_t C2AidlNode::getPixelFormat() {
+ return mImpl->getPixelFormat();
+}
+
+void C2AidlNode::setPriority(int priority) {
+ return mImpl->setPriority(priority);
+}
+
+} // namespace android
diff --git a/media/codec2/sfplugin/C2AidlNode.h b/media/codec2/sfplugin/C2AidlNode.h
new file mode 100644
index 0000000..a7c328e
--- /dev/null
+++ b/media/codec2/sfplugin/C2AidlNode.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2024, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <aidl/android/media/BnAidlNode.h>
+#include <codec2/hidl/client.h>
+
+namespace android {
+
+struct C2NodeImpl;
+
+/**
+ * Thin Codec2 AIdL encoder HAL wrapper for InputSurface
+ */
+class C2AidlNode : public ::aidl::android::media::BnAidlNode {
+public:
+ explicit C2AidlNode(const std::shared_ptr<Codec2Client::Component> &comp);
+ ~C2AidlNode() override = default;
+
+ // IAidlNode
+ ::ndk::ScopedAStatus freeNode() override;
+
+ ::ndk::ScopedAStatus sendCommand(int32_t cmd, int32_t param) override;
+
+ ::ndk::ScopedAStatus getConsumerUsage(int64_t *_aidl_return) override;
+
+ ::ndk::ScopedAStatus getInputBufferParams(
+ ::aidl::android::media::IAidlNode::InputBufferParams *_aidl_return) override;
+
+ ::ndk::ScopedAStatus setConsumerUsage(int64_t usage) override;
+
+ ::ndk::ScopedAStatus setAdjustTimestampGapUs(int32_t gapUs) override;
+
+ ::ndk::ScopedAStatus setInputSurface(
+ const std::shared_ptr<::aidl::android::media::IAidlBufferSource>&
+ bufferSource) override;
+
+ ::ndk::ScopedAStatus submitBuffer(
+ int32_t buffer,
+ const ::aidl::android::hardware::HardwareBuffer& hBuffer,
+ int32_t flags,
+ int64_t timestampUs,
+ const ::ndk::ScopedFileDescriptor& fence) override;
+
+ ::ndk::ScopedAStatus onDataSpaceChanged(
+ int dataSpace, int aspects, int pixelFormat) override;
+
+ /**
+ * Returns underlying IAidlBufferSource object.
+ */
+ std::shared_ptr<::aidl::android::media::IAidlBufferSource> getSource();
+
+ /**
+ * Configure the frame size.
+ */
+ void setFrameSize(uint32_t width, uint32_t height);
+
+ /**
+ * Clean up work item reference.
+ *
+ * \param index input work index
+ */
+ void onInputBufferDone(c2_cntr64_t index);
+
+ /**
+ * Returns dataspace information from GraphicBufferSource.
+ */
+ android_dataspace getDataspace();
+
+ /**
+ * Returns dataspace information from GraphicBufferSource.
+ */
+ uint32_t getPixelFormat();
+
+ /**
+ * Sets priority of the queue thread.
+ */
+ void setPriority(int priority);
+
+private:
+ std::shared_ptr<C2NodeImpl> mImpl;
+};
+
+} // namespace android
+
diff --git a/media/codec2/sfplugin/C2NodeImpl.cpp b/media/codec2/sfplugin/C2NodeImpl.cpp
index 778686c..6f53e0f 100644
--- a/media/codec2/sfplugin/C2NodeImpl.cpp
+++ b/media/codec2/sfplugin/C2NodeImpl.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2018, The Android Open Source Project
+ * Copyright 2024, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,30 +14,22 @@
* limitations under the License.
*/
-#ifdef __LP64__
-#define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS
-#endif
-
//#define LOG_NDEBUG 0
-#define LOG_TAG "C2OMXNode"
+#define LOG_TAG "C2NodeImpl"
#include <log/log.h>
#include <C2AllocatorGralloc.h>
#include <C2BlockInternal.h>
#include <C2Component.h>
#include <C2Config.h>
+#include <C2Debug.h>
#include <C2PlatformSupport.h>
-#include <OMX_Component.h>
-#include <OMX_Index.h>
-#include <OMX_IndexExt.h>
-
#include <android/fdsan.h>
#include <media/stagefright/foundation/ColorUtils.h>
-#include <media/stagefright/omx/OMXUtils.h>
-#include <media/stagefright/MediaErrors.h>
#include <ui/Fence.h>
#include <ui/GraphicBuffer.h>
+#include <utils/Errors.h>
#include <utils/Thread.h>
#include "utils/Codec2Mapper.h"
@@ -46,9 +38,12 @@
namespace android {
-namespace {
+using ::aidl::android::media::IAidlBufferSource;
+using ::aidl::android::media::IAidlNode;
-constexpr OMX_U32 kPortIndexInput = 0;
+using ::android::media::BUFFERFLAG_EOS;
+
+namespace {
class Buffer2D : public C2Buffer {
public:
@@ -57,7 +52,7 @@
} // namespace
-class C2OMXNode::QueueThread : public Thread {
+class C2NodeImpl::QueueThread : public Thread {
public:
QueueThread() : Thread(false) {}
~QueueThread() override = default;
@@ -195,12 +190,12 @@
Mutexed<Jobs> mJobs;
};
-C2OMXNode::C2OMXNode(const std::shared_ptr<Codec2Client::Component> &comp)
+C2NodeImpl::C2NodeImpl(const std::shared_ptr<Codec2Client::Component> &comp, bool aidl)
: mComp(comp), mFrameIndex(0), mWidth(0), mHeight(0), mUsage(0),
mAdjustTimestampGapUs(0), mFirstInputFrame(true),
- mQueueThread(new QueueThread) {
+ mQueueThread(new QueueThread), mAidlHal(aidl) {
android_fdsan_set_error_level(ANDROID_FDSAN_ERROR_LEVEL_WARN_ALWAYS);
- mQueueThread->run("C2OMXNode", PRIORITY_AUDIO);
+ mQueueThread->run("C2NodeImpl", PRIORITY_AUDIO);
android_dataspace ds = HAL_DATASPACE_UNKNOWN;
mDataspace.lock().set(ds);
@@ -208,224 +203,105 @@
mPixelFormat.lock().set(pf);
}
-status_t C2OMXNode::freeNode() {
+C2NodeImpl::~C2NodeImpl() {
+}
+
+status_t C2NodeImpl::freeNode() {
mComp.reset();
android_fdsan_set_error_level(ANDROID_FDSAN_ERROR_LEVEL_WARN_ONCE);
return mQueueThread->requestExitAndWait();
}
-status_t C2OMXNode::sendCommand(OMX_COMMANDTYPE cmd, OMX_S32 param) {
- if (cmd == OMX_CommandStateSet && param == OMX_StateLoaded) {
- // Reset first input frame so if C2OMXNode is recycled, the timestamp does not become
- // negative. This is a workaround for HW codecs that do not handle timestamp rollover.
- mFirstInputFrame = true;
- }
- return ERROR_UNSUPPORTED;
+void C2NodeImpl::onFirstInputFrame() {
+ mFirstInputFrame = true;
}
-status_t C2OMXNode::getParameter(OMX_INDEXTYPE index, void *params, size_t size) {
- status_t err = ERROR_UNSUPPORTED;
- switch ((uint32_t)index) {
- case OMX_IndexParamConsumerUsageBits: {
- OMX_U32 *usage = (OMX_U32 *)params;
- *usage = mUsage;
- err = OK;
- break;
+void C2NodeImpl::getConsumerUsageBits(uint64_t *usage) {
+ *usage = mUsage;
+}
+
+void C2NodeImpl::getInputBufferParams(IAidlNode::InputBufferParams *params) {
+ params->bufferCountActual = 16;
+
+ // WORKAROUND: having more slots improve performance while consuming
+ // more memory. This is a temporary workaround to reduce memory for
+ // larger-than-4K scenario.
+ if (mWidth * mHeight > 4096 * 2340) {
+ std::shared_ptr<Codec2Client::Component> comp = mComp.lock();
+ C2PortActualDelayTuning::input inputDelay(0);
+ C2ActualPipelineDelayTuning pipelineDelay(0);
+ c2_status_t c2err = C2_NOT_FOUND;
+ if (comp) {
+ c2err = comp->query(
+ {&inputDelay, &pipelineDelay}, {}, C2_DONT_BLOCK, nullptr);
}
- case OMX_IndexParamConsumerUsageBits64: {
- OMX_U64 *usage = (OMX_U64 *)params;
- *usage = mUsage;
- err = OK;
- break;
+ if (c2err == C2_OK || c2err == C2_BAD_INDEX) {
+ params->bufferCountActual = 4;
+ params->bufferCountActual += (inputDelay ? inputDelay.value : 0u);
+ params->bufferCountActual += (pipelineDelay ? pipelineDelay.value : 0u);
}
- case OMX_IndexParamPortDefinition: {
- if (size < sizeof(OMX_PARAM_PORTDEFINITIONTYPE)) {
- return BAD_VALUE;
- }
- OMX_PARAM_PORTDEFINITIONTYPE *pDef = (OMX_PARAM_PORTDEFINITIONTYPE *)params;
- if (pDef->nPortIndex != kPortIndexInput) {
- break;
- }
-
- pDef->nBufferCountActual = 16;
-
- // WORKAROUND: having more slots improve performance while consuming
- // more memory. This is a temporary workaround to reduce memory for
- // larger-than-4K scenario.
- if (mWidth * mHeight > 4096 * 2340) {
- std::shared_ptr<Codec2Client::Component> comp = mComp.lock();
- C2PortActualDelayTuning::input inputDelay(0);
- C2ActualPipelineDelayTuning pipelineDelay(0);
- c2_status_t c2err = C2_NOT_FOUND;
- if (comp) {
- c2err = comp->query(
- {&inputDelay, &pipelineDelay}, {}, C2_DONT_BLOCK, nullptr);
- }
- if (c2err == C2_OK || c2err == C2_BAD_INDEX) {
- pDef->nBufferCountActual = 4;
- pDef->nBufferCountActual += (inputDelay ? inputDelay.value : 0u);
- pDef->nBufferCountActual += (pipelineDelay ? pipelineDelay.value : 0u);
- }
- }
-
- pDef->eDomain = OMX_PortDomainVideo;
- pDef->format.video.nFrameWidth = mWidth;
- pDef->format.video.nFrameHeight = mHeight;
- pDef->format.video.eColorFormat = OMX_COLOR_FormatAndroidOpaque;
- err = OK;
- break;
- }
- default:
- break;
}
- return err;
+
+ params->frameWidth = mWidth;
+ params->frameHeight = mHeight;
}
-status_t C2OMXNode::setParameter(OMX_INDEXTYPE index, const void *params, size_t size) {
- if (params == NULL) {
- return BAD_VALUE;
- }
- switch ((uint32_t)index) {
- case OMX_IndexParamMaxFrameDurationForBitrateControl:
- // handle max/fixed frame duration control
- if (size != sizeof(OMX_PARAM_U32TYPE)) {
- return BAD_VALUE;
- }
- // The incoming number is an int32_t contained in OMX_U32.
- mAdjustTimestampGapUs = (int32_t)((OMX_PARAM_U32TYPE*)params)->nU32;
- return OK;
-
- case OMX_IndexParamConsumerUsageBits:
- if (size != sizeof(OMX_U32)) {
- return BAD_VALUE;
- }
- mUsage = *((OMX_U32 *)params);
- return OK;
-
- case OMX_IndexParamConsumerUsageBits64:
- if (size != sizeof(OMX_U64)) {
- return BAD_VALUE;
- }
- mUsage = *((OMX_U64 *)params);
- return OK;
- }
- return ERROR_UNSUPPORTED;
+void C2NodeImpl::setConsumerUsageBits(uint64_t usage) {
+ mUsage = usage;
}
-status_t C2OMXNode::getConfig(OMX_INDEXTYPE index, void *config, size_t size) {
- (void)index;
- (void)config;
- (void)size;
- return ERROR_UNSUPPORTED;
+void C2NodeImpl::setAdjustTimestampGapUs(int32_t gapUs) {
+ mAdjustTimestampGapUs = gapUs;
}
-status_t C2OMXNode::setConfig(OMX_INDEXTYPE index, const void *config, size_t size) {
- (void)index;
- (void)config;
- (void)size;
- return ERROR_UNSUPPORTED;
-}
-
-status_t C2OMXNode::setPortMode(OMX_U32 portIndex, IOMX::PortMode mode) {
- (void)portIndex;
- (void)mode;
- return ERROR_UNSUPPORTED;
-}
-
-status_t C2OMXNode::prepareForAdaptivePlayback(
- OMX_U32 portIndex, OMX_BOOL enable,
- OMX_U32 maxFrameWidth, OMX_U32 maxFrameHeight) {
- (void)portIndex;
- (void)enable;
- (void)maxFrameWidth;
- (void)maxFrameHeight;
- return ERROR_UNSUPPORTED;
-}
-
-status_t C2OMXNode::configureVideoTunnelMode(
- OMX_U32 portIndex, OMX_BOOL tunneled,
- OMX_U32 audioHwSync, native_handle_t **sidebandHandle) {
- (void)portIndex;
- (void)tunneled;
- (void)audioHwSync;
- *sidebandHandle = nullptr;
- return ERROR_UNSUPPORTED;
-}
-
-status_t C2OMXNode::getGraphicBufferUsage(OMX_U32 portIndex, OMX_U32* usage) {
- (void)portIndex;
- *usage = 0;
- return ERROR_UNSUPPORTED;
-}
-
-status_t C2OMXNode::setInputSurface(const sp<IOMXBufferSource> &bufferSource) {
+status_t C2NodeImpl::setInputSurface(const sp<IOMXBufferSource> &bufferSource) {
c2_status_t err = GetCodec2PlatformAllocatorStore()->fetchAllocator(
C2PlatformAllocatorStore::GRALLOC,
&mAllocator);
if (err != OK) {
return UNKNOWN_ERROR;
}
+ CHECK(!mAidlHal);
mBufferSource = bufferSource;
return OK;
}
-status_t C2OMXNode::allocateSecureBuffer(
- OMX_U32 portIndex, size_t size, buffer_id *buffer,
- void **bufferData, sp<NativeHandle> *nativeHandle) {
- (void)portIndex;
- (void)size;
- (void)nativeHandle;
- *buffer = 0;
- *bufferData = nullptr;
- return ERROR_UNSUPPORTED;
+status_t C2NodeImpl::setAidlInputSurface(
+ const std::shared_ptr<IAidlBufferSource> &aidlBufferSource) {
+ c2_status_t err = GetCodec2PlatformAllocatorStore()->fetchAllocator(
+ C2PlatformAllocatorStore::GRALLOC,
+ &mAllocator);
+ if (err != OK) {
+ return UNKNOWN_ERROR;
+ }
+ CHECK(mAidlHal);
+ mAidlBufferSource = aidlBufferSource;
+ return OK;
}
-status_t C2OMXNode::useBuffer(
- OMX_U32 portIndex, const OMXBuffer &omxBuf, buffer_id *buffer) {
- (void)portIndex;
- (void)omxBuf;
- *buffer = 0;
- return ERROR_UNSUPPORTED;
-}
-
-status_t C2OMXNode::freeBuffer(OMX_U32 portIndex, buffer_id buffer) {
- (void)portIndex;
- (void)buffer;
- return ERROR_UNSUPPORTED;
-}
-
-status_t C2OMXNode::fillBuffer(
- buffer_id buffer, const OMXBuffer &omxBuf, int fenceFd) {
- (void)buffer;
- (void)omxBuf;
- (void)fenceFd;
- return ERROR_UNSUPPORTED;
-}
-
-status_t C2OMXNode::emptyBuffer(
- buffer_id buffer, const OMXBuffer &omxBuf,
- OMX_U32 flags, OMX_TICKS timestamp, int fenceFd) {
+status_t C2NodeImpl::submitBuffer(
+ uint32_t buffer, const sp<GraphicBuffer> &graphicBuffer,
+ uint32_t flags, int64_t timestamp, int fenceFd) {
std::shared_ptr<Codec2Client::Component> comp = mComp.lock();
if (!comp) {
return NO_INIT;
}
- uint32_t c2Flags = (flags & OMX_BUFFERFLAG_EOS)
+ uint32_t c2Flags = (flags & BUFFERFLAG_EOS)
? C2FrameData::FLAG_END_OF_STREAM : 0;
std::shared_ptr<C2GraphicBlock> block;
android::base::unique_fd fd0, fd1;
C2Handle *handle = nullptr;
- if (omxBuf.mBufferType == OMXBuffer::kBufferTypeANWBuffer
- && omxBuf.mGraphicBuffer != nullptr) {
+ if (graphicBuffer) {
std::shared_ptr<C2GraphicAllocation> alloc;
handle = WrapNativeCodec2GrallocHandle(
- omxBuf.mGraphicBuffer->handle,
- omxBuf.mGraphicBuffer->width,
- omxBuf.mGraphicBuffer->height,
- omxBuf.mGraphicBuffer->format,
- omxBuf.mGraphicBuffer->usage,
- omxBuf.mGraphicBuffer->stride);
+ graphicBuffer->handle,
+ graphicBuffer->width,
+ graphicBuffer->height,
+ graphicBuffer->format,
+ graphicBuffer->usage,
+ graphicBuffer->stride);
if (handle != nullptr) {
// unique_fd takes ownership of the fds, we'll get warning if these
// fds get closed by somebody else. Onwership will be released before
@@ -444,7 +320,7 @@
return UNKNOWN_ERROR;
}
block = _C2BlockFactory::CreateGraphicBlock(alloc);
- } else if (!(flags & OMX_BUFFERFLAG_EOS)) {
+ } else if (!(flags & BUFFERFLAG_EOS)) {
return BAD_VALUE;
}
@@ -503,44 +379,42 @@
return OK;
}
-status_t C2OMXNode::getExtensionIndex(
- const char *parameterName, OMX_INDEXTYPE *index) {
- (void)parameterName;
- *index = OMX_IndexMax;
- return ERROR_UNSUPPORTED;
-}
-
-status_t C2OMXNode::dispatchMessage(const omx_message& msg) {
- if (msg.type != omx_message::EVENT) {
- return ERROR_UNSUPPORTED;
- }
- if (msg.u.event_data.event != OMX_EventDataSpaceChanged) {
- return ERROR_UNSUPPORTED;
- }
- android_dataspace dataSpace = (android_dataspace)msg.u.event_data.data1;
- uint32_t pixelFormat = msg.u.event_data.data3;
-
+status_t C2NodeImpl::onDataspaceChanged(uint32_t dataSpace, uint32_t pixelFormat) {
ALOGD("dataspace changed to %#x pixel format: %#x", dataSpace, pixelFormat);
- mQueueThread->setDataspace(dataSpace);
+ android_dataspace d = (android_dataspace)dataSpace;
+ mQueueThread->setDataspace(d);
- mDataspace.lock().set(dataSpace);
+ mDataspace.lock().set(d);
mPixelFormat.lock().set(pixelFormat);
return OK;
}
-sp<IOMXBufferSource> C2OMXNode::getSource() {
+sp<IOMXBufferSource> C2NodeImpl::getSource() {
+ CHECK(!mAidlHal);
return mBufferSource;
}
-void C2OMXNode::setFrameSize(uint32_t width, uint32_t height) {
+std::shared_ptr<IAidlBufferSource> C2NodeImpl::getAidlSource() {
+ CHECK(mAidlHal);
+ return mAidlBufferSource;
+}
+
+void C2NodeImpl::setFrameSize(uint32_t width, uint32_t height) {
mWidth = width;
mHeight = height;
}
-void C2OMXNode::onInputBufferDone(c2_cntr64_t index) {
- if (!mBufferSource) {
- ALOGD("Buffer source not set (index=%llu)", index.peekull());
- return;
+void C2NodeImpl::onInputBufferDone(c2_cntr64_t index) {
+ if (mAidlHal) {
+ if (!mAidlBufferSource) {
+ ALOGD("Buffer source not set (index=%llu)", index.peekull());
+ return;
+ }
+ } else {
+ if (!mBufferSource) {
+ ALOGD("Buffer source not set (index=%llu)", index.peekull());
+ return;
+ }
}
int32_t bufferId = 0;
@@ -554,18 +428,23 @@
bufferId = it->second;
(void)bufferIds->erase(it);
}
- (void)mBufferSource->onInputBufferEmptied(bufferId, -1);
+ if (mAidlHal) {
+ ::ndk::ScopedFileDescriptor nullFence;
+ (void)mAidlBufferSource->onInputBufferEmptied(bufferId, nullFence);
+ } else {
+ (void)mBufferSource->onInputBufferEmptied(bufferId, -1);
+ }
}
-android_dataspace C2OMXNode::getDataspace() {
+android_dataspace C2NodeImpl::getDataspace() {
return *mDataspace.lock();
}
-uint32_t C2OMXNode::getPixelFormat() {
+uint32_t C2NodeImpl::getPixelFormat() {
return *mPixelFormat.lock();
}
-void C2OMXNode::setPriority(int priority) {
+void C2NodeImpl::setPriority(int priority) {
mQueueThread->setPriority(priority);
}
diff --git a/media/codec2/sfplugin/C2NodeImpl.h b/media/codec2/sfplugin/C2NodeImpl.h
index c8ce336..e060fd8 100644
--- a/media/codec2/sfplugin/C2NodeImpl.h
+++ b/media/codec2/sfplugin/C2NodeImpl.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2018, The Android Open Source Project
+ * Copyright 2024, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,67 +14,48 @@
* limitations under the License.
*/
-#ifndef C2_OMX_NODE_H_
-#define C2_OMX_NODE_H_
+#pragma once
#include <atomic>
#include <android/IOMXBufferSource.h>
+#include <aidl/android/media/IAidlBufferSource.h>
+#include <aidl/android/media/IAidlNode.h>
#include <codec2/hidl/client.h>
#include <media/stagefright/foundation/Mutexed.h>
-#include <media/IOMX.h>
-#include <media/OMXBuffer.h>
+#include <media/stagefright/aidlpersistentsurface/C2NodeDef.h>
namespace android {
/**
* IOmxNode implementation around codec 2.0 component, only to be used in
- * IGraphicBufferSource::configure. Only subset of IOmxNode API is implemented
- * and others are left as stub. As a result, one cannot expect this IOmxNode
- * to work in any other usage than IGraphicBufferSource.
+ * IGraphicBufferSource::configure. Only subset of IOmxNode API is implemented.
+ * As a result, one cannot expect this IOmxNode to work in any other usage than
+ * IGraphicBufferSource(if aidl hal is used, IAidlGraphicBufferSource).
*/
-struct C2OMXNode : public BnOMXNode {
- explicit C2OMXNode(const std::shared_ptr<Codec2Client::Component> &comp);
- ~C2OMXNode() override = default;
+struct C2NodeImpl {
+ explicit C2NodeImpl(const std::shared_ptr<Codec2Client::Component> &comp, bool aidl);
+ ~C2NodeImpl();
- // IOMXNode
- status_t freeNode() override;
- status_t sendCommand(OMX_COMMANDTYPE cmd, OMX_S32 param) override;
- status_t getParameter(
- OMX_INDEXTYPE index, void *params, size_t size) override;
- status_t setParameter(
- OMX_INDEXTYPE index, const void *params, size_t size) override;
- status_t getConfig(
- OMX_INDEXTYPE index, void *params, size_t size) override;
- status_t setConfig(
- OMX_INDEXTYPE index, const void *params, size_t size) override;
- status_t setPortMode(OMX_U32 port_index, IOMX::PortMode mode) override;
- status_t prepareForAdaptivePlayback(
- OMX_U32 portIndex, OMX_BOOL enable,
- OMX_U32 maxFrameWidth, OMX_U32 maxFrameHeight) override;
- status_t configureVideoTunnelMode(
- OMX_U32 portIndex, OMX_BOOL tunneled,
- OMX_U32 audioHwSync, native_handle_t **sidebandHandle) override;
- status_t getGraphicBufferUsage(
- OMX_U32 port_index, OMX_U32* usage) override;
+ // IOMXNode and/or IAidlNode
+ status_t freeNode();
+
+ void onFirstInputFrame();
+ void getConsumerUsageBits(uint64_t *usage /* nonnull */);
+ void getInputBufferParams(
+ ::aidl::android::media::IAidlNode::InputBufferParams *params /* nonnull */);
+ void setConsumerUsageBits(uint64_t usage);
+ void setAdjustTimestampGapUs(int32_t gapUs);
+
status_t setInputSurface(
- const sp<IOMXBufferSource> &bufferSource) override;
- status_t allocateSecureBuffer(
- OMX_U32 port_index, size_t size, buffer_id *buffer,
- void **buffer_data, sp<NativeHandle> *native_handle) override;
- status_t useBuffer(
- OMX_U32 port_index, const OMXBuffer &omxBuf, buffer_id *buffer) override;
- status_t freeBuffer(
- OMX_U32 port_index, buffer_id buffer) override;
- status_t fillBuffer(
- buffer_id buffer, const OMXBuffer &omxBuf, int fenceFd) override;
- status_t emptyBuffer(
- buffer_id buffer, const OMXBuffer &omxBuf,
- OMX_U32 flags, OMX_TICKS timestamp, int fenceFd) override;
- status_t getExtensionIndex(
- const char *parameter_name,
- OMX_INDEXTYPE *index) override;
- status_t dispatchMessage(const omx_message &msg) override;
+ const sp<IOMXBufferSource> &bufferSource);
+ status_t setAidlInputSurface(
+ const std::shared_ptr<::aidl::android::media::IAidlBufferSource> &aidlBufferSource);
+
+ status_t submitBuffer(
+ uint32_t buffer, const sp<GraphicBuffer> &graphicBuffer,
+ uint32_t flags, int64_t timestamp, int fenceFd);
+ status_t onDataspaceChanged(uint32_t dataSpace, uint32_t pixelFormat);
/**
* Returns underlying IOMXBufferSource object.
@@ -82,6 +63,11 @@
sp<IOMXBufferSource> getSource();
/**
+ * Returns underlying IAidlBufferSource object.
+ */
+ std::shared_ptr<::aidl::android::media::IAidlBufferSource> getAidlSource();
+
+ /**
* Configure the frame size.
*/
void setFrameSize(uint32_t width, uint32_t height);
@@ -110,7 +96,10 @@
private:
std::weak_ptr<Codec2Client::Component> mComp;
+
sp<IOMXBufferSource> mBufferSource;
+ std::shared_ptr<::aidl::android::media::IAidlBufferSource> mAidlBufferSource;
+
std::shared_ptr<C2Allocator> mAllocator;
std::atomic_uint64_t mFrameIndex;
uint32_t mWidth;
@@ -129,12 +118,12 @@
c2_cntr64_t mPrevInputTimestamp; // input timestamp for previous frame
c2_cntr64_t mPrevCodecTimestamp; // adjusted (codec) timestamp for previous frame
- Mutexed<std::map<uint64_t, buffer_id>> mBufferIdsInUse;
+ Mutexed<std::map<uint64_t, uint32_t>> mBufferIdsInUse;
class QueueThread;
sp<QueueThread> mQueueThread;
+
+ bool mAidlHal;
};
} // namespace android
-
-#endif // C2_OMX_NODE_H_
diff --git a/media/codec2/sfplugin/C2OMXNode.cpp b/media/codec2/sfplugin/C2OMXNode.cpp
new file mode 100644
index 0000000..ce02c88
--- /dev/null
+++ b/media/codec2/sfplugin/C2OMXNode.cpp
@@ -0,0 +1,306 @@
+/*
+ * Copyright 2024, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef __LP64__
+#define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS
+#endif
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "C2OMXNODE"
+#include <log/log.h>
+
+#include <OMX_Component.h>
+#include <OMX_Index.h>
+#include <OMX_IndexExt.h>
+
+#include <media/stagefright/MediaErrors.h>
+
+#include "C2OMXNode.h"
+#include "C2NodeImpl.h"
+
+namespace android {
+
+namespace {
+
+constexpr OMX_U32 kPortIndexInput = 0;
+
+} // anomymous namespace
+
+using ::android::media::BUFFERFLAG_ENDOFFRAME;
+using ::android::media::BUFFERFLAG_EOS;
+
+using ::aidl::android::media::IAidlNode;
+
+C2OMXNode::C2OMXNode(const std::shared_ptr<Codec2Client::Component> &comp)
+ : mImpl(new C2NodeImpl(comp, false)) {}
+
+status_t C2OMXNode::freeNode() {
+ return mImpl->freeNode();
+}
+
+status_t C2OMXNode::sendCommand(OMX_COMMANDTYPE cmd, OMX_S32 param) {
+ if (cmd == OMX_CommandStateSet && param == OMX_StateLoaded) {
+ // Reset first input frame so if C2OMXNode is recycled, the timestamp does not become
+ // negative. This is a workaround for HW codecs that do not handle timestamp rollover.
+ mImpl->onFirstInputFrame();
+ }
+ return ERROR_UNSUPPORTED;
+}
+
+status_t C2OMXNode::getParameter(OMX_INDEXTYPE index, void *params, size_t size) {
+ status_t err = ERROR_UNSUPPORTED;
+ switch ((uint32_t)index) {
+ case OMX_IndexParamConsumerUsageBits: {
+ OMX_U32 *usage = (OMX_U32 *)params;
+ uint64_t val;
+ mImpl->getConsumerUsageBits(&val);
+ *usage = static_cast<uint32_t>(val & 0xFFFFFFFF);
+ ALOGW("retrieving usage bits in 32 bits %llu -> %u",
+ (unsigned long long)val, (unsigned int)*usage);
+ err = OK;
+ break;
+ }
+ case OMX_IndexParamConsumerUsageBits64: {
+ OMX_U64 *usage = (OMX_U64 *)params;
+ uint64_t val;
+ mImpl->getConsumerUsageBits(&val);
+ *usage = val;
+ err = OK;
+ break;
+ }
+ case OMX_IndexParamPortDefinition: {
+ if (size < sizeof(OMX_PARAM_PORTDEFINITIONTYPE)) {
+ return BAD_VALUE;
+ }
+ OMX_PARAM_PORTDEFINITIONTYPE *pDef = (OMX_PARAM_PORTDEFINITIONTYPE *)params;
+ if (pDef->nPortIndex != kPortIndexInput) {
+ break;
+ }
+ IAidlNode::InputBufferParams bufferParams;
+ mImpl->getInputBufferParams(&bufferParams);
+ pDef->nBufferCountActual = bufferParams.bufferCountActual;
+ pDef->eDomain = OMX_PortDomainVideo;
+ pDef->format.video.nFrameWidth = bufferParams.frameWidth;
+ pDef->format.video.nFrameHeight = bufferParams.frameHeight;
+ pDef->format.video.eColorFormat = OMX_COLOR_FormatAndroidOpaque;
+ err = OK;
+ break;
+ }
+ default:
+ break;
+ }
+ return err;
+}
+
+status_t C2OMXNode::setParameter(OMX_INDEXTYPE index, const void *params, size_t size) {
+ if (params == NULL) {
+ return BAD_VALUE;
+ }
+ switch ((uint32_t)index) {
+ case OMX_IndexParamMaxFrameDurationForBitrateControl: {
+ // handle max/fixed frame duration control
+ if (size != sizeof(OMX_PARAM_U32TYPE)) {
+ return BAD_VALUE;
+ }
+ // The incoming number is an int32_t contained in OMX_U32.
+ int32_t gapUs = (int32_t)((OMX_PARAM_U32TYPE*)params)->nU32;
+ mImpl->setAdjustTimestampGapUs(gapUs);
+ return OK;
+ }
+ case OMX_IndexParamConsumerUsageBits: {
+ if (size != sizeof(OMX_U32)) {
+ return BAD_VALUE;
+ }
+ uint32_t usage = *((OMX_U32 *)params);
+ mImpl->setConsumerUsageBits(static_cast<uint64_t>(usage));
+ return OK;
+ }
+ case OMX_IndexParamConsumerUsageBits64: {
+ if (size != sizeof(OMX_U64)) {
+ return BAD_VALUE;
+ }
+ uint64_t usagell = *((OMX_U64 *)params);
+ mImpl->setConsumerUsageBits(usagell);
+ return OK;
+ }
+ default:
+ break;
+ }
+ return ERROR_UNSUPPORTED;
+}
+
+status_t C2OMXNode::getConfig(OMX_INDEXTYPE index, void *config, size_t size) {
+ (void)index;
+ (void)config;
+ (void)size;
+ return ERROR_UNSUPPORTED;
+}
+
+status_t C2OMXNode::setConfig(OMX_INDEXTYPE index, const void *config, size_t size) {
+ (void)index;
+ (void)config;
+ (void)size;
+ return ERROR_UNSUPPORTED;
+}
+
+status_t C2OMXNode::setPortMode(OMX_U32 portIndex, IOMX::PortMode mode) {
+ (void)portIndex;
+ (void)mode;
+ return ERROR_UNSUPPORTED;
+}
+
+status_t C2OMXNode::prepareForAdaptivePlayback(
+ OMX_U32 portIndex, OMX_BOOL enable,
+ OMX_U32 maxFrameWidth, OMX_U32 maxFrameHeight) {
+ (void)portIndex;
+ (void)enable;
+ (void)maxFrameWidth;
+ (void)maxFrameHeight;
+ return ERROR_UNSUPPORTED;
+}
+
+status_t C2OMXNode::configureVideoTunnelMode(
+ OMX_U32 portIndex, OMX_BOOL tunneled,
+ OMX_U32 audioHwSync, native_handle_t **sidebandHandle) {
+ (void)portIndex;
+ (void)tunneled;
+ (void)audioHwSync;
+ *sidebandHandle = nullptr;
+ return ERROR_UNSUPPORTED;
+}
+
+status_t C2OMXNode::getGraphicBufferUsage(OMX_U32 portIndex, OMX_U32* usage) {
+ (void)portIndex;
+ *usage = 0;
+ return ERROR_UNSUPPORTED;
+}
+
+status_t C2OMXNode::setInputSurface(const sp<IOMXBufferSource> &bufferSource) {
+ return mImpl->setInputSurface(bufferSource);
+}
+
+status_t C2OMXNode::allocateSecureBuffer(
+ OMX_U32 portIndex, size_t size, buffer_id *buffer,
+ void **bufferData, sp<NativeHandle> *nativeHandle) {
+ (void)portIndex;
+ (void)size;
+ (void)nativeHandle;
+ *buffer = 0;
+ *bufferData = nullptr;
+ return ERROR_UNSUPPORTED;
+}
+
+status_t C2OMXNode::useBuffer(
+ OMX_U32 portIndex, const OMXBuffer &omxBuf, buffer_id *buffer) {
+ (void)portIndex;
+ (void)omxBuf;
+ *buffer = 0;
+ return ERROR_UNSUPPORTED;
+}
+
+status_t C2OMXNode::freeBuffer(OMX_U32 portIndex, buffer_id buffer) {
+ (void)portIndex;
+ (void)buffer;
+ return ERROR_UNSUPPORTED;
+}
+
+status_t C2OMXNode::fillBuffer(
+ buffer_id buffer, const OMXBuffer &omxBuf, int fenceFd) {
+ (void)buffer;
+ (void)omxBuf;
+ (void)fenceFd;
+ return ERROR_UNSUPPORTED;
+}
+
+namespace {
+ uint32_t toNodeFlags(OMX_U32 flags) {
+ uint32_t retFlags = 0;
+ if (flags & OMX_BUFFERFLAG_ENDOFFRAME) {
+ retFlags |= BUFFERFLAG_ENDOFFRAME;
+ }
+ if (flags & OMX_BUFFERFLAG_EOS) {
+ retFlags |= BUFFERFLAG_EOS;
+ }
+ return retFlags;
+ }
+ int64_t toNodeTimestamp(OMX_TICKS ticks) {
+ int64_t timestamp = 0;
+#ifndef OMX_SKIP64BIT
+ timestamp = ticks;
+#else
+ timestamp = ((ticks.nHighPart << 32) | ticks.nLowPart);
+#endif
+ return timestamp;
+ }
+} // anonymous namespace
+
+status_t C2OMXNode::emptyBuffer(
+ buffer_id buffer, const OMXBuffer &omxBuf,
+ OMX_U32 flags, OMX_TICKS timestamp, int fenceFd) {
+ if (omxBuf.mBufferType == OMXBuffer::kBufferTypeANWBuffer
+ && omxBuf.mGraphicBuffer != nullptr) {
+ return mImpl->submitBuffer(buffer, omxBuf.mGraphicBuffer, toNodeFlags(flags),
+ toNodeTimestamp(timestamp), fenceFd);
+ }
+ sp<GraphicBuffer> gBuf;
+ return mImpl->submitBuffer(buffer, gBuf, toNodeFlags(flags),
+ toNodeTimestamp(timestamp), fenceFd);
+}
+
+status_t C2OMXNode::getExtensionIndex(
+ const char *parameterName, OMX_INDEXTYPE *index) {
+ (void)parameterName;
+ *index = OMX_IndexMax;
+ return ERROR_UNSUPPORTED;
+}
+
+status_t C2OMXNode::dispatchMessage(const omx_message& msg) {
+ if (msg.type != omx_message::EVENT) {
+ return ERROR_UNSUPPORTED;
+ }
+ if (msg.u.event_data.event != OMX_EventDataSpaceChanged) {
+ return ERROR_UNSUPPORTED;
+ }
+ return mImpl->onDataspaceChanged(
+ msg.u.event_data.data1,
+ msg.u.event_data.data3);
+}
+
+sp<IOMXBufferSource> C2OMXNode::getSource() {
+ return mImpl->getSource();
+}
+
+void C2OMXNode::setFrameSize(uint32_t width, uint32_t height) {
+ return mImpl->setFrameSize(width, height);
+}
+
+void C2OMXNode::onInputBufferDone(c2_cntr64_t index) {
+ return mImpl->onInputBufferDone(index);
+}
+
+android_dataspace C2OMXNode::getDataspace() {
+ return mImpl->getDataspace();
+}
+
+uint32_t C2OMXNode::getPixelFormat() {
+ return mImpl->getPixelFormat();
+}
+
+void C2OMXNode::setPriority(int priority) {
+ return mImpl->setPriority(priority);
+}
+
+} // namespace android
diff --git a/media/codec2/sfplugin/C2OMXNode.h b/media/codec2/sfplugin/C2OMXNode.h
new file mode 100644
index 0000000..d077202
--- /dev/null
+++ b/media/codec2/sfplugin/C2OMXNode.h
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2024, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef C2_OMX_NODE_H_
+#define C2_OMX_NODE_H_
+
+#include <android/IOMXBufferSource.h>
+#include <codec2/hidl/client.h>
+#include <media/IOMX.h>
+#include <media/OMXBuffer.h>
+
+namespace android {
+
+struct C2NodeImpl;
+
+/**
+ * IOmxNode implementation around codec 2.0 component, only to be used in
+ * IGraphicBufferSource::configure. Only subset of IOmxNode API is implemented
+ * and others are left as stub. As a result, one cannot expect this IOmxNode
+ * to work in any other usage than IGraphicBufferSource.
+ */
+struct C2OMXNode : public BnOMXNode {
+ explicit C2OMXNode(const std::shared_ptr<Codec2Client::Component> &comp);
+ ~C2OMXNode() override = default;
+
+ // IOMXNode
+ status_t freeNode() override;
+ status_t sendCommand(OMX_COMMANDTYPE cmd, OMX_S32 param) override;
+ status_t getParameter(
+ OMX_INDEXTYPE index, void *params, size_t size) override;
+ status_t setParameter(
+ OMX_INDEXTYPE index, const void *params, size_t size) override;
+ status_t getConfig(
+ OMX_INDEXTYPE index, void *params, size_t size) override;
+ status_t setConfig(
+ OMX_INDEXTYPE index, const void *params, size_t size) override;
+ status_t setPortMode(OMX_U32 port_index, IOMX::PortMode mode) override;
+ status_t prepareForAdaptivePlayback(
+ OMX_U32 portIndex, OMX_BOOL enable,
+ OMX_U32 maxFrameWidth, OMX_U32 maxFrameHeight) override;
+ status_t configureVideoTunnelMode(
+ OMX_U32 portIndex, OMX_BOOL tunneled,
+ OMX_U32 audioHwSync, native_handle_t **sidebandHandle) override;
+ status_t getGraphicBufferUsage(
+ OMX_U32 port_index, OMX_U32* usage) override;
+ status_t setInputSurface(
+ const sp<IOMXBufferSource> &bufferSource) override;
+ status_t allocateSecureBuffer(
+ OMX_U32 port_index, size_t size, buffer_id *buffer,
+ void **buffer_data, sp<NativeHandle> *native_handle) override;
+ status_t useBuffer(
+ OMX_U32 port_index, const OMXBuffer &omxBuf, buffer_id *buffer) override;
+ status_t freeBuffer(
+ OMX_U32 port_index, buffer_id buffer) override;
+ status_t fillBuffer(
+ buffer_id buffer, const OMXBuffer &omxBuf, int fenceFd) override;
+ status_t emptyBuffer(
+ buffer_id buffer, const OMXBuffer &omxBuf,
+ OMX_U32 flags, OMX_TICKS timestamp, int fenceFd) override;
+ status_t getExtensionIndex(
+ const char *parameter_name,
+ OMX_INDEXTYPE *index) override;
+ status_t dispatchMessage(const omx_message &msg) override;
+
+ /**
+ * Returns underlying IOMXBufferSource object.
+ */
+ sp<IOMXBufferSource> getSource();
+
+ /**
+ * Configure the frame size.
+ */
+ void setFrameSize(uint32_t width, uint32_t height);
+
+ /**
+ * Clean up work item reference.
+ *
+ * \param index input work index
+ */
+ void onInputBufferDone(c2_cntr64_t index);
+
+ /**
+ * Returns dataspace information from GraphicBufferSource.
+ */
+ android_dataspace getDataspace();
+
+ /**
+ * Returns dataspace information from GraphicBufferSource.
+ */
+ uint32_t getPixelFormat();
+
+ /**
+ * Sets priority of the queue thread.
+ */
+ void setPriority(int priority);
+
+private:
+ std::shared_ptr<C2NodeImpl> mImpl;
+};
+
+} // namespace android
+
+#endif // C2_OMX_NODE_H_
diff --git a/media/codec2/sfplugin/CCodec.cpp b/media/codec2/sfplugin/CCodec.cpp
index 1135cae..7bf4dcc 100644
--- a/media/codec2/sfplugin/CCodec.cpp
+++ b/media/codec2/sfplugin/CCodec.cpp
@@ -51,7 +51,7 @@
#include <media/stagefright/RenderedFrameInfo.h>
#include <utils/NativeHandle.h>
-#include "C2NodeImpl.h"
+#include "C2OMXNode.h"
#include "CCodecBufferChannel.h"
#include "CCodecConfig.h"
#include "Codec2Mapper.h"