Loading...
Searching...
No Matches
ipc_pipe.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2020, Google Inc.
*
* Image Processing Algorithm IPC module for IPA proxies
*/
#pragma once
#include <stdint.h>
#include <vector>
#include <libcamera/base/shared_fd.h>
#include <libcamera/base/signal.h>
#include "libcamera/internal/ipc_unixsocket.h"
namespace libcamera {
class IPCMessage
{
public:
struct Header {
uint32_t cmd;
uint32_t cookie;
};
IPCMessage();
IPCMessage(uint32_t cmd);
IPCMessage(const Header &header);
IPCMessage(IPCUnixSocket::Payload &payload);
IPCUnixSocket::Payload payload() const;
Header &header() { return header_; }
std::vector<uint8_t> &data() { return data_; }
std::vector<SharedFD> &fds() { return fds_; }
const Header &header() const { return header_; }
const std::vector<uint8_t> &data() const { return data_; }
const std::vector<SharedFD> &fds() const { return fds_; }
private:
Header header_;
std::vector<uint8_t> data_;
std::vector<SharedFD> fds_;
};
class IPCPipe
{
public:
IPCPipe();
virtual ~IPCPipe();
bool isConnected() const { return connected_; }
virtual int sendSync(const IPCMessage &in,
IPCMessage *out) = 0;
virtual int sendAsync(const IPCMessage &data) = 0;
Signal<const IPCMessage &> recv;
protected:
bool connected_;
};
} /* 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:24