2004-01-28 20:02:12 -05:00
|
|
|
/* Icecast
|
|
|
|
*
|
|
|
|
* This program is distributed under the GNU General Public License, version 2.
|
|
|
|
* A copy of this license is included with this source.
|
|
|
|
*
|
|
|
|
* Copyright 2000-2004, Jack Moffitt <jack@xiph.org,
|
|
|
|
* Michael Smith <msmith@xiph.org>,
|
|
|
|
* oddsock <oddsock@xiph.org>,
|
|
|
|
* Karl Heyes <karl@xiph.org>
|
|
|
|
* and others (see AUTHORS for details).
|
2022-03-01 06:17:28 -05:00
|
|
|
* Copyright 2012-2022, Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>,
|
2004-01-28 20:02:12 -05:00
|
|
|
*/
|
|
|
|
|
2001-09-09 22:21:46 -04:00
|
|
|
#ifndef __SOURCE_H__
|
|
|
|
#define __SOURCE_H__
|
|
|
|
|
2018-06-17 08:28:38 -04:00
|
|
|
#include <stdio.h>
|
2022-03-30 18:46:10 -04:00
|
|
|
#include <stdint.h>
|
2022-02-28 05:56:35 -05:00
|
|
|
#include <stdbool.h>
|
2018-06-17 08:28:38 -04:00
|
|
|
|
|
|
|
#include "common/thread/thread.h"
|
|
|
|
#include "common/httpp/httpp.h"
|
|
|
|
|
2018-06-17 06:12:15 -04:00
|
|
|
#include "icecasttypes.h"
|
2020-09-30 13:25:49 -04:00
|
|
|
#include "connection.h"
|
2003-02-02 09:33:17 -05:00
|
|
|
#include "yp.h"
|
2003-02-26 18:52:23 -05:00
|
|
|
#include "util.h"
|
2002-12-30 02:55:56 -05:00
|
|
|
#include "format.h"
|
2015-03-28 12:15:49 -04:00
|
|
|
#include "playlist.h"
|
2003-03-02 05:13:59 -05:00
|
|
|
|
2022-03-30 18:46:10 -04:00
|
|
|
typedef uint_least32_t source_flags_t;
|
|
|
|
|
|
|
|
#define SOURCE_FLAG_GOT_DATA ((source_flags_t)0x00000001U)
|
2022-03-30 19:51:30 -04:00
|
|
|
#define SOURCE_FLAG_FORMAT_GENERIC ((source_flags_t)0x00000002U)
|
|
|
|
#define SOURCE_FLAG_LEGACY_METADATA ((source_flags_t)0x00000004U)
|
2022-03-31 19:34:10 -04:00
|
|
|
#define SOURCE_FLAG_AGED ((source_flags_t)0x00000008U)
|
2022-03-30 18:46:10 -04:00
|
|
|
|
2022-03-30 19:51:30 -04:00
|
|
|
#define SOURCE_FLAGS_CLEARABLE (SOURCE_FLAG_LEGACY_METADATA)
|
2022-03-31 19:34:10 -04:00
|
|
|
#define SOURCE_FLAGS_GOOD (SOURCE_FLAG_GOT_DATA|SOURCE_FLAG_AGED)
|
2022-03-30 18:46:10 -04:00
|
|
|
|
2018-05-25 07:42:08 -04:00
|
|
|
struct source_tag {
|
2012-07-17 10:03:37 -04:00
|
|
|
mutex_t lock;
|
2002-08-16 10:26:48 -04:00
|
|
|
client_t *client;
|
2003-03-14 21:10:19 -05:00
|
|
|
connection_t *con;
|
|
|
|
http_parser_t *parser;
|
2022-03-30 05:08:13 -04:00
|
|
|
time_t last_stats_update;
|
2022-03-31 19:19:18 -04:00
|
|
|
time_t create_time;
|
2003-03-14 21:10:19 -05:00
|
|
|
|
2020-10-24 04:06:08 -04:00
|
|
|
char *mount; // TODO: Should we at some point migrate away from this to only use identifier?
|
|
|
|
mount_identifier_t *identifier;
|
2002-12-30 10:19:46 -05:00
|
|
|
|
2023-01-30 05:41:34 -05:00
|
|
|
/* Instance UUID for this source. Will be different every time a source is connected. */
|
|
|
|
const char *instance_uuid;
|
|
|
|
|
2002-12-30 10:19:46 -05:00
|
|
|
/* If this source drops, try to move all clients to this fallback */
|
|
|
|
char *fallback_mount;
|
|
|
|
|
2003-02-06 08:10:48 -05:00
|
|
|
/* set to zero to request the source to shutdown without causing a global
|
|
|
|
* shutdown */
|
|
|
|
int running;
|
2022-03-30 18:46:10 -04:00
|
|
|
source_flags_t flags;
|
2003-02-06 08:10:48 -05:00
|
|
|
|
2003-03-14 21:10:19 -05:00
|
|
|
struct _format_plugin_tag *format;
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2003-03-14 21:10:19 -05:00
|
|
|
avl_tree *client_tree;
|
|
|
|
avl_tree *pending_tree;
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2003-03-14 21:10:19 -05:00
|
|
|
rwlock_t *shutdown_rwlock;
|
2003-02-26 18:52:23 -05:00
|
|
|
util_dict *audio_info;
|
2003-03-02 05:13:59 -05:00
|
|
|
|
2005-06-03 11:35:52 -04:00
|
|
|
FILE *intro_file;
|
|
|
|
|
2022-03-21 12:34:45 -04:00
|
|
|
/* Dumpfile related data */
|
|
|
|
/* Config */
|
2003-03-02 05:13:59 -05:00
|
|
|
char *dumpfilename; /* Name of a file to dump incoming stream to */
|
2022-10-25 05:05:24 -04:00
|
|
|
interpolation_t dumpfile_interpolation;
|
2022-03-22 11:33:11 -04:00
|
|
|
uint64_t dumpfile_size_limit;
|
|
|
|
unsigned int dumpfile_time_limit;
|
2022-03-21 12:34:45 -04:00
|
|
|
/* Runtime */
|
2003-03-02 05:13:59 -05:00
|
|
|
FILE *dumpfile;
|
2022-03-21 12:34:45 -04:00
|
|
|
time_t dumpfile_start;
|
|
|
|
uint64_t dumpfile_written;
|
2003-03-02 05:13:59 -05:00
|
|
|
|
2005-06-10 21:24:58 -04:00
|
|
|
unsigned long peak_listeners;
|
2005-05-25 23:04:48 -04:00
|
|
|
unsigned long listeners;
|
2007-08-09 11:43:00 -04:00
|
|
|
unsigned long prev_listeners;
|
2003-02-11 09:23:34 -05:00
|
|
|
long max_listeners;
|
2003-06-26 09:32:04 -04:00
|
|
|
int yp_public;
|
2020-10-25 09:07:27 -04:00
|
|
|
fallback_override_t fallback_override;
|
2005-08-23 14:40:20 -04:00
|
|
|
int fallback_when_full;
|
2004-11-11 10:47:33 -05:00
|
|
|
int shoutcast_compat;
|
2004-08-20 11:13:59 -04:00
|
|
|
|
|
|
|
/* per source burst handling for connecting clients */
|
|
|
|
unsigned int burst_size; /* trigger level for burst on connect */
|
|
|
|
unsigned int burst_offset;
|
|
|
|
refbuf_t *burst_point;
|
|
|
|
|
|
|
|
unsigned int queue_size;
|
|
|
|
unsigned int queue_size_limit;
|
|
|
|
|
2004-02-26 06:56:48 -05:00
|
|
|
unsigned timeout; /* source timeout in seconds */
|
2005-06-08 21:51:47 -04:00
|
|
|
int on_demand;
|
|
|
|
int on_demand_req;
|
2004-11-22 13:21:48 -05:00
|
|
|
int hidden;
|
2022-02-28 05:56:35 -05:00
|
|
|
bool allow_direct_access; // copy of mount_proxy->allow_direct_access
|
2004-08-20 11:13:59 -04:00
|
|
|
time_t last_read;
|
|
|
|
int short_delay;
|
|
|
|
|
|
|
|
refbuf_t *stream_data;
|
|
|
|
refbuf_t *stream_data_tail;
|
|
|
|
|
2015-03-28 12:15:49 -04:00
|
|
|
playlist_t *history;
|
2018-06-09 05:54:38 -04:00
|
|
|
};
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2004-02-19 11:32:26 -05:00
|
|
|
source_t *source_reserve (const char *mount);
|
|
|
|
void *source_client_thread (void *arg);
|
2005-08-12 11:27:32 -04:00
|
|
|
void source_client_callback (client_t *client, void *source);
|
2005-05-30 10:50:57 -04:00
|
|
|
void source_update_settings (ice_config_t *config, source_t *source, mount_proxy *mountinfo);
|
2004-02-19 11:32:26 -05:00
|
|
|
void source_clear_source (source_t *source);
|
2020-11-08 13:23:03 -05:00
|
|
|
#define source_find_mount(mount) source_find_mount_with_history((mount), NULL)
|
|
|
|
source_t *source_find_mount_with_history(const char *mount, navigation_history_t *history);
|
2004-01-14 20:01:09 -05:00
|
|
|
source_t *source_find_mount_raw(const char *mount);
|
2020-09-30 13:25:49 -04:00
|
|
|
client_t *source_find_client(source_t *source, connection_id_t id);
|
2001-09-09 22:21:46 -04:00
|
|
|
int source_compare_sources(void *arg, void *a, void *b);
|
2004-02-27 10:15:40 -05:00
|
|
|
void source_free_source(source_t *source);
|
2020-10-25 05:05:28 -04:00
|
|
|
void source_move_clients(source_t *source, source_t *dest, connection_id_t *id, navigation_direction_t direction);
|
2003-03-14 02:59:58 -05:00
|
|
|
int source_remove_client(void *key);
|
2004-02-26 11:51:43 -05:00
|
|
|
void source_main(source_t *source);
|
2007-08-11 13:44:45 -04:00
|
|
|
void source_recheck_mounts (int update_all);
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2022-03-21 12:15:15 -04:00
|
|
|
/* Writes a buffer of raw data to a dumpfile. returns true if the write was successful (and complete). */
|
|
|
|
bool source_write_dumpfile(source_t *source, const void *buffer, size_t len);
|
2022-03-21 16:03:16 -04:00
|
|
|
void source_kill_dumpfile(source_t *source);
|
2022-03-30 18:46:10 -04:00
|
|
|
health_t source_get_health(source_t *source);
|
2022-03-30 19:53:09 -04:00
|
|
|
health_t source_get_health_by_flags(source_flags_t flags);
|
2022-03-30 19:51:30 -04:00
|
|
|
void source_set_flags(source_t *source, source_flags_t flags);
|
2022-03-21 12:15:15 -04:00
|
|
|
|
2004-01-29 11:46:54 -05:00
|
|
|
extern mutex_t move_clients_mutex;
|
|
|
|
|
2001-09-09 22:21:46 -04:00
|
|
|
#endif
|