/* * Copyright (c) 2022 Huawei Device Co., Ltd. * 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. */ /** * @addtogroup Codec * @{ * * @brief Defines APIs related to the Codec module. * * The Codec module provides APIs for initializing the custom data and audio and video codecs, * setting codec parameters, and controlling and transferring data. * * @since 3.1 */ /** * @file codec_callback_if.h * * @brief Defines the callbacks used to report codec events and processing results of the input and output buffers. * * @since 3.1 */ #ifndef CODEC_CALLBACK_TYPE_H #define CODEC_CALLBACK_TYPE_H #include #include #include "codec_component_type.h" #include "OMX_Core.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** * @brief Defines the callbacks of the Codec module. * * The following callbacks are provided: * 1. Callback used to report component error events, command completion events, and port setting events. * For details, see {@link EventHandler}. * 2. Callback invoked when the input port processes data in the buffer. For details, see {@link EmptyBufferDone}. * 3. Callback invoked when the output port fills data into the buffer. For details, see {@link FillBufferDone}. * The callbacks are registered by using: * 1. {@link CreateComponent} when a component is created. * 2. {@link SetCallbacks} when the component is in the OMX_StateLoaded state. */ struct CodecCallbackType { struct HdfRemoteService *remote; /** * @brief Reports an event, such as an error, a command completion event, and port setting changes * during the running of a component. * * When eEvent is OMX_EventCmdComplete, eventData is null, and data1 is * OMX_COMMANDTYPE, data1 indicates a state, if data1 is OMX_CommandStateSet * and indicates a port in other cases. * If eEvent is OMX_EventError, data1 indicates an error code and data2 and * eventData are both 0. * If eEvent is OMX_EventMark, data1 and data2 are both 0 and * eventData points to the mark. * When eEvent is OMX_EventPortSettingsChanged, data1 indicates a port and * data2 and eventData are 0. * When eEvent is OMX_EventBufferFlag, data1 indicates a port, data2 indicates a flag, * and eventData is 0. * When eEvent is OMX_EventResourcesAcquired or OMX_EventDynamicResourcesAvailable, * the values of data1, data2, and eventData are 0. * * @param self Indicates the pointer to the callback to be invoked. * @param event Indicates the type of events to report. For details, see {@link OMX_EVENTTYPE}. * @param info Indicates the pointer to event info. For detials see{@link EventInfo}. * * @return Returns HDF_SUCCESS if the operation is successful. * @return Returns HDF_ERR_INVALID_PARAM if the operation failed due to invalid parameters. * @return Returns HDF_ERR_INVALID_OBJECT if the operation failed due to invalid objects. * @return Returns HDF_ERR_MALLOC_FAIL if the operation failed due to insufficient memory. */ int32_t (*EventHandler)(struct CodecCallbackType *self, enum OMX_EVENTTYPE event, struct EventInfo *info); /** * @brief Reports an event indicating that the encoding or decoding in the input buffer is complete. * * @param self Indicates the pointer to the callback to be invoked. * @param appData Indicates the pointer to the upper-layer instance passed to the callback. * @param buffer Indicates the pointer to the input buffer {@link OmxCodecBuffer} that has data processed. * * @return Returns HDF_SUCCESS if the operation is successful. * @return Returns HDF_ERR_INVALID_PARAM if the operation failed due to invalid parameters. * @return Returns HDF_ERR_INVALID_OBJECT if the operation failed due to invalid objects. * @return Returns HDF_ERR_MALLOC_FAIL if the operation failed due to insufficient memory. */ int32_t (*EmptyBufferDone)(struct CodecCallbackType *self, int64_t appData, const struct OmxCodecBuffer *buffer); /** * @brief Reports an event indicating that the output buffer is filled. * * @param self Indicates the pointer to the callback to be invoked. * @param appData Indicates the pointer to the upper-layer instance passed to the callback. * @param buffer Indicates the pointer to the buffer {@link OmxCodecBuffer} that has data filled. * * @return Returns HDF_SUCCESS if the operation is successful. * @return Returns HDF_ERR_INVALID_PARAM if the operation failed due to invalid parameters. * @return Returns HDF_ERR_INVALID_OBJECT if the operation failed due to invalid objects. * @return Returns HDF_ERR_MALLOC_FAIL if the operation failed due to insufficient memory. */ int32_t (*FillBufferDone)(struct CodecCallbackType *self, int64_t appData, const struct OmxCodecBuffer *buffer); }; /** * @brief Instantiates a CodecCallbackType object. * * @param remote Indicates the pointer to the HdfRemoteService. * * @return Returns the CodecCallbackType object instantiated. */ struct CodecCallbackType *CodecCallbackTypeGet(struct HdfRemoteService *remote); /** * @brief Releases a CodecCallbackType instance. * * @param instance Indicates the pointer to the CodecCallbackType instance to release. */ void CodecCallbackTypeRelease(struct CodecCallbackType *instance); #ifdef __cplusplus } #endif /* __cplusplus */ #endif // CODEC_CALLBACK_TYPE_H