blob: 2b87196c48511656460764c01812c825e18a4fc9 (
plain)
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
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* ipc_unixsocket.h - IPC mechanism based on Unix sockets
*/
#ifndef __LIBCAMERA_INTERNAL_IPC_UNIXSOCKET_H__
#define __LIBCAMERA_INTERNAL_IPC_UNIXSOCKET_H__
#include <stdint.h>
#include <sys/types.h>
#include <vector>
#include <libcamera/base/signal.h>
namespace libcamera {
class EventNotifier;
class IPCUnixSocket
{
public:
struct Payload {
std::vector<uint8_t> data;
std::vector<int32_t> fds;
};
IPCUnixSocket();
~IPCUnixSocket();
int create();
int bind(int fd);
void close();
bool isBound() const;
int send(const Payload &payload);
int receive(Payload *payload);
Signal<> readyRead;
private:
struct Header {
uint32_t data;
uint8_t fds;
};
int sendData(const void *buffer, size_t length, const int32_t *fds, unsigned int num);
int recvData(void *buffer, size_t length, int32_t *fds, unsigned int num);
void dataNotifier();
int fd_;
bool headerReceived_;
struct Header header_;
EventNotifier *notifier_;
};
} /* namespace libcamera */
#endif /* __LIBCAMERA_INTERNAL_IPC_UNIXSOCKET_H__ */
|