X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fkaeru.cpp;h=390e3cc5f7754c092baa32131a79f595943b00d1;hb=eeda8995329601f9f4e35047358400833eeae68e;hp=0e555862969234246087ed4f2436015d95db35db;hpb=af8007aa958271ba16b15e7d11a891570488f6c9;p=nageru diff --git a/nageru/kaeru.cpp b/nageru/kaeru.cpp index 0e55586..390e3cc 100644 --- a/nageru/kaeru.cpp +++ b/nageru/kaeru.cpp @@ -6,7 +6,7 @@ #include "flags.h" #include "ffmpeg_capture.h" #include "mixer.h" -#include "mux.h" +#include "shared/mux.h" #include "quittable_sleeper.h" #include "shared/timebase.h" #include "x264_encoder.h" @@ -31,6 +31,8 @@ BasicStats *global_basic_stats = nullptr; QuittableSleeper should_quit; MuxMetrics stream_mux_metrics; +namespace { + int write_packet(void *opaque, uint8_t *buf, int buf_size, AVIODataMarkerType type, int64_t time) { static bool seen_sync_markers = false; @@ -47,13 +49,15 @@ int write_packet(void *opaque, uint8_t *buf, int buf_size, AVIODataMarkerType ty if (type == AVIO_DATA_MARKER_HEADER) { stream_mux_header.append((char *)buf, buf_size); - httpd->set_header(stream_mux_header); + httpd->set_header(HTTPD::MAIN_STREAM, stream_mux_header); } else { - httpd->add_data((char *)buf, buf_size, type == AVIO_DATA_MARKER_SYNC_POINT, time, AVRational{ AV_TIME_BASE, 1 }); + httpd->add_data(HTTPD::MAIN_STREAM, (char *)buf, buf_size, type == AVIO_DATA_MARKER_SYNC_POINT, time, AVRational{ AV_TIME_BASE, 1 }); } return buf_size; } +} // namespace + unique_ptr create_mux(HTTPD *httpd, AVOutputFormat *oformat, X264Encoder *x264_encoder, AudioEncoder *audio_encoder) { AVFormatContext *avctx = avformat_alloc_context(); @@ -68,7 +72,8 @@ unique_ptr create_mux(HTTPD *httpd, AVOutputFormat *oformat, X264Encoder *x string video_extradata = x264_encoder->get_global_headers(); unique_ptr mux; - mux.reset(new Mux(avctx, global_flags.width, global_flags.height, Mux::CODEC_H264, video_extradata, audio_encoder->get_codec_parameters().get(), COARSE_TIMEBASE, + mux.reset(new Mux(avctx, global_flags.width, global_flags.height, Mux::CODEC_H264, video_extradata, audio_encoder->get_codec_parameters().get(), + get_color_space(global_flags.ycbcr_rec709_coefficients), Mux::WITH_AUDIO, COARSE_TIMEBASE, /*write_callback=*/nullptr, Mux::WRITE_FOREGROUND, { &stream_mux_metrics })); stream_mux_metrics.init({{ "destination", "http" }}); return mux;