]> git.sesse.net Git - nageru/blobdiff - nageru/video_encoder.h
Constify FFmpeg callbacks.
[nageru] / nageru / video_encoder.h
index 86badf2a9a189fa708789045273f576336225e5e..c9eaf2fb769c0274df2ee0d4d98c6423a30009a8 100644 (file)
@@ -6,6 +6,7 @@
 #define _VIDEO_ENCODER_H
 
 #include <epoxy/gl.h>
+#include <epoxy/gl_generated.h>
 #include <movit/image_format.h>
 #include <stdbool.h>
 #include <stdint.h>
@@ -22,8 +23,10 @@ extern "C" {
 
 #include <srt/srt.h>
 
+#include "shared/ff_maybe_const.h"
 #include "shared/mux.h"
 #include "shared/ref_counted_gl_sync.h"
+#include "srt_metrics.h"
 
 class AudioEncoder;
 class AV1Encoder;
@@ -78,11 +81,11 @@ public:
 
 private:
        void open_output_streams();
-       static int write_packet2_thunk(void *opaque, uint8_t *buf, int buf_size, AVIODataMarkerType type, int64_t time);
-       int write_packet2(uint8_t *buf, int buf_size, AVIODataMarkerType type, int64_t time);
+       static int write_packet2_thunk(void *opaque, FF_MAYBE_CONST uint8_t *buf, int buf_size, AVIODataMarkerType type, int64_t time);
+       int write_packet2(FF_MAYBE_CONST uint8_t *buf, int buf_size, AVIODataMarkerType type, int64_t time);
 
-       static int write_srt_packet_thunk(void *opaque, uint8_t *buf, int buf_size);
-       int write_srt_packet(uint8_t *buf, int buf_size);
+       static int write_srt_packet_thunk(void *opaque, FF_MAYBE_CONST uint8_t *buf, int buf_size);
+       int write_srt_packet(FF_MAYBE_CONST uint8_t *buf, int buf_size);
        int open_srt_socket();  // Returns -1 on error.
        int connect_to_srt();  // Returns -1 on error.
 
@@ -112,9 +115,13 @@ private:
        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};
+       std::atomic<bool> should_quit{false};
 
        // Encoders that are shutdown, but need to call release_gl_resources()
        // (or be deleted) from some thread with an OpenGL context.