]> sigrok.org Git - libsigrokflow.git/blame - include/libsigrokflow/libsigrokflow.hpp
Add missing copyright lines.
[libsigrokflow.git] / include / libsigrokflow / libsigrokflow.hpp
CommitLineData
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>
f7363af1 27#include <libsigrokcxx/libsigrokcxx.hpp>
b1322000 28#include <libsigrokdecode/libsigrokdecode.h>
f7363af1 29
b903bb0a
UH
30namespace Srf
31{
32
f7363af1
ML
33using namespace std;
34
b903bb0a
UH
35void init();
36
f7363af1
ML
37class Block
38{
39 /* Config API etc goes here */
40};
41
e2cfc0ef
ML
42class Sink :
43 public Gst::BaseSink
f7363af1 44{
6d71d36a 45protected:
e2cfc0ef 46 explicit Sink(GstBaseSink *gobj);
f7363af1
ML
47};
48
49class Device :
e2cfc0ef 50 public Gst::Element
f7363af1
ML
51{
52 /* Operations specific to hardware devices go here */
6d71d36a
ML
53protected:
54 explicit Device(GstElement *gobj);
f7363af1 55};
b903bb0a 56
f7363af1
ML
57class CaptureDevice :
58 public Device
59{
60 /* Operations specific to capture (source) devices go here */
6d71d36a
ML
61protected:
62 explicit CaptureDevice(GstElement *gobj);
f7363af1
ML
63};
64
65class LegacyCaptureDevice :
66 public CaptureDevice
67{
68public:
64b0db03
ML
69 /* Create from libsigrok device object */
70 static Glib::RefPtr<LegacyCaptureDevice> create(
71 shared_ptr<sigrok::HardwareDevice> libsigrok_device);
f7363af1
ML
72
73 /* Retrieve libsigrok device object */
d03b3a98
ML
74 shared_ptr<sigrok::HardwareDevice> libsigrok_device();
75
76 /* Override state change */
77 Gst::StateChangeReturn change_state_vfunc(Gst::StateChange transition);
6d71d36a
ML
78
79 /* Gst class init */
80 static void class_init(Gst::ElementClass<LegacyCaptureDevice> *klass);
81
82 /* Register class with plugin */
83 static bool register_element(Glib::RefPtr<Gst::Plugin> plugin);
84
85 /* Construcor used by element factory */
86 explicit LegacyCaptureDevice(GstElement *gobj);
f7363af1 87private:
64b0db03 88 shared_ptr<sigrok::HardwareDevice> _libsigrok_device;
d03b3a98
ML
89 Glib::RefPtr<Gst::Pad> _src_pad;
90 Glib::Threads::RecMutex _mutex;
91 Glib::RefPtr<Gst::Task> _task;
92 shared_ptr<sigrok::Session> _session;
93
94 void _datafeed_callback(shared_ptr<sigrok::Device> device,
95 shared_ptr<sigrok::Packet> packet);
96 void _run();
f7363af1
ML
97};
98
e2cfc0ef
ML
99class LegacyOutput :
100 public Sink
101{
102public:
103 /* Create from libsigrok output object */
104 static Glib::RefPtr<LegacyOutput> create(
726122c2
ML
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>());
e2cfc0ef 108
726122c2
ML
109 /* Override start */
110 bool start_vfunc();
e2cfc0ef
ML
111
112 /* Override render */
113 Gst::FlowReturn render_vfunc(const Glib::RefPtr<Gst::Buffer> &buffer);
114
115 /* Override stop */
116 bool stop_vfunc();
117
118 /* Gst class init */
119 static void class_init(Gst::ElementClass<LegacyOutput> *klass);
120
121 /* Register class with plugin */
122 static bool register_element(Glib::RefPtr<Gst::Plugin> plugin);
123
124 /* Constructor used by element factory */
125 explicit LegacyOutput(GstBaseSink *gobj);
126private:
726122c2
ML
127 shared_ptr<sigrok::OutputFormat> _libsigrok_output_format;
128 shared_ptr<sigrok::Device> _libsigrok_device;
e2cfc0ef 129 shared_ptr<sigrok::Output> _libsigrok_output;
726122c2 130 map<string, Glib::VariantBase> _options;
e2cfc0ef
ML
131};
132
b1322000
UH
133class LegacyDecoder :
134 public Sink
135{
136public:
137 static Glib::RefPtr<LegacyDecoder> create(
138 struct srd_session *libsigrokdecode_session, uint64_t unitsize);
139
140 /* Retrieve libsigrokdecode session */
141 struct srd_session *libsigrokdecode_session();
142
143 /* Override start */
144 bool start_vfunc();
145
146 /* Override render */
147 Gst::FlowReturn render_vfunc(const Glib::RefPtr<Gst::Buffer> &buffer);
148
149 /* Override stop */
150 bool stop_vfunc();
151
152 /* Gst class init */
153 static void class_init(Gst::ElementClass<LegacyDecoder> *klass);
154
155 /* Register class with plugin */
156 static bool register_element(Glib::RefPtr<Gst::Plugin> plugin);
157
158 /* Constructor used by element factory */
159 explicit LegacyDecoder(GstBaseSink *gobj);
160private:
161 struct srd_session *_session;
162 uint64_t _abs_ss;
163 uint64_t _unitsize;
164};
f7363af1
ML
165
166}
572e76fe 167#endif