libcamera  v0.5.0+88-663ab2ee
Supporting cameras in Linux since 2019
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 <stdint.h>
11 #include <vector>
12 
14 #include <libcamera/base/signal.h>
15 
17 
18 namespace libcamera {
19 
21 {
22 public:
23  struct Header {
24  uint32_t cmd;
25  uint32_t cookie;
26  };
27 
28  IPCMessage();
29  IPCMessage(uint32_t cmd);
30  IPCMessage(const Header &header);
32 
34 
35  Header &header() { return header_; }
36  std::vector<uint8_t> &data() { return data_; }
37  std::vector<SharedFD> &fds() { return fds_; }
38 
39  const Header &header() const { return header_; }
40  const std::vector<uint8_t> &data() const { return data_; }
41  const std::vector<SharedFD> &fds() const { return fds_; }
42 
43 private:
44  Header header_;
45 
46  std::vector<uint8_t> data_;
47  std::vector<SharedFD> fds_;
48 };
49 
50 class IPCPipe
51 {
52 public:
53  IPCPipe();
54  virtual ~IPCPipe();
55 
56  bool isConnected() const { return connected_; }
57 
58  virtual int sendSync(const IPCMessage &in,
59  IPCMessage *out) = 0;
60 
61  virtual int sendAsync(const IPCMessage &data) = 0;
62 
64 
65 protected:
66  bool connected_;
67 };
68 
69 } /* namespace libcamera */
uint32_t cookie
Cookie to identify the message and a corresponding reply.
Definition: ipc_pipe.h:25
File descriptor wrapper.
bool connected_
Flag to indicate if the IPCPipe instance is connected.
Definition: ipc_pipe.h:66
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:36
Signal< const IPCMessage & > recv
Signal to be emitted when a message is received over IPC.
Definition: ipc_pipe.h:63
IPC message to be passed through IPC message pipe.
Definition: ipc_pipe.h:20
const std::vector< SharedFD > & fds() const
Returns a const reference to the vector containing file descriptors.
Definition: ipc_pipe.h:41
Container for an IPCMessage header.
Definition: ipc_pipe.h:23
IPC mechanism based on Unix sockets.
Header & header()
Returns a reference to the header.
Definition: ipc_pipe.h:35
Generic signal and slot communication mechanism.
Definition: object.h:22
uint32_t cmd
Type of IPCMessage.
Definition: ipc_pipe.h:24
const Header & header() const
Returns a const reference to the header.
Definition: ipc_pipe.h:39
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:56
const std::vector< uint8_t > & data() const
Returns a const reference to the byte vector containing data.
Definition: ipc_pipe.h:40
std::vector< SharedFD > & fds()
Returns a reference to the vector containing file descriptors.
Definition: ipc_pipe.h:37
IPC message pipe for IPA isolation.
Definition: ipc_pipe.h:50