X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=include%2Flibsigrokflow%2Flibsigrokflow.hpp;h=ee71487cf3d1c638b7e9d4b4a64a95bc7921336d;hb=1060e9b5f80cde2c6b6cb18ded1fdbe0862c7796;hp=a5fc25314c57c3d518852a3fa6d40f55793ff254;hpb=f7363af19dd8d9a0e07d1b315fe3a8392d7acf25;p=libsigrokflow.git diff --git a/include/libsigrokflow/libsigrokflow.hpp b/include/libsigrokflow/libsigrokflow.hpp index a5fc253..ee71487 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 @@ -21,7 +22,12 @@ #define LIBSIGROKFLOW_LIBSIGROKFLOW_HPP #include +#include +#include +#ifdef HAVE_LIBSIGROKCXX #include +#endif +#include namespace Srf { @@ -35,39 +41,170 @@ 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); }; +#ifdef HAVE_LIBSIGROKCXX class LegacyCaptureDevice : public CaptureDevice { public: - /* Construct from libsigrok device object */ - LegacyCaptureDevice(shared_ptr); + /* Create from libsigrok device object */ + static Glib::RefPtr create( + shared_ptr libsigrok_device); /* Retrieve libsigrok device object */ - shared_ptr libsigrok_device(); + shared_ptr libsigrok_device(); + + /* Override state change */ + Gst::StateChangeReturn change_state_vfunc(Gst::StateChange transition); + + /* Gst class init */ + static void class_init(Gst::ElementClass *klass); + + /* Register class with plugin */ + static bool register_element(Glib::RefPtr plugin); + + /* Construcor 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: + /* Create from libsigrok input */ + static Glib::RefPtr create( + shared_ptr format, + map options = map()); + + /* Override start */ + bool start_vfunc(); + + /* Chain function */ + Gst::FlowReturn chain(const Glib::RefPtr &pad, + const Glib::RefPtr &buf); + + /* Override stop */ + bool stop_vfunc(); + + /* Gst class init */ + static void class_init(Gst::ElementClass *klass); + + /* Register class with plugin */ + static bool register_element(Glib::RefPtr plugin); + + /* Construcor used by element factory */ + explicit LegacyInput(GstElement *gobj); +private: + 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, + shared_ptr libsigrok_device, + map options = map()); + + /* Override start */ + bool start_vfunc(); + + /* Override render */ + Gst::FlowReturn render_vfunc(const Glib::RefPtr &buffer); + + /* Override stop */ + bool stop_vfunc(); + + /* 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 _device; + shared_ptr _libsigrok_output_format; + shared_ptr _libsigrok_device; + shared_ptr _libsigrok_output; + map _options; }; +#endif +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 render */ + Gst::FlowReturn render_vfunc(const Glib::RefPtr &buffer); + + /* Override stop */ + bool stop_vfunc(); + + /* 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 _unitsize; +}; } #endif