libcamera/include/libcamera/internal/ipc_unixsocket.h
Kieran Bingham 27aff949fb libcamera/base: Move extended base functionality
Move the functionality for the following components to the new
base support library:

 - BoundMethod
 - EventDispatcher
 - EventDispatcherPoll
 - Log
 - Message
 - Object
 - Signal
 - Semaphore
 - Thread
 - Timer

While it would be preferable to see these split to move one component
per commit, these components are all interdependent upon each other,
which leaves us with one big change performing the move for all of them.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-06-25 16:11:08 +01:00

61 lines
1.1 KiB
C++

/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* ipc_unixsocket.h - IPC mechanism based on Unix sockets
*/
#ifndef __LIBCAMERA_INTERNAL_IPC_UNIXSOCKET_H__
#define __LIBCAMERA_INTERNAL_IPC_UNIXSOCKET_H__
#include <stdint.h>
#include <sys/types.h>
#include <vector>
#include <libcamera/base/signal.h>
namespace libcamera {
class EventNotifier;
class IPCUnixSocket
{
public:
struct Payload {
std::vector<uint8_t> data;
std::vector<int32_t> fds;
};
IPCUnixSocket();
~IPCUnixSocket();
int create();
int bind(int fd);
void close();
bool isBound() const;
int send(const Payload &payload);
int receive(Payload *payload);
Signal<IPCUnixSocket *> readyRead;
private:
struct Header {
uint32_t data;
uint8_t fds;
};
int sendData(const void *buffer, size_t length, const int32_t *fds, unsigned int num);
int recvData(void *buffer, size_t length, int32_t *fds, unsigned int num);
void dataNotifier(EventNotifier *notifier);
int fd_;
bool headerReceived_;
struct Header header_;
EventNotifier *notifier_;
};
} /* namespace libcamera */
#endif /* __LIBCAMERA_INTERNAL_IPC_UNIXSOCKET_H__ */