]> sigrok.org Git - libsigrokflow.git/blobdiff - include/libsigrokflow/libsigrokflow.hpp
Add missing copyright lines.
[libsigrokflow.git] / include / libsigrokflow / libsigrokflow.hpp
index e800be0d45cc38248fc55fd8a0ae92d3195b096a..cbae5c7e1adc371d7d5e57749b882e5114d900c7 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
 #define LIBSIGROKFLOW_LIBSIGROKFLOW_HPP
 
 #include <gstreamermm.h>
+#include <gstreamermm/private/element_p.h>
+#include <gstreamermm/private/basesink_p.h>
 #include <libsigrokcxx/libsigrokcxx.hpp>
+#include <libsigrokdecode/libsigrokdecode.h>
 
 namespace Srf
 {
@@ -35,40 +39,53 @@ class Block
         /* Config API etc goes here */
 };
 
-class GstBlock :
-        public Gst::Element
+class Sink :
+        public Gst::BaseSink
 {
-        /* Operations specific to sigrok GStreamer blocks go here. */
+protected:
+        explicit Sink(GstBaseSink *gobj);
 };
 
 class Device :
-        public GstBlock
+        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 :
-        CaptureDevice();
+protected:
+        explicit CaptureDevice(GstElement *gobj);
 };
 
 class LegacyCaptureDevice :
         public CaptureDevice
 {
 public:
-        /* Construct from libsigrok device object */
-        LegacyCaptureDevice(shared_ptr<sigrok::HardwareDevice>);
+        /* 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> _device;
+        shared_ptr<sigrok::HardwareDevice> _libsigrok_device;
         Glib::RefPtr<Gst::Pad> _src_pad;
         Glib::Threads::RecMutex _mutex;
         Glib::RefPtr<Gst::Task> _task;
@@ -79,6 +96,72 @@ private:
         void _run();
 };
 
+class LegacyOutput :
+        public Sink
+{
+public:
+        /* Create from libsigrok output object */
+        static Glib::RefPtr<LegacyOutput> create(
+                shared_ptr<sigrok::OutputFormat> libsigrok_output_format,
+                shared_ptr<sigrok::Device> libsigrok_device,
+                map<string, Glib::VariantBase> options = map<string, Glib::VariantBase>());
+
+        /* Override start */
+        bool start_vfunc();
+
+        /* 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::OutputFormat> _libsigrok_output_format;
+        shared_ptr<sigrok::Device> _libsigrok_device;
+        shared_ptr<sigrok::Output> _libsigrok_output;
+        map<string, Glib::VariantBase> _options;
+};
+
+class LegacyDecoder :
+        public Sink
+{
+public:
+        static Glib::RefPtr<LegacyDecoder> create(
+                struct srd_session *libsigrokdecode_session, uint64_t unitsize);
+
+        /* Retrieve libsigrokdecode session */
+        struct srd_session *libsigrokdecode_session();
+
+        /* Override start */
+        bool start_vfunc();
+
+        /* 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<LegacyDecoder> *klass);
+
+        /* Register class with plugin */
+        static bool register_element(Glib::RefPtr<Gst::Plugin> plugin);
+
+        /* Constructor used by element factory */
+        explicit LegacyDecoder(GstBaseSink *gobj);
+private:
+        struct srd_session *_session;
+        uint64_t _abs_ss;
+        uint64_t _unitsize;
+};
 
 }
 #endif