RefCountedGLsync VideoEncoder::end_frame()
{
+ want_srt_metric_update = true;
lock_guard<mutex> lock(qs_mu);
return quicksync_encoder->end_frame();
}
if (is_srt) {
srt_mux.reset(mux);
srt_mux_metrics.init({{ "destination", "srt" }});
+ srt_metrics.init({{ "cardtype", "output" }});
+ global_metrics.add("srt_num_connection_attempts", {{ "cardtype", "output" }}, &metric_srt_num_connection_attempts);
} else {
http_mux.reset(mux);
http_mux_metrics.init({{ "destination", "http" }});
// Die immediately.
return sock;
}
+ ++metric_srt_num_connection_attempts;
if (srt_connect(sock, cur->ai_addr, cur->ai_addrlen) < 0) {
fprintf(stderr, "srt_connect(%s): %s\n", print_addrinfo(cur).c_str(), srt_getlasterror_str());
srt_close(sock);
int VideoEncoder::write_srt_packet(uint8_t *buf, int buf_size)
{
+ if (want_srt_metric_update.exchange(false) && srt_sock != -1) {
+ srt_metrics.update_srt_stats(srt_sock);
+ }
while (buf_size > 0) {
if (srt_sock == -1) {
srt_sock = connect_to_srt();
usleep(100000);
continue;
}
+ srt_metrics.update_srt_stats(srt_sock);
}
int to_send = min(buf_size, SRT_LIVE_DEF_PLSIZE);
int ret = srt_send(srt_sock, (char *)buf, to_send);
if (ret < 0) {
fprintf(stderr, "srt_send(): %s\n", srt_getlasterror_str());
srt_close(srt_sock);
+ srt_metrics.metric_srt_uptime_seconds = 0.0 / 0.0;
srt_sock = connect_to_srt();
continue;
}
#include <mutex>
#include <string>
#include <vector>
+#include <chrono>
extern "C" {
#include <libavformat/avformat.h>
#include "shared/mux.h"
#include "shared/ref_counted_gl_sync.h"
+#include "srt_metrics.h"
class AudioEncoder;
class AV1Encoder;
std::string http_mux_header;
MuxMetrics http_mux_metrics;
MuxMetrics srt_mux_metrics;
+ SRTMetrics srt_metrics;
+ std::atomic<int64_t> metric_srt_num_connection_attempts{0};
+ std::atomic<bool> want_srt_metric_update{true}; // Is nominally set every frame. Some racing is OK (this is mainly a rate-limiter).
std::atomic<int> quicksync_encoders_in_shutdown{0};
std::atomic<int> overriding_bitrate{0};