]> git.sesse.net Git - nageru/blobdiff - nageru/mixer.cpp
Stop using the deprecated srt_socket().
[nageru] / nageru / mixer.cpp
index 5df80dfba0c2923820e014df5572284d9f6ed8b3..01f6abede373918a723629b9ccc0d379cd6911bc 100644 (file)
@@ -41,6 +41,7 @@
 #include "shared/context.h"
 #include "decklink_capture.h"
 #include "decklink_output.h"
+#include "decklink_util.h"
 #include "defs.h"
 #include "shared/disk_space_estimator.h"
 #include "ffmpeg_capture.h"
@@ -410,6 +411,12 @@ Mixer::Mixer(const QSurfaceFormat &format)
                                        break;
                                }
 
+                               if (!decklink_card_is_active(decklink, card_index)) {
+                                       fprintf(stderr, "DeckLink card %u is inactive in current profile, skipping (try changing it in Desktop Video Setup)\n", card_index);
+                                       decklink->Release();
+                                       continue;
+                               }
+
                                DeckLinkCapture *capture = new DeckLinkCapture(decklink, card_index);
                                DeckLinkOutput *output = new DeckLinkOutput(resource_pool.get(), decklink_output_surface, global_flags.width, global_flags.height, card_index);
                                if (!output->set_device(decklink)) {
@@ -492,10 +499,6 @@ Mixer::Mixer(const QSurfaceFormat &format)
        }
 #endif
 
-       for (unsigned card_index = 0; card_index < MAX_VIDEO_CARDS; ++card_index) {
-               cards[card_index].queue_length_policy.reset(card_index);
-       }
-
        chroma_subsampler.reset(new ChromaSubsampler(resource_pool.get()));
 
        if (global_flags.ten_bit_input) {
@@ -883,7 +886,7 @@ void Mixer::set_output_card_internal(int card_index)
                card->parked_capture = move(card->capture);
                CaptureInterface *fake_capture = new FakeCapture(global_flags.width, global_flags.height, FAKE_FPS, OUTPUT_FREQUENCY, card_index, global_flags.fake_cards_audio);
                configure_card(card_index, fake_capture, CardType::FAKE_CAPTURE, card->output.release(), /*is_srt_card=*/false);
-               card->queue_length_policy.reset(card_index);
+               card->jitter_history.clear();
                card->capture->start_bm_capture();
                desired_output_video_mode = output_video_mode = card->output->pick_video_mode(desired_output_video_mode);
                card->output->start_output(desired_output_video_mode, pts_int);
@@ -1601,7 +1604,7 @@ void Mixer::handle_hotplugged_cards()
                                fprintf(stderr, "Card %u went away, replacing with a fake card.\n", card_index);
                                FakeCapture *capture = new FakeCapture(global_flags.width, global_flags.height, FAKE_FPS, OUTPUT_FREQUENCY, card_index, global_flags.fake_cards_audio);
                                configure_card(card_index, capture, CardType::FAKE_CAPTURE, /*output=*/nullptr, /*is_srt_card=*/false);
-                               card->queue_length_policy.reset(card_index);
+                               card->jitter_history.clear();
                                card->capture->start_bm_capture();
                        } else {
                                // NOTE: The theme might end up forcing the card back at some later point
@@ -1611,7 +1614,7 @@ void Mixer::handle_hotplugged_cards()
                                fprintf(stderr, "Card %u went away, removing. (To keep a fake card, increase --num-cards.)\n", card_index);
                                theme->remove_card(card_index);
                                configure_card(card_index, /*capture=*/nullptr, CardType::FAKE_CAPTURE, /*output=*/nullptr, /*is_srt_card=*/false);
-                               card->queue_length_policy.reset(card_index);
+                               card->jitter_history.clear();
                        }
                }
        }
@@ -1658,7 +1661,7 @@ void Mixer::handle_hotplugged_cards()
                        CaptureCard *card = &cards[free_card_index];
                        BMUSBCapture *capture = new BMUSBCapture(free_card_index, new_dev);
                        configure_card(free_card_index, capture, CardType::LIVE_CARD, /*output=*/nullptr, /*is_srt_card=*/false);
-                       card->queue_length_policy.reset(free_card_index);
+                       card->jitter_history.clear();
                        capture->set_card_disconnected_callback(bind(&Mixer::bm_hotplug_remove, this, free_card_index));
                        capture->start_bm_capture();
                }
@@ -1714,7 +1717,7 @@ void Mixer::handle_hotplugged_cards()
                        configure_card(free_card_index, capture, CardType::FFMPEG_INPUT, /*output=*/nullptr, /*is_srt_card=*/true);
                        update_srt_stats(sock, card);  // Initial zero stats.
                        card->last_srt_stream_id = stream_id;
-                       card->queue_length_policy.reset(free_card_index);
+                       card->jitter_history.clear();
                        capture->set_card_disconnected_callback(bind(&Mixer::bm_hotplug_remove, this, free_card_index));
                        capture->start_bm_capture();
                }
@@ -1727,7 +1730,7 @@ void Mixer::handle_hotplugged_cards()
                if (card->capture == nullptr && card->force_active) {
                        FakeCapture *capture = new FakeCapture(global_flags.width, global_flags.height, FAKE_FPS, OUTPUT_FREQUENCY, card_index, global_flags.fake_cards_audio);
                        configure_card(card_index, capture, CardType::FAKE_CAPTURE, /*output=*/nullptr, /*is_srt_card=*/false);
-                       card->queue_length_policy.reset(card_index);
+                       card->jitter_history.clear();
                        card->capture->start_bm_capture();
                }
        }
@@ -1973,7 +1976,7 @@ void Mixer::quit()
        if (global_flags.srt_port >= 0) {
                // There's seemingly no other reasonable way to wake up the thread
                // (libsrt's epoll equivalent is busy-waiting).
-               int sock = srt_socket(AF_INET6, 0, 0);
+               int sock = srt_create_socket();
                if (sock != -1) {
                        sockaddr_in6 addr;
                        memset(&addr, 0, sizeof(addr));
@@ -2182,7 +2185,7 @@ void Mixer::OutputChannel::set_color_updated_callback(Mixer::color_updated_callb
 #ifdef HAVE_SRT
 void Mixer::start_srt()
 {
-       SRTSOCKET sock = srt_socket(AF_INET6, 0, 0);
+       SRTSOCKET sock = srt_create_socket();
        sockaddr_in6 addr;
        memset(&addr, 0, sizeof(addr));
        addr.sin6_family = AF_INET6;