+
+#ifdef HAVE_SRT
+ // Same, for SRT inputs.
+ // TODO: On disconnect and reconnect, we might want to use the stream ID
+ // to find the slot it used to go into?
+ for (SRTSOCKET sock : hotplugged_srt_cards_copy) {
+ // Look for a fake capture card where we can stick this in.
+ int free_card_index = -1;
+ for (unsigned card_index = 0; card_index < num_cards; ++card_index) {
+ if (cards[card_index].is_fake_capture) {
+ free_card_index = card_index;
+ break;
+ }
+ }
+
+ char name[256];
+ int namelen = sizeof(name);
+ srt_getsockopt(sock, /*ignored=*/0, SRTO_STREAMID, name, &namelen);
+ string stream_id(name, namelen);
+
+ if (free_card_index == -1) {
+ if (stream_id.empty()) {
+ stream_id = "no name";
+ }
+ fprintf(stderr, "New SRT stream connected (%s), but no free slots -- ignoring.\n", stream_id.c_str());
+ srt_close(sock);
+ } else {
+ // FFmpegCapture takes ownership.
+ if (stream_id.empty()) {
+ fprintf(stderr, "New unnamed SRT stream connected, choosing slot %d.\n", free_card_index);
+ } else {
+ fprintf(stderr, "New SRT stream connected (%s), choosing slot %d.\n", stream_id.c_str(), free_card_index);
+ }
+ CaptureCard *card = &cards[free_card_index];
+ FFmpegCapture *capture = new FFmpegCapture(sock, stream_id);
+ capture->set_card_index(free_card_index);
+ configure_card(free_card_index, capture, CardType::FFMPEG_INPUT, /*output=*/nullptr, /*override_card_as_live=*/true);
+ card->queue_length_policy.reset(free_card_index);
+ capture->set_card_disconnected_callback(bind(&Mixer::bm_hotplug_remove, this, free_card_index));
+ capture->start_bm_capture();
+ }
+ }
+#endif