input: provide accessor routine for (struct sr_input *)->module

Add a public API routine which allows applications to query the
sr_input_module from an sr_input.
This commit is contained in:
Gerhard Sittig 2018-05-13 08:54:48 +02:00 committed by Uwe Hermann
parent 83df004be1
commit c83bdde9da
2 changed files with 17 additions and 0 deletions

View File

@ -170,6 +170,7 @@ SR_API struct sr_input *sr_input_new(const struct sr_input_module *imod,
GHashTable *options);
SR_API int sr_input_scan_buffer(GString *buf, const struct sr_input **in);
SR_API int sr_input_scan_file(const char *filename, const struct sr_input **in);
SR_API const struct sr_input_module *sr_input_module_get(const struct sr_input *in);
SR_API struct sr_dev_inst *sr_input_dev_inst_get(const struct sr_input *in);
SR_API int sr_input_send(const struct sr_input *in, GString *buf);
SR_API int sr_input_end(const struct sr_input *in);

View File

@ -532,6 +532,22 @@ SR_API int sr_input_scan_file(const char *filename, const struct sr_input **in)
return SR_ERR;
}
/**
* Return the input instance's module "class". This can be used to find out
* which input module handles a specific input file. This is especially
* useful when an application did not create the input stream by specifying
* an input module, but instead some shortcut or convenience wrapper did.
*
* @since 0.6.0
*/
SR_API const struct sr_input_module *sr_input_module_get(const struct sr_input *in)
{
if (!in)
return NULL;
return in->module;
}
/**
* Return the input instance's (virtual) device instance. This can be
* used to find out the number of channels and other information.