X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=mixer.cpp;h=202617b9b718aae8b05ffb3872bafce980cc5b2a;hb=ffd68fbfb90242069af957f2a28908f0559f8348;hp=557452db91cb9e7176b7df51ebecedb7c286c355;hpb=b68d8a25951faf5b967b7a35fa0a363b4b68fbc0;p=nageru diff --git a/mixer.cpp b/mixer.cpp index 557452d..202617b 100644 --- a/mixer.cpp +++ b/mixer.cpp @@ -33,7 +33,9 @@ #include "basic_stats.h" #include "bmusb/bmusb.h" #include "bmusb/fake_capture.h" +#ifdef HAVE_CEF #include "cef_capture.h" +#endif #include "chroma_subsampler.h" #include "context.h" #include "decklink_capture.h" @@ -155,6 +157,8 @@ void ensure_texture_resolution(PBOFrameAllocator::Userdata *userdata, unsigned f } check_error(); break; + default: + assert(false); } userdata->last_width[field] = width; userdata->last_height[field] = height; @@ -428,6 +432,7 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards) } num_video_inputs = video_inputs.size(); +#ifdef HAVE_CEF // Same, for HTML inputs. std::vector html_inputs = theme->get_html_inputs(); for (unsigned html_card_index = 0; html_card_index < html_inputs.size(); ++card_index, ++html_card_index) { @@ -439,6 +444,7 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards) html_inputs[html_card_index]->set_card_index(card_index); } num_html_inputs = html_inputs.size(); +#endif BMUSBCapture::set_card_connected_callback(bind(&Mixer::bm_hotplug_add, this, _1)); BMUSBCapture::start_bm_thread(); @@ -519,6 +525,8 @@ void Mixer::configure_card(unsigned card_index, CaptureInterface *capture, CardT } card->capture.reset(capture); card->is_fake_capture = (card_type == CardType::FAKE_CAPTURE); + card->is_cef_capture = (card_type == CardType::CEF_INPUT); + card->may_have_dropped_last_frame = false; card->type = card_type; if (card->output.get() != output) { card->output.reset(output); @@ -936,6 +944,7 @@ void Mixer::bm_frame(unsigned card_index, uint16_t timecode, new_frame.received_timestamp = video_frame.received_timestamp; // Ignore the audio timestamp. 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; } card->new_frames_changed.notify_all(); } @@ -1112,6 +1121,10 @@ void Mixer::trim_queue(CaptureCard *card, size_t safe_queue_length) card->new_frames_changed.notify_all(); --queue_length; ++dropped_frames; + + if (queue_length == 0 && card->is_cef_capture) { + card->may_have_dropped_last_frame = true; + } } card->metric_input_dropped_frames_jitter += dropped_frames; @@ -1176,6 +1189,16 @@ start: CaptureCard *card = &cards[card_index]; if (card->new_frames.empty()) { // Starvation. ++card->metric_input_duped_frames; +#ifdef HAVE_CEF + if (card->is_cef_capture && card->may_have_dropped_last_frame) { + // Unlike other sources, CEF is not guaranteed to send us a steady + // stream of frames, so we'll have to ask it to repaint the frame + // we dropped. (may_have_dropped_last_frame is set whenever we + // trim the queue completely away, and cleared when we actually + // get a new frame.) + ((CEFCapture *)card->capture.get())->request_new_frame(); + } +#endif } else { new_frames[card_index] = move(card->new_frames.front()); has_new_frame[card_index] = true; @@ -1327,15 +1350,6 @@ void Mixer::render_one_frame(int64_t duration) theme_main_chain.setup_chain(); //theme_main_chain.chain->enable_phase_timing(true); - // The theme can't (or at least shouldn't!) call connect_signal() on - // each FFmpeg or CEF input, so we'll do it here. - for (const pair &conn : theme->get_video_signal_connections()) { - conn.first->connect_signal_raw(conn.second->get_card_index(), input_state); - } - for (const pair &conn : theme->get_html_signal_connections()) { - conn.first->connect_signal_raw(conn.second->get_card_index(), input_state); - } - // If HDMI/SDI output is active and the user has requested auto mode, // its mode overrides the existing Y'CbCr setting for the chain. YCbCrLumaCoefficients ycbcr_output_coefficients;