1 /*
2 * Copyright (c) 2023 Shenzhen Kaihong DID 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 #include "codec_dfx_service.h"
16 #include <hdf_base.h>
17 #include "codec_adapter_interface.h"
18 #include "codec_component_manager_service.h"
19 #include "codec_log_wrapper.h"
20
21 #define CODEC_MAX_DFX_DUMP_LEN 256
22
DevCodecHostDump(struct HdfSBuf * data,struct HdfSBuf * reply)23 int32_t DevCodecHostDump(struct HdfSBuf *data, struct HdfSBuf *reply)
24 {
25 uint32_t argv = 0;
26 (void)HdfSbufReadUint32(data, &argv);
27 if (argv != 1) {
28 HdfSbufWriteString(reply, "please enter -h for help!! \n");
29 return HDF_SUCCESS;
30 }
31 const char *para = HdfSbufReadString(data);
32 if (strcmp(para, "-h") == 0) {
33 HdfSbufWriteString(reply, "-h: codec dump help ! \n");
34 HdfSbufWriteString(reply, "-l: dump codec components info list ! \n");
35 return HDF_SUCCESS;
36 }
37
38 if (strcmp(para, "-l") == 0) {
39 struct CodecComponentManagerSerivce *managerService = CodecComponentManagerSerivceGet();
40 if (managerService == NULL) {
41 CODEC_LOGE("managerService is NULL");
42 return HDF_FAILURE;
43 }
44 struct ComponentTypeNode *pos = NULL;
45 struct ComponentTypeNode *next = NULL;
46 DLIST_FOR_EACH_ENTRY_SAFE(pos, next, &managerService->head, struct ComponentTypeNode, node)
47 {
48 if (pos == NULL) {
49 CODEC_LOGE("pos is NULL");
50 return HDF_FAILURE;
51 }
52 struct CodecComponentNode *codecNode = CodecComponentTypeServiceGetCodecNode(pos->service);
53 if (codecNode != NULL) {
54 char dump[CODEC_MAX_DFX_DUMP_LEN + 1] = { 0 };
55 int32_t ret = OmxAdapterWriteDumperData(dump, CODEC_MAX_DFX_DUMP_LEN, pos->componentId, codecNode);
56 if (ret != HDF_SUCCESS) {
57 CODEC_LOGE("OmxAdapterWriteDumperData err");
58 return HDF_FAILURE;
59 }
60 HdfSbufWriteString(reply, dump);
61 HdfSbufWriteString(reply, "--------------------------------------------------------------------- \n");
62 }
63 }
64 CODEC_LOGI("codec hidumper success!");
65 return HDF_SUCCESS;
66 }
67 HdfSbufWriteString(reply, "unknow param, please enter -h for help! \n");
68 return HDF_SUCCESS;
69 }
70