1/*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @addtogroup Codec
18 * @{
19 *
20 * @brief Defines APIs of the Codec module.
21 *
22 * The Codec module provides APIs for initializing the custom data and audio and video codecs,
23 * setting codec parameters, and controlling and transferring data.
24 *
25 * @since 4.1
26 * @version 3.0
27 */
28
29/**
30 * @file ICodecCallback.idl
31 *
32 * @brief Defines the callbacks used to report codec events and processing results of the input and output buffers.
33 *
34 *
35 *
36 * @since 4.1
37 * @version 2.0
38 */
39
40/**
41 * @brief Defines the path for the package of the Codec module APIs.
42 *
43 * @since 4.1
44 * @version 2.0
45 */
46package ohos.hdi.codec.v3_0;
47
48import ohos.hdi.codec.v3_0.CodecTypes;
49
50/**
51 * @brief Defines the callbacks of the Codec module.
52 *
53 * The following callbacks are provided:
54 * - Callback used to report component error events, command completion events, and port setting events.
55 * For details, see {@link EventHandler}.
56 * - Callback invoked when the input port has data processed in the buffer. For details, see {@link EmptyBufferDone}.
57 * - Callback invoked when the output port has data filled into the buffer. For details, see {@link FillBufferDone}.
58 * The callbacks are registered by using:
59 * - {@link CreateComponent} when a component is created.
60 * - {@link SetCallbacks} when the component is in the OMX_StateLoaded state.
61 */
62
63
64[callback] interface ICodecCallback {
65
66    /**
67     * @brief Reports an event, such as an error, a command completion event, and port setting changes.
68     *
69     * - When <b>event</b> is <b>CODEC_EVENT_CMD_COMPLETE</b> and <b>eventData</b> is null,
70     * <b>data2</b> indicates a state if <b>data1</b> is <b>CODEC_COMMAND_STATE_SET</b> and indicates a port if
71     * <b>data1</b> is any <b>CodecCommandType</b> other than <b>CODEC_COMMAND_STATE_SET</b>.
72     * - When <b>event</b> is <b>CODEC_EVENT_ERROR</b>, <b>data1</b> indicates an error code and <b>data2</b>
73     * and <b>eventData</b> are both <b>0</b>.
74     * - When <b>event</b> is <b>CODEC_EVENT_MARK</b>, <b>data1</b> and <b>data2</b> are both <b>0</b> and
75     * <b>eventData</b> points to the mark.
76     * - When <b>event</b> is <b>CODEC_EVENT_PORT_SETTINGS_CHANGED</b>, <b>data1</b> indicates a port and <b>data2</b>
77     * and <b>eventData</b> are <b>0</b>.
78     * - When <b>event</b> is <b>CODEC_EVENT_BUFFER_FLAG</b>, <b>data1</b> indicates a port, <b>data2</b> indicates a
79     * flag, and <b>eventData</b> is <b>0</b>.
80     * - When <b>event</b> is <b>CODEC_EVENT_RESOURCES_ACQUIRED</b> or <b>CODEC_EVENT_DYNAMIC_RESOURCES_AVAILABLE</b>,
81     * <b>data1</b>, <b>data2</b>, and <b>eventData</b> are <b>0</b>.
82     *
83     * @param event Indicates the type of the event to report. For details, see {@link CodecEventType}.
84     * @param info Indicates the pointer to the information to report. For details, see {@link EventInfo}.
85     *
86     * @return Returns <b>HDF_SUCCESS</b> if the operation is successful.
87     * @return Returns <b>HDF_ERR_INVALID_PARAM</b> if the operation fails due to invalid parameters.
88     * @return Returns <b>HDF_FAILURE</b> if the execution fails.
89     * @return Returns other values if the underlying layer returns a failure. For details about the error codes,
90     * see <b>OMX_ERRORTYPE</b> defined by OpenMAX IL.
91     *
92     * @since 4.1
93     * @version 2.0
94     */
95    EventHandler([in] enum CodecEventType event, [in] struct EventInfo info);
96
97    /**
98     * @brief Reports an event indicating that the encoding or decoding in the input buffer is complete.
99     *
100     *
101     * @param appData Indicates the application data. Generally, it is an upper-layer instance
102     * passed in for the callback.
103     * @param buffer Indicates information about the input buffer that was emptied. For details,
104     * see {@link OmxCodecBuffer}.
105     *
106     * @return Returns <b>HDF_SUCCESS</b> if the operation is successful.
107     * @return Returns <b>HDF_ERR_INVALID_PARAM</b> if the operation fails due to invalid parameters.
108     * @return Returns <b>HDF_FAILURE</b> if the execution fails.
109     * @return Returns other values if the underlying layer returns a failure. For details about the
110     * error codes, see <b>OMX_ERRORTYPE</b> defined by OpenMAX IL.
111     *
112     * @since 4.1
113     * @version 2.0
114     */
115    EmptyBufferDone([in] long appData, [in] struct OmxCodecBuffer buffer);
116
117    /**
118     * @brief Reports an event indicating that the output buffer is filled.
119     *
120     *
121     * @param appData Indicates the application data. Generally, it is an upper-layer instance
122     * passed in for the callback.
123     * @param buffer Indicates information about the buffer that was filled. For details, see {@link OmxCodecBuffer}.
124     *
125     * @return Returns <b>HDF_SUCCESS</b> if the operation is successful.
126     * @return Returns <b>HDF_ERR_INVALID_PARAM</b> if the operation fails due to invalid parameters.
127     * @return Returns <b>HDF_FAILURE</b> if the execution fails.
128     * @return Returns other values if the underlying layer returns a failure. For details about the error codes,
129     * see <b>OMX_ERRORTYPE</b> defined by OpenMAX IL.
130     *
131     * @since 4.1
132     * @version 2.0
133     */
134    FillBufferDone([in] long appData, [in] struct OmxCodecBuffer buffer);
135}
136