• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     if (!HdfSbufReadUint32(data, &argv)) {
27         CODEC_LOGE("read argv failed!");
28         return HDF_FAILURE;
29     }
30     if (argv != 1) {
31         HdfSbufWriteString(reply, "please enter -h for help!! \n");
32         return HDF_SUCCESS;
33     }
34     const char *para = HdfSbufReadString(data);
35     if (para == NULL) {
36         CODEC_LOGE("para is NULL");
37         return HDF_FAILURE;
38     }
39     if (strcmp(para, "-h") == 0) {
40         HdfSbufWriteString(reply, "-h: codec dump help ! -l: dump codec components info list ! \n");
41         return HDF_SUCCESS;
42     }
43     if (strcmp(para, "-l") == 0) {
44         struct CodecComponentManagerSerivce *managerService = CodecComponentManagerSerivceGet();
45         if (managerService == NULL) {
46             CODEC_LOGE("managerService is NULL");
47             return HDF_FAILURE;
48         }
49         struct ComponentTypeNode *pos = NULL;
50         struct ComponentTypeNode *next = NULL;
51         DLIST_FOR_EACH_ENTRY_SAFE(pos, next, &managerService->head, struct ComponentTypeNode, node)
52         {
53             if (pos == NULL) {
54                 CODEC_LOGE("pos is NULL");
55                 return HDF_FAILURE;
56             }
57             struct CodecComponentNode *codecNode = CodecComponentTypeServiceGetCodecNode(pos->service);
58             if (codecNode != NULL) {
59                 char dump[CODEC_MAX_DFX_DUMP_LEN + 1] = { 0 };
60                 int32_t ret = OmxAdapterWriteDumperData(dump, CODEC_MAX_DFX_DUMP_LEN, pos->componentId, codecNode);
61                 if (ret != HDF_SUCCESS) {
62                     CODEC_LOGE("OmxAdapterWriteDumperData err");
63                     return HDF_FAILURE;
64                 }
65                 HdfSbufWriteString(reply, dump);
66             }
67         }
68         CODEC_LOGI("codec hidumper success!");
69         return HDF_SUCCESS;
70     }
71     HdfSbufWriteString(reply, "unknow param, please enter -h for help! \n");
72     return HDF_SUCCESS;
73 }
74