/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (C) 2021, Vedant Paranjape * * gstreamer_single_stream_test.cpp - GStreamer single stream capture test */ #include #include #include #include "gstreamer_test.h" #include "test.h" using namespace std; class GstreamerSingleStreamTest : public GstreamerTest, public Test { public: GstreamerSingleStreamTest() : GstreamerTest() { } protected: int init() override { if (status_ != TestPass) return status_; const gchar *streamDescription = "videoconvert ! fakesink"; g_autoptr(GError) error0 = NULL; stream0_ = gst_parse_bin_from_description_full(streamDescription, TRUE, NULL, GST_PARSE_FLAG_FATAL_ERRORS, &error0); if (!stream0_) { g_printerr("Bin could not be created (%s)\n", error0->message); return TestFail; } g_object_ref_sink(stream0_); if (createPipeline() != TestPass) return TestFail; return TestPass; } int run() override { /* Build the pipeline */ gst_bin_add_many(GST_BIN(pipeline_), libcameraSrc_, stream0_, NULL); if (gst_element_link(libcameraSrc_, stream0_) != TRUE) { g_printerr("Elements could not be linked.\n"); return TestFail; } if (startPipeline() != TestPass) return TestFail; if (processEvent() != TestPass) return TestFail; return TestPass; } void cleanup() override { g_clear_object(&stream0_); } private: GstElement *stream0_; }; TEST_REGISTER(GstreamerSingleStreamTest) ogtreecommitdiff
blob: d82b302c4aeab1768051ade58677d3618535ee26 (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
55
56
57
58
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2019, Google Inc.
 *
 * event_dispatcher_poll.h - Poll-based event dispatcher
 */
#ifndef __LIBCAMERA_EVENT_DISPATCHER_POLL_H__
#define __LIBCAMERA_EVENT_DISPATCHER_POLL_H__

#include <libcamera/event_dispatcher.h>

#include <list>
#include <map>
#include <vector>

struct pollfd;

namespace libcamera {

class EventNotifier;
class Timer;

class EventDispatcherPoll final : public EventDispatcher
{
public:
	EventDispatcherPoll();
	~EventDispatcherPoll();

	void registerEventNotifier(EventNotifier *notifier);
	void unregisterEventNotifier(EventNotifier *notifier);

	void registerTimer(Timer *timer);
	void unregisterTimer(Timer *timer);

	void processEvents();
	void interrupt();

private:
	struct EventNotifierSetPoll {
		short events() const;
		EventNotifier *notifiers[3];
	};

	std::map<int, EventNotifierSetPoll> notifiers_;
	std::list<Timer *> timers_;
	int eventfd_;

	bool processingEvents_;

	int poll(std::vector<struct pollfd> *pollfds);
	void processInterrupt(const struct pollfd &pfd);
	void processNotifiers(const std::vector<struct pollfd> &pollfds);
	void processTimers();
};

} /* namespace libcamera */

#endif /* __LIBCAMERA_EVENT_DISPATCHER_POLL_H__ */