]> git.sesse.net Git - nageru/blobdiff - mixer.cpp
Add an exported metrics for number of connected clients.
[nageru] / mixer.cpp
index 421efea9f13a096a16b8460ae42152ead88fa164..4b45b511e686e91be148035deb62caeb7fbd4eb2 100644 (file)
--- a/mixer.cpp
+++ b/mixer.cpp
@@ -42,6 +42,7 @@
 #include "ffmpeg_capture.h"
 #include "flags.h"
 #include "input_mapping.h"
+#include "metrics.h"
 #include "pbo_frame_allocator.h"
 #include "ref_counted_gl_sync.h"
 #include "resampling_queue.h"
@@ -388,6 +389,10 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards)
                desired_output_card_index = global_flags.output_card;
                set_output_card_internal(global_flags.output_card);
        }
+
+       global_metrics.register_int_metric("num_frames", &metrics_num_frames);
+       global_metrics.register_int_metric("dropped_frames", &metrics_dropped_frames);
+       global_metrics.register_double_metric("uptime", &metrics_uptime);
 }
 
 Mixer::~Mixer()
@@ -715,6 +720,13 @@ void Mixer::bm_frame(unsigned card_index, uint16_t timecode,
                        case PixelFormat_8BitBGRA: {
                                size_t field_start = video_offset + video_format.stride * field_start_line;
                                upload_texture(userdata->tex_rgba[field], video_format.width, video_format.height, video_format.stride, interlaced_stride, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, field_start);
+                               // These could be asked to deliver mipmaps at any time.
+                               glBindTexture(GL_TEXTURE_2D, userdata->tex_rgba[field]);
+                               check_error();
+                               glGenerateMipmap(GL_TEXTURE_2D);
+                               check_error();
+                               glBindTexture(GL_TEXTURE_2D, 0);
+                               check_error();
                                break;
                        }
                        default:
@@ -864,6 +876,11 @@ void Mixer::thread_func()
 
                now = steady_clock::now();
                double elapsed = duration<double>(now - start).count();
+
+               metrics_num_frames = frame_num;
+               metrics_dropped_frames = stats_dropped_frames;
+               metrics_uptime = elapsed;
+
                if (frame_num % 100 == 0) {
                        printf("%d frames (%d dropped) in %.3f seconds = %.1f fps (%.1f ms/frame)",
                                frame_num, stats_dropped_frames, elapsed, frame_num / elapsed,