2 * This file is part of the libsigrokflow project.
4 * Copyright (C) 2018 Martin Ling <martin-sigrok@earth.li>
5 * Copyright (C) 2018 Uwe Hermann <uwe@hermann-uwe.de>
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef LIBSIGROKFLOW_LIBSIGROKFLOW_HPP
22 #define LIBSIGROKFLOW_LIBSIGROKFLOW_HPP
24 #include <gstreamermm.h>
25 #include <gstreamermm/private/element_p.h>
26 #include <gstreamermm/private/basesink_p.h>
27 #ifdef HAVE_LIBSIGROKCXX
28 #include <libsigrokcxx/libsigrokcxx.hpp>
30 #ifdef HAVE_LIBSIGROKDECODE
31 #include <libsigrokdecode/libsigrokdecode.h>
43 /* Config API etc goes here */
50 explicit Sink(GstBaseSink *gobj);
56 /* Operations specific to hardware devices go here */
58 explicit Device(GstElement *gobj);
64 /* Operations specific to capture (source) devices go here */
66 explicit CaptureDevice(GstElement *gobj);
69 #ifdef HAVE_LIBSIGROKCXX
70 class LegacyCaptureDevice :
74 /* Create from libsigrok device object */
75 static Glib::RefPtr<LegacyCaptureDevice> create(
76 shared_ptr<sigrok::HardwareDevice> libsigrok_device);
78 /* Retrieve libsigrok device object */
79 shared_ptr<sigrok::HardwareDevice> libsigrok_device();
81 /* Override state change */
82 Gst::StateChangeReturn change_state_vfunc(Gst::StateChange transition);
85 static void class_init(Gst::ElementClass<LegacyCaptureDevice> *klass);
87 /* Register class with plugin */
88 static bool register_element(Glib::RefPtr<Gst::Plugin> plugin);
90 /* Construcor used by element factory */
91 explicit LegacyCaptureDevice(GstElement *gobj);
93 shared_ptr<sigrok::HardwareDevice> _libsigrok_device;
94 Glib::RefPtr<Gst::Pad> _src_pad;
95 Glib::Threads::RecMutex _mutex;
96 Glib::RefPtr<Gst::Task> _task;
97 shared_ptr<sigrok::Session> _session;
99 void _datafeed_callback(shared_ptr<sigrok::Device> device,
100 shared_ptr<sigrok::Packet> packet);
108 /* Create from libsigrok input */
109 static Glib::RefPtr<LegacyInput> create(
110 shared_ptr<sigrok::InputFormat> format,
111 map<string, Glib::VariantBase> options = map<string, Glib::VariantBase>());
117 Gst::FlowReturn chain(const Glib::RefPtr<Gst::Pad> &pad,
118 const Glib::RefPtr<Gst::Buffer> &buf);
124 static void class_init(Gst::ElementClass<LegacyInput> *klass);
126 /* Register class with plugin */
127 static bool register_element(Glib::RefPtr<Gst::Plugin> plugin);
129 /* Construcor used by element factory */
130 explicit LegacyInput(GstElement *gobj);
132 shared_ptr<sigrok::InputFormat> _libsigrok_input_format;
133 shared_ptr<sigrok::Input> _libsigrok_input;
134 shared_ptr<sigrok::Session> _session;
135 map<string, Glib::VariantBase> _options;
136 Glib::RefPtr<Gst::Pad> _sink_pad;
137 Glib::RefPtr<Gst::Pad> _src_pad;
139 void _datafeed_callback(shared_ptr<sigrok::Device> device,
140 shared_ptr<sigrok::Packet> packet);
147 /* Create from libsigrok output object */
148 static Glib::RefPtr<LegacyOutput> create(
149 shared_ptr<sigrok::OutputFormat> libsigrok_output_format,
150 shared_ptr<sigrok::Device> libsigrok_device,
151 map<string, Glib::VariantBase> options = map<string, Glib::VariantBase>());
156 /* Override render */
157 Gst::FlowReturn render_vfunc(const Glib::RefPtr<Gst::Buffer> &buffer);
163 static void class_init(Gst::ElementClass<LegacyOutput> *klass);
165 /* Register class with plugin */
166 static bool register_element(Glib::RefPtr<Gst::Plugin> plugin);
168 /* Constructor used by element factory */
169 explicit LegacyOutput(GstBaseSink *gobj);
171 shared_ptr<sigrok::OutputFormat> _libsigrok_output_format;
172 shared_ptr<sigrok::Device> _libsigrok_device;
173 shared_ptr<sigrok::Output> _libsigrok_output;
174 map<string, Glib::VariantBase> _options;
178 #ifdef HAVE_LIBSIGROKDECODE
179 class LegacyDecoder :
183 static Glib::RefPtr<LegacyDecoder> create(
184 struct srd_session *libsigrokdecode_session, uint64_t unitsize);
186 /* Retrieve libsigrokdecode session */
187 struct srd_session *libsigrokdecode_session();
192 /* Override render */
193 Gst::FlowReturn render_vfunc(const Glib::RefPtr<Gst::Buffer> &buffer);
199 static void class_init(Gst::ElementClass<LegacyDecoder> *klass);
201 /* Register class with plugin */
202 static bool register_element(Glib::RefPtr<Gst::Plugin> plugin);
204 /* Constructor used by element factory */
205 explicit LegacyDecoder(GstBaseSink *gobj);
207 struct srd_session *_session;