2020-06-02 15:37:45 +00:00
|
|
|
/* 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>
|
|
|
|
|
2021-02-19 22:52:28 +00:00
|
|
|
#include "videoformattypes.h"
|
|
|
|
#include "videoframetypes.h"
|
2020-06-02 15:37:45 +00:00
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
namespace AkVCam
|
|
|
|
{
|
|
|
|
class IpcBridgePrivate;
|
|
|
|
class VideoFormat;
|
|
|
|
class VideoFrame;
|
|
|
|
|
2020-09-09 15:21:03 +00:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2020-06-02 15:37:45 +00:00
|
|
|
class IpcBridge
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum ServerState
|
|
|
|
{
|
|
|
|
ServerStateAvailable,
|
|
|
|
ServerStateGone
|
|
|
|
};
|
|
|
|
|
2020-08-22 00:31:45 +00:00
|
|
|
enum StreamType
|
2020-06-02 15:37:45 +00:00
|
|
|
{
|
2020-08-22 00:31:45 +00:00
|
|
|
StreamTypeOutput,
|
|
|
|
StreamTypeInput
|
2020-06-02 15:37:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
AKVCAM_SIGNAL(ServerStateChanged,
|
|
|
|
ServerState state)
|
|
|
|
AKVCAM_SIGNAL(FrameReady,
|
|
|
|
const std::string &deviceId,
|
|
|
|
const VideoFrame &frame)
|
2020-09-09 15:21:03 +00:00
|
|
|
AKVCAM_SIGNAL(PictureChanged,
|
|
|
|
const std::string &picture)
|
2020-10-06 14:36:34 +00:00
|
|
|
AKVCAM_SIGNAL(DevicesChanged,
|
|
|
|
const std::vector<std::string> &devices)
|
2020-06-02 15:37:45 +00:00
|
|
|
AKVCAM_SIGNAL(ListenerAdded,
|
|
|
|
const std::string &deviceId,
|
|
|
|
const std::string &listener)
|
|
|
|
AKVCAM_SIGNAL(ListenerRemoved,
|
|
|
|
const std::string &deviceId,
|
|
|
|
const std::string &listener)
|
|
|
|
AKVCAM_SIGNAL(BroadcastingChanged,
|
|
|
|
const std::string &deviceId,
|
|
|
|
const std::string &broadcaster)
|
2020-09-09 15:21:03 +00:00
|
|
|
AKVCAM_SIGNAL(ControlsChanged,
|
2020-06-02 15:37:45 +00:00
|
|
|
const std::string &deviceId,
|
2020-09-09 15:21:03 +00:00
|
|
|
const std::map<std::string, int> &controls)
|
2020-06-02 15:37:45 +00:00
|
|
|
|
|
|
|
public:
|
2021-06-16 19:49:23 +00:00
|
|
|
IpcBridge(bool isVCam=false);
|
2020-06-02 15:37:45 +00:00
|
|
|
~IpcBridge();
|
|
|
|
|
|
|
|
/* Server & Client */
|
|
|
|
|
2020-10-06 23:06:54 +00:00
|
|
|
std::string picture() const;
|
|
|
|
void setPicture(const std::string &picture);
|
2020-08-22 00:31:45 +00:00
|
|
|
int logLevel() const;
|
|
|
|
void setLogLevel(int logLevel);
|
2021-06-09 20:37:36 +00:00
|
|
|
std::string logPath(const std::string &logName={}) const;
|
2020-08-22 00:31:45 +00:00
|
|
|
|
2020-06-02 15:37:45 +00:00
|
|
|
// Register the peer to the global server.
|
2021-06-16 19:49:23 +00:00
|
|
|
bool registerPeer(bool isVCam=false);
|
2020-06-02 15:37:45 +00:00
|
|
|
|
|
|
|
// Unregister the peer to the global server.
|
|
|
|
void unregisterPeer();
|
|
|
|
|
|
|
|
// List available devices.
|
2020-08-10 18:37:33 +00:00
|
|
|
std::vector<std::string> devices() const;
|
2020-06-02 15:37:45 +00:00
|
|
|
|
|
|
|
// Return human readable description of the device.
|
2020-10-06 23:06:54 +00:00
|
|
|
std::string description(const std::string &deviceId) const;
|
2020-08-10 18:37:33 +00:00
|
|
|
void setDescription(const std::string &deviceId,
|
2020-10-06 23:06:54 +00:00
|
|
|
const std::string &description);
|
2020-06-02 15:37:45 +00:00
|
|
|
|
2021-02-06 04:45:40 +00:00
|
|
|
// Pixel formats supported by the driver.
|
2020-08-22 00:31:45 +00:00
|
|
|
std::vector<PixelFormat> supportedPixelFormats(StreamType type) const;
|
2020-06-02 15:37:45 +00:00
|
|
|
|
2021-02-06 04:45:40 +00:00
|
|
|
// Default pixel format of the driver.
|
2020-08-22 00:31:45 +00:00
|
|
|
PixelFormat defaultPixelFormat(StreamType type) const;
|
2020-06-02 15:37:45 +00:00
|
|
|
|
|
|
|
// Return supported formats for the device.
|
|
|
|
std::vector<VideoFormat> formats(const std::string &deviceId) const;
|
2020-08-10 18:37:33 +00:00
|
|
|
void setFormats(const std::string &deviceId,
|
|
|
|
const std::vector<VideoFormat> &formats);
|
2020-06-02 15:37:45 +00:00
|
|
|
|
|
|
|
// Return return the status of the device.
|
|
|
|
std::string broadcaster(const std::string &deviceId) const;
|
|
|
|
|
2020-09-09 15:21:03 +00:00
|
|
|
std::vector<DeviceControl> controls(const std::string &deviceId);
|
|
|
|
void setControls(const std::string &deviceId,
|
|
|
|
const std::map<std::string, int> &controls);
|
2020-06-02 15:37:45 +00:00
|
|
|
|
|
|
|
// Returns the clients that are capturing from a virtual camera.
|
|
|
|
std::vector<std::string> listeners(const std::string &deviceId);
|
|
|
|
|
|
|
|
// 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 */
|
|
|
|
|
2021-06-19 16:45:59 +00:00
|
|
|
std::string addDevice(const std::string &description,
|
|
|
|
const std::string &deviceId={});
|
2020-07-28 00:43:21 +00:00
|
|
|
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();
|
|
|
|
|
2020-06-02 15:37:45 +00:00
|
|
|
// Start frame transfer to the device.
|
|
|
|
bool deviceStart(const std::string &deviceId,
|
|
|
|
const VideoFormat &format);
|
|
|
|
|
|
|
|
// 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 */
|
|
|
|
|
|
|
|
// Increment the count of device listeners
|
|
|
|
bool addListener(const std::string &deviceId);
|
|
|
|
|
|
|
|
// Decrement the count of device listeners
|
|
|
|
bool removeListener(const std::string &deviceId);
|
|
|
|
|
2021-06-16 19:49:23 +00:00
|
|
|
bool isBusyFor(const std::string &operation) const;
|
|
|
|
|
2021-02-06 04:45:40 +00:00
|
|
|
bool needsRoot(const std::string &operation) const;
|
|
|
|
|
2021-05-24 22:47:39 +00:00
|
|
|
/* 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);
|
|
|
|
|
2020-06-02 15:37:45 +00:00
|
|
|
private:
|
|
|
|
IpcBridgePrivate *d;
|
|
|
|
|
|
|
|
friend class IpcBridgePrivate;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // IPCBRIDGE_H
|