source.h 2.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
/* 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).
 */

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

16
#include "cfgfile.h"
17
#include "yp.h"
18
#include "util.h"
Michael Smith's avatar
Michael Smith committed
19 20
#include "format.h"

Michael Smith's avatar
Michael Smith committed
21 22
#include <stdio.h>

Jack Moffitt's avatar
Jack Moffitt committed
23 24
typedef struct source_tag
{
25
    client_t *client;
26 27
    connection_t *con;
    http_parser_t *parser;
28
    time_t client_stats_update;
29 30
    
    char *mount;
Michael Smith's avatar
Michael Smith committed
31 32 33 34

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

35 36 37 38
    /* set to zero to request the source to shutdown without causing a global
     * shutdown */
    int running;

39
    struct _format_plugin_tag *format;
Jack Moffitt's avatar
Jack Moffitt committed
40

41 42
    avl_tree *client_tree;
    avl_tree *pending_tree;
Jack Moffitt's avatar
Jack Moffitt committed
43

44
    rwlock_t *shutdown_rwlock;
45
    util_dict *audio_info;
Michael Smith's avatar
Michael Smith committed
46

Karl Heyes's avatar
Karl Heyes committed
47 48
    FILE *intro_file;

Michael Smith's avatar
Michael Smith committed
49 50 51
    char *dumpfilename; /* Name of a file to dump incoming stream to */
    FILE *dumpfile;

Karl Heyes's avatar
Karl Heyes committed
52
    unsigned long peak_listeners;
53
    unsigned long listeners;
54
    unsigned long prev_listeners;
55
    long max_listeners;
56
    int yp_public;
Michael Smith's avatar
Michael Smith committed
57
    int fallback_override;
58
    int fallback_when_full;
59
    int shoutcast_compat;
Karl Heyes's avatar
Karl Heyes committed
60 61 62 63 64 65 66 67 68

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

69
    unsigned timeout;  /* source timeout in seconds */
70 71
    int on_demand;
    int on_demand_req;
72
    int hidden;
Karl Heyes's avatar
Karl Heyes committed
73 74 75 76 77 78
    time_t last_read;
    int short_delay;

    refbuf_t *stream_data;
    refbuf_t *stream_data_tail;

Jack Moffitt's avatar
Jack Moffitt committed
79 80
} source_t;

81 82
source_t *source_reserve (const char *mount);
void *source_client_thread (void *arg);
83
void source_startup (client_t *client, const char *uri, int auth_style);
84
void source_client_callback (client_t *client, void *source);
85
void source_update_settings (ice_config_t *config, source_t *source, mount_proxy *mountinfo);
86
void source_clear_source (source_t *source);
Jack Moffitt's avatar
Jack Moffitt committed
87
source_t *source_find_mount(const char *mount);
Michael Smith's avatar
Michael Smith committed
88
source_t *source_find_mount_raw(const char *mount);
89
client_t *source_find_client(source_t *source, int id);
Jack Moffitt's avatar
Jack Moffitt committed
90
int source_compare_sources(void *arg, void *a, void *b);
91
void source_free_source(source_t *source);
92
void source_move_clients (source_t *source, source_t *dest);
93
int source_remove_client(void *key);
94
void source_main(source_t *source);
95
void source_recheck_mounts (int update_all);
Jack Moffitt's avatar
Jack Moffitt committed
96

97 98
extern mutex_t move_clients_mutex;

Jack Moffitt's avatar
Jack Moffitt committed
99 100 101
#endif