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(
34 : ret != ACL_SUCCESS,
35 : HCCL_ERROR("[PluginRunner][isStreamCapture]rtGet stream get capture status fail. return[%d]", ret),
36 : HCCL_E_RUNTIME);
37 : }
38 :
39 66 : switch (captureStatus) {
40 9 : case aclmdlRICaptureStatus::ACL_MODEL_RI_CAPTURE_STATUS_ACTIVE: {
41 9 : isCapture = true;
42 9 : break;
43 : }
44 57 : case aclmdlRICaptureStatus::ACL_MODEL_RI_CAPTURE_STATUS_NONE: {
45 57 : isCapture = false;
46 57 : break;
47 : }
48 0 : case aclmdlRICaptureStatus::ACL_MODEL_RI_CAPTURE_STATUS_INVALIDATED: {
49 0 : HCCL_ERROR("[PluginRunner][isStreamCapture]rtGet stream capture status invalidated.");
50 0 : break;
51 : }
52 0 : default: {
53 0 : HCCL_ERROR("[PluginRunner][isStreamCapture]rtGet not support stream capture status.");
54 0 : break;
55 : }
56 : }
57 66 : return HCCL_SUCCESS;
58 : }
|