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