Vuo  2.3.2
VuoNdiSource.c
Go to the documentation of this file.
1 
10 #include "type.h"
11 #include "VuoNdiSource.h"
12 
14 #ifdef VUO_COMPILER
16  "title": "NDI Source",
17  "description": "Information about an NDI device.",
18  "keywords": [ ],
19  "version": "1.0.0",
20  "dependencies": [
21  "VuoText",
22  ],
23  });
24 #endif
26 
39 {
40  return (VuoNdiSource){
41  VuoJson_getObjectValue(VuoText, js, "name", NULL),
42  VuoJson_getObjectValue(VuoText, js, "ipAddress", NULL),
43  VuoJson_getObjectValue(VuoInteger, js, "port", NULL)};
44 }
45 
50 {
51  json_object *js = json_object_new_object();
52 
53  if (value.name)
54  json_object_object_add(js, "name", VuoText_getJson(value.name));
55 
56  if (value.ipAddress)
57  json_object_object_add(js, "ipAddress", VuoText_getJson(value.ipAddress));
58 
59  json_object_object_add(js, "port", VuoInteger_getJson(value.port));
60 
61  return js;
62 }
63 
68 {
69  if (value.name && value.ipAddress)
70  return VuoText_format("%s (%s:%lld)", value.name, value.ipAddress, value.port);
71  else if (value.name)
72  return strdup(value.name);
73  else if (value.ipAddress)
74  return VuoText_format("%s:%lld", value.ipAddress, value.port);
75  else
76  return strdup("First available public source");
77 }
78 
83 {
84  if (value.name)
85  return strdup(value.name);
86  else if (value.ipAddress)
87  return VuoText_format("%s:%lld", value.ipAddress, value.port);
88  else
89  return strdup("First");
90 }
91 
95 bool VuoNdiSource_areEqual(const VuoNdiSource value1, const VuoNdiSource value2)
96 {
97  if (!VuoText_areEqual(value1.name, value2.name))
98  return false;
99 
100  if (!VuoText_areEqual(value1.ipAddress, value2.ipAddress))
101  return false;
102 
103  if (value1.port != value2.port)
104  return false;
105 
106  return true;
107 }
108 
113 {
114  VuoType_returnInequality(VuoText, a.name, b.name);
115  VuoType_returnInequality(VuoText, a.ipAddress, b.ipAddress);
116  VuoType_returnInequality(VuoInteger, a.port, b.port);
117  return false;
118 }
119 
124 {
125  return VuoText_isPopulated(source.name)
126  || VuoText_isPopulated(source.ipAddress);
127 }