/** * Copyright (C) 2019 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. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "media/hardware/HardwareAPI.h" #include "OMX_Component.h" #include #include #include #include #include #include #include #include #define DEFAULT_TIMEOUT 5000000 #define OMX_UTILS_IP_PORT 0 #define OMX_UTILS_OP_PORT 1 using namespace android; typedef hidl::allocator::V1_0::IAllocator IAllocator; template static void InitOMXParams(T *params) { params->nSize = sizeof(T); params->nVersion.s.nVersionMajor = 1; params->nVersion.s.nVersionMinor = 0; params->nVersion.s.nRevision = 0; params->nVersion.s.nStep = 0; } struct Buffer { IOMX::buffer_id mID; sp mMemory; hidl_memory mHidlMemory; uint32_t mFlags; }; status_t omxUtilsInit(char *codecName); status_t omxUtilsGetParameter(int portIndex, OMX_PARAM_PORTDEFINITIONTYPE *params); status_t omxUtilsSetParameter(int portIndex, OMX_PARAM_PORTDEFINITIONTYPE *params); status_t omxUtilsSetPortMode(OMX_U32 port_index, IOMX::PortMode mode); status_t omxUtilsUseBuffer(OMX_U32 portIndex, const OMXBuffer &omxBuf, android::IOMX::buffer_id *buffer); status_t omxUtilsSendCommand(OMX_COMMANDTYPE cmd, OMX_S32 param); status_t omxUtilsEmptyBuffer(android::IOMX::buffer_id buffer, const OMXBuffer &omxBuf, OMX_U32 flags, OMX_TICKS timestamp, int fenceFd); status_t omxUtilsFillBuffer(android::IOMX::buffer_id buffer, const OMXBuffer &omxBuf, int fenceFd); status_t omxUtilsFreeBuffer(OMX_U32 portIndex, android::IOMX::buffer_id buffer); status_t omxUtilsFreeNode(); status_t dequeueMessageForNode(omx_message *msg, int64_t timeoutUs); void omxExitOnError(status_t ret);