]> sigrok.org Git - libsigrokflow.git/blobdiff - include/libsigrokflow/libsigrokflow.hpp
tests/init: Multiple Srf::init() calls should throw.
[libsigrokflow.git] / include / libsigrokflow / libsigrokflow.hpp
index abde3756255a0519277ac7f071a3947337e5bce5..c13e1c65203b96215e0a7c5c14ad740eff575311 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
 #ifndef LIBSIGROKFLOW_LIBSIGROKFLOW_HPP
 #define LIBSIGROKFLOW_LIBSIGROKFLOW_HPP
 
+/* Temporary workaround, will be dropped later. */
+#define HAVE_LIBSIGROKCXX 1
+#define HAVE_LIBSIGROKDECODE 1
+
 #include <gstreamermm.h>
 #include <gstreamermm/private/element_p.h>
 #include <gstreamermm/private/basesink_p.h>
+#ifdef HAVE_LIBSIGROKCXX
 #include <libsigrokcxx/libsigrokcxx.hpp>
+#endif
+#ifdef HAVE_LIBSIGROKDECODE
 #include <libsigrokdecode/libsigrokdecode.h>
+#endif
 
 namespace Srf
 {
@@ -61,6 +70,7 @@ protected:
         explicit CaptureDevice(GstElement *gobj);
 };
 
+#ifdef HAVE_LIBSIGROKCXX
 class LegacyCaptureDevice :
         public CaptureDevice
 {
@@ -95,6 +105,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,7 +177,9 @@ private:
         shared_ptr<sigrok::Output> _libsigrok_output;
         map<string, Glib::VariantBase> _options;
 };
+#endif
 
+#ifdef HAVE_LIBSIGROKDECODE
 class LegacyDecoder :
         public Sink
 {
@@ -161,6 +212,7 @@ private:
         uint64_t _abs_ss;
         uint64_t _unitsize;
 };
+#endif
 
 }
 #endif