X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=shared%2Fhttpd.cpp;fp=shared%2Fhttpd.cpp;h=a2668f5987c352d2d3c7c501a86cd86828ffe682;hb=eeda8995329601f9f4e35047358400833eeae68e;hp=28ed783872ff2ab18bf1b1bf8e175b0dd520835c;hpb=9ddb2d850c90ae1ab333ca92683db5cc12de07ca;p=nageru diff --git a/shared/httpd.cpp b/shared/httpd.cpp index 28ed783..a2668f5 100644 --- a/shared/httpd.cpp +++ b/shared/httpd.cpp @@ -58,11 +58,13 @@ void HTTPD::stop() } } -void HTTPD::add_data(const char *buf, size_t size, bool keyframe, int64_t time, AVRational timebase) +void HTTPD::add_data(StreamType stream_type, const char *buf, size_t size, bool keyframe, int64_t time, AVRational timebase) { unique_lock lock(streams_mutex); for (Stream *stream : streams) { - stream->add_data(buf, size, keyframe ? Stream::DATA_TYPE_KEYFRAME : Stream::DATA_TYPE_OTHER, time, timebase); + if (stream->get_stream_type() == stream_type) { + stream->add_data(buf, size, keyframe ? Stream::DATA_TYPE_KEYFRAME : Stream::DATA_TYPE_OTHER, time, timebase); + } } } @@ -87,6 +89,12 @@ int HTTPD::answer_to_connection(MHD_Connection *connection, } else { framing = HTTPD::Stream::FRAMING_RAW; } + HTTPD::StreamType stream_type; + if (strcmp(url, "/multicam.mp4") == 0) { + stream_type = HTTPD::StreamType::MULTICAM_STREAM; + } else { + stream_type = HTTPD::StreamType::MAIN_STREAM; + } if (strcmp(url, "/metrics") == 0) { string contents = global_metrics.serialize(); @@ -121,8 +129,8 @@ int HTTPD::answer_to_connection(MHD_Connection *connection, return ret; } - HTTPD::Stream *stream = new HTTPD::Stream(this, framing); - stream->add_data(header.data(), header.size(), Stream::DATA_TYPE_HEADER, AV_NOPTS_VALUE, AVRational{ 1, 0 }); + HTTPD::Stream *stream = new HTTPD::Stream(this, framing, stream_type); + stream->add_data(header[stream_type].data(), header[stream_type].size(), Stream::DATA_TYPE_HEADER, AV_NOPTS_VALUE, AVRational{ 1, 0 }); { unique_lock lock(streams_mutex); streams.insert(stream);