1094332d3Sopenharmony_ci/* 2094332d3Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License. 5094332d3Sopenharmony_ci * You may obtain a copy of the License at 6094332d3Sopenharmony_ci * 7094332d3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8094332d3Sopenharmony_ci * 9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and 13094332d3Sopenharmony_ci * limitations under the License. 14094332d3Sopenharmony_ci */ 15094332d3Sopenharmony_ci 16094332d3Sopenharmony_ci/** 17094332d3Sopenharmony_ci * @addtogroup Codec 18094332d3Sopenharmony_ci * @{ 19094332d3Sopenharmony_ci * 20094332d3Sopenharmony_ci * @brief Defines APIs related to the Codec module. 21094332d3Sopenharmony_ci * 22094332d3Sopenharmony_ci * The Codec module provides APIs for initializing the custom data and audio and video codecs, 23094332d3Sopenharmony_ci * setting codec parameters, and controlling and transferring data. 24094332d3Sopenharmony_ci * 25094332d3Sopenharmony_ci * @since 3.1 26094332d3Sopenharmony_ci */ 27094332d3Sopenharmony_ci 28094332d3Sopenharmony_ci/** 29094332d3Sopenharmony_ci * @file codec_callback_if.h 30094332d3Sopenharmony_ci * 31094332d3Sopenharmony_ci * @brief Defines the callbacks used to report codec events and processing results of the input and output buffers. 32094332d3Sopenharmony_ci * 33094332d3Sopenharmony_ci * @since 3.1 34094332d3Sopenharmony_ci */ 35094332d3Sopenharmony_ci 36094332d3Sopenharmony_ci#ifndef CODEC_CALLBACK_TYPE_H 37094332d3Sopenharmony_ci#define CODEC_CALLBACK_TYPE_H 38094332d3Sopenharmony_ci 39094332d3Sopenharmony_ci#include <stdint.h> 40094332d3Sopenharmony_ci#include <netinet/in.h> 41094332d3Sopenharmony_ci#include "codec_component_type.h" 42094332d3Sopenharmony_ci#include "OMX_Core.h" 43094332d3Sopenharmony_ci 44094332d3Sopenharmony_ci#ifdef __cplusplus 45094332d3Sopenharmony_ciextern "C" { 46094332d3Sopenharmony_ci#endif /* __cplusplus */ 47094332d3Sopenharmony_ci 48094332d3Sopenharmony_ci/** 49094332d3Sopenharmony_ci * @brief Defines the callbacks of the Codec module. 50094332d3Sopenharmony_ci * 51094332d3Sopenharmony_ci * The following callbacks are provided: 52094332d3Sopenharmony_ci * 1. Callback used to report component error events, command completion events, and port setting events. 53094332d3Sopenharmony_ci * For details, see {@link EventHandler}. 54094332d3Sopenharmony_ci * 2. Callback invoked when the input port processes data in the buffer. For details, see {@link EmptyBufferDone}. 55094332d3Sopenharmony_ci * 3. Callback invoked when the output port fills data into the buffer. For details, see {@link FillBufferDone}. 56094332d3Sopenharmony_ci * The callbacks are registered by using: 57094332d3Sopenharmony_ci * 1. {@link CreateComponent} when a component is created. 58094332d3Sopenharmony_ci * 2. {@link SetCallbacks} when the component is in the OMX_StateLoaded state. 59094332d3Sopenharmony_ci */ 60094332d3Sopenharmony_cistruct CodecCallbackType { 61094332d3Sopenharmony_ci struct HdfRemoteService *remote; 62094332d3Sopenharmony_ci 63094332d3Sopenharmony_ci /** 64094332d3Sopenharmony_ci * @brief Reports an event, such as an error, a command completion event, and port setting changes 65094332d3Sopenharmony_ci * during the running of a component. 66094332d3Sopenharmony_ci * 67094332d3Sopenharmony_ci * When <b>eEvent</b> is <b>OMX_EventCmdComplete</b>, <b>eventData</b> is null, and <b>data1</b> is 68094332d3Sopenharmony_ci * <b>OMX_COMMANDTYPE</b>, <b>data1</b> indicates a state, if <b>data1</b> is <b>OMX_CommandStateSet</b> 69094332d3Sopenharmony_ci * and indicates a port in other cases. 70094332d3Sopenharmony_ci * If <b>eEvent</b> is <b>OMX_EventError</b>, <b>data1</b> indicates an error code and <b>data2</b> and 71094332d3Sopenharmony_ci * <b>eventData</b> are both <b>0</b>. 72094332d3Sopenharmony_ci * If <b>eEvent</b> is <b>OMX_EventMark</b>, <b>data1</b> and <b>data2</b> are both <b>0</b> and 73094332d3Sopenharmony_ci * <b>eventData</b> points to the mark. 74094332d3Sopenharmony_ci * When <b>eEvent</b> is <b>OMX_EventPortSettingsChanged</b>, <b>data1</b> indicates a port and 75094332d3Sopenharmony_ci * <b>data2</b> and <b>eventData</b> are <b>0</b>. 76094332d3Sopenharmony_ci * When <b>eEvent</b> is <b>OMX_EventBufferFlag</b>, <b>data1</b> indicates a port, <b>data2</b> indicates a flag, 77094332d3Sopenharmony_ci * and <b>eventData</b> is <b>0</b>. 78094332d3Sopenharmony_ci * When <b>eEvent</b> is <b>OMX_EventResourcesAcquired</b> or <b>OMX_EventDynamicResourcesAvailable</b>, 79094332d3Sopenharmony_ci * the values of <b>data1</b>, <b>data2</b>, and <b>eventData</b> are <b>0</b>. 80094332d3Sopenharmony_ci * 81094332d3Sopenharmony_ci * @param self Indicates the pointer to the callback to be invoked. 82094332d3Sopenharmony_ci * @param event Indicates the type of events to report. For details, see {@link OMX_EVENTTYPE}. 83094332d3Sopenharmony_ci * @param info Indicates the pointer to event info. For detials see{@link EventInfo}. 84094332d3Sopenharmony_ci * 85094332d3Sopenharmony_ci * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 86094332d3Sopenharmony_ci * @return Returns <b>HDF_ERR_INVALID_PARAM</b> if the operation failed due to invalid parameters. 87094332d3Sopenharmony_ci * @return Returns <b>HDF_ERR_INVALID_OBJECT</b> if the operation failed due to invalid objects. 88094332d3Sopenharmony_ci * @return Returns <b>HDF_ERR_MALLOC_FAIL</b> if the operation failed due to insufficient memory. 89094332d3Sopenharmony_ci */ 90094332d3Sopenharmony_ci int32_t (*EventHandler)(struct CodecCallbackType *self, enum OMX_EVENTTYPE event, struct EventInfo *info); 91094332d3Sopenharmony_ci 92094332d3Sopenharmony_ci /** 93094332d3Sopenharmony_ci * @brief Reports an event indicating that the encoding or decoding in the input buffer is complete. 94094332d3Sopenharmony_ci * 95094332d3Sopenharmony_ci * @param self Indicates the pointer to the callback to be invoked. 96094332d3Sopenharmony_ci * @param appData Indicates the pointer to the upper-layer instance passed to the callback. 97094332d3Sopenharmony_ci * @param buffer Indicates the pointer to the input buffer {@link OmxCodecBuffer} that has data processed. 98094332d3Sopenharmony_ci * 99094332d3Sopenharmony_ci * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 100094332d3Sopenharmony_ci * @return Returns <b>HDF_ERR_INVALID_PARAM</b> if the operation failed due to invalid parameters. 101094332d3Sopenharmony_ci * @return Returns <b>HDF_ERR_INVALID_OBJECT</b> if the operation failed due to invalid objects. 102094332d3Sopenharmony_ci * @return Returns <b>HDF_ERR_MALLOC_FAIL</b> if the operation failed due to insufficient memory. 103094332d3Sopenharmony_ci */ 104094332d3Sopenharmony_ci int32_t (*EmptyBufferDone)(struct CodecCallbackType *self, int64_t appData, const struct OmxCodecBuffer *buffer); 105094332d3Sopenharmony_ci 106094332d3Sopenharmony_ci /** 107094332d3Sopenharmony_ci * @brief Reports an event indicating that the output buffer is filled. 108094332d3Sopenharmony_ci * 109094332d3Sopenharmony_ci * @param self Indicates the pointer to the callback to be invoked. 110094332d3Sopenharmony_ci * @param appData Indicates the pointer to the upper-layer instance passed to the callback. 111094332d3Sopenharmony_ci * @param buffer Indicates the pointer to the buffer {@link OmxCodecBuffer} that has data filled. 112094332d3Sopenharmony_ci * 113094332d3Sopenharmony_ci * @return Returns <b>HDF_SUCCESS</b> if the operation is successful. 114094332d3Sopenharmony_ci * @return Returns <b>HDF_ERR_INVALID_PARAM</b> if the operation failed due to invalid parameters. 115094332d3Sopenharmony_ci * @return Returns <b>HDF_ERR_INVALID_OBJECT</b> if the operation failed due to invalid objects. 116094332d3Sopenharmony_ci * @return Returns <b>HDF_ERR_MALLOC_FAIL</b> if the operation failed due to insufficient memory. 117094332d3Sopenharmony_ci */ 118094332d3Sopenharmony_ci int32_t (*FillBufferDone)(struct CodecCallbackType *self, int64_t appData, const struct OmxCodecBuffer *buffer); 119094332d3Sopenharmony_ci}; 120094332d3Sopenharmony_ci 121094332d3Sopenharmony_ci/** 122094332d3Sopenharmony_ci * @brief Instantiates a <b>CodecCallbackType</b> object. 123094332d3Sopenharmony_ci * 124094332d3Sopenharmony_ci * @param remote Indicates the pointer to the <b>HdfRemoteService</b>. 125094332d3Sopenharmony_ci * 126094332d3Sopenharmony_ci * @return Returns the <b>CodecCallbackType</b> object instantiated. 127094332d3Sopenharmony_ci */ 128094332d3Sopenharmony_cistruct CodecCallbackType *CodecCallbackTypeGet(struct HdfRemoteService *remote); 129094332d3Sopenharmony_ci 130094332d3Sopenharmony_ci/** 131094332d3Sopenharmony_ci * @brief Releases a <b>CodecCallbackType</b> instance. 132094332d3Sopenharmony_ci * 133094332d3Sopenharmony_ci * @param instance Indicates the pointer to the <b>CodecCallbackType</b> instance to release. 134094332d3Sopenharmony_ci */ 135094332d3Sopenharmony_civoid CodecCallbackTypeRelease(struct CodecCallbackType *instance); 136094332d3Sopenharmony_ci 137094332d3Sopenharmony_ci#ifdef __cplusplus 138094332d3Sopenharmony_ci} 139094332d3Sopenharmony_ci#endif /* __cplusplus */ 140094332d3Sopenharmony_ci 141094332d3Sopenharmony_ci#endif // CODEC_CALLBACK_TYPE_H