source.h 2.16 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>

Michael Smith's avatar
Michael Smith committed
23 24
struct auth_tag;

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

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

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

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

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

45 46
    rwlock_t *shutdown_rwlock;
    ypdata_t *ypdata[MAX_YP_DIRECTORIES];
47
    util_dict *audio_info;
Michael Smith's avatar
Michael Smith committed
48 49 50 51

    char *dumpfilename; /* Name of a file to dump incoming stream to */
    FILE *dumpfile;

52 53
    int    num_yp_directories;
    long listeners;
54
    long max_listeners;
55
    int yp_public;
56
    int send_return;
Michael Smith's avatar
Michael Smith committed
57 58 59
    struct auth_tag *authenticator;
    int fallback_override;
    int no_mount;
Jack Moffitt's avatar
Jack Moffitt committed
60 61
} source_t;

Michael Smith's avatar
Michael Smith committed
62 63 64
source_t *source_create(client_t *client, connection_t *con, 
        http_parser_t *parser, const char *mount, format_type_t type,
        mount_proxy *mountinfo);
65 66 67 68
source_t *source_reserve (const char *mount);
void *source_client_thread (void *arg);
void source_apply_mount (source_t *source, mount_proxy *mountinfo);
void source_clear_source (source_t *source);
Jack Moffitt's avatar
Jack Moffitt committed
69
source_t *source_find_mount(const char *mount);
Michael Smith's avatar
Michael Smith committed
70
source_t *source_find_mount_raw(const char *mount);
71
client_t *source_find_client(source_t *source, int id);
Jack Moffitt's avatar
Jack Moffitt committed
72 73
int source_compare_sources(void *arg, void *a, void *b);
int source_free_source(void *key);
74
void source_move_clients (source_t *source, source_t *dest);
75
int source_remove_client(void *key);
Jack Moffitt's avatar
Jack Moffitt committed
76 77
void *source_main(void *arg);

78 79
extern mutex_t move_clients_mutex;

Jack Moffitt's avatar
Jack Moffitt committed
80 81 82
#endif