summaryrefslogtreecommitdiff
path: root/include/libcamera/internal/ipc_pipe_unixsocket.h
blob: ad2927fed7f07f9a07e536e9b2e53e0b390d4f5c (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
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2020, Google Inc.
 *
 * ipc_pipe_unixsocket.h - Image Processing Algorithm IPC module using unix socket
 */
#ifndef __LIBCAMERA_INTERNAL_IPA_IPC_UNIXSOCKET_H__
#define __LIBCAMERA_INTERNAL_IPA_IPC_UNIXSOCKET_H__

#include <map>
#include <memory>
#include <vector>

#include "libcamera/internal/ipc_pipe.h"
#include "libcamera/internal/ipc_unixsocket.h"

namespace libcamera {

class Process;

class IPCPipeUnixSocket : public IPCPipe
{
public:
	IPCPipeUnixSocket(const char *ipaModulePath, const char *ipaProxyWorkerPath);
	~IPCPipeUnixSocket();

	int sendSync(const IPCMessage &in,
		     IPCMessage *out = nullptr) override;

	int sendAsync(const IPCMessage &data) override;

private:
	struct CallData {
		IPCUnixSocket::Payload *response;
		bool done;
	};

	void readyRead();
	int call(const IPCUnixSocket::Payload &message,
		 IPCUnixSocket::Payload *response, uint32_t seq);

	std::unique_ptr<Process> proc_;
	std::unique_ptr<IPCUnixSocket> socket_;
	std::map<uint32_t, CallData> callData_;
};

} /* namespace libcamera */

#endif /* __LIBCAMERA_INTERNAL_IPA_IPC_UNIXSOCKET_H__ */