mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-25 22:55:56 -05:00
[input] Add interface for getting metadata from input modules
This commit is contained in:
parent
2696b27972
commit
7b6a7b65b3
42
src/input.c
42
src/input.c
@ -463,6 +463,48 @@ input_flush(short *flags)
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
input_metadata_get(struct input_metadata *metadata, struct player_source *ps, int startup)
|
||||
{
|
||||
int type;
|
||||
|
||||
if (!metadata || !ps || !ps->stream_start || !ps->output_start)
|
||||
{
|
||||
DPRINTF(E_LOG, L_PLAYER, "Bug! Unhandled case in input_metadata_get()\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(metadata, 0, sizeof(struct input_metadata));
|
||||
|
||||
metadata->item_id = ps->item_id;
|
||||
|
||||
metadata->startup = startup;
|
||||
metadata->offset = ps->output_start - ps->stream_start;
|
||||
metadata->rtptime = ps->stream_start;
|
||||
|
||||
// Note that the source may overwrite the above progress metadata
|
||||
type = source_check_and_map(ps, "metadata_get", 1);
|
||||
if ((type < 0) || (inputs[type]->disabled))
|
||||
return -1;
|
||||
|
||||
if (!inputs[type]->metadata_get)
|
||||
return 0;
|
||||
|
||||
return inputs[type]->metadata_get(metadata, ps);
|
||||
}
|
||||
|
||||
void
|
||||
input_metadata_free(struct input_metadata *metadata, int content_only)
|
||||
{
|
||||
free(metadata->artist);
|
||||
free(metadata->title);
|
||||
free(metadata->album);
|
||||
free(metadata->artwork_url);
|
||||
|
||||
if (!content_only)
|
||||
free(metadata);
|
||||
}
|
||||
|
||||
int
|
||||
input_init(void)
|
||||
{
|
||||
|
30
src/input.h
30
src/input.h
@ -73,6 +73,21 @@ struct player_source
|
||||
|
||||
typedef int (*input_cb)(void);
|
||||
|
||||
struct input_metadata
|
||||
{
|
||||
uint32_t item_id;
|
||||
|
||||
int startup;
|
||||
|
||||
uint64_t rtptime;
|
||||
uint64_t offset;
|
||||
|
||||
char *artist;
|
||||
char *title;
|
||||
char *album;
|
||||
char *artwork_url;
|
||||
};
|
||||
|
||||
struct input_definition
|
||||
{
|
||||
// Name of the input
|
||||
@ -96,6 +111,9 @@ struct input_definition
|
||||
// Changes the playback position
|
||||
int (*seek)(struct player_source *ps, int seek_ms);
|
||||
|
||||
// Return metadata
|
||||
int (*metadata_get)(struct input_metadata *metadata, struct player_source *ps);
|
||||
|
||||
// Initialization function called during startup
|
||||
int (*init)(void);
|
||||
|
||||
@ -192,6 +210,18 @@ input_seek(struct player_source *ps, int seek_ms);
|
||||
void
|
||||
input_flush(short *flags);
|
||||
|
||||
/*
|
||||
* Gets metadata from the input, returns 0 if metadata is set, otherwise -1
|
||||
*/
|
||||
int
|
||||
input_metadata_get(struct input_metadata *metadata, struct player_source *ps, int startup);
|
||||
|
||||
/*
|
||||
* Free the entire struct
|
||||
*/
|
||||
void
|
||||
input_metadata_free(struct input_metadata *metadata, int content_only);
|
||||
|
||||
/*
|
||||
* Called by player_init (so will run in main thread)
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user