X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=include%2Flibsigrokflow%2Flibsigrokflow.hpp;h=8f188248749e6bcf6693d22b5409650349e872c9;hb=fce9342ebac11cc96e702d74c82f3455469ce8fb;hp=e800be0d45cc38248fc55fd8a0ae92d3195b096a;hpb=d03b3a9898b6da83867b27ab76261fbecdcb54e3;p=libsigrokflow.git diff --git a/include/libsigrokflow/libsigrokflow.hpp b/include/libsigrokflow/libsigrokflow.hpp index e800be0..8f18824 100644 --- a/include/libsigrokflow/libsigrokflow.hpp +++ b/include/libsigrokflow/libsigrokflow.hpp @@ -1,6 +1,7 @@ /* * This file is part of the libsigrokflow project. * + * Copyright (C) 2018 Martin Ling * Copyright (C) 2018 Uwe Hermann * * This program is free software: you can redistribute it and/or modify @@ -20,8 +21,19 @@ #ifndef LIBSIGROKFLOW_LIBSIGROKFLOW_HPP #define LIBSIGROKFLOW_LIBSIGROKFLOW_HPP +/* Temporary workaround, will be dropped later. */ +#define HAVE_LIBSIGROKCXX 1 +#define HAVE_LIBSIGROKDECODE 1 + #include +#include +#include +#ifdef HAVE_LIBSIGROKCXX #include +#endif +#ifdef HAVE_LIBSIGROKDECODE +#include +#endif namespace Srf { @@ -30,55 +42,180 @@ using namespace std; void init(); +void deinit(); + class Block { - /* Config API etc goes here */ + /* 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 */ + /* Operations specific to hardware devices go here. */ +protected: + explicit Device(GstElement *gobj); }; class CaptureDevice : - public Device + public Device { - /* Operations specific to capture (source) devices go here */ -protected : - CaptureDevice(); + /* Operations specific to capture (source) devices go here. */ +protected: + explicit CaptureDevice(GstElement *gobj); }; +#ifdef HAVE_LIBSIGROKCXX class LegacyCaptureDevice : - public CaptureDevice + public CaptureDevice +{ +public: + /* Create from libsigrok device object. */ + static Glib::RefPtr create( + shared_ptr libsigrok_device); + + /* Retrieve libsigrok device object. */ + shared_ptr libsigrok_device(); + + /* Override state change. */ + Gst::StateChangeReturn change_state_vfunc(Gst::StateChange transition) override; + + /* Gst class init. */ + static void class_init(Gst::ElementClass *klass); + + /* Register class with plugin. */ + static bool register_element(Glib::RefPtr plugin); + + /* Constructor used by element factory. */ + explicit LegacyCaptureDevice(GstElement *gobj); + +private: + shared_ptr libsigrok_device_; + Glib::RefPtr src_pad_; + Glib::Threads::RecMutex mutex_; + Glib::RefPtr task_; + shared_ptr session_; + + void datafeed_callback(shared_ptr device, + shared_ptr packet); + void run(); +}; + +class LegacyInput : + public Gst::Element { public: - /* Construct from libsigrok device object */ - LegacyCaptureDevice(shared_ptr); + /* Create from libsigrok input. */ + static Glib::RefPtr create( + shared_ptr format, + map options = map()); + + /* Chain function (not an override). */ + Gst::FlowReturn chain(const Glib::RefPtr &pad, + const Glib::RefPtr &buf); + + /* Event function (not an override). */ + bool event(const Glib::RefPtr &pad, + Glib::RefPtr &event); - /* Retrieve libsigrok device object */ - shared_ptr libsigrok_device(); + /* Gst class init. */ + static void class_init(Gst::ElementClass *klass); + + /* Register class with plugin. */ + static bool register_element(Glib::RefPtr plugin); + + /* Constructor used by element factory. */ + explicit LegacyInput(GstElement *gobj); - /* Override state change */ - Gst::StateChangeReturn change_state_vfunc(Gst::StateChange transition); private: - shared_ptr _device; - Glib::RefPtr _src_pad; - Glib::Threads::RecMutex _mutex; - Glib::RefPtr _task; - shared_ptr _session; - - void _datafeed_callback(shared_ptr device, - shared_ptr packet); - void _run(); + shared_ptr libsigrok_input_format_; + shared_ptr libsigrok_input_; + shared_ptr session_; + map options_; + Glib::RefPtr sink_pad_; + Glib::RefPtr src_pad_; + + void datafeed_callback(shared_ptr device, + shared_ptr packet); }; +class LegacyOutput : + public Sink +{ +public: + /* Create from libsigrok output object. */ + static Glib::RefPtr create( + shared_ptr libsigrok_output_format, + map options = map()); + + /* Override start. */ + bool start_vfunc() override; + + /* Override render. */ + Gst::FlowReturn render_vfunc(const Glib::RefPtr &buffer) override; + + /* Override stop. */ + bool stop_vfunc() override; + + /* Gst class init. */ + static void class_init(Gst::ElementClass *klass); + + /* Register class with plugin. */ + static bool register_element(Glib::RefPtr plugin); + + /* Constructor used by element factory. */ + explicit LegacyOutput(GstBaseSink *gobj); + +private: + shared_ptr libsigrok_output_format_; + shared_ptr libsigrok_device_; + shared_ptr libsigrok_output_; + map options_; +}; +#endif + +#ifdef HAVE_LIBSIGROKDECODE +class LegacyDecoder : + public Sink +{ +public: + static Glib::RefPtr create( + struct srd_session *libsigrokdecode_session, uint64_t unitsize); + + /* Retrieve libsigrokdecode session. */ + struct srd_session *libsigrokdecode_session(); + + /* Override start. */ + bool start_vfunc() override; + + /* Override render. */ + Gst::FlowReturn render_vfunc(const Glib::RefPtr &buffer) override; + + /* Override stop. */ + bool stop_vfunc() override; + + /* Gst class init. */ + static void class_init(Gst::ElementClass *klass); + + /* Register class with plugin. */ + static bool register_element(Glib::RefPtr plugin); + + /* Constructor used by element factory. */ + explicit LegacyDecoder(GstBaseSink *gobj); + +private: + struct srd_session *session_; + uint64_t abs_ss_; + uint64_t unitsite_; +}; +#endif } #endif