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 #include "codec_callback_if.h"
17 #include <hdf_base.h>
18 #include <hdf_log.h>
19 #include <osal_mem.h>
20
21 #define HDF_LOG_TAG codec_hdi_passthrough
22
CodecCallbackTypeEventHandler(struct CodecCallbackType * self,enum OMX_EVENTTYPE eEvent,struct EventInfo * info)23 static int32_t CodecCallbackTypeEventHandler(
24 struct CodecCallbackType *self, enum OMX_EVENTTYPE eEvent, struct EventInfo *info)
25 {
26 HDF_LOGI("%{public}s, callback service impl", __func__);
27 return HDF_SUCCESS;
28 }
29
CodecCallbackTypeEmptyBufferDone(struct CodecCallbackType * self,int64_t appData,const struct OmxCodecBuffer * buffer)30 static int32_t CodecCallbackTypeEmptyBufferDone(
31 struct CodecCallbackType *self, int64_t appData, const struct OmxCodecBuffer *buffer)
32 {
33 HDF_LOGI("%{public}s, callback service impl", __func__);
34 return HDF_SUCCESS;
35 }
36
CodecCallbackTypeFillBufferDone(struct CodecCallbackType * self,int64_t appData,const struct OmxCodecBuffer * buffer)37 static int32_t CodecCallbackTypeFillBufferDone(
38 struct CodecCallbackType *self, int64_t appData, const struct OmxCodecBuffer *buffer)
39 {
40 HDF_LOGI("%{public}s, callback service impl", __func__);
41 return HDF_SUCCESS;
42 }
43
CodecCallbackTypeConstruct(struct CodecCallbackType * instance)44 static void CodecCallbackTypeConstruct(struct CodecCallbackType *instance)
45 {
46 instance->EventHandler = CodecCallbackTypeEventHandler;
47 instance->EmptyBufferDone = CodecCallbackTypeEmptyBufferDone;
48 instance->FillBufferDone = CodecCallbackTypeFillBufferDone;
49 }
50
CodecCallbackTypeGet(struct HdfRemoteService * remote)51 struct CodecCallbackType *CodecCallbackTypeGet(struct HdfRemoteService *remote)
52 {
53 struct CodecCallbackType *instance = (struct CodecCallbackType *)OsalMemAlloc(sizeof(struct CodecCallbackType));
54 if (instance == NULL) {
55 HDF_LOGE("%{public}s: OsalMemAlloc failed!", __func__);
56 return NULL;
57 }
58 CodecCallbackTypeConstruct(instance);
59 return instance;
60 }
61
CodecCallbackTypeRelease(struct CodecCallbackType * instance)62 void CodecCallbackTypeRelease(struct CodecCallbackType *instance)
63 {
64 if (instance == NULL) {
65 HDF_LOGE("%{public}s: instance is null", __func__);
66 return;
67 }
68 OsalMemFree(instance);
69 instance = NULL;
70 }
71