From c8ee45ce3732a2c5ec58153e97c155ce5daea3a7 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Tue, 14 Apr 2020 14:49:41 +0200 Subject: [PATCH] Syphon: probe individual servers --- src/video_capture/syphon.mm | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/video_capture/syphon.mm b/src/video_capture/syphon.mm index 090ae8219..dc85028b2 100644 --- a/src/video_capture/syphon.mm +++ b/src/video_capture/syphon.mm @@ -452,14 +452,28 @@ static struct video_frame *vidcap_syphon_grab(void *state, struct audio_frame ** static struct vidcap_type *vidcap_syphon_probe(bool verbose, void (**deleter)(void *)) { - UNUSED(verbose); *deleter = free; struct vidcap_type *vt; vt = (struct vidcap_type *) calloc(1, sizeof(struct vidcap_type)); - if (vt != NULL) { - vt->name = "syphon"; - vt->description = "Syphon capture client"; + if (vt == NULL) { + return NULL; + } + vt->name = "syphon"; + vt->description = "Syphon capture client"; + if (!verbose) { + return vt; + } + + NSArray *descriptions = [[SyphonServerDirectory sharedDirectory] servers]; + for (id item in descriptions) { + vt->card_count += 1; + vt->cards = (struct device_info *) realloc(vt->cards, vt->card_count * sizeof(struct device_info)); + memset(&vt->cards[vt->card_count - 1], 0, sizeof(struct device_info)); + snprintf(vt->cards[vt->card_count - 1].id, sizeof vt->cards[vt->card_count - 1].id, + "app=%s", [[item objectForKey:@"SyphonServerDescriptionAppNameKey"] UTF8String]); + snprintf(vt->cards[vt->card_count - 1].name, sizeof vt->cards[vt->card_count - 1].name, + "Syphon %s", [[item objectForKey:@"SyphonServerDescriptionAppNameKey"] UTF8String]); } return vt; }