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);
/* 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;
};
}
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);
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;