]> sigrok.org Git - libsigrokflow.git/blame - include/libsigrokflow/libsigrokflow.hpp
Create LegacyOutput from format, device and options.
[libsigrokflow.git] / include / libsigrokflow / libsigrokflow.hpp
CommitLineData
572e76fe
UH
1/*
2 * This file is part of the libsigrokflow project.
3 *
4 * Copyright (C) 2018 Uwe Hermann <uwe@hermann-uwe.de>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBSIGROKFLOW_LIBSIGROKFLOW_HPP
21#define LIBSIGROKFLOW_LIBSIGROKFLOW_HPP
22
f7363af1 23#include <gstreamermm.h>
37469b3d 24#include <gstreamermm/private/element_p.h>
e2cfc0ef 25#include <gstreamermm/private/basesink_p.h>
f7363af1
ML
26#include <libsigrokcxx/libsigrokcxx.hpp>
27
b903bb0a
UH
28namespace Srf
29{
30
f7363af1
ML
31using namespace std;
32
b903bb0a
UH
33void init();
34
f7363af1
ML
35class Block
36{
37 /* Config API etc goes here */
38};
39
e2cfc0ef
ML
40class Sink :
41 public Gst::BaseSink
f7363af1 42{
6d71d36a 43protected:
e2cfc0ef 44 explicit Sink(GstBaseSink *gobj);
f7363af1
ML
45};
46
47class Device :
e2cfc0ef 48 public Gst::Element
f7363af1
ML
49{
50 /* Operations specific to hardware devices go here */
6d71d36a
ML
51protected:
52 explicit Device(GstElement *gobj);
f7363af1 53};
b903bb0a 54
f7363af1
ML
55class CaptureDevice :
56 public Device
57{
58 /* Operations specific to capture (source) devices go here */
6d71d36a
ML
59protected:
60 explicit CaptureDevice(GstElement *gobj);
f7363af1
ML
61};
62
63class LegacyCaptureDevice :
64 public CaptureDevice
65{
66public:
64b0db03
ML
67 /* Create from libsigrok device object */
68 static Glib::RefPtr<LegacyCaptureDevice> create(
69 shared_ptr<sigrok::HardwareDevice> libsigrok_device);
f7363af1
ML
70
71 /* Retrieve libsigrok device object */
d03b3a98
ML
72 shared_ptr<sigrok::HardwareDevice> libsigrok_device();
73
74 /* Override state change */
75 Gst::StateChangeReturn change_state_vfunc(Gst::StateChange transition);
6d71d36a
ML
76
77 /* Gst class init */
78 static void class_init(Gst::ElementClass<LegacyCaptureDevice> *klass);
79
80 /* Register class with plugin */
81 static bool register_element(Glib::RefPtr<Gst::Plugin> plugin);
82
83 /* Construcor used by element factory */
84 explicit LegacyCaptureDevice(GstElement *gobj);
f7363af1 85private:
64b0db03 86 shared_ptr<sigrok::HardwareDevice> _libsigrok_device;
d03b3a98
ML
87 Glib::RefPtr<Gst::Pad> _src_pad;
88 Glib::Threads::RecMutex _mutex;
89 Glib::RefPtr<Gst::Task> _task;
90 shared_ptr<sigrok::Session> _session;
91
92 void _datafeed_callback(shared_ptr<sigrok::Device> device,
93 shared_ptr<sigrok::Packet> packet);
94 void _run();
f7363af1
ML
95};
96
e2cfc0ef
ML
97class LegacyOutput :
98 public Sink
99{
100public:
101 /* Create from libsigrok output object */
102 static Glib::RefPtr<LegacyOutput> create(
726122c2
ML
103 shared_ptr<sigrok::OutputFormat> libsigrok_output_format,
104 shared_ptr<sigrok::Device> libsigrok_device,
105 map<string, Glib::VariantBase> options = map<string, Glib::VariantBase>());
e2cfc0ef 106
726122c2
ML
107 /* Override start */
108 bool start_vfunc();
e2cfc0ef
ML
109
110 /* Override render */
111 Gst::FlowReturn render_vfunc(const Glib::RefPtr<Gst::Buffer> &buffer);
112
113 /* Override stop */
114 bool stop_vfunc();
115
116 /* Gst class init */
117 static void class_init(Gst::ElementClass<LegacyOutput> *klass);
118
119 /* Register class with plugin */
120 static bool register_element(Glib::RefPtr<Gst::Plugin> plugin);
121
122 /* Constructor used by element factory */
123 explicit LegacyOutput(GstBaseSink *gobj);
124private:
726122c2
ML
125 shared_ptr<sigrok::OutputFormat> _libsigrok_output_format;
126 shared_ptr<sigrok::Device> _libsigrok_device;
e2cfc0ef 127 shared_ptr<sigrok::Output> _libsigrok_output;
726122c2 128 map<string, Glib::VariantBase> _options;
e2cfc0ef
ML
129};
130
f7363af1
ML
131
132}
572e76fe 133#endif