source.h 2.82 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/* 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).
11
 * Copyright 2012-2018, Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>,
12 13
 */

Jack Moffitt's avatar
Jack Moffitt committed
14 15 16
#ifndef __SOURCE_H__
#define __SOURCE_H__

17 18
typedef struct source_tag source_t;

19
#include "cfgfile.h"
20
#include "yp.h"
21
#include "util.h"
Michael Smith's avatar
Michael Smith committed
22
#include "format.h"
23
#include "playlist.h"
Marvin Scholz's avatar
Marvin Scholz committed
24
#include "common/thread/thread.h"
Michael Smith's avatar
Michael Smith committed
25

Michael Smith's avatar
Michael Smith committed
26 27
#include <stdio.h>

28
struct source_tag
Jack Moffitt's avatar
Jack Moffitt committed
29
{
30
    mutex_t lock;
31
    client_t *client;
32 33
    connection_t *con;
    http_parser_t *parser;
34
    time_t client_stats_update;
35 36
    
    char *mount;
Michael Smith's avatar
Michael Smith committed
37 38 39 40

    /* If this source drops, try to move all clients to this fallback */
    char *fallback_mount;

41 42 43 44
    /* set to zero to request the source to shutdown without causing a global
     * shutdown */
    int running;

45
    struct _format_plugin_tag *format;
Jack Moffitt's avatar
Jack Moffitt committed
46

47 48
    avl_tree *client_tree;
    avl_tree *pending_tree;
Jack Moffitt's avatar
Jack Moffitt committed
49

50
    rwlock_t *shutdown_rwlock;
51
    util_dict *audio_info;
Michael Smith's avatar
Michael Smith committed
52

Karl Heyes's avatar
Karl Heyes committed
53 54
    FILE *intro_file;

Michael Smith's avatar
Michael Smith committed
55 56 57
    char *dumpfilename; /* Name of a file to dump incoming stream to */
    FILE *dumpfile;

Karl Heyes's avatar
Karl Heyes committed
58
    unsigned long peak_listeners;
59
    unsigned long listeners;
60
    unsigned long prev_listeners;
61
    long max_listeners;
62
    int yp_public;
Michael Smith's avatar
Michael Smith committed
63
    int fallback_override;
64
    int fallback_when_full;
65
    int shoutcast_compat;
Karl Heyes's avatar
Karl Heyes committed
66 67 68 69 70 71 72 73 74

    /* 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;

75
    unsigned timeout;  /* source timeout in seconds */
76 77
    int on_demand;
    int on_demand_req;
78
    int hidden;
Karl Heyes's avatar
Karl Heyes committed
79 80 81 82 83 84
    time_t last_read;
    int short_delay;

    refbuf_t *stream_data;
    refbuf_t *stream_data_tail;

85 86
    playlist_t *history;

87
};
Jack Moffitt's avatar
Jack Moffitt committed
88

89 90
source_t *source_reserve (const char *mount);
void *source_client_thread (void *arg);
91
void source_client_callback (client_t *client, void *source);
92
void source_update_settings (ice_config_t *config, source_t *source, mount_proxy *mountinfo);
93
void source_clear_source (source_t *source);
Jack Moffitt's avatar
Jack Moffitt committed
94
source_t *source_find_mount(const char *mount);
Michael Smith's avatar
Michael Smith committed
95
source_t *source_find_mount_raw(const char *mount);
96
client_t *source_find_client(source_t *source, int id);
Jack Moffitt's avatar
Jack Moffitt committed
97
int source_compare_sources(void *arg, void *a, void *b);
98
void source_free_source(source_t *source);
99
void source_move_clients (source_t *source, source_t *dest);
100
int source_remove_client(void *key);
101
void source_main(source_t *source);
102
void source_recheck_mounts (int update_all);
Jack Moffitt's avatar
Jack Moffitt committed
103

104 105
extern mutex_t move_clients_mutex;

Jack Moffitt's avatar
Jack Moffitt committed
106
#endif