Vuo 2.4.4
Loading...
Searching...
No Matches
VuoSyphon.m
Go to the documentation of this file.
1
10#include "VuoImageRenderer.h"
11#include "VuoApp.h"
12#include "VuoSyphon.h"
13#include "VuoSyphonListener.h"
14#include "VuoSyphonSender.h"
15#include <Syphon.h>
16
17#ifdef VUO_COMPILER
19 "title" : "VuoSyphon",
20 "dependencies" : [
21 "VuoSyphonServerDescription",
22 "VuoList_VuoSyphonServerDescription",
23 "VuoImageRenderer",
24 "VuoSyphonListener",
25 "VuoSyphonSender",
26 "Syphon.framework"
27 ]
28 });
29#endif
30
31
36{
37 NSArray *servers = [[SyphonServerDirectory sharedDirectory] serversMatchingName:nil appName:nil];
39
40 for (NSDictionary *server in servers)
41 {
42 VuoText serverUUID = VuoText_make([[server objectForKey:SyphonServerDescriptionUUIDKey] UTF8String]);
43 VuoText serverName = VuoText_make([[server objectForKey:SyphonServerDescriptionNameKey] UTF8String]);
44 VuoText applicationName = VuoText_make([[server objectForKey:SyphonServerDescriptionAppNameKey] UTF8String]);
45
46 VuoSyphonServerDescription description = VuoSyphonServerDescription_make(serverUUID, serverName, applicationName, true);
47 VuoListAppendValue_VuoSyphonServerDescription(descriptions, description);
48 }
49
50 return descriptions;
51}
52
60 VuoSyphonServerDescription partialDescription)
61{
63
64 unsigned long count = VuoListGetCount_VuoSyphonServerDescription(allDescriptions);
65 for (int i = 1; i <= count; ++i)
66 {
68
69 if (partialDescription.useWildcard)
70 {
71 if (VuoText_compare(description.serverUUID, (VuoTextComparison){VuoTextComparison_MatchesWildcard, true}, partialDescription.serverUUID)
72 && VuoText_compare(description.serverName, (VuoTextComparison){VuoTextComparison_MatchesWildcard, true}, partialDescription.serverName)
73 && VuoText_compare(description.applicationName, (VuoTextComparison){VuoTextComparison_MatchesWildcard, true}, partialDescription.applicationName))
74 VuoListAppendValue_VuoSyphonServerDescription(filteredDescriptions, description);
75 }
76 else
77 {
79 if ((!partialDescription.serverUUID || strstr(description.serverUUID, partialDescription.serverUUID ) != NULL)
80 && (!partialDescription.serverName || strstr(description.serverName, partialDescription.serverName ) != NULL)
81 && (!partialDescription.applicationName || strstr(description.applicationName, partialDescription.applicationName) != NULL))
82 VuoListAppendValue_VuoSyphonServerDescription(filteredDescriptions, description);
83 }
84 }
85
86 return filteredDescriptions;
87}
88
89
90void VuoSyphonClient_free(void *syphonClient);
91
96{
97 VuoSyphonListener *listener = [[VuoSyphonListener alloc] init];
99 return (VuoSyphonClient)listener;
100}
101
108 VuoSyphonServerDescription serverDescription,
109 VuoOutputTrigger(receivedFrame, VuoImage))
110{
111 VuoApp_init(false);
112 VuoSyphonListener *listener = (VuoSyphonListener *)syphonClient;
113 [listener startListeningWithServerDescription:serverDescription callback:receivedFrame];
114}
115
120{
121 VuoSyphonListener *listener = (VuoSyphonListener *)syphonClient;
122 [listener stopListening];
123}
124
128void VuoSyphonClient_free(void *syphonClient)
129{
130 VuoSyphonListener *listener = (VuoSyphonListener *)syphonClient;
131 [listener release];
132}
133
134
135
136void VuoSyphonServer_free(void *server);
137
147{
148 if (!serverName)
149 serverName = "Vuo Syphon Server";
150
151 VuoApp_init(false);
152 VuoSyphonSender *server = [[VuoSyphonSender alloc] init];
153 [server initServerWithName:[NSString stringWithUTF8String:serverName]];
155 return (VuoSyphonServer)server;
156}
157
162{
163 [(VuoSyphonSender*)server publishFrame:frame];
164}
165
169void VuoSyphonServer_setName(VuoSyphonServer server, const char *serverName)
170{
171 if (!serverName)
172 return;
173
174 [(VuoSyphonSender*)server setName:[NSString stringWithUTF8String:serverName]];
175}
176
180void VuoSyphonServer_free(void *server)
181{
182 [(VuoSyphonSender*)server stop];
183 [(VuoSyphonSender*)server release];
184}