summaryrefslogtreecommitdiff
path: root/src/android/thread_rpc.h
blob: 6d8992839d0b006c4d506e16a999eb7bbfbca02c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2019, Google Inc.
 *
 * thread_rpc.h - Inter-thread procedure call
 */
#ifndef __ANDROID_THREAD_RPC_H__
#define __ANDROID_THREAD_RPC_H__

#include <condition_variable>
#include <mutex>

#include <hardware/camera3.h>

#include "message.h"
#include "thread.h"

class ThreadRpc
{
public:
	enum RpcTag {
		ProcessCaptureRequest,
		Close,
	};

	ThreadRpc()
		: delivered_(false) {}

	void notifyReception();
	void waitDelivery();

	RpcTag tag;

	camera3_capture_request_t *request;

private:
	bool delivered_;
	std::mutex mutex_;
	std::condition_variable cv_;
};

class ThreadRpcMessage : public libcamera::Message
{
public:
	ThreadRpcMessage();
	ThreadRpc *rpc;

	static Message::Type type();

private:
	static libcamera::Message::Type rpcType_;
};

#endif /* __ANDROID_THREAD_RPC_H__ */