mirror of
https://github.com/owntone/owntone-server.git
synced 2025-11-11 22:40:17 -05:00
[misc/player] Introduce output ability to announce supported formats
Also introduce default output format and selected device format, should the user want another format. As part of this, change enum player_format in player.h to enum media_format in misc.h so that it is akin to struct media_quality. Modify json API to support this.
This commit is contained in:
@@ -3737,6 +3737,7 @@ airplay_device_cb(const char *name, const char *type, const char *domain, const
|
||||
rd->type = OUTPUT_TYPE_AIRPLAY;
|
||||
rd->type_name = outputs_name(rd->type);
|
||||
rd->extra_device_info = re;
|
||||
rd->supported_formats = MEDIA_FORMAT_ALAC;
|
||||
|
||||
if (port < 0)
|
||||
{
|
||||
|
||||
@@ -1374,6 +1374,7 @@ alsa_device_add(cfg_t* cfg_audio, int id)
|
||||
device->type = OUTPUT_TYPE_ALSA;
|
||||
device->type_name = outputs_name(device->type);
|
||||
device->extra_device_info = ae;
|
||||
device->supported_formats = MEDIA_FORMAT_PCM;
|
||||
|
||||
// The audio section will have no title, so there we get the value from the
|
||||
// "card" option
|
||||
|
||||
@@ -1778,6 +1778,7 @@ cast_device_cb(const char *name, const char *type, const char *domain, const cha
|
||||
device->name = strdup(name);
|
||||
device->type = OUTPUT_TYPE_CAST;
|
||||
device->type_name = outputs_name(device->type);
|
||||
device->supported_formats = MEDIA_FORMAT_OPUS;
|
||||
|
||||
if (port < 0)
|
||||
{
|
||||
|
||||
@@ -491,6 +491,7 @@ fifo_init(void)
|
||||
device->type_name = outputs_name(device->type);
|
||||
device->has_video = 0;
|
||||
device->extra_device_info = path;
|
||||
device->supported_formats = MEDIA_FORMAT_PCM;
|
||||
DPRINTF(E_INFO, L_FIFO, "Adding fifo output device '%s' with path '%s'\n", nickname, path);
|
||||
|
||||
player_device_add(device);
|
||||
|
||||
@@ -436,6 +436,7 @@ sinklist_cb(pa_context *ctx, const pa_sink_info *info, int eol, void *userdata)
|
||||
device->type = OUTPUT_TYPE_PULSE;
|
||||
device->type_name = outputs_name(device->type);
|
||||
device->extra_device_info = strdup(info->name);
|
||||
device->supported_formats = MEDIA_FORMAT_PCM;
|
||||
|
||||
player_device_add(device);
|
||||
}
|
||||
|
||||
@@ -4230,6 +4230,7 @@ raop_device_cb(const char *name, const char *type, const char *domain, const cha
|
||||
rd->type = OUTPUT_TYPE_RAOP;
|
||||
rd->type_name = outputs_name(rd->type);
|
||||
rd->extra_device_info = re;
|
||||
rd->supported_formats = MEDIA_FORMAT_ALAC;
|
||||
|
||||
if (port < 0)
|
||||
{
|
||||
|
||||
@@ -1295,6 +1295,8 @@ rcp_mdns_device_cb(const char *name, const char *type, const char *domain, const
|
||||
device->name = strdup(name);
|
||||
device->type = OUTPUT_TYPE_RCP;
|
||||
device->type_name = outputs_name(device->type);
|
||||
device->default_format = MEDIA_FORMAT_WAV;
|
||||
device->supported_formats = MEDIA_FORMAT_WAV | MEDIA_FORMAT_MP3 | MEDIA_FORMAT_ALAC;
|
||||
|
||||
if (port < 0 || !address)
|
||||
{
|
||||
|
||||
@@ -65,7 +65,7 @@ struct streaming_wanted
|
||||
struct pipepair audio[WANTED_PIPES_MAX];
|
||||
struct pipepair metadata[WANTED_PIPES_MAX];
|
||||
|
||||
enum player_format format;
|
||||
enum media_format format;
|
||||
struct media_quality quality;
|
||||
|
||||
struct evbuffer *audio_in;
|
||||
@@ -113,7 +113,7 @@ extern struct event_base *evbase_player;
|
||||
/* ------------------------------- Helpers ---------------------------------- */
|
||||
|
||||
static struct encode_ctx *
|
||||
encoder_setup(enum player_format format, struct media_quality *quality)
|
||||
encoder_setup(enum media_format format, struct media_quality *quality)
|
||||
{
|
||||
struct transcode_encode_setup_args encode_args = { .profile = XCODE_MP3, .quality = quality };
|
||||
struct encode_ctx *encode_ctx = NULL;
|
||||
@@ -132,7 +132,7 @@ encoder_setup(enum player_format format, struct media_quality *quality)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (format == PLAYER_FORMAT_MP3)
|
||||
if (format == MEDIA_FORMAT_MP3)
|
||||
encode_ctx = transcode_encode_setup(encode_args);
|
||||
|
||||
if (!encode_ctx)
|
||||
@@ -217,7 +217,7 @@ pipe_index_find_byreadfd(struct pipepair *p, int readfd)
|
||||
}
|
||||
|
||||
static struct streaming_wanted *
|
||||
wanted_new(enum player_format format, struct media_quality quality)
|
||||
wanted_new(enum media_format format, struct media_quality quality)
|
||||
{
|
||||
struct streaming_wanted *w;
|
||||
|
||||
@@ -277,7 +277,7 @@ wanted_remove(struct streaming_wanted **wanted, struct streaming_wanted *remove)
|
||||
}
|
||||
|
||||
static struct streaming_wanted *
|
||||
wanted_add(struct streaming_wanted **wanted, enum player_format format, struct media_quality quality)
|
||||
wanted_add(struct streaming_wanted **wanted, enum media_format format, struct media_quality quality)
|
||||
{
|
||||
struct streaming_wanted *w;
|
||||
|
||||
@@ -289,7 +289,7 @@ wanted_add(struct streaming_wanted **wanted, enum player_format format, struct m
|
||||
}
|
||||
|
||||
static struct streaming_wanted *
|
||||
wanted_find_byformat(struct streaming_wanted *wanted, enum player_format format, struct media_quality quality)
|
||||
wanted_find_byformat(struct streaming_wanted *wanted, enum media_format format, struct media_quality quality)
|
||||
{
|
||||
struct streaming_wanted *w;
|
||||
|
||||
@@ -623,9 +623,9 @@ streaming_start(struct output_device *device, int callback_id)
|
||||
int ret;
|
||||
|
||||
pthread_mutex_lock(&streaming_wanted_lck);
|
||||
w = wanted_find_byformat(streaming.wanted, device->format, device->quality);
|
||||
w = wanted_find_byformat(streaming.wanted, device->selected_format, device->quality);
|
||||
if (!w)
|
||||
w = wanted_add(&streaming.wanted, device->format, device->quality);
|
||||
w = wanted_add(&streaming.wanted, device->selected_format, device->quality);
|
||||
ret = wanted_session_add(&device->audio_fd, &device->metadata_fd, w);
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
|
||||
Reference in New Issue
Block a user