]> sigrok.org Git - libsigrokflow.git/commitdiff
Create LegacyOutput from format, device and options.
authorMartin Ling <redacted>
Sun, 30 Dec 2018 03:29:10 +0000 (04:29 +0100)
committerUwe Hermann <redacted>
Tue, 8 Jan 2019 18:41:58 +0000 (19:41 +0100)
include/libsigrokflow/libsigrokflow.hpp
src/main.cpp

index e9a725ec431bc9ce8eaaacd945d86ba5d23de6b0..59de83c6307d6c3802fe58c20c48e12988fb6b43 100644 (file)
@@ -100,10 +100,12 @@ class LegacyOutput :
 public:
         /* Create from libsigrok output object */
         static Glib::RefPtr<LegacyOutput> create(
-                shared_ptr<sigrok::Output> libsigrok_output);
+                shared_ptr<sigrok::OutputFormat> libsigrok_output_format,
+                shared_ptr<sigrok::Device> libsigrok_device,
+                map<string, Glib::VariantBase> options = map<string, Glib::VariantBase>());
 
-        /* Retrieve libsigrok output object */
-        shared_ptr<sigrok::Output> libsigrok_output();
+        /* Override start */
+        bool start_vfunc();
 
         /* Override render */
         Gst::FlowReturn render_vfunc(const Glib::RefPtr<Gst::Buffer> &buffer);
@@ -120,8 +122,10 @@ public:
         /* 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;
-        Glib::RefPtr<Gst::Pad> _sink_pad;
+        map<string, Glib::VariantBase> _options;
 };
 
 
index 10baaeced4e2db7f7e82cb25986f7f9d8e0bab3c..cd9c1347f761476e06961682f484c9f691fc2a9c 100644 (file)
@@ -185,26 +185,32 @@ LegacyOutput::LegacyOutput(GstBaseSink *gobj) :
 }
 
 Glib::RefPtr<LegacyOutput>LegacyOutput::create(
-       shared_ptr<sigrok::Output> libsigrok_output)
+       shared_ptr<sigrok::OutputFormat> libsigrok_output_format,
+       shared_ptr<sigrok::Device> libsigrok_device,
+       map<string, Glib::VariantBase> options)
 {
        auto element = Gst::ElementFactory::create_element("sigrok_legacy_output");
        if (!element)
                throw runtime_error("Failed to create element - plugin not registered?");
        auto output = Glib::RefPtr<LegacyOutput>::cast_static(element);
-       output->_libsigrok_output = libsigrok_output;
+       output->_libsigrok_output_format = libsigrok_output_format;
+       output->_libsigrok_device = libsigrok_device;
+       output->_options = options;
        return output;
 }
 
-shared_ptr<sigrok::Output> LegacyOutput::libsigrok_output()
+bool LegacyOutput::start_vfunc()
 {
-       return _libsigrok_output;
+       _libsigrok_output = _libsigrok_output_format->create_output(
+                       _libsigrok_device, _options);
+       return true;
 }
 
 Gst::FlowReturn LegacyOutput::render_vfunc(const Glib::RefPtr<Gst::Buffer> &buffer)
 {
        Gst::MapInfo info;
        buffer->map(info, Gst::MAP_READ);
-       auto context = _libsigrok_output->format()->parent();
+       auto context = _libsigrok_output_format->parent();
        auto packet = context->create_logic_packet(
                        info.get_data(), info.get_size(), 2);
        auto result = _libsigrok_output->receive(packet);
@@ -215,7 +221,7 @@ Gst::FlowReturn LegacyOutput::render_vfunc(const Glib::RefPtr<Gst::Buffer> &buff
 
 bool LegacyOutput::stop_vfunc()
 {
-       auto context = _libsigrok_output->format()->parent();
+       auto context = _libsigrok_output_format->parent();
        auto end_packet = context->create_end_packet();
        auto result = _libsigrok_output->receive(end_packet);
        cout << result;