]>
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 | ||
f7363af1 | 24 | #include <gstreamermm.h> |
37469b3d | 25 | #include <gstreamermm/private/element_p.h> |
e2cfc0ef | 26 | #include <gstreamermm/private/basesink_p.h> |
1060e9b5 | 27 | #ifdef HAVE_LIBSIGROKCXX |
f7363af1 | 28 | #include <libsigrokcxx/libsigrokcxx.hpp> |
1060e9b5 | 29 | #endif |
45e6e688 | 30 | #ifdef HAVE_LIBSIGROKDECODE |
b1322000 | 31 | #include <libsigrokdecode/libsigrokdecode.h> |
45e6e688 | 32 | #endif |
f7363af1 | 33 | |
b903bb0a UH |
34 | namespace Srf |
35 | { | |
36 | ||
f7363af1 ML |
37 | using namespace std; |
38 | ||
b903bb0a UH |
39 | void init(); |
40 | ||
f7363af1 ML |
41 | class Block |
42 | { | |
43 | /* Config API etc goes here */ | |
44 | }; | |
45 | ||
e2cfc0ef ML |
46 | class Sink : |
47 | public Gst::BaseSink | |
f7363af1 | 48 | { |
6d71d36a | 49 | protected: |
e2cfc0ef | 50 | explicit Sink(GstBaseSink *gobj); |
f7363af1 ML |
51 | }; |
52 | ||
53 | class Device : | |
e2cfc0ef | 54 | public Gst::Element |
f7363af1 ML |
55 | { |
56 | /* Operations specific to hardware devices go here */ | |
6d71d36a ML |
57 | protected: |
58 | explicit Device(GstElement *gobj); | |
f7363af1 | 59 | }; |
b903bb0a | 60 | |
f7363af1 ML |
61 | class CaptureDevice : |
62 | public Device | |
63 | { | |
64 | /* Operations specific to capture (source) devices go here */ | |
6d71d36a ML |
65 | protected: |
66 | explicit CaptureDevice(GstElement *gobj); | |
f7363af1 ML |
67 | }; |
68 | ||
1060e9b5 | 69 | #ifdef HAVE_LIBSIGROKCXX |
f7363af1 ML |
70 | class LegacyCaptureDevice : |
71 | public CaptureDevice | |
72 | { | |
73 | public: | |
64b0db03 ML |
74 | /* Create from libsigrok device object */ |
75 | static Glib::RefPtr<LegacyCaptureDevice> create( | |
76 | shared_ptr<sigrok::HardwareDevice> libsigrok_device); | |
f7363af1 ML |
77 | |
78 | /* Retrieve libsigrok device object */ | |
d03b3a98 ML |
79 | shared_ptr<sigrok::HardwareDevice> libsigrok_device(); |
80 | ||
81 | /* Override state change */ | |
82 | Gst::StateChangeReturn change_state_vfunc(Gst::StateChange transition); | |
6d71d36a ML |
83 | |
84 | /* Gst class init */ | |
85 | static void class_init(Gst::ElementClass<LegacyCaptureDevice> *klass); | |
86 | ||
87 | /* Register class with plugin */ | |
88 | static bool register_element(Glib::RefPtr<Gst::Plugin> plugin); | |
89 | ||
90 | /* Construcor used by element factory */ | |
91 | explicit LegacyCaptureDevice(GstElement *gobj); | |
f7363af1 | 92 | private: |
64b0db03 | 93 | shared_ptr<sigrok::HardwareDevice> _libsigrok_device; |
d03b3a98 ML |
94 | Glib::RefPtr<Gst::Pad> _src_pad; |
95 | Glib::Threads::RecMutex _mutex; | |
96 | Glib::RefPtr<Gst::Task> _task; | |
97 | shared_ptr<sigrok::Session> _session; | |
98 | ||
99 | void _datafeed_callback(shared_ptr<sigrok::Device> device, | |
100 | shared_ptr<sigrok::Packet> packet); | |
101 | void _run(); | |
f7363af1 ML |
102 | }; |
103 | ||
92d521e7 ML |
104 | class LegacyInput : |
105 | public Gst::Element | |
106 | { | |
107 | public: | |
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>()); | |
112 | ||
113 | /* Override start */ | |
114 | bool start_vfunc(); | |
115 | ||
116 | /* Chain function */ | |
117 | Gst::FlowReturn chain(const Glib::RefPtr<Gst::Pad> &pad, | |
118 | const Glib::RefPtr<Gst::Buffer> &buf); | |
119 | ||
120 | /* Override stop */ | |
121 | bool stop_vfunc(); | |
122 | ||
123 | /* Gst class init */ | |
124 | static void class_init(Gst::ElementClass<LegacyInput> *klass); | |
125 | ||
126 | /* Register class with plugin */ | |
127 | static bool register_element(Glib::RefPtr<Gst::Plugin> plugin); | |
128 | ||
129 | /* Construcor used by element factory */ | |
130 | explicit LegacyInput(GstElement *gobj); | |
131 | private: | |
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; | |
138 | ||
139 | void _datafeed_callback(shared_ptr<sigrok::Device> device, | |
140 | shared_ptr<sigrok::Packet> packet); | |
141 | }; | |
142 | ||
e2cfc0ef ML |
143 | class LegacyOutput : |
144 | public Sink | |
145 | { | |
146 | public: | |
147 | /* Create from libsigrok output object */ | |
148 | static Glib::RefPtr<LegacyOutput> create( | |
726122c2 ML |
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>()); | |
e2cfc0ef | 152 | |
726122c2 ML |
153 | /* Override start */ |
154 | bool start_vfunc(); | |
e2cfc0ef ML |
155 | |
156 | /* Override render */ | |
157 | Gst::FlowReturn render_vfunc(const Glib::RefPtr<Gst::Buffer> &buffer); | |
158 | ||
159 | /* Override stop */ | |
160 | bool stop_vfunc(); | |
161 | ||
162 | /* Gst class init */ | |
163 | static void class_init(Gst::ElementClass<LegacyOutput> *klass); | |
164 | ||
165 | /* Register class with plugin */ | |
166 | static bool register_element(Glib::RefPtr<Gst::Plugin> plugin); | |
167 | ||
168 | /* Constructor used by element factory */ | |
169 | explicit LegacyOutput(GstBaseSink *gobj); | |
170 | private: | |
726122c2 ML |
171 | shared_ptr<sigrok::OutputFormat> _libsigrok_output_format; |
172 | shared_ptr<sigrok::Device> _libsigrok_device; | |
e2cfc0ef | 173 | shared_ptr<sigrok::Output> _libsigrok_output; |
726122c2 | 174 | map<string, Glib::VariantBase> _options; |
e2cfc0ef | 175 | }; |
1060e9b5 | 176 | #endif |
e2cfc0ef | 177 | |
45e6e688 | 178 | #ifdef HAVE_LIBSIGROKDECODE |
b1322000 UH |
179 | class LegacyDecoder : |
180 | public Sink | |
181 | { | |
182 | public: | |
183 | static Glib::RefPtr<LegacyDecoder> create( | |
184 | struct srd_session *libsigrokdecode_session, uint64_t unitsize); | |
185 | ||
186 | /* Retrieve libsigrokdecode session */ | |
187 | struct srd_session *libsigrokdecode_session(); | |
188 | ||
189 | /* Override start */ | |
190 | bool start_vfunc(); | |
191 | ||
192 | /* Override render */ | |
193 | Gst::FlowReturn render_vfunc(const Glib::RefPtr<Gst::Buffer> &buffer); | |
194 | ||
195 | /* Override stop */ | |
196 | bool stop_vfunc(); | |
197 | ||
198 | /* Gst class init */ | |
199 | static void class_init(Gst::ElementClass<LegacyDecoder> *klass); | |
200 | ||
201 | /* Register class with plugin */ | |
202 | static bool register_element(Glib::RefPtr<Gst::Plugin> plugin); | |
203 | ||
204 | /* Constructor used by element factory */ | |
205 | explicit LegacyDecoder(GstBaseSink *gobj); | |
206 | private: | |
207 | struct srd_session *_session; | |
208 | uint64_t _abs_ss; | |
209 | uint64_t _unitsize; | |
210 | }; | |
45e6e688 | 211 | #endif |
f7363af1 ML |
212 | |
213 | } | |
572e76fe | 214 | #endif |