]> sigrok.org Git - libsigrokflow.git/blobdiff - include/libsigrokflow/libsigrokflow.hpp
Check for the (optional) libsigrokcxx dependency.
[libsigrokflow.git] / include / libsigrokflow / libsigrokflow.hpp
index abde3756255a0519277ac7f071a3947337e5bce5..ee71487cf3d1c638b7e9d4b4a64a95bc7921336d 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * This file is part of the libsigrokflow project.
  *
+ * Copyright (C) 2018 Martin Ling <martin-sigrok@earth.li>
  * Copyright (C) 2018 Uwe Hermann <uwe@hermann-uwe.de>
  *
  * This program is free software: you can redistribute it and/or modify
@@ -23,7 +24,9 @@
 #include <gstreamermm.h>
 #include <gstreamermm/private/element_p.h>
 #include <gstreamermm/private/basesink_p.h>
+#ifdef HAVE_LIBSIGROKCXX
 #include <libsigrokcxx/libsigrokcxx.hpp>
+#endif
 #include <libsigrokdecode/libsigrokdecode.h>
 
 namespace Srf
@@ -61,6 +64,7 @@ protected:
         explicit CaptureDevice(GstElement *gobj);
 };
 
+#ifdef HAVE_LIBSIGROKCXX
 class LegacyCaptureDevice :
         public CaptureDevice
 {
@@ -95,6 +99,45 @@ private:
         void _run();
 };
 
+class LegacyInput :
+        public Gst::Element
+{
+public:
+        /* Create from libsigrok input */
+        static Glib::RefPtr<LegacyInput> create(
+                shared_ptr<sigrok::InputFormat> format,
+                map<string, Glib::VariantBase> options = map<string, Glib::VariantBase>());
+
+        /* Override start */
+        bool start_vfunc();
+
+        /* Chain function */
+        Gst::FlowReturn chain(const Glib::RefPtr<Gst::Pad> &pad,
+                        const Glib::RefPtr<Gst::Buffer> &buf);
+
+        /* Override stop */
+        bool stop_vfunc();
+
+        /* Gst class init */
+        static void class_init(Gst::ElementClass<LegacyInput> *klass);
+
+        /* Register class with plugin */
+        static bool register_element(Glib::RefPtr<Gst::Plugin> plugin);
+
+        /* Construcor used by element factory */
+        explicit LegacyInput(GstElement *gobj);
+private:
+        shared_ptr<sigrok::InputFormat> _libsigrok_input_format;
+        shared_ptr<sigrok::Input> _libsigrok_input;
+        shared_ptr<sigrok::Session> _session;
+        map<string, Glib::VariantBase> _options;
+        Glib::RefPtr<Gst::Pad> _sink_pad;
+        Glib::RefPtr<Gst::Pad> _src_pad;
+
+        void _datafeed_callback(shared_ptr<sigrok::Device> device,
+                        shared_ptr<sigrok::Packet> packet);
+};
+
 class LegacyOutput :
         public Sink
 {
@@ -128,6 +171,7 @@ private:
         shared_ptr<sigrok::Output> _libsigrok_output;
         map<string, Glib::VariantBase> _options;
 };
+#endif
 
 class LegacyDecoder :
         public Sink