Commit 2aa34882 authored by Max Kellermann's avatar Max Kellermann

output/httpd: move functions into the HttpdOutput class

parent 27f8ef2f
......@@ -55,7 +55,7 @@ HttpdClient::~HttpdClient()
void
HttpdClient::Close()
{
httpd_output_remove_client(httpd, this);
httpd->RemoveClient(*this);
}
void
......@@ -74,7 +74,7 @@ HttpdClient::BeginResponse()
write_source_id = 0;
current_page = nullptr;
httpd_output_send_header(httpd, this);
httpd->SendHeader(*this);
}
/**
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment