summaryrefslogtreecommitdiff
path: root/src/android/jpeg/encoder.h
blob: 8d449369869f72e93b883d6afc5b40560464deca (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
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2020, Google Inc.
 *
 * encoder.h - Image encoding interface
 */
#ifndef __ANDROID_JPEG_ENCODER_H__
#define __ANDROID_JPEG_ENCODER_H__

#include <libcamera/buffer.h>
#include <libcamera/span.h>
#include <libcamera/stream.h>

class Encoder
{
public:
	virtual ~Encoder() = default;

	virtual int configure(const libcamera::StreamConfiguration &cfg) = 0;
	virtual int encode(const libcamera::FrameBuffer &source,
			   libcamera::Span<uint8_t> destination,
			   libcamera::Span<const uint8_t> exifData,
			   unsigned int quality) = 0;
};

#endif /* __ANDROID_JPEG_ENCODER_H__ */
#n46'>46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2019, Google Inc.
 *
 * Message queue support
 */

#pragma once

#include <atomic>

#include <libcamera/base/private.h>

#include <libcamera/base/bound_method.h>

namespace libcamera {

class BoundMethodBase;
class Object;
class Semaphore;
class Thread;

class Message
{
public:
	enum Type {
		None = 0,
		InvokeMessage = 1,
		ThreadMoveMessage = 2,
		DeferredDelete = 3,
		UserMessage = 1000,
	};

	Message(Type type);
	virtual ~Message();

	Type type() const { return type_; }
	Object *receiver() const { return receiver_; }

	static Type registerMessageType();

private:
	friend class Thread;

	Type type_;
	Object *receiver_;

	static std::atomic_uint nextUserType_;
};

class InvokeMessage : public Message
{
public:
	InvokeMessage(BoundMethodBase *method,
		      std::shared_ptr<BoundMethodPackBase> pack,
		      Semaphore *semaphore = nullptr,
		      bool deleteMethod = false);
	~InvokeMessage();

	Semaphore *semaphore() const { return semaphore_; }

	void invoke();

private:
	BoundMethodBase *method_;
	std::shared_ptr<BoundMethodPackBase> pack_;
	Semaphore *semaphore_;
	bool deleteMethod_;
};

} /* namespace libcamera */