2 * This file is part of the libsigrok project.
4 * Copyright (C) 2013-2014 Martin Ling <martin-sigrok@earth.li>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "libsigrok/libsigrok.hpp"
25 /** Custom shared_ptr deleter for children owned by their parent object. */
26 template <class T> void reset_parent(T *child)
28 child->parent.reset();
31 /** Helper function to translate C errors to C++ exceptions. */
32 static void check(int result)
38 /** Helper function to obtain valid strings from possibly null input. */
39 static const char *valid_string(const char *input)
47 /** Helper function to convert between map<string, string> and GHashTable */
49 static GHashTable *map_to_hash(map<string, string> input)
51 auto output = g_hash_table_new_full(
52 g_str_hash, g_str_equal, g_free, g_free);
53 for (auto entry : input)
54 g_hash_table_insert(output,
55 g_strdup(entry.first.c_str()),
56 g_strdup(entry.second.c_str()));
60 Error::Error(int result) : result(result)
64 const char *Error::what() const throw()
66 return sr_strerror(result);
69 Error::~Error() throw()
73 shared_ptr<Context> Context::create()
75 return shared_ptr<Context>(new Context(), Context::Deleter());
81 check(sr_init(&structure));
82 struct sr_dev_driver **driver_list = sr_driver_list();
84 for (int i = 0; driver_list[i]; i++)
85 drivers[driver_list[i]->name] =
86 new Driver(driver_list[i]);
87 struct sr_input_format **input_list = sr_input_list();
89 for (int i = 0; input_list[i]; i++)
90 input_formats[input_list[i]->id] =
91 new InputFormat(input_list[i]);
92 struct sr_output_format **output_list = sr_output_list();
94 for (int i = 0; output_list[i]; i++)
95 output_formats[output_list[i]->id] =
96 new OutputFormat(output_list[i]);
99 string Context::get_package_version()
101 return sr_package_version_string_get();
104 string Context::get_lib_version()
106 return sr_lib_version_string_get();
109 map<string, shared_ptr<Driver>> Context::get_drivers()
111 map<string, shared_ptr<Driver>> result;
112 for (auto entry: drivers)
114 auto name = entry.first;
115 auto driver = entry.second;
116 driver->parent = static_pointer_cast<Context>(shared_from_this());
117 result[name] = shared_ptr<Driver>(driver, reset_parent<Driver>);
122 map<string, shared_ptr<InputFormat>> Context::get_input_formats()
124 map<string, shared_ptr<InputFormat>> result;
125 for (auto entry: input_formats)
127 auto name = entry.first;
128 auto input_format = entry.second;
129 input_format->parent = static_pointer_cast<Context>(shared_from_this());
130 result[name] = shared_ptr<InputFormat>(input_format,
131 reset_parent<InputFormat>);
136 map<string, shared_ptr<OutputFormat>> Context::get_output_formats()
138 map<string, shared_ptr<OutputFormat>> result;
139 for (auto entry: output_formats)
141 auto name = entry.first;
142 auto output_format = entry.second;
143 output_format->parent = static_pointer_cast<Context>(shared_from_this());
144 result[name] = shared_ptr<OutputFormat>(output_format,
145 reset_parent<OutputFormat>);
152 for (auto entry : drivers)
154 for (auto entry : input_formats)
156 for (auto entry : output_formats)
158 check(sr_exit(structure));
161 const LogLevel *Context::get_log_level()
163 return LogLevel::get(sr_log_loglevel_get());
166 void Context::set_log_level(const LogLevel *level)
168 check(sr_log_loglevel_set(level->get_id()));
171 string Context::get_log_domain()
173 return valid_string(sr_log_logdomain_get());
176 void Context::set_log_domain(string value)
178 check(sr_log_logdomain_set(value.c_str()));
181 static int call_log_callback(void *cb_data, int loglevel, const char *format, va_list args)
184 va_copy(args_copy, args);
185 int length = vsnprintf(NULL, 0, format, args_copy);
187 char *buf = (char *) g_malloc(length + 1);
188 vsprintf(buf, format, args);
189 string message(buf, length);
192 LogCallbackFunction callback = *((LogCallbackFunction *) cb_data);
196 callback(LogLevel::get(loglevel), message);
206 void Context::set_log_callback(LogCallbackFunction callback)
208 log_callback = callback;
209 check(sr_log_callback_set(call_log_callback, &log_callback));
212 void Context::set_log_callback_default()
214 check(sr_log_callback_set_default());
215 log_callback = nullptr;
218 shared_ptr<Session> Context::create_session()
220 return shared_ptr<Session>(
221 new Session(shared_from_this()), Session::Deleter());
224 shared_ptr<Session> Context::load_session(string filename)
226 return shared_ptr<Session>(
227 new Session(shared_from_this(), filename), Session::Deleter());
230 shared_ptr<Trigger> Context::create_trigger(string name)
232 return shared_ptr<Trigger>(
233 new Trigger(shared_from_this(), name), Trigger::Deleter());
236 Driver::Driver(struct sr_dev_driver *structure) :
237 StructureWrapper<Context, struct sr_dev_driver>(structure),
244 for (auto device : devices)
248 string Driver::get_name()
250 return valid_string(structure->name);
253 string Driver::get_long_name()
255 return valid_string(structure->longname);
258 vector<shared_ptr<HardwareDevice>> Driver::scan(
259 map<const ConfigKey *, Glib::VariantBase> options)
261 /* Initialise the driver if not yet done. */
264 check(sr_driver_init(parent->structure, structure));
268 /* Clear all existing instances. */
269 for (auto device : devices)
273 /* Translate scan options to GSList of struct sr_config pointers. */
274 GSList *option_list = NULL;
275 for (auto entry : options)
277 auto key = entry.first;
278 auto value = entry.second;
279 auto config = g_new(struct sr_config, 1);
280 config->key = key->get_id();
281 config->data = value.gobj();
282 option_list = g_slist_append(option_list, config);
286 GSList *device_list = sr_driver_scan(structure, option_list);
288 /* Free option list. */
289 g_slist_free_full(option_list, g_free);
291 /* Create device objects. */
292 for (GSList *device = device_list; device; device = device->next)
294 auto sdi = (struct sr_dev_inst *) device->data;
295 devices.push_back(new HardwareDevice(this, sdi));
298 /* Free GSList returned from scan. */
299 g_slist_free(device_list);
301 /* Create list of shared pointers to device instances for return. */
302 vector<shared_ptr<HardwareDevice>> result;
303 for (auto device : devices)
305 device->parent = parent->shared_from_this();
306 result.push_back(shared_ptr<HardwareDevice>(device,
307 reset_parent<HardwareDevice>));
312 Configurable::Configurable(
313 struct sr_dev_driver *driver,
314 struct sr_dev_inst *sdi,
315 struct sr_channel_group *cg) :
316 config_driver(driver),
318 config_channel_group(cg)
322 Configurable::~Configurable()
326 Glib::VariantBase Configurable::config_get(const ConfigKey *key)
330 config_driver, config_sdi, config_channel_group,
331 key->get_id(), &data));
332 return Glib::VariantBase(data);
335 void Configurable::config_set(const ConfigKey *key, Glib::VariantBase value)
338 config_sdi, config_channel_group,
339 key->get_id(), value.gobj()));
342 Glib::VariantBase Configurable::config_list(const ConfigKey *key)
345 check(sr_config_list(
346 config_driver, config_sdi, config_channel_group,
347 key->get_id(), &data));
348 return Glib::VariantBase(data);
351 Device::Device(struct sr_dev_inst *structure) :
352 Configurable(structure->driver, structure, NULL),
353 StructureWrapper<Context, struct sr_dev_inst>(structure)
355 for (GSList *entry = structure->channels; entry; entry = entry->next)
357 auto channel = (struct sr_channel *) entry->data;
358 channels.push_back(new Channel(channel));
364 for (auto channel : channels)
368 string Device::get_vendor()
370 return valid_string(structure->vendor);
373 string Device::get_model()
375 return valid_string(structure->model);
378 string Device::get_version()
380 return valid_string(structure->version);
383 vector<shared_ptr<Channel>> Device::get_channels()
385 vector<shared_ptr<Channel>> result;
386 for (auto channel : channels)
388 channel->parent = static_pointer_cast<Device>(shared_from_this());
389 result.push_back(shared_ptr<Channel>(channel, reset_parent<Channel>));
396 check(sr_dev_open(structure));
401 check(sr_dev_close(structure));
404 HardwareDevice::HardwareDevice(Driver *driver, struct sr_dev_inst *structure) :
408 for (GSList *entry = structure->channel_groups; entry; entry = entry->next)
410 auto group = (struct sr_channel_group *) entry->data;
411 channel_groups[group->name] = new ChannelGroup(this, group);
415 HardwareDevice::~HardwareDevice()
417 for (auto entry : channel_groups)
421 shared_ptr<Driver> HardwareDevice::get_driver()
423 return static_pointer_cast<Driver>(driver->shared_from_this());
426 map<string, shared_ptr<ChannelGroup>>
427 HardwareDevice::get_channel_groups()
429 map<string, shared_ptr<ChannelGroup>> result;
430 for (auto entry: channel_groups)
432 auto name = entry.first;
433 auto channel_group = entry.second;
434 channel_group->parent =
435 static_pointer_cast<HardwareDevice>(shared_from_this());
436 result[name] = shared_ptr<ChannelGroup>(channel_group,
437 reset_parent<ChannelGroup>);
442 Channel::Channel(struct sr_channel *structure) :
443 StructureWrapper<Device, struct sr_channel>(structure),
444 type(ChannelType::get(structure->type))
452 string Channel::get_name()
454 return valid_string(structure->name);
457 void Channel::set_name(string name)
459 check(sr_dev_channel_name_set(parent->structure, structure->index, name.c_str()));
462 const ChannelType *Channel::get_type()
464 return ChannelType::get(structure->type);
467 bool Channel::get_enabled()
469 return structure->enabled;
472 void Channel::set_enabled(bool value)
474 check(sr_dev_channel_enable(parent->structure, structure->index, value));
477 ChannelGroup::ChannelGroup(HardwareDevice *device,
478 struct sr_channel_group *structure) :
479 StructureWrapper<HardwareDevice, struct sr_channel_group>(structure),
480 Configurable(device->structure->driver, device->structure, structure)
482 for (GSList *entry = structure->channels; entry; entry = entry->next)
484 auto channel = (struct sr_channel *) entry->data;
485 for (auto device_channel : device->channels)
486 if (channel == device_channel->structure)
487 channels.push_back(device_channel);
491 ChannelGroup::~ChannelGroup()
495 string ChannelGroup::get_name()
497 return valid_string(structure->name);
500 vector<shared_ptr<Channel>> ChannelGroup::get_channels()
502 vector<shared_ptr<Channel>> result;
503 for (auto channel : channels)
505 channel->parent = static_pointer_cast<Device>(parent->shared_from_this());
506 result.push_back(shared_ptr<Channel>(channel, reset_parent<Channel>));
511 Trigger::Trigger(shared_ptr<Context> context, string name) :
512 structure(sr_trigger_new(name.c_str())), context(context)
514 for (auto stage = structure->stages; stage; stage = stage->next)
515 stages.push_back(new TriggerStage((struct sr_trigger_stage *) stage->data));
520 for (auto stage: stages)
523 sr_trigger_free(structure);
526 string Trigger::get_name()
528 return structure->name;
531 vector<shared_ptr<TriggerStage>> Trigger::get_stages()
533 vector<shared_ptr<TriggerStage>> result;
534 for (auto stage : stages)
536 stage->parent = static_pointer_cast<Trigger>(shared_from_this());
537 result.push_back(shared_ptr<TriggerStage>(stage, reset_parent<TriggerStage>));
542 shared_ptr<TriggerStage> Trigger::add_stage()
544 auto stage = new TriggerStage(sr_trigger_stage_add(structure));
545 stages.push_back(stage);
546 stage->parent = static_pointer_cast<Trigger>(shared_from_this());
547 return shared_ptr<TriggerStage>(stage, reset_parent<TriggerStage>);
550 TriggerStage::TriggerStage(struct sr_trigger_stage *structure) :
551 StructureWrapper<Trigger, struct sr_trigger_stage>(structure)
555 TriggerStage::~TriggerStage()
557 for (auto match : matches)
561 int TriggerStage::get_number()
563 return structure->stage;
566 vector<shared_ptr<TriggerMatch>> TriggerStage::get_matches()
568 vector<shared_ptr<TriggerMatch>> result;
569 for (auto match : matches)
571 match->parent = static_pointer_cast<TriggerStage>(shared_from_this());
572 result.push_back(shared_ptr<TriggerMatch>(match, reset_parent<TriggerMatch>));
577 void TriggerStage::add_match(shared_ptr<Channel> channel, const TriggerMatchType *type, float value)
579 check(sr_trigger_match_add(structure, channel->structure, type->get_id(), value));
580 matches.push_back(new TriggerMatch(
581 (struct sr_trigger_match *) g_slist_last(structure->matches)->data, channel));
584 void TriggerStage::add_match(shared_ptr<Channel> channel, const TriggerMatchType *type)
586 add_match(channel, type, NAN);
589 TriggerMatch::TriggerMatch(struct sr_trigger_match *structure, shared_ptr<Channel> channel) :
590 StructureWrapper<TriggerStage, struct sr_trigger_match>(structure), channel(channel)
594 TriggerMatch::~TriggerMatch()
598 shared_ptr<Channel> TriggerMatch::get_channel()
603 const TriggerMatchType *TriggerMatch::get_type()
605 return TriggerMatchType::get(structure->match);
608 float TriggerMatch::get_value()
610 return structure->value;
613 DatafeedCallbackData::DatafeedCallbackData(Session *session,
614 DatafeedCallbackFunction callback) :
615 callback(callback), session(session)
619 void DatafeedCallbackData::run(const struct sr_dev_inst *sdi,
620 const struct sr_datafeed_packet *pkt)
622 auto device = session->devices[sdi];
623 auto packet = shared_ptr<Packet>(new Packet(pkt), Packet::Deleter());
624 callback(device, packet);
627 SourceCallbackData::SourceCallbackData(shared_ptr<EventSource> source) :
632 bool SourceCallbackData::run(int revents)
634 return source->callback((Glib::IOCondition) revents);
637 shared_ptr<EventSource> EventSource::create(int fd, Glib::IOCondition events,
638 int timeout, SourceCallbackFunction callback)
640 auto result = new EventSource(timeout, callback);
641 result->type = EventSource::SOURCE_FD;
643 result->events = events;
644 return shared_ptr<EventSource>(result, EventSource::Deleter());
647 shared_ptr<EventSource> EventSource::create(Glib::PollFD pollfd, int timeout,
648 SourceCallbackFunction callback)
650 auto result = new EventSource(timeout, callback);
651 result->type = EventSource::SOURCE_POLLFD;
652 result->pollfd = pollfd;
653 return shared_ptr<EventSource>(result, EventSource::Deleter());
656 shared_ptr<EventSource> EventSource::create(Glib::RefPtr<Glib::IOChannel> channel,
657 Glib::IOCondition events, int timeout, SourceCallbackFunction callback)
659 auto result = new EventSource(timeout, callback);
660 result->type = EventSource::SOURCE_IOCHANNEL;
661 result->channel = channel;
662 result->events = events;
663 return shared_ptr<EventSource>(result, EventSource::Deleter());
666 EventSource::EventSource(int timeout, SourceCallbackFunction callback) :
667 timeout(timeout), callback(callback)
671 EventSource::~EventSource()
675 Session::Session(shared_ptr<Context> context) :
676 context(context), saving(false)
678 check(sr_session_new(&structure));
679 context->session = this;
682 Session::Session(shared_ptr<Context> context, string filename) :
683 context(context), saving(false)
685 check(sr_session_load(filename.c_str(), &structure));
686 context->session = this;
691 check(sr_session_destroy(structure));
693 for (auto callback : datafeed_callbacks)
696 for (auto entry : source_callbacks)
700 void Session::add_device(shared_ptr<Device> device)
702 check(sr_session_dev_add(structure, device->structure));
703 devices[device->structure] = device;
706 vector<shared_ptr<Device>> Session::get_devices()
709 check(sr_session_dev_list(structure, &dev_list));
710 vector<shared_ptr<Device>> result;
711 for (GSList *dev = dev_list; dev; dev = dev->next)
713 auto sdi = (struct sr_dev_inst *) dev->data;
714 if (devices.count(sdi) == 0)
715 devices[sdi] = shared_ptr<Device>(
716 new Device(sdi), Device::Deleter());
717 result.push_back(devices[sdi]);
722 void Session::remove_devices()
725 check(sr_session_dev_remove_all(structure));
728 void Session::start()
730 check(sr_session_start(structure));
735 check(sr_session_run(structure));
740 check(sr_session_stop(structure));
743 void Session::begin_save(string filename)
746 save_initialized = false;
747 save_filename = filename;
751 void Session::append(shared_ptr<Device> device, shared_ptr<Packet> packet)
756 switch (packet->structure->type)
760 auto meta = (const struct sr_datafeed_meta *)
761 packet->structure->payload;
763 for (auto l = meta->config; l; l = l->next)
765 auto config = (struct sr_config *) l->data;
766 if (config->key == SR_CONF_SAMPLERATE)
767 save_samplerate = g_variant_get_uint64(config->data);
774 if (save_samplerate == 0)
776 GVariant *samplerate;
778 check(sr_config_get(device->structure->driver,
779 device->structure, NULL, SR_CONF_SAMPLERATE, &samplerate));
781 save_samplerate = g_variant_get_uint64(samplerate);
783 g_variant_unref(samplerate);
786 if (!save_initialized)
788 vector<shared_ptr<Channel>> save_channels;
790 for (auto channel : device->get_channels())
791 if (channel->structure->enabled &&
792 channel->structure->type == SR_CHANNEL_LOGIC)
793 save_channels.push_back(channel);
795 auto channels = g_new(char *, save_channels.size());
798 for (auto channel : save_channels)
799 channels[i++] = channel->structure->name;
802 int ret = sr_session_save_init(structure, save_filename.c_str(),
803 save_samplerate, channels);
810 save_initialized = true;
813 auto logic = (const struct sr_datafeed_logic *)
814 packet->structure->payload;
816 check(sr_session_append(structure, save_filename.c_str(),
817 (uint8_t *) logic->data, logic->unitsize,
818 logic->length / logic->unitsize));
823 static void datafeed_callback(const struct sr_dev_inst *sdi,
824 const struct sr_datafeed_packet *pkt, void *cb_data)
826 auto callback = static_cast<DatafeedCallbackData *>(cb_data);
827 callback->run(sdi, pkt);
830 void Session::add_datafeed_callback(DatafeedCallbackFunction callback)
832 auto cb_data = new DatafeedCallbackData(this, callback);
833 check(sr_session_datafeed_callback_add(structure, datafeed_callback, cb_data));
834 datafeed_callbacks.push_back(cb_data);
837 void Session::remove_datafeed_callbacks(void)
839 check(sr_session_datafeed_callback_remove_all(structure));
840 for (auto callback : datafeed_callbacks)
842 datafeed_callbacks.clear();
845 static int source_callback(int fd, int revents, void *cb_data)
848 auto callback = (SourceCallbackData *) cb_data;
849 return callback->run(revents);
852 void Session::add_source(shared_ptr<EventSource> source)
854 if (source_callbacks.count(source) == 1)
855 throw Error(SR_ERR_ARG);
857 auto cb_data = new SourceCallbackData(source);
859 switch (source->type)
861 case EventSource::SOURCE_FD:
862 check(sr_session_source_add(structure, source->fd, source->events,
863 source->timeout, source_callback, cb_data));
865 case EventSource::SOURCE_POLLFD:
866 check(sr_session_source_add_pollfd(structure,
867 source->pollfd.gobj(), source->timeout, source_callback,
870 case EventSource::SOURCE_IOCHANNEL:
871 check(sr_session_source_add_channel(structure,
872 source->channel->gobj(), source->events, source->timeout,
873 source_callback, cb_data));
877 source_callbacks[source] = cb_data;
880 void Session::remove_source(shared_ptr<EventSource> source)
882 if (source_callbacks.count(source) == 0)
883 throw Error(SR_ERR_ARG);
885 switch (source->type)
887 case EventSource::SOURCE_FD:
888 check(sr_session_source_remove(structure, source->fd));
890 case EventSource::SOURCE_POLLFD:
891 check(sr_session_source_remove_pollfd(structure,
892 source->pollfd.gobj()));
894 case EventSource::SOURCE_IOCHANNEL:
895 check(sr_session_source_remove_channel(structure,
896 source->channel->gobj()));
900 delete source_callbacks[source];
902 source_callbacks.erase(source);
905 shared_ptr<Trigger> Session::get_trigger()
910 void Session::set_trigger(shared_ptr<Trigger> trigger)
912 check(sr_session_trigger_set(structure, trigger->structure));
913 this->trigger = trigger;
916 Packet::Packet(const struct sr_datafeed_packet *structure) :
919 switch (structure->type)
923 static_cast<const struct sr_datafeed_logic *>(
924 structure->payload));
927 payload = new Analog(
928 static_cast<const struct sr_datafeed_analog *>(
929 structure->payload));
942 PacketPayload *Packet::get_payload()
947 PacketPayload::PacketPayload()
951 PacketPayload::~PacketPayload()
955 Logic::Logic(const struct sr_datafeed_logic *structure) : PacketPayload(),
956 structure(structure),
957 data(static_cast<uint8_t *>(structure->data),
958 static_cast<uint8_t *>(structure->data) + structure->length) {}
964 void *Logic::get_data()
966 return structure->data;
969 size_t Logic::get_data_size()
971 return structure->length;
974 Analog::Analog(const struct sr_datafeed_analog *structure) :
984 void *Analog::get_data()
986 return structure->data;
989 size_t Analog::get_data_size()
991 return structure->num_samples * sizeof(float);
994 unsigned int Analog::get_num_samples()
996 return structure->num_samples;
999 const Quantity *Analog::get_mq()
1001 return Quantity::get(structure->mq);
1004 const Unit *Analog::get_unit()
1006 return Unit::get(structure->unit);
1009 vector<const QuantityFlag *> Analog::get_mq_flags()
1011 return QuantityFlag::flags_from_mask(structure->mqflags);
1014 InputFormat::InputFormat(struct sr_input_format *structure) :
1015 StructureWrapper<Context, struct sr_input_format>(structure)
1019 InputFormat::~InputFormat()
1023 string InputFormat::get_name()
1025 return valid_string(structure->id);
1028 string InputFormat::get_description()
1030 return valid_string(structure->description);
1033 bool InputFormat::format_match(string filename)
1035 return structure->format_match(filename.c_str());
1038 shared_ptr<InputFileDevice> InputFormat::open_file(string filename,
1039 map<string, string> options)
1041 auto input = g_new(struct sr_input, 1);
1042 input->param = map_to_hash(options);
1044 /** Run initialisation. */
1045 check(structure->init(input, filename.c_str()));
1047 /** Create virtual device. */
1048 return shared_ptr<InputFileDevice>(new InputFileDevice(
1049 static_pointer_cast<InputFormat>(shared_from_this()), input, filename),
1050 InputFileDevice::Deleter());
1053 InputFileDevice::InputFileDevice(shared_ptr<InputFormat> format,
1054 struct sr_input *input, string filename) :
1062 InputFileDevice::~InputFileDevice()
1064 g_hash_table_unref(input->param);
1068 void InputFileDevice::load()
1070 check(format->structure->loadfile(input, filename.c_str()));
1073 OutputFormat::OutputFormat(struct sr_output_format *structure) :
1074 StructureWrapper<Context, struct sr_output_format>(structure)
1078 OutputFormat::~OutputFormat()
1082 string OutputFormat::get_name()
1084 return valid_string(structure->id);
1087 string OutputFormat::get_description()
1089 return valid_string(structure->description);
1092 shared_ptr<Output> OutputFormat::create_output(
1093 shared_ptr<Device> device, map<string, string> options)
1095 return shared_ptr<Output>(
1097 static_pointer_cast<OutputFormat>(shared_from_this()),
1102 Output::Output(shared_ptr<OutputFormat> format,
1103 shared_ptr<Device> device, map<string, string> options) :
1104 structure(sr_output_new(format->structure,
1105 map_to_hash(options), device->structure)),
1106 format(format), device(device), options(options)
1112 g_hash_table_unref(structure->params);
1113 check(sr_output_free(structure));
1116 string Output::receive(shared_ptr<Packet> packet)
1119 check(sr_output_send(structure, packet->structure, &out));
1122 auto result = string(out->str, out->str + out->len);
1123 g_string_free(out, true);
1132 #include "enums.cpp"