Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #include "plugin_runner.h"
12 : #include "adapter_rts_common.h"
13 : #include "externalinput_pub.h"
14 : #include "acl/error_codes/rt_error_codes.h"
15 :
16 : using namespace hccl;
17 138 : HcclResult PluginRunner::isStreamCapture(rtStream_t stream, bool &isCapture) const
18 : {
19 138 : isCapture = false;
20 : DevType devType;
21 138 : CHK_RET(hrtGetDeviceType(devType));
22 138 : if (GetWorkflowMode() != HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE) {
23 72 : HCCL_WARNING("[PluginRunner][isStreamCapture]Stream capture only support opbase mode!");
24 72 : return HCCL_SUCCESS;
25 : }
26 66 : aclmdlRICaptureStatus captureStatus = aclmdlRICaptureStatus::ACL_MODEL_RI_CAPTURE_STATUS_NONE;
27 66 : aclmdlRI rtModel = nullptr;
28 66 : aclError ret = aclmdlRICaptureGetInfo(stream, &captureStatus, &rtModel);
29 66 : if (ret == ACL_ERROR_RT_FEATURE_NOT_SUPPORT) {
30 0 : HCCL_WARNING("[PluginRunner][isStreamCapture]Stream capture does not support!");
31 0 : return HCCL_SUCCESS;
32 : } else {
33 66 : CHK_PRT_RET(ret != ACL_SUCCESS,
34 : HCCL_ERROR("[PluginRunner][isStreamCapture]rtGet stream get capture status fail. return[%d]", ret), HCCL_E_RUNTIME);
35 : }
36 :
37 66 : switch (captureStatus) {
38 9 : case aclmdlRICaptureStatus::ACL_MODEL_RI_CAPTURE_STATUS_ACTIVE: {
39 9 : isCapture = true;
40 9 : break;
41 : }
42 57 : case aclmdlRICaptureStatus::ACL_MODEL_RI_CAPTURE_STATUS_NONE: {
43 57 : isCapture = false;
44 57 : break;
45 : }
46 0 : case aclmdlRICaptureStatus::ACL_MODEL_RI_CAPTURE_STATUS_INVALIDATED: {
47 0 : HCCL_ERROR("[PluginRunner][isStreamCapture]rtGet stream capture status invalidated.");
48 0 : break;
49 : }
50 0 : default: {
51 0 : HCCL_ERROR("[PluginRunner][isStreamCapture]rtGet not support stream capture status.");
52 0 : break;
53 : }
54 : }
55 66 : return HCCL_SUCCESS;
56 : }
|