libcamera v0.3.2 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
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
12#include <libcamera/base/shared_fd.h>
13#include <libcamera/base/signal.h>
14
15#include "libcamera/internal/ipc_unixsocket.h"
16
17 namespace libcamera {
18
19 class IPCMessage
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);
30 IPCMessage(IPCUnixSocket::Payload &payload);
31
32 IPCUnixSocket::Payload payload() const;
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
62 Signal<const IPCMessage &> recv;
63
64 protected:
65 bool connected_;
66};
67
68} /* namespace libcamera */
libcamera::IPCMessage
IPC message to be passed through IPC message pipe.
Definition ipc_pipe.h:20
libcamera::IPCMessage::IPCMessage
IPCMessage()
Construct an empty IPCMessage instance.
Definition ipc_pipe.cpp:51
libcamera::IPCMessage::payload
IPCUnixSocket::Payload payload() const
Create an IPCUnixSocket payload from the IPCMessage.
Definition ipc_pipe.cpp:100
libcamera::IPCMessage::fds
const std::vector< SharedFD > & fds() const
Returns a const reference to the vector containing file descriptors.
Definition ipc_pipe.h:40
libcamera::IPCMessage::fds
std::vector< SharedFD > & fds()
Returns a reference to the vector containing file descriptors.
Definition ipc_pipe.h:36
libcamera::IPCMessage::data
std::vector< uint8_t > & data()
Returns a reference to the byte vector containing data.
Definition ipc_pipe.h:35
libcamera::IPCMessage::header
Header & header()
Returns a reference to the header.
Definition ipc_pipe.h:34
libcamera::IPCMessage::data
const std::vector< uint8_t > & data() const
Returns a const reference to the byte vector containing data.
Definition ipc_pipe.h:39
libcamera::IPCMessage::header
const Header & header() const
Returns a const reference to the header.
Definition ipc_pipe.h:38
libcamera::IPCPipe
IPC message pipe for IPA isolation.
Definition ipc_pipe.h:50
libcamera::IPCPipe::sendAsync
virtual int sendAsync(const IPCMessage &data)=0
Send a message over IPC asynchronously.
libcamera::IPCPipe::recv
Signal< const IPCMessage & > recv
Signal to be emitted when a message is received over IPC.
Definition ipc_pipe.h:62
libcamera::IPCPipe::IPCPipe
IPCPipe()
Construct an IPCPipe instance.
Definition ipc_pipe.cpp:163
libcamera::IPCPipe::connected_
bool connected_
Flag to indicate if the IPCPipe instance is connected.
Definition ipc_pipe.h:65
libcamera::IPCPipe::isConnected
bool isConnected() const
Check if the IPCPipe instance is connected.
Definition ipc_pipe.h:55
libcamera::IPCPipe::sendSync
virtual int sendSync(const IPCMessage &in, IPCMessage *out)=0
Send a message over IPC synchronously.
libcamera::Signal
Generic signal and slot communication mechanism.
Definition signal.h:39
ipc_unixsocket.h
IPC mechanism based on Unix sockets.
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
shared_fd.h
File descriptor wrapper.
signal.h
Signal & slot implementation.
libcamera::IPCMessage::Header
Container for an IPCMessage header.
Definition ipc_pipe.h:22
libcamera::IPCMessage::Header::cookie
uint32_t cookie
Cookie to identify the message and a corresponding reply.
Definition ipc_pipe.h:24
libcamera::IPCMessage::Header::cmd
uint32_t cmd
Type of IPCMessage.
Definition ipc_pipe.h:23
libcamera::IPCUnixSocket::Payload
Container for an IPC payload.
Definition ipc_unixsocket.h:24