aboutsummaryrefslogtreecommitdiffstats
path: root/src/output/HttpdInternal.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-27 23:23:46 +0100
committerMax Kellermann <max@duempel.org>2013-01-27 23:23:46 +0100
commit2aa34882b7aef2b029df2acbbb17f742eb5fefaa (patch)
tree1b92ecb4125f73e9f1fceed436b065cb3a180304 /src/output/HttpdInternal.hxx
parent27f8ef2f338440f0d4d258f0f2dfc3ca88e83ab2 (diff)
downloadmpd-2aa34882b7aef2b029df2acbbb17f742eb5fefaa.tar.gz
mpd-2aa34882b7aef2b029df2acbbb17f742eb5fefaa.tar.xz
mpd-2aa34882b7aef2b029df2acbbb17f742eb5fefaa.zip
output/httpd: move functions into the HttpdOutput class
Diffstat (limited to 'src/output/HttpdInternal.hxx')
-rw-r--r--src/output/HttpdInternal.hxx86
1 files changed, 72 insertions, 14 deletions
diff --git a/src/output/HttpdInternal.hxx b/src/output/HttpdInternal.hxx
index e948afa1b..1c2fdfb16 100644
--- a/src/output/HttpdInternal.hxx
+++ b/src/output/HttpdInternal.hxx
@@ -122,21 +122,79 @@ struct HttpdOutput {
* at the same time.
*/
guint clients_max, clients_cnt;
-};
-/**
- * Removes a client from the httpd_output.clients linked list.
- */
-void
-httpd_output_remove_client(struct HttpdOutput *httpd,
- HttpdClient *client);
+ bool Bind(GError **error_r);
+ void Unbind();
-/**
- * Sends the encoder header to the client. This is called right after
- * the response headers have been sent.
- */
-void
-httpd_output_send_header(struct HttpdOutput *httpd,
- HttpdClient *client);
+ /**
+ * Caller must lock the mutex.
+ */
+ bool OpenEncoder(struct audio_format *audio_format,
+ GError **error_r);
+
+ /**
+ * Caller must lock the mutex.
+ */
+ bool Open(struct audio_format *audio_format, GError **error_r);
+
+ /**
+ * Caller must lock the mutex.
+ */
+ void Close();
+
+ /**
+ * Check whether there is at least one client.
+ *
+ * Caller must lock the mutex.
+ */
+ gcc_pure
+ bool HasClients() const {
+ return !clients.empty();
+ }
+
+ /**
+ * Check whether there is at least one client.
+ */
+ gcc_pure
+ bool LockHasClients() const {
+ const ScopeLock protect(mutex);
+ return HasClients();
+ }
+
+ void AddClient(int fd);
+
+ /**
+ * Removes a client from the httpd_output.clients linked list.
+ */
+ void RemoveClient(HttpdClient &client);
+
+ /**
+ * Sends the encoder header to the client. This is called
+ * right after the response headers have been sent.
+ */
+ void SendHeader(HttpdClient &client) const;
+
+ /**
+ * Reads data from the encoder (as much as available) and
+ * returns it as a new #page object.
+ */
+ page *ReadPage();
+
+ /**
+ * Broadcasts a page struct to all clients.
+ *
+ * Mutext must not be locked.
+ */
+ void BroadcastPage(struct page *page);
+
+ /**
+ * Broadcasts data from the encoder to all clients.
+ */
+ void BroadcastFromEncoder();
+
+ bool EncodeAndPlay(const void *chunk, size_t size, GError **error_r);
+
+ void SendTag(const struct tag *tag);
+};
#endif