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
// 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_DBSERVER_PROXY_H_
#define _RK_DBUS_DBSERVER_PROXY_H_
 
#include <assert.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
 
#include "dbus_dbserver_proxy.h"
#include "dbus_dispatcher.h"
#include <dbus-c++/dbus.h>
 
namespace rockchip {
namespace aiserver {
 
#define DB_UPDATE_CMD                                                          \
  "{ \"table\": \"media\", "                                                   \
  "\"key\": { \"id\": %d }, "                                                  \
  "\"data\": { \"sResolution\": \"1280*720\", "                                \
  "\"iMaxRate\": 500, "                                                        \
  "\"cmd\": \"Update\" }"
 
#define DB_SELECT_VIDEO_CMD                                                    \
  "{ \"table\": \"video\", "                                                   \
  "\"key\": { \"id\": %d }, "                                                  \
  "\"data\": \"*\", "                                                          \
  "\"cmd\": \"Select\" }"
 
#define DB_SELECT_AUDIO_CMD                                                    \
  "{ \"table\": \"audio\", "                                                   \
  "\"key\": { \"id\": %d }, "                                                  \
  "\"data\": \"*\", "                                                          \
  "\"cmd\": \"Select\" }"
 
#define DB_SELECT_OSD_REGION_CMD                                               \
  "{ \"table\": \"osd\", "                                                     \
  "\"key\": { \"id\": %d }, "                                                  \
  "\"data\": \"*\", "                                                          \
  "\"cmd\": \"Select\" }"
 
#define DB_SELECT_ROI_REGION_CMD                                               \
  "{ \"table\": \"roi\", "                                                     \
  "\"key\": { \"id\": %d }, "                                                  \
  "\"data\": \"*\", "                                                          \
  "\"cmd\": \"Select\" }"
 
class DBusDbServer : public rockchip::dbserver::media_proxy,
                     public DBus::IntrospectableProxy,
                     public DBus::ObjectProxy {
public:
  DBusDbServer(DBus::Connection &connection, const char *adaptor_path,
               const char *adaptor_name);
  virtual ~DBusDbServer();
 
  std::string SelectVideoDb(int id);
  std::string SelectAudioDb(int id);
  std::string SelectOsdDb(int region_id);
  std::string SelectRoiDb(int region_id);
  void UpdateMediaDb(std::string table) { Cmd(table); }
  void DataChanged(const std::string &param);
 
private:
  DBus::Pipe *pipe_;
};
 
class DBusDbListener : public DBus::InterfaceProxy, public DBus::ObjectProxy {
public:
  DBusDbListener(DBus::Connection &connection);
  virtual ~DBusDbListener();
  void DataChangedCb(const DBus::SignalMessage &sig);
};
 
#define DB_SELECT_REGION_INVADE_CMD                                            \
  "{ \"table\": \"RegionalInvasion\", "                                        \
  "\"key\": { \"id\": %d }, "                                                  \
  "\"data\": \"*\", "                                                          \
  "\"cmd\": \"Select\" }"
 
#define DB_SELECT_MOVE_DETECTION_CMD                                           \
  "{ \"table\": \"MoveDetection\", "                                           \
  "\"key\": { \"id\": %d }, "                                                  \
  "\"data\": \"*\", "                                                          \
  "\"cmd\": \"Select\" }"
 
#define DB_SELECT_SMART_COVER_CMD                                              \
  "{ \"table\": \"SmartCover\", "                                              \
  "\"key\": { \"id\": %d }, "                                                  \
  "\"data\": \"*\", "                                                          \
  "\"cmd\": \"Select\" }"
 
class DBusDbEvent : public rockchip::dbserver::event_proxy,
                    public DBus::IntrospectableProxy,
                    public DBus::ObjectProxy {
public:
  DBusDbEvent(DBus::Connection &connection, const char *adaptor_path,
              const char *adaptor_name);
  virtual ~DBusDbEvent();
  void DataChanged(const std::string &param);
  std::string SelectRegionInvade(int id);
  std::string SelectMoveDetectDb(int id);
 
private:
  DBus::Pipe *pipe_;
};
 
class DBusDbEventListener : public DBus::InterfaceProxy,
                          public DBus::ObjectProxy {
public:
  DBusDbEventListener(DBus::Connection &connection);
  virtual ~DBusDbEventListener();
  void DataChangedCb(const DBus::SignalMessage &sig);
};
 
} // namespace aiserver
} // namespace rockchip
 
#endif // _RK_MEDIA_CONTROL_H_