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