]> sigrok.org Git - libsigrokflow.git/blobdiff - include/libsigrokflow/libsigrokflow.hpp
Implement LegacyOutput.
[libsigrokflow.git] / include / libsigrokflow / libsigrokflow.hpp
index 381c46bbbf4783aefa64efa290eb1c5c31776fe1..e9a725ec431bc9ce8eaaacd945d86ba5d23de6b0 100644 (file)
 #ifndef LIBSIGROKFLOW_LIBSIGROKFLOW_HPP
 #define LIBSIGROKFLOW_LIBSIGROKFLOW_HPP
 
+#include <gstreamermm.h>
+#include <gstreamermm/private/element_p.h>
+#include <gstreamermm/private/basesink_p.h>
+#include <libsigrokcxx/libsigrokcxx.hpp>
+
 namespace Srf
 {
 
+using namespace std;
+
 void init();
 
-}
+class Block
+{
+        /* Config API etc goes here */
+};
+
+class Sink :
+        public Gst::BaseSink
+{
+protected:
+        explicit Sink(GstBaseSink *gobj);
+};
+
+class Device :
+        public Gst::Element
+{
+        /* Operations specific to hardware devices go here */
+protected:
+        explicit Device(GstElement *gobj);
+};
+
+class CaptureDevice :
+        public Device
+{
+        /* Operations specific to capture (source) devices go here */
+protected:
+        explicit CaptureDevice(GstElement *gobj);
+};
+
+class LegacyCaptureDevice :
+        public CaptureDevice
+{
+public:
+        /* Create from libsigrok device object */
+        static Glib::RefPtr<LegacyCaptureDevice> create(
+                shared_ptr<sigrok::HardwareDevice> libsigrok_device);
+
+        /* Retrieve libsigrok device object */
+        shared_ptr<sigrok::HardwareDevice> libsigrok_device();
+
+        /* Override state change */
+        Gst::StateChangeReturn change_state_vfunc(Gst::StateChange transition);
 
+        /* Gst class init */
+        static void class_init(Gst::ElementClass<LegacyCaptureDevice> *klass);
+
+        /* Register class with plugin */
+        static bool register_element(Glib::RefPtr<Gst::Plugin> plugin);
+
+        /* Construcor used by element factory */
+        explicit LegacyCaptureDevice(GstElement *gobj);
+private:
+        shared_ptr<sigrok::HardwareDevice> _libsigrok_device;
+        Glib::RefPtr<Gst::Pad> _src_pad;
+        Glib::Threads::RecMutex _mutex;
+        Glib::RefPtr<Gst::Task> _task;
+        shared_ptr<sigrok::Session> _session;
+
+        void _datafeed_callback(shared_ptr<sigrok::Device> device,
+                        shared_ptr<sigrok::Packet> packet);
+        void _run();
+};
+
+class LegacyOutput :
+        public Sink
+{
+public:
+        /* Create from libsigrok output object */
+        static Glib::RefPtr<LegacyOutput> create(
+                shared_ptr<sigrok::Output> libsigrok_output);
+
+        /* Retrieve libsigrok output object */
+        shared_ptr<sigrok::Output> libsigrok_output();
+
+        /* Override render */
+        Gst::FlowReturn render_vfunc(const Glib::RefPtr<Gst::Buffer> &buffer);
+
+        /* Override stop */
+        bool stop_vfunc();
+
+        /* Gst class init */
+        static void class_init(Gst::ElementClass<LegacyOutput> *klass);
+
+        /* Register class with plugin */
+        static bool register_element(Glib::RefPtr<Gst::Plugin> plugin);
+
+        /* Constructor used by element factory */
+        explicit LegacyOutput(GstBaseSink *gobj);
+private:
+        shared_ptr<sigrok::Output> _libsigrok_output;
+        Glib::RefPtr<Gst::Pad> _sink_pad;
+};
+
+
+}
 #endif