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 19 20 21
#include <stdio.h>

#include "common/thread/thread.h"
#include "common/httpp/httpp.h"

22
#include "icecasttypes.h"
23
#include "yp.h"
24
#include "util.h"
25
#include "format.h"
26
#include "playlist.h"
Michael Smith's avatar
Michael Smith committed
27

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

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

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

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

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

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

52 53
    FILE *intro_file;

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

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

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

74
    unsigned timeout;  /* source timeout in seconds */
75 76
    int on_demand;
    int on_demand_req;
77
    int hidden;
78 79 80 81 82 83
    time_t last_read;
    int short_delay;

    refbuf_t *stream_data;
    refbuf_t *stream_data_tail;

84
    playlist_t *history;
85
};
Jack Moffitt's avatar
Jack Moffitt committed
86

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

102 103
extern mutex_t move_clients_mutex;

Jack Moffitt's avatar
Jack Moffitt committed
104
#endif