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_LEGACY_CAPTURE_DEVICE_HPP
22 #define LIBSIGROKFLOW_LEGACY_CAPTURE_DEVICE_HPP
24 /* Temporary workaround, will be dropped later. */
25 #define HAVE_LIBSIGROKCXX 1
27 #include <gstreamermm.h>
28 #ifdef HAVE_LIBSIGROKCXX
29 #include <libsigrokcxx/libsigrokcxx.hpp>
31 #include <libsigrokflow/main.hpp>
36 using std::shared_ptr;
38 #ifdef HAVE_LIBSIGROKCXX
39 class LegacyCaptureDevice :
43 /* Create from libsigrok device object. */
44 static Glib::RefPtr<LegacyCaptureDevice> create(
45 shared_ptr<sigrok::HardwareDevice> libsigrok_device);
47 /* Retrieve libsigrok device object. */
48 shared_ptr<sigrok::HardwareDevice> libsigrok_device();
50 /* Override state change. */
51 Gst::StateChangeReturn change_state_vfunc(Gst::StateChange transition) override;
54 static void class_init(Gst::ElementClass<LegacyCaptureDevice> *klass);
56 /* Register class with plugin. */
57 static bool register_element(Glib::RefPtr<Gst::Plugin> plugin);
59 /* Constructor used by element factory. */
60 explicit LegacyCaptureDevice(GstElement *gobj);
63 shared_ptr<sigrok::HardwareDevice> libsigrok_device_;
64 Glib::RefPtr<Gst::Pad> src_pad_;
65 Glib::Threads::RecMutex mutex_;
66 Glib::RefPtr<Gst::Task> task_;
67 shared_ptr<sigrok::Session> session_;
69 void datafeed_callback(shared_ptr<sigrok::Device> device,
70 shared_ptr<sigrok::Packet> packet);