X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=httpd.cpp;fp=httpd.cpp;h=f6441768bbdde1df3d31e2b42a2cb13430019376;hb=a50660d96686b0f997c135691d2f74e084dcae2b;hp=9782dca7ba7807ab45c0e1994cd6a25642623086;hpb=aca8e7f15c4fd9d49875ad2bde27f7f467a6869e;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);