X-Git-Url: https://git.sesse.net/?p=nageru;a=blobdiff_plain;f=httpd.cpp;h=8d33e75a4f6b5bde8e6f8b79aa23ffa007e8351f;hp=f6441768bbdde1df3d31e2b42a2cb13430019376;hb=817fffe1ef3bd87f2387395f49487cf5255d8daf;hpb=330ca2f0052b06d91004c6ceb73cd57ab95e7fe1 diff --git a/httpd.cpp b/httpd.cpp index f644176..8d33e75 100644 --- a/httpd.cpp +++ b/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);