Skip to content
13 changes: 1 addition & 12 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@

// For version strings of upnp and gstreamer
#include <upnpconfig.h>
#ifdef HAVE_GST
# include <gst/gst.h>
#endif

#include "git-version.h"
#include "logging.h"
Expand Down Expand Up @@ -133,18 +130,10 @@ static GOptionEntry option_entries[] = {

// Fill buffer with version information. Returns pointer to beginning of string.
static const char *GetVersionInfo(char *buffer, size_t len) {
#ifdef HAVE_GST
snprintf(buffer, len, "gmediarender %s "
"(libupnp-%s; glib-%d.%d.%d; gstreamer-%d.%d.%d)",
GM_COMPILE_VERSION, UPNP_VERSION_STRING,
GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION,
GST_VERSION_MAJOR, GST_VERSION_MINOR, GST_VERSION_MICRO);
#else
snprintf(buffer, len, "gmediarender %s "
"(libupnp-%s; glib-%d.%d.%d; without gstreamer.)",
"(libupnp-%s; glib-%d.%d.%d)",
GM_COMPILE_VERSION, UPNP_VERSION_STRING,
GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);
#endif
return buffer;
}

Expand Down
5 changes: 5 additions & 0 deletions src/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ void output_dump_modules(void)
modules->shortname,
modules->description,
(i==0) ? " (default)" : "");
if (module->version != NULL)
{
char buffer[64];
printf("\tversion: %s\n", module->version(buffer, sizeof(buffer)));
}
i = 1;
module = module->next;
}
Expand Down
10 changes: 10 additions & 0 deletions src/output_gstreamer.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,12 +577,22 @@ static int output_gstreamer_init(void)
return 0;
}

static const char *output_gstreamer_version(char *buffer, size_t len)
{
snprintf(buffer, len, "%s (glib-%d.%d.%d; gstreamer-%d.%d.%d)",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd be also fine if the module would return a statically allocated string. We could either have a static allocated buffer and snprintf() into it, or just assemble the stirng with macro tricks.

Providing less headache for the reader of the calling code is a good thing.

Also, it keeps our API interface lean. It is not that we have a heavy lifting function here that requires some external megabyte buffer to be filled, but something that for essentially all known implementation will return a static string in the first place.

PACKAGE_VERSION,
GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION,
GST_VERSION_MAJOR, GST_VERSION_MINOR, GST_VERSION_MICRO);
return buffer;
}

struct output_module gstreamer_output = {
.shortname = "gst",
.description = "GStreamer multimedia framework",
.add_options = output_gstreamer_add_options,

.init = output_gstreamer_init,
.version = output_gstreamer_version,
.set_uri = output_gstreamer_set_uri,
.set_next_uri= output_gstreamer_set_next_uri,
.play = output_gstreamer_play,
Expand Down
1 change: 1 addition & 0 deletions src/output_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct output_module {

// Commands.
int (*init)(void);
const char *(*version)(char *buffer, size_t len);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(here would be just a simpler const char *(*version)();)

void (*set_uri)(const char *uri, output_update_meta_cb_t meta_info);
void (*set_next_uri)(const char *uri);
int (*play)(output_transition_cb_t transition_callback);
Expand Down