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
// 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.
 
#ifndef _RK_DBUS_GRAPH_CONTROL_H_
#define _RK_DBUS_GRAPH_CONTROL_H_
 
#include <assert.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
 
#include <memory>
 
#include "dbus_dispatcher.h"
#include "ai_uvc_graph.h"
 
#define RT_APP_UVC                     "app_uvc"
#define RT_APP_NN                      "app_nn"
#define RT_APP_AI_FEATURE              "app_feature"
#define RT_ACTION_CONFIG_CAMERA        "updateCameraParams"
#define RT_ACTION_CONFIG_ENCODER       "updateEncoderParams"
#define RT_ACTION_RETRIVE_FEATURE      "retriveAIFeature"
 
namespace rockchip {
namespace aiserver {
 
class RTGraphListener {
 public:
    virtual ~RTGraphListener() {}
    virtual int32_t start(const std::string &appName) = 0;
    virtual int32_t stop(const std::string &appName) = 0;
    virtual int32_t observeGraphOutput(const std::string &appName, const int32_t &enable) = 0;
 
    virtual int32_t setEPTZ(const AI_UVC_EPTZ_MODE &mode, const int32_t &enabled) = 0;
    virtual int32_t setZoom(const double &val) = 0;
    virtual int32_t setFaceAE(const int32_t &enabled) = 0;
    virtual int32_t setFaceLine(const int32_t &enabled) = 0;
    virtual int32_t enableAIAlgorithm(const std::string &type) = 0;
    virtual int32_t disableAIAlgorithm(const std::string &type) = 0;
    virtual int32_t updateAIAlgorithmParams(const std::string &type) = 0;
    virtual int32_t openAIMatting() = 0;
    virtual int32_t closeAIMatting() = 0;
 
    virtual int32_t invoke(const std::string &appName, const std::string &actionName, void *params) = 0;
    virtual int32_t ctrlSubGraph(const char* nnName, int32_t enable) = 0;
};
 
class DBusGraphControl : public control::graph_adaptor,
                         public DBus::IntrospectableAdaptor,
                         public DBus::ObjectAdaptor {
 public:
    DBusGraphControl() = delete;
    DBusGraphControl(DBus::Connection &connection, RTGraphListener* listener);
    virtual ~DBusGraphControl();
 
 public:
    int32_t Start(const std::string &appName);
    int32_t Stop(const std::string &appName);
    int32_t SetGraphOutputObserver(const std::string &appName, const int32_t &enabled);
 
    // UVC
    int32_t EnableEPTZ(const int32_t &enabled);
    int32_t SetZoom(const double &val);
    int32_t EnableFaceAE(const int32_t &enabled);
    int32_t EnableFaceLine(const int32_t &enabled);
 
    // AI
    int32_t EnableAIAlgorithm(const std::string &type);
    int32_t DisableAIAlgorithm(const std::string &type);
    int32_t UpdateAIAlgorithmParams(const std::string &cmdName);
 
    int32_t OpenAIMatting(const std::string &type);
    int32_t CloseAIMatting(const std::string &type);
    // Extension
    int32_t Invoke(const std::string &appName, const std::string &actionName,
                        const int32_t &ext1, const int64_t &ext2);
    // Old API
    int32_t SetRockxStatus(const std::string &nnName);
    int32_t SetNpuCtlStatus(const std::string &cmdName);
 
private:
    RTGraphListener* mGraphListener;
};
 
} // namespace aiserver
} // namespace rockchip
 
#endif // _RK_DBUS_GRAPH_CONTROL_H_