libcamera: include/libcamera/internal/ipc_pipe.h Source File

libcamera v0.7.1 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 <stdint.h>
11#include <vector>
12
13#include <libcamera/base/shared_fd.h>
14#include <libcamera/base/signal.h>
15
16#include "libcamera/internal/ipc_unixsocket.h"
17
18namespace libcamera {
19
20 class IPCMessage
21{
22public:
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);
31 IPCMessage(IPCUnixSocket::Payload &payload);
32
33 IPCUnixSocket::Payload payload() const;
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
43private:
44 Header header_;
45
46 std::vector<uint8_t> data_;
47 std::vector<SharedFD> fds_;
48};
49
50 class IPCPipe
51{
52public:
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
63 Signal<const IPCMessage &> recv;
64
65protected:
66 bool connected_;
67};
68
69} /* namespace libcamera */
libcamera::IPCMessage
IPC message to be passed through IPC message pipe.
Definition ipc_pipe.h:21
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:41
libcamera::IPCMessage::fds
std::vector< SharedFD > & fds()
Returns a reference to the vector containing file descriptors.
Definition ipc_pipe.h:37
libcamera::IPCMessage::data
std::vector< uint8_t > & data()
Returns a reference to the byte vector containing data.
Definition ipc_pipe.h:36
libcamera::IPCMessage::header
Header & header()
Returns a reference to the header.
Definition ipc_pipe.h:35
libcamera::IPCMessage::data
const std::vector< uint8_t > & data() const
Returns a const reference to the byte vector containing data.
Definition ipc_pipe.h:40
libcamera::IPCMessage::header
const Header & header() const
Returns a const reference to the header.
Definition ipc_pipe.h:39
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:63
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:66
libcamera::IPCPipe::isConnected
bool isConnected() const
Check if the IPCPipe instance is connected.
Definition ipc_pipe.h:56
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:23
libcamera::IPCMessage::Header::cookie
uint32_t cookie
Cookie to identify the message and a corresponding reply.
Definition ipc_pipe.h:25
libcamera::IPCMessage::Header::cmd
uint32_t cmd
Type of IPCMessage.
Definition ipc_pipe.h:24
libcamera::IPCUnixSocket::Payload
Container for an IPC payload.
Definition ipc_unixsocket.h:25