libcamera  v0.0.0+100-debian/0_git20200629+e7aa92a-8-9-g77f5237c-dirty (2021-05-05T16:20:29+01:00)
Supporting cameras in Linux since 2019
ipc_pipe.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /*
3  * Copyright (C) 2020, Google Inc.
4  *
5  * ipc_pipe.h - Image Processing Algorithm IPC module for IPA proxies
6  */
7 #ifndef __LIBCAMERA_INTERNAL_IPA_IPC_H__
8 #define __LIBCAMERA_INTERNAL_IPA_IPC_H__
9 
10 #include <vector>
11 
13 
14 #include <libcamera/signal.h>
15 
16 namespace libcamera {
17 
19 {
20 public:
21  struct Header {
22  uint32_t cmd;
23  uint32_t cookie;
24  };
25 
26  IPCMessage();
27  IPCMessage(uint32_t cmd);
28  IPCMessage(const Header &header);
30 
32 
33  Header &header() { return header_; }
34  std::vector<uint8_t> &data() { return data_; }
35  std::vector<int32_t> &fds() { return fds_; }
36 
37  const Header &header() const { return header_; }
38  const std::vector<uint8_t> &data() const { return data_; }
39  const std::vector<int32_t> &fds() const { return fds_; }
40 
41 private:
42  Header header_;
43 
44  std::vector<uint8_t> data_;
45  std::vector<int32_t> fds_;
46 };
47 
48 class IPCPipe
49 {
50 public:
51  IPCPipe();
52  virtual ~IPCPipe();
53 
54  bool isConnected() const { return connected_; }
55 
56  virtual int sendSync(const IPCMessage &in,
57  IPCMessage *out) = 0;
58 
59  virtual int sendAsync(const IPCMessage &data) = 0;
60 
62 
63 protected:
64  bool connected_;
65 };
66 
67 } /* namespace libcamera */
68 
69 #endif /* __LIBCAMERA_INTERNAL_IPA_IPC_H__ */
uint32_t cookie
Cookie to identify the message and a corresponding reply.
Definition: ipc_pipe.h:23
bool connected_
Flag to indicate if the IPCPipe instance is connected.
Definition: ipc_pipe.h:64
IPCMessage()
Construct an empty IPCMessage instance.
Definition: ipc_pipe.cpp:51
Top-level libcamera namespace.
Definition: bound_method.h:15
Signal & slot implementation.
std::vector< uint8_t > & data()
Returns a reference to the byte vector containing data.
Definition: ipc_pipe.h:34
Signal< const IPCMessage & > recv
Signal to be emitted when a message is received over IPC.
Definition: ipc_pipe.h:61
IPC message to be passed through IPC message pipe.
Definition: ipc_pipe.h:18
const std::vector< int32_t > & fds() const
Returns a const reference to the vector containing file descriptors.
Definition: ipc_pipe.h:39
Container for an IPCMessage header.
Definition: ipc_pipe.h:21
IPC mechanism based on Unix sockets.
Header & header()
Returns a reference to the header.
Definition: ipc_pipe.h:33
Generic signal and slot communication mechanism.
Definition: object.h:20
uint32_t cmd
Type of IPCMessage.
Definition: ipc_pipe.h:22
const Header & header() const
Returns a const reference to the header.
Definition: ipc_pipe.h:37
Container for an IPC payload.
Definition: ipc_unixsocket.h:24
IPCUnixSocket::Payload payload() const
Create an IPCUnixSocket payload from the IPCMessage.
Definition: ipc_pipe.cpp:96
bool isConnected() const
Check if the IPCPipe instance is connected.
Definition: ipc_pipe.h:54
const std::vector< uint8_t > & data() const
Returns a const reference to the byte vector containing data.
Definition: ipc_pipe.h:38
std::vector< int32_t > & fds()
Returns a reference to the vector containing file descriptors.
Definition: ipc_pipe.h:35
IPC message pipe for IPA isolation.
Definition: ipc_pipe.h:48