]> sigrok.org Git - libsigrokflow.git/blob - include/libsigrokflow/libsigrokflow.hpp
Include gstreamermm/private/element_p.h header to subclass Element.
[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 <gstreamermm/private/element_p.h>
25 #include <libsigrokcxx/libsigrokcxx.hpp>
26
27 namespace Srf
28 {
29
30 using namespace std;
31
32 void init();
33
34 class Block
35 {
36         /* Config API etc goes here */
37 };
38
39 class GstBlock :
40         public Gst::Element
41 {
42         /* Operations specific to sigrok GStreamer blocks go here. */
43 protected:
44         explicit GstBlock(GstElement *gobj);
45 };
46
47 class Device :
48         public GstBlock
49 {
50         /* Operations specific to hardware devices go here */
51 protected:
52         explicit Device(GstElement *gobj);
53 };
54
55 class CaptureDevice :
56         public Device
57 {
58         /* Operations specific to capture (source) devices go here */
59 protected:
60         explicit CaptureDevice(GstElement *gobj);
61 };
62
63 class LegacyCaptureDevice :
64         public CaptureDevice
65 {
66 public:
67         /* Create from libsigrok device object */
68         static Glib::RefPtr<LegacyCaptureDevice> create(
69                 shared_ptr<sigrok::HardwareDevice> libsigrok_device);
70
71         /* Retrieve libsigrok device object */
72         shared_ptr<sigrok::HardwareDevice> libsigrok_device();
73
74         /* Override state change */
75         Gst::StateChangeReturn change_state_vfunc(Gst::StateChange transition);
76
77         /* Gst class init */
78         static void class_init(Gst::ElementClass<LegacyCaptureDevice> *klass);
79
80         /* Register class with plugin */
81         static bool register_element(Glib::RefPtr<Gst::Plugin> plugin);
82
83         /* Construcor used by element factory */
84         explicit LegacyCaptureDevice(GstElement *gobj);
85 private:
86         shared_ptr<sigrok::HardwareDevice> _libsigrok_device;
87         Glib::RefPtr<Gst::Pad> _src_pad;
88         Glib::Threads::RecMutex _mutex;
89         Glib::RefPtr<Gst::Task> _task;
90         shared_ptr<sigrok::Session> _session;
91
92         void _datafeed_callback(shared_ptr<sigrok::Device> device,
93                         shared_ptr<sigrok::Packet> packet);
94         void _run();
95 };
96
97
98 }
99 #endif