]> sigrok.org Git - libsigrokflow.git/blob - include/libsigrokflow/libsigrokflow.hpp
WIP on plugin registration.
[libsigrokflow.git] / include / libsigrokflow / libsigrokflow.hpp
1 /*
2  * This file is part of the libsigrokflow project.
3  *
4  * Copyright (C) 2018 Uwe Hermann <uwe@hermann-uwe.de>
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #ifndef LIBSIGROKFLOW_LIBSIGROKFLOW_HPP
21 #define LIBSIGROKFLOW_LIBSIGROKFLOW_HPP
22
23 #include <gstreamermm.h>
24 #include <libsigrokcxx/libsigrokcxx.hpp>
25
26 namespace Srf
27 {
28
29 using namespace std;
30
31 void init();
32
33 class Block
34 {
35         /* Config API etc goes here */
36 };
37
38 class GstBlock :
39         public Gst::Element
40 {
41         /* Operations specific to sigrok GStreamer blocks go here. */
42 protected:
43         explicit GstBlock(GstElement *gobj);
44 };
45
46 class Device :
47         public GstBlock
48 {
49         /* Operations specific to hardware devices go here */
50 protected:
51         explicit Device(GstElement *gobj);
52 };
53
54 class CaptureDevice :
55         public Device
56 {
57         /* Operations specific to capture (source) devices go here */
58 protected:
59         explicit CaptureDevice(GstElement *gobj);
60 };
61
62 class LegacyCaptureDevice :
63         public CaptureDevice
64 {
65 public:
66         /* Create from libsigrok device object */
67         static Glib::RefPtr<LegacyCaptureDevice> create(
68                 shared_ptr<sigrok::HardwareDevice> libsigrok_device);
69
70         /* Retrieve libsigrok device object */
71         shared_ptr<sigrok::HardwareDevice> libsigrok_device();
72
73         /* Override state change */
74         Gst::StateChangeReturn change_state_vfunc(Gst::StateChange transition);
75
76         /* Gst class init */
77         static void class_init(Gst::ElementClass<LegacyCaptureDevice> *klass);
78
79         /* Register class with plugin */
80         static bool register_element(Glib::RefPtr<Gst::Plugin> plugin);
81
82         /* Construcor used by element factory */
83         explicit LegacyCaptureDevice(GstElement *gobj);
84 private:
85         shared_ptr<sigrok::HardwareDevice> _libsigrok_device;
86         Glib::RefPtr<Gst::Pad> _src_pad;
87         Glib::Threads::RecMutex _mutex;
88         Glib::RefPtr<Gst::Task> _task;
89         shared_ptr<sigrok::Session> _session;
90
91         void _datafeed_callback(shared_ptr<sigrok::Device> device,
92                         shared_ptr<sigrok::Packet> packet);
93         void _run();
94 };
95
96
97 }
98 #endif