X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=httpd.cpp;h=f6441768bbdde1df3d31e2b42a2cb13430019376;hb=778fe6ec989e7ed640a6c3d209099b6be3945bba;hp=9782dca7ba7807ab45c0e1994cd6a25642623086;hpb=5743f5528c75acdfd381a494db0b4936a3ab218b;p=nageru diff --git a/httpd.cpp b/httpd.cpp index 9782dca..f644176 100644 --- a/httpd.cpp +++ b/httpd.cpp @@ -30,13 +30,7 @@ HTTPD::HTTPD() HTTPD::~HTTPD() { - if (mhd) { - MHD_quiesce_daemon(mhd); - for (Stream *stream : streams) { - stream->stop(); - } - MHD_stop_daemon(mhd); - } + stop(); } void HTTPD::start(int port) @@ -52,6 +46,18 @@ void HTTPD::start(int port) } } +void HTTPD::stop() +{ + if (mhd) { + MHD_quiesce_daemon(mhd); + for (Stream *stream : streams) { + stream->stop(); + } + MHD_stop_daemon(mhd); + mhd = nullptr; + } +} + void HTTPD::add_data(const char *buf, size_t size, bool keyframe, int64_t time, AVRational timebase) { unique_lock lock(streams_mutex);