libcamera  v0.3.1+12-19bbca3c
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  * Image Processing Algorithm IPC module for IPA proxies
6  */
7 
8 #pragma once
9 
10 #include <vector>
11 
13 #include <libcamera/base/signal.h>
14 
16 
17 namespace libcamera {
18 
20 {
21 public:
22  struct Header {
23  uint32_t cmd;
24  uint32_t cookie;
25  };
26 
27  IPCMessage();
28  IPCMessage(uint32_t cmd);
29  IPCMessage(const Header &header);
31 
33 
34  Header &header() { return header_; }
35  std::vector<uint8_t> &data() { return data_; }
36  std::vector<SharedFD> &fds() { return fds_; }
37 
38  const Header &header() const { return header_; }
39  const std::vector<uint8_t> &data() const { return data_; }
40  const std::vector<SharedFD> &fds() const { return fds_; }
41 
42 private:
43  Header header_;
44 
45  std::vector<uint8_t> data_;
46  std::vector<SharedFD> fds_;
47 };
48 
49 class IPCPipe
50 {
51 public:
52  IPCPipe();
53  virtual ~IPCPipe();
54 
55  bool isConnected() const { return connected_; }
56 
57  virtual int sendSync(const IPCMessage &in,
58  IPCMessage *out) = 0;
59 
60  virtual int sendAsync(const IPCMessage &data) = 0;
61 
63 
64 protected:
65  bool connected_;
66 };
67 
68 } /* namespace libcamera */
uint32_t cookie
Cookie to identify the message and a corresponding reply.
Definition: ipc_pipe.h:24
File descriptor wrapper.
bool connected_
Flag to indicate if the IPCPipe instance is connected.
Definition: ipc_pipe.h:65
IPCMessage()
Construct an empty IPCMessage instance.
Definition: ipc_pipe.cpp:51
Top-level libcamera namespace.
Definition: backtrace.h:17
Signal & slot implementation.
std::vector< uint8_t > & data()
Returns a reference to the byte vector containing data.
Definition: ipc_pipe.h:35
Signal< const IPCMessage & > recv
Signal to be emitted when a message is received over IPC.
Definition: ipc_pipe.h:62
IPC message to be passed through IPC message pipe.
Definition: ipc_pipe.h:19
const std::vector< SharedFD > & fds() const
Returns a const reference to the vector containing file descriptors.
Definition: ipc_pipe.h:40
Container for an IPCMessage header.
Definition: ipc_pipe.h:22
IPC mechanism based on Unix sockets.
Header & header()
Returns a reference to the header.
Definition: ipc_pipe.h:34
Generic signal and slot communication mechanism.
Definition: object.h:20
uint32_t cmd
Type of IPCMessage.
Definition: ipc_pipe.h:23
const Header & header() const
Returns a const reference to the header.
Definition: ipc_pipe.h:38
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:100
bool isConnected() const
Check if the IPCPipe instance is connected.
Definition: ipc_pipe.h:55
const std::vector< uint8_t > & data() const
Returns a const reference to the byte vector containing data.
Definition: ipc_pipe.h:39
std::vector< SharedFD > & fds()
Returns a reference to the vector containing file descriptors.
Definition: ipc_pipe.h:36
IPC message pipe for IPA isolation.
Definition: ipc_pipe.h:49