]>
Commit | Line | Data |
---|---|---|
572e76fe UH |
1 | /* |
2 | * This file is part of the libsigrokflow project. | |
3 | * | |
f1eaad84 | 4 | * Copyright (C) 2018 Martin Ling <martin-sigrok@earth.li> |
572e76fe UH |
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_LIBSIGROKFLOW_HPP | |
22 | #define LIBSIGROKFLOW_LIBSIGROKFLOW_HPP | |
23 | ||
15c57e97 UH |
24 | /* Temporary workaround, will be dropped later. */ |
25 | #define HAVE_LIBSIGROKCXX 1 | |
26 | #define HAVE_LIBSIGROKDECODE 1 | |
27 | ||
f7363af1 | 28 | #include <gstreamermm.h> |
37469b3d | 29 | #include <gstreamermm/private/element_p.h> |
e2cfc0ef | 30 | #include <gstreamermm/private/basesink_p.h> |
1060e9b5 | 31 | #ifdef HAVE_LIBSIGROKCXX |
f7363af1 | 32 | #include <libsigrokcxx/libsigrokcxx.hpp> |
1060e9b5 | 33 | #endif |
45e6e688 | 34 | #ifdef HAVE_LIBSIGROKDECODE |
b1322000 | 35 | #include <libsigrokdecode/libsigrokdecode.h> |
45e6e688 | 36 | #endif |
f7363af1 | 37 | |
3f86037d | 38 | #include <libsigrokflow/main.hpp> |
8ab86460 | 39 | #include <libsigrokflow/init.hpp> |
a43e2005 | 40 | #include <libsigrokflow/legacy_capture_device.hpp> |
8ab86460 | 41 | |
b903bb0a UH |
42 | namespace Srf |
43 | { | |
44 | ||
f7363af1 ML |
45 | using namespace std; |
46 | ||
1060e9b5 | 47 | #ifdef HAVE_LIBSIGROKCXX |
92d521e7 | 48 | class LegacyInput : |
31b3babd | 49 | public Gst::Element |
92d521e7 ML |
50 | { |
51 | public: | |
31b3babd UH |
52 | /* Create from libsigrok input. */ |
53 | static Glib::RefPtr<LegacyInput> create( | |
54 | shared_ptr<sigrok::InputFormat> format, | |
55 | map<string, Glib::VariantBase> options = map<string, Glib::VariantBase>()); | |
56 | ||
8ddc0b74 | 57 | /* Chain function (not an override). */ |
31b3babd UH |
58 | Gst::FlowReturn chain(const Glib::RefPtr<Gst::Pad> &pad, |
59 | const Glib::RefPtr<Gst::Buffer> &buf); | |
92d521e7 | 60 | |
fce9342e ML |
61 | /* Event function (not an override). */ |
62 | bool event(const Glib::RefPtr<Gst::Pad> &pad, | |
63 | Glib::RefPtr<Gst::Event> &event); | |
92d521e7 | 64 | |
31b3babd UH |
65 | /* Gst class init. */ |
66 | static void class_init(Gst::ElementClass<LegacyInput> *klass); | |
92d521e7 | 67 | |
31b3babd UH |
68 | /* Register class with plugin. */ |
69 | static bool register_element(Glib::RefPtr<Gst::Plugin> plugin); | |
92d521e7 | 70 | |
31b3babd UH |
71 | /* Constructor used by element factory. */ |
72 | explicit LegacyInput(GstElement *gobj); | |
92d521e7 | 73 | |
92d521e7 | 74 | private: |
b37c14d6 UH |
75 | shared_ptr<sigrok::InputFormat> libsigrok_input_format_; |
76 | shared_ptr<sigrok::Input> libsigrok_input_; | |
77 | shared_ptr<sigrok::Session> session_; | |
78 | map<string, Glib::VariantBase> options_; | |
79 | Glib::RefPtr<Gst::Pad> sink_pad_; | |
80 | Glib::RefPtr<Gst::Pad> src_pad_; | |
81 | ||
897cb509 | 82 | void datafeed_callback(shared_ptr<sigrok::Device> device, |
31b3babd | 83 | shared_ptr<sigrok::Packet> packet); |
92d521e7 ML |
84 | }; |
85 | ||
e2cfc0ef | 86 | class LegacyOutput : |
31b3babd | 87 | public Sink |
e2cfc0ef ML |
88 | { |
89 | public: | |
31b3babd UH |
90 | /* Create from libsigrok output object. */ |
91 | static Glib::RefPtr<LegacyOutput> create( | |
92 | shared_ptr<sigrok::OutputFormat> libsigrok_output_format, | |
31b3babd | 93 | map<string, Glib::VariantBase> options = map<string, Glib::VariantBase>()); |
e2cfc0ef | 94 | |
31b3babd | 95 | /* Override start. */ |
8ddc0b74 | 96 | bool start_vfunc() override; |
e2cfc0ef | 97 | |
31b3babd | 98 | /* Override render. */ |
8ddc0b74 | 99 | Gst::FlowReturn render_vfunc(const Glib::RefPtr<Gst::Buffer> &buffer) override; |
e2cfc0ef | 100 | |
31b3babd | 101 | /* Override stop. */ |
8ddc0b74 | 102 | bool stop_vfunc() override; |
e2cfc0ef | 103 | |
31b3babd UH |
104 | /* Gst class init. */ |
105 | static void class_init(Gst::ElementClass<LegacyOutput> *klass); | |
e2cfc0ef | 106 | |
31b3babd UH |
107 | /* Register class with plugin. */ |
108 | static bool register_element(Glib::RefPtr<Gst::Plugin> plugin); | |
109 | ||
110 | /* Constructor used by element factory. */ | |
111 | explicit LegacyOutput(GstBaseSink *gobj); | |
e2cfc0ef | 112 | |
e2cfc0ef | 113 | private: |
b37c14d6 | 114 | shared_ptr<sigrok::OutputFormat> libsigrok_output_format_; |
9710a16a | 115 | shared_ptr<sigrok::UserDevice> libsigrok_device_; |
b37c14d6 UH |
116 | shared_ptr<sigrok::Output> libsigrok_output_; |
117 | map<string, Glib::VariantBase> options_; | |
e2cfc0ef | 118 | }; |
1060e9b5 | 119 | #endif |
e2cfc0ef | 120 | |
45e6e688 | 121 | #ifdef HAVE_LIBSIGROKDECODE |
b1322000 | 122 | class LegacyDecoder : |
31b3babd | 123 | public Sink |
b1322000 UH |
124 | { |
125 | public: | |
31b3babd UH |
126 | static Glib::RefPtr<LegacyDecoder> create( |
127 | struct srd_session *libsigrokdecode_session, uint64_t unitsize); | |
128 | ||
129 | /* Retrieve libsigrokdecode session. */ | |
130 | struct srd_session *libsigrokdecode_session(); | |
b1322000 | 131 | |
31b3babd | 132 | /* Override start. */ |
8ddc0b74 | 133 | bool start_vfunc() override; |
b1322000 | 134 | |
31b3babd | 135 | /* Override render. */ |
8ddc0b74 | 136 | Gst::FlowReturn render_vfunc(const Glib::RefPtr<Gst::Buffer> &buffer) override; |
b1322000 | 137 | |
31b3babd | 138 | /* Override stop. */ |
8ddc0b74 | 139 | bool stop_vfunc() override; |
b1322000 | 140 | |
31b3babd UH |
141 | /* Gst class init. */ |
142 | static void class_init(Gst::ElementClass<LegacyDecoder> *klass); | |
b1322000 | 143 | |
31b3babd UH |
144 | /* Register class with plugin. */ |
145 | static bool register_element(Glib::RefPtr<Gst::Plugin> plugin); | |
b1322000 | 146 | |
31b3babd UH |
147 | /* Constructor used by element factory. */ |
148 | explicit LegacyDecoder(GstBaseSink *gobj); | |
b1322000 | 149 | |
b1322000 | 150 | private: |
b37c14d6 UH |
151 | struct srd_session *session_; |
152 | uint64_t abs_ss_; | |
153 | uint64_t unitsite_; | |
b1322000 | 154 | }; |
45e6e688 | 155 | #endif |
f7363af1 ML |
156 | |
157 | } | |
572e76fe | 158 | #endif |