ipcbridge.h
5.3 KB
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
/* akvirtualcamera, virtual camera for Mac and Windows.
* Copyright (C) 2020 Gonzalo Exequiel Pedone
*
* akvirtualcamera is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* akvirtualcamera is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>.
*
* Web-Site: http://webcamoid.github.io/
*/
#ifndef IPCBRIDGE_H
#define IPCBRIDGE_H
#include <string>
#include <map>
#include <memory>
#include "videoformattypes.h"
#include "videoframetypes.h"
#include "utils.h"
namespace AkVCam
{
class IpcBridge;
class IpcBridgePrivate;
class VideoFormat;
class VideoFrame;
enum ControlType
{
ControlTypeInteger,
ControlTypeBoolean,
ControlTypeMenu,
};
struct DeviceControl
{
std::string id;
std::string description;
ControlType type;
int minimum;
int maximum;
int step;
int defaultValue;
int value;
std::vector<std::string> menu;
};
using IpcBridgePtr = std::shared_ptr<IpcBridge>;
class IpcBridge
{
public:
enum StreamType
{
StreamType_Output,
StreamType_Input
};
AKVCAM_SIGNAL(FrameReady,
const std::string &deviceId,
const VideoFrame &frame,
bool isActive)
AKVCAM_SIGNAL(PictureChanged,
const std::string &picture)
AKVCAM_SIGNAL(DevicesChanged,
const std::vector<std::string> &devices)
AKVCAM_SIGNAL(ControlsChanged,
const std::string &deviceId,
const std::map<std::string, int> &controls)
public:
IpcBridge();
~IpcBridge();
/* Server & Client */
std::string picture() const;
void setPicture(const std::string &picture);
int logLevel() const;
void setLogLevel(int logLevel);
std::string logPath(const std::string &logName={}) const;
void stopNotifications();
// List available devices.
std::vector<std::string> devices() const;
// Return human readable description of the device.
std::string description(const std::string &deviceId) const;
void setDescription(const std::string &deviceId,
const std::string &description);
// Pixel formats supported by the driver.
std::vector<PixelFormat> supportedPixelFormats(StreamType type) const;
// Default pixel format of the driver.
PixelFormat defaultPixelFormat(StreamType type) const;
// Return supported formats for the device.
std::vector<VideoFormat> formats(const std::string &deviceId) const;
void setFormats(const std::string &deviceId,
const std::vector<VideoFormat> &formats);
std::vector<DeviceControl> controls(const std::string &deviceId);
void setControls(const std::string &deviceId,
const std::map<std::string, int> &controls);
// Returns clients PIDs using the virtual devices.
std::vector<uint64_t> clientsPids() const;
// Returns client executable from PID.
std::string clientExe(uint64_t pid) const;
/* Server */
std::string addDevice(const std::string &description,
const std::string &deviceId={});
void removeDevice(const std::string &deviceId);
void addFormat(const std::string &deviceId,
const VideoFormat &format,
int index=-1);
void removeFormat(const std::string &deviceId, int index);
void updateDevices();
// Start frame transfer to the device.
bool deviceStart(StreamType type, const std::string &deviceId);
// Stop frame transfer to the device.
void deviceStop(const std::string &deviceId);
// Transfer a frame to the device.
bool write(const std::string &deviceId, const VideoFrame &frame);
/* Client */
bool isBusyFor(const std::string &operation) const;
bool needsRoot(const std::string &operation) const;
/* Hacks */
std::vector<std::string> hacks() const;
std::string hackDescription(const std::string &hack) const;
bool hackIsSafe(const std::string &hack) const;
bool hackNeedsRoot(const std::string &hack) const;
int execHack(const std::string &hack,
const std::vector<std::string> &args);
private:
IpcBridgePrivate *d;
friend class IpcBridgePrivate;
};
}
#endif // IPCBRIDGE_H