Add support for building httpd_output plugin for win32
[mpd-mk.git] / src / output / httpd_internal.h
blobe77a2fe0fb1dc1829a4a7715f25a45eae9505529
1 /*
2 * Copyright (C) 2003-2010 The Music Player Daemon Project
3 * http://www.musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 /** \file
22 * Internal declarations for the "httpd" audio output plugin.
25 #ifndef MPD_OUTPUT_HTTPD_INTERNAL_H
26 #define MPD_OUTPUT_HTTPD_INTERNAL_H
28 #include "timer.h"
30 #include <glib.h>
32 #ifdef WIN32
33 #include <winsock2.h>
34 #include <ws2tcpip.h>
35 #else
36 #include <sys/socket.h>
37 #endif
38 #include <stdbool.h>
40 struct httpd_client;
42 struct httpd_output {
43 /**
44 * True if the audio output is open and accepts client
45 * connections.
47 bool open;
49 /**
50 * The configured encoder plugin.
52 struct encoder *encoder;
54 /**
55 * The MIME type produced by the #encoder.
57 const char *content_type;
59 /**
60 * The configured address of the listener socket.
62 struct sockaddr_storage address;
64 /**
65 * The size of #address.
67 socklen_t address_size;
69 /**
70 * This mutex protects the listener socket and the client
71 * list.
73 GMutex *mutex;
75 /**
76 * A #Timer object to synchronize this output with the
77 * wallclock.
79 Timer *timer;
81 /**
82 * The listener socket.
84 int fd;
86 /**
87 * A GLib main loop source id for the listener socket.
89 guint source_id;
91 /**
92 * The header page, which is sent to every client on connect.
94 struct page *header;
96 /**
97 * The metadata, which is sent to every client.
99 struct page *metadata;
102 * A linked list containing all clients which are currently
103 * connected.
105 GList *clients;
108 * A temporary buffer for the httpd_output_read_page()
109 * function.
111 char buffer[32768];
114 * The maximum and current number of clients connected
115 * at the same time.
117 guint clients_max, clients_cnt;
121 * Removes a client from the httpd_output.clients linked list.
123 void
124 httpd_output_remove_client(struct httpd_output *httpd,
125 struct httpd_client *client);
128 * Sends the encoder header to the client. This is called right after
129 * the response headers have been sent.
131 void
132 httpd_output_send_header(struct httpd_output *httpd,
133 struct httpd_client *client);
135 #endif