]> git.sesse.net Git - nageru/blobdiff - nageru/mixer.cpp
Merge branch 'mjpeg'
[nageru] / nageru / mixer.cpp
index 0d782e8d8758674e033b867353041bb7598118b1..953fd8133db59410ab2973d7592a05e5d133bc09 100644 (file)
 #include "flags.h"
 #include "input_mapping.h"
 #include "shared/metrics.h"
+#include "mjpeg_encoder.h"
 #include "pbo_frame_allocator.h"
 #include "shared/ref_counted_gl_sync.h"
 #include "resampling_queue.h"
 #include "shared/timebase.h"
 #include "timecode_renderer.h"
 #include "v210_converter.h"
+#include "va_display_with_cleanup.h"
 #include "video_encoder.h"
 
 #undef Status
@@ -356,6 +358,7 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards)
        display_chain->finalize();
 
        video_encoder.reset(new VideoEncoder(resource_pool.get(), h264_encoder_surface, global_flags.va_display, global_flags.width, global_flags.height, &httpd, global_disk_space_estimator));
+       mjpeg_encoder.reset(new MJPEGEncoder(&httpd, global_flags.va_display));
 
        // Must be instantiated after VideoEncoder has initialized global_flags.use_zerocopy.
        theme.reset(new Theme(global_flags.theme_filename, global_flags.theme_dirs, resource_pool.get(), num_cards));
@@ -499,6 +502,7 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards)
 
 Mixer::~Mixer()
 {
+       mjpeg_encoder->stop();
        httpd.stop();
        BMUSBCapture::stop_bm_thread();
 
@@ -954,6 +958,9 @@ void Mixer::bm_frame(unsigned card_index, uint16_t timecode,
                        new_frame.upload_func = upload_func;
                        new_frame.dropped_frames = dropped_frames;
                        new_frame.received_timestamp = video_frame.received_timestamp;  // Ignore the audio timestamp.
+                       new_frame.video_format = video_format;
+                       new_frame.y_offset = y_offset;
+                       new_frame.cbcr_offset = cbcr_offset;
                        card->new_frames.push_back(move(new_frame));
                        card->jitter_history.frame_arrived(video_frame.received_timestamp, frame_length, dropped_frames);
                        card->may_have_dropped_last_frame = false;
@@ -1063,6 +1070,14 @@ void Mixer::thread_func()
                                new_frame->upload_func();
                                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);
+                       }
                }
 
                int64_t frame_duration = output_frame_info.frame_duration;