hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
// Copyright 2019 Fuzhou Rockchip Electronics Co., Ltd. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
 
#include <cstring>
 
#include "logger/log.h"
#include "dbus_graph_control.h"
 
namespace rockchip {
namespace aiserver {
 
DBusGraphControl::DBusGraphControl(DBus::Connection &connection, RTGraphListener* listener)
                 :DBus::ObjectAdaptor(connection, MEDIA_CONTROL_PATH_GRAPH){
    mGraphListener = listener;
}
 
DBusGraphControl::~DBusGraphControl() {}
 
int32_t DBusGraphControl::Start(const std::string &appName) {
    if (NULL != mGraphListener) {
        return mGraphListener->start(appName);
    }
 
    return -1;
}
 
int32_t DBusGraphControl::Stop(const std::string &appName) {
    if (NULL != mGraphListener) {
        return mGraphListener->stop(appName);
    }
 
    return -1;
}
 
int32_t DBusGraphControl::SetGraphOutputObserver(const std::string &appName, const int32_t &enabled) {
    if (NULL != mGraphListener) {
        return mGraphListener->observeGraphOutput(appName, enabled);
    }
 
    return -1;
}
 
int32_t DBusGraphControl::EnableEPTZ(const int32_t &enabled) {
    if (NULL != mGraphListener) {
        return mGraphListener->setEPTZ(AI_UVC_EPTZ_AUTO, enabled);
    }
 
    return -1;
}
 
int32_t DBusGraphControl::SetZoom(const double &val) {
    if (NULL != mGraphListener) {
        return mGraphListener->setZoom(val);
    }
 
    return -1;
}
int32_t DBusGraphControl::EnableFaceAE(const int32_t &enabled){
    if (NULL != mGraphListener) {
        return mGraphListener->setFaceAE(enabled);
    }
 
    return -1;
 
}
int32_t DBusGraphControl::EnableFaceLine(const int32_t &enabled){
    if (NULL != mGraphListener) {
        return mGraphListener->setFaceLine(enabled);
    }
 
    return -1;
 
}
 
int32_t DBusGraphControl::EnableAIAlgorithm(const std::string &type) {
    if (NULL != mGraphListener) {
        return mGraphListener->enableAIAlgorithm(type);
    }
 
    return -1;
}
 
int32_t DBusGraphControl::DisableAIAlgorithm(const std::string &type) {
    if (NULL != mGraphListener) {
        return mGraphListener->disableAIAlgorithm(type);
    }
 
    return -1;
}
 
int32_t DBusGraphControl::OpenAIMatting(const std::string &type) {
    if (NULL != mGraphListener) {
        return mGraphListener->openAIMatting();
    }
 
    return -1;
}
 
int32_t DBusGraphControl::CloseAIMatting(const std::string &type) {
    if (NULL != mGraphListener) {
        return mGraphListener->closeAIMatting();
    }
 
    return -1;
}
 
int32_t DBusGraphControl::Invoke(const std::string &appName, const std::string &actionName,
                    const int32_t &ext1, const int64_t &ext2) {
    if (NULL != mGraphListener) {
        int64_t exts[] = {ext1, ext2};
        return mGraphListener->invoke(appName, actionName, exts);
    }
 
    return -1;
}
 
int32_t DBusGraphControl::SetRockxStatus(const std::string &nnName) {
    LOG_INFO("%s: Dbus GraphCtrl received: %s\n", __FUNCTION__, nnName.c_str());
    char nnTypeName[64];
    memset(nnTypeName, 0, 64);
    const char *s = nullptr;
    if (!(s = strstr(nnName.c_str(), ":"))) {
        LOG_INFO("string trans rect format error, string=%s\n", nnName.c_str());
        return -1;
    }
    strncpy(nnTypeName, nnName.c_str(), s - nnName.c_str());
    int32_t enable = atoi(s + 1);
 
    if (NULL != mGraphListener) {
        mGraphListener->ctrlSubGraph(nnTypeName, enable);
    }
    return 0;
}
 
int32_t DBusGraphControl::SetNpuCtlStatus(const std::string &cmdName) {
    LOG_INFO("%s: Dbus GraphCtrl received: %s\n", __FUNCTION__, cmdName.c_str());
    const char *ss = nullptr;
    if (!(ss = strstr(cmdName.c_str(), ":"))) {
        LOG_INFO("unkown npu control format, rawcmd:%s\n", cmdName.c_str());
        return -1;
    }
 
    if (NULL != mGraphListener) {
        return mGraphListener->invoke(RT_APP_AI_FEATURE, RT_ACTION_RETRIVE_FEATURE, (void *)cmdName.c_str());
    }
 
    return 0;
}
 
int32_t DBusGraphControl::UpdateAIAlgorithmParams(const std::string &cmdName) {
    LOG_INFO("%s: Dbus GraphCtrl received: %s\n", __FUNCTION__, cmdName.c_str());
    const char *ss = nullptr;
    if (!(ss = strstr(cmdName.c_str(), ":"))) {
        LOG_INFO("unkown npu control format, rawcmd:%s\n", cmdName.c_str());
        return -1;
    }
 
    if (NULL != mGraphListener) {
        return mGraphListener->updateAIAlgorithmParams(cmdName.c_str());
    }
 
    return 0;
}
 
} // namespace aiserver
} // namespace rockchip