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