• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 #ifndef HDI_CODEC_CLIENT_INF_H
17 #define HDI_CODEC_CLIENT_INF_H
18 
19 #include "codec_callback.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif /* __cplusplus */
24 
25 struct HdfRemoteService;
26 
27 enum {
28     CMD_CODEC_INIT,
29     CMD_CODEC_DEINIT,
30     CMD_CODEC_ENUM_CAP,
31     CMD_CODEC_GET_CAP,
32     CMD_CODEC_CREATE,
33     CMD_CODEC_CREATE_BY_TYPE,
34     CMD_CODEC_DESTROY,
35     CMD_CODEC_SET_MODE,
36     CMD_CODEC_GET_MODE,
37     CMD_CODEC_SET_PARAMS,
38     CMD_CODEC_GET_PARAMS,
39     CMD_CODEC_START,
40     CMD_CODEC_STOP,
41     CMD_CODEC_RESET,
42     CMD_CODEC_FLUSH,
43     CMD_CODEC_QUEQUE_INPUT,
44     CMD_CODEC_DEQUEQUE_INPUT,
45     CMD_CODEC_QUEQUE_OUTPUT,
46     CMD_CODEC_DEQUEQUE_OUTPUT,
47     CMD_CODEC_SET_CBK,
48 };
49 
50 struct ICodec {
51     struct HdfRemoteService *remote;
52     int32_t (*CodecInit)(struct ICodec *self);
53     int32_t (*CodecDeinit)(struct ICodec *self);
54     int32_t (*CodecEnumerateCapability)(struct ICodec *self, uint32_t index, CodecCapability *cap);
55     int32_t (*CodecGetCapability)(struct ICodec *self, AvCodecMime mime, CodecType type,
56                                  uint32_t flags, CodecCapability *cap);
57     int32_t (*CodecCreate)(struct ICodec *self, const char* name, CODEC_HANDLETYPE *handle);
58     int32_t (*CodecCreateByType)(struct ICodec *self, CodecType type, AvCodecMime mime, CODEC_HANDLETYPE *handle);
59     int32_t (*CodecDestroy)(struct ICodec *self, CODEC_HANDLETYPE handle);
60     int32_t (*CodecSetPortMode)(struct ICodec *self, CODEC_HANDLETYPE handle, DirectionType direct,
61                                 AllocateBufferMode mode, BufferType type);
62     int32_t (*CodecGetPortMode)(struct ICodec *self, CODEC_HANDLETYPE handle, DirectionType direct,
63                                 AllocateBufferMode *mode, BufferType *type);
64     int32_t (*CodecSetParameter)(struct ICodec *self, CODEC_HANDLETYPE handle, const Param *params, int paramCnt);
65     int32_t (*CodecGetParameter)(struct ICodec *self, CODEC_HANDLETYPE handle, Param *params, int paramCnt);
66     int32_t (*CodecStart)(struct ICodec *self, CODEC_HANDLETYPE handle);
67     int32_t (*CodecStop)(struct ICodec *self, CODEC_HANDLETYPE handle);
68     int32_t (*CodecReset)(struct ICodec *self, CODEC_HANDLETYPE handle);
69     int32_t (*CodecFlush)(struct ICodec *self, CODEC_HANDLETYPE handle, DirectionType directType);
70     int32_t (*CodecQueueInput)(struct ICodec *self, CODEC_HANDLETYPE handle,
71                                const CodecBuffer *inputData, uint32_t timeoutMs, int releaseFenceFd);
72     int32_t (*CodecDequeueInput)(struct ICodec *self, CODEC_HANDLETYPE handle,
73                                 uint32_t timeoutMs, int32_t *acquireFd, CodecBuffer *inputData);
74     int32_t (*CodecQueueOutput)(struct ICodec *self, CODEC_HANDLETYPE handle,
75                                 CodecBuffer *outInfo, uint32_t timeoutMs, int releaseFenceFd);
76     int32_t (*CodecDequeueOutput)(struct ICodec *self, CODEC_HANDLETYPE handle,
77                                   uint32_t timeoutMs, int32_t *acquireFd, CodecBuffer *outInfo);
78     int32_t (*CodecSetCallback)(struct ICodec *self, CODEC_HANDLETYPE handle,
79                                 struct ICodecCallback *cb, UINTPTR instance);
80 };
81 
82 struct ICodec *HdiCodecGet(const char *serviceName);
83 void HdiCodecRelease(struct ICodec *instance);
84 
85 #ifdef __cplusplus
86 }
87 #endif /* __cplusplus */
88 
89 #endif // HDI_SAMPLE_CLIENT_C_INF_H