HTTPD::HTTPD()
{
global_metrics.add("num_connected_clients", &metric_num_connected_clients, Metrics::TYPE_GAUGE);
+ global_metrics.add("num_connected_multicam_clients", &metric_num_connected_multicam_clients, Metrics::TYPE_GAUGE);
}
HTTPD::~HTTPD()
streams.insert(stream);
}
++metric_num_connected_clients;
+ if (stream_type == HTTPD::StreamType::MULTICAM_STREAM) {
+ ++metric_num_connected_multicam_clients;
+ }
*con_cls = stream;
// Does not strictly have to be equal to MUX_BUFFER_SIZE.
{
HTTPD::Stream *stream = (HTTPD::Stream *)cls;
HTTPD *httpd = stream->get_parent();
+ if (stream->get_stream_type() == HTTPD::StreamType::MULTICAM_STREAM) {
+ --httpd->metric_num_connected_multicam_clients;
+ }
{
unique_lock<mutex> lock(httpd->streams_mutex);
delete stream;
int64_t get_num_connected_clients() const {
return metric_num_connected_clients.load();
}
+ int64_t get_num_connected_multicam_clients() const {
+ return metric_num_connected_multicam_clients.load();
+ }
private:
static int answer_to_connection_thunk(void *cls, MHD_Connection *connection,
// Metrics.
std::atomic<int64_t> metric_num_connected_clients{0};
+ std::atomic<int64_t> metric_num_connected_multicam_clients{0};
};
#endif // !defined(_HTTPD_H)
new_frame->upload_func = nullptr;
}
- // There are situations where we could possibly want to
- // include FFmpeg inputs (CEF inputs are unlikely),
- // but they're not necessarily in 4:2:2 Y'CbCr, so it would
- // require more functionality the the JPEG encoder.
- if (card_index < num_cards) {
- mjpeg_encoder->upload_frame(pts_int, card_index, new_frame->frame, new_frame->video_format, new_frame->y_offset, new_frame->cbcr_offset);
+ // Only bother doing MJPEG encoding if there are any connected clients
+ // that want the stream.
+ if (httpd.get_num_connected_multicam_clients() > 0) {
+ // There are situations where we could possibly want to
+ // include FFmpeg inputs (CEF inputs are unlikely),
+ // but they're not necessarily in 4:2:2 Y'CbCr, so it would
+ // require more functionality the the JPEG encoder.
+ if (card_index < num_cards) {
+ mjpeg_encoder->upload_frame(pts_int, card_index, new_frame->frame, new_frame->video_format, new_frame->y_offset, new_frame->cbcr_offset);
+ }
}
}