• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 related to 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 3.1
26  */
27 
28 /**
29  * @file codec_callback_if.h
30  *
31  * @brief Defines the callbacks used to report codec events and processing results of the input and output buffers.
32  *
33  * @since 3.1
34  */
35 
36 #ifndef CODEC_CALLBACK_TYPE_H
37 #define CODEC_CALLBACK_TYPE_H
38 
39 #include <stdint.h>
40 #include <netinet/in.h>
41 #include "codec_component_type.h"
42 #include "OMX_Core.h"
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif /* __cplusplus */
47 
48 /**
49  * @brief Defines the callbacks of the Codec module.
50  *
51  * The following callbacks are provided:
52  * 1. Callback used to report component error events, command completion events, and port setting events.
53  * For details, see {@link EventHandler}.
54  * 2. Callback invoked when the input port processes data in the buffer. For details, see {@link EmptyBufferDone}.
55  * 3. Callback invoked when the output port fills data into the buffer. For details, see {@link FillBufferDone}.
56  * The callbacks are registered by using:
57  * 1. {@link CreateComponent} when a component is created.
58  * 2. {@link SetCallbacks} when the component is in the OMX_StateLoaded state.
59  */
60 struct CodecCallbackType {
61     struct HdfRemoteService *remote;
62 
63     /**
64      * @brief Reports an event, such as an error, a command completion event, and port setting changes
65      * during the running of a component.
66      *
67      * When <b>eEvent</b> is <b>OMX_EventCmdComplete</b>, <b>eventData</b> is null, and <b>data1</b> is
68      * <b>OMX_COMMANDTYPE</b>, <b>data1</b> indicates a state, if <b>data1</b> is <b>OMX_CommandStateSet</b>
69      * and indicates a port in other cases.
70      * If <b>eEvent</b> is <b>OMX_EventError</b>, <b>data1</b> indicates an error code and <b>data2</b> and
71      * <b>eventData</b> are both <b>0</b>.
72      * If <b>eEvent</b> is <b>OMX_EventMark</b>, <b>data1</b> and <b>data2</b> are both <b>0</b> and
73      * <b>eventData</b> points to the mark.
74      * When <b>eEvent</b> is <b>OMX_EventPortSettingsChanged</b>, <b>data1</b> indicates a port and
75      * <b>data2</b> and <b>eventData</b> are <b>0</b>.
76      * When <b>eEvent</b> is <b>OMX_EventBufferFlag</b>, <b>data1</b> indicates a port, <b>data2</b> indicates a flag,
77      * and <b>eventData</b> is <b>0</b>.
78      * When <b>eEvent</b> is <b>OMX_EventResourcesAcquired</b> or <b>OMX_EventDynamicResourcesAvailable</b>,
79      * the values of <b>data1</b>, <b>data2</b>, and <b>eventData</b> are <b>0</b>.
80      *
81      * @param self Indicates the pointer to the callback to be invoked.
82      * @param event Indicates the type of events to report. For details, see {@link OMX_EVENTTYPE}.
83      * @param info Indicates the pointer to event info. For detials see{@link EventInfo}.
84      *
85      * @return Returns <b>HDF_SUCCESS</b> if the operation is successful.
86      * @return Returns <b>HDF_ERR_INVALID_PARAM</b> if the operation failed due to invalid parameters.
87      * @return Returns <b>HDF_ERR_INVALID_OBJECT</b> if the operation failed due to invalid objects.
88      * @return Returns <b>HDF_ERR_MALLOC_FAIL</b> if the operation failed due to insufficient memory.
89      */
90     int32_t (*EventHandler)(struct CodecCallbackType *self, enum OMX_EVENTTYPE event, struct EventInfo *info);
91 
92     /**
93      * @brief Reports an event indicating that the encoding or decoding in the input buffer is complete.
94      *
95      * @param self Indicates the pointer to the callback to be invoked.
96      * @param appData Indicates the pointer to the upper-layer instance passed to the callback.
97      * @param buffer Indicates the pointer to the input buffer {@link OmxCodecBuffer} that has data processed.
98      *
99      * @return Returns <b>HDF_SUCCESS</b> if the operation is successful.
100      * @return Returns <b>HDF_ERR_INVALID_PARAM</b> if the operation failed due to invalid parameters.
101      * @return Returns <b>HDF_ERR_INVALID_OBJECT</b> if the operation failed due to invalid objects.
102      * @return Returns <b>HDF_ERR_MALLOC_FAIL</b> if the operation failed due to insufficient memory.
103      */
104     int32_t (*EmptyBufferDone)(struct CodecCallbackType *self, int64_t appData, const struct OmxCodecBuffer *buffer);
105 
106     /**
107      * @brief Reports an event indicating that the output buffer is filled.
108      *
109      * @param self Indicates the pointer to the callback to be invoked.
110      * @param appData Indicates the pointer to the upper-layer instance passed to the callback.
111      * @param buffer Indicates the pointer to the buffer {@link OmxCodecBuffer} that has data filled.
112      *
113      * @return Returns <b>HDF_SUCCESS</b> if the operation is successful.
114      * @return Returns <b>HDF_ERR_INVALID_PARAM</b> if the operation failed due to invalid parameters.
115      * @return Returns <b>HDF_ERR_INVALID_OBJECT</b> if the operation failed due to invalid objects.
116      * @return Returns <b>HDF_ERR_MALLOC_FAIL</b> if the operation failed due to insufficient memory.
117      */
118     int32_t (*FillBufferDone)(struct CodecCallbackType *self, int64_t appData, const struct OmxCodecBuffer *buffer);
119 };
120 
121 /**
122  * @brief Instantiates a <b>CodecCallbackType</b> object.
123  *
124  * @param remote Indicates the pointer to the <b>HdfRemoteService</b>.
125  *
126  * @return Returns the <b>CodecCallbackType</b> object instantiated.
127  */
128 struct CodecCallbackType *CodecCallbackTypeGet(struct HdfRemoteService *remote);
129 
130 /**
131  * @brief Releases a <b>CodecCallbackType</b> instance.
132  *
133  * @param instance Indicates the pointer to the <b>CodecCallbackType</b> instance to release.
134  */
135 void CodecCallbackTypeRelease(struct CodecCallbackType *instance);
136 
137 #ifdef __cplusplus
138 }
139 #endif /* __cplusplus */
140 
141 #endif // CODEC_CALLBACK_TYPE_H