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 #include <libsigrokcxx/libsigrokcxx.hpp>
28 #include <libsigrokdecode/libsigrokdecode.h>
39 /* Config API etc goes here */
46 explicit Sink(GstBaseSink *gobj);
52 /* Operations specific to hardware devices go here */
54 explicit Device(GstElement *gobj);
60 /* Operations specific to capture (source) devices go here */
62 explicit CaptureDevice(GstElement *gobj);
65 class LegacyCaptureDevice :
69 /* Create from libsigrok device object */
70 static Glib::RefPtr<LegacyCaptureDevice> create(
71 shared_ptr<sigrok::HardwareDevice> libsigrok_device);
73 /* Retrieve libsigrok device object */
74 shared_ptr<sigrok::HardwareDevice> libsigrok_device();
76 /* Override state change */
77 Gst::StateChangeReturn change_state_vfunc(Gst::StateChange transition);
80 static void class_init(Gst::ElementClass<LegacyCaptureDevice> *klass);
82 /* Register class with plugin */
83 static bool register_element(Glib::RefPtr<Gst::Plugin> plugin);
85 /* Construcor used by element factory */
86 explicit LegacyCaptureDevice(GstElement *gobj);
88 shared_ptr<sigrok::HardwareDevice> _libsigrok_device;
89 Glib::RefPtr<Gst::Pad> _src_pad;
90 Glib::Threads::RecMutex _mutex;
91 Glib::RefPtr<Gst::Task> _task;
92 shared_ptr<sigrok::Session> _session;
94 void _datafeed_callback(shared_ptr<sigrok::Device> device,
95 shared_ptr<sigrok::Packet> packet);
103 /* Create from libsigrok output object */
104 static Glib::RefPtr<LegacyOutput> create(
105 shared_ptr<sigrok::OutputFormat> libsigrok_output_format,
106 shared_ptr<sigrok::Device> libsigrok_device,
107 map<string, Glib::VariantBase> options = map<string, Glib::VariantBase>());
112 /* Override render */
113 Gst::FlowReturn render_vfunc(const Glib::RefPtr<Gst::Buffer> &buffer);
119 static void class_init(Gst::ElementClass<LegacyOutput> *klass);
121 /* Register class with plugin */
122 static bool register_element(Glib::RefPtr<Gst::Plugin> plugin);
124 /* Constructor used by element factory */
125 explicit LegacyOutput(GstBaseSink *gobj);
127 shared_ptr<sigrok::OutputFormat> _libsigrok_output_format;
128 shared_ptr<sigrok::Device> _libsigrok_device;
129 shared_ptr<sigrok::Output> _libsigrok_output;
130 map<string, Glib::VariantBase> _options;
133 class LegacyDecoder :
137 static Glib::RefPtr<LegacyDecoder> create(
138 struct srd_session *libsigrokdecode_session, uint64_t unitsize);
140 /* Retrieve libsigrokdecode session */
141 struct srd_session *libsigrokdecode_session();
146 /* Override render */
147 Gst::FlowReturn render_vfunc(const Glib::RefPtr<Gst::Buffer> &buffer);
153 static void class_init(Gst::ElementClass<LegacyDecoder> *klass);
155 /* Register class with plugin */
156 static bool register_element(Glib::RefPtr<Gst::Plugin> plugin);
158 /* Constructor used by element factory */
159 explicit LegacyDecoder(GstBaseSink *gobj);
161 struct srd_session *_session;