]>
Commit | Line | Data |
---|---|---|
3d1f327f UH |
1 | /* |
2 | * This file is part of the libsigrokflow project. | |
3 | * | |
4 | * Copyright (C) 2018 Martin Ling <martin-sigrok@earth.li> | |
5 | * Copyright (C) 2018 Uwe Hermann <uwe@hermann-uwe.de> | |
6 | * | |
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. | |
11 | * | |
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. | |
16 | * | |
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/>. | |
19 | */ | |
20 | ||
21 | #ifndef LIBSIGROKFLOW_LEGACY_INPUT_HPP | |
22 | #define LIBSIGROKFLOW_LEGACY_INPUT_HPP | |
23 | ||
24 | /* Temporary workaround, will be dropped later. */ | |
25 | #define HAVE_LIBSIGROKCXX 1 | |
26 | ||
27 | #include <gstreamermm.h> | |
28 | #ifdef HAVE_LIBSIGROKCXX | |
29 | #include <libsigrokcxx/libsigrokcxx.hpp> | |
30 | #endif | |
31 | #include <libsigrokflow/main.hpp> | |
32 | ||
33 | namespace Srf | |
34 | { | |
35 | ||
f638442b UH |
36 | using std::map; |
37 | using std::shared_ptr; | |
38 | using std::string; | |
3d1f327f UH |
39 | |
40 | #ifdef HAVE_LIBSIGROKCXX | |
41 | class LegacyInput : | |
42 | public Gst::Element | |
43 | { | |
44 | public: | |
45 | /* Create from libsigrok input. */ | |
46 | static Glib::RefPtr<LegacyInput> create( | |
47 | shared_ptr<sigrok::InputFormat> format, | |
48 | map<string, Glib::VariantBase> options = map<string, Glib::VariantBase>()); | |
49 | ||
50 | /* Chain function (not an override). */ | |
51 | Gst::FlowReturn chain(const Glib::RefPtr<Gst::Pad> &pad, | |
52 | const Glib::RefPtr<Gst::Buffer> &buf); | |
53 | ||
54 | /* Event function (not an override). */ | |
55 | bool event(const Glib::RefPtr<Gst::Pad> &pad, | |
56 | Glib::RefPtr<Gst::Event> &event); | |
57 | ||
58 | /* Gst class init. */ | |
59 | static void class_init(Gst::ElementClass<LegacyInput> *klass); | |
60 | ||
61 | /* Register class with plugin. */ | |
62 | static bool register_element(Glib::RefPtr<Gst::Plugin> plugin); | |
63 | ||
64 | /* Constructor used by element factory. */ | |
65 | explicit LegacyInput(GstElement *gobj); | |
66 | ||
67 | private: | |
68 | shared_ptr<sigrok::InputFormat> libsigrok_input_format_; | |
69 | shared_ptr<sigrok::Input> libsigrok_input_; | |
70 | shared_ptr<sigrok::Session> session_; | |
71 | map<string, Glib::VariantBase> options_; | |
72 | Glib::RefPtr<Gst::Pad> sink_pad_; | |
73 | Glib::RefPtr<Gst::Pad> src_pad_; | |
74 | ||
75 | void datafeed_callback(shared_ptr<sigrok::Device> device, | |
76 | shared_ptr<sigrok::Packet> packet); | |
77 | }; | |
78 | #endif | |
79 | ||
80 | } | |
81 | #endif |