Vuo
2.4.4
Loading...
Searching...
No Matches
node
vuo.video
VuoVideoInputDevice.c
Go to the documentation of this file.
1
10
#include <string.h>
11
#include "
VuoVideoInputDevice.h
"
12
14
#ifdef VUO_COMPILER
15
VuoModuleMetadata
({
16
"title"
:
"Video Input Device"
,
17
"description"
:
"Information about a video input device."
,
18
"keywords"
: [ ],
19
"version"
:
"1.0.0"
,
20
"dependencies"
: [
21
"VuoText"
22
]
23
});
24
#endif
26
30
static
VuoVideoInputDevice_MatchType
VuoVideoInputDevice_getMatchTypeForString
(
const
char
*
string
)
31
{
32
if
(strcmp(
string
,
"id"
) == 0)
33
return
VuoVideoInputDevice_MatchId;
34
35
return
VuoVideoInputDevice_MatchIdThenName;
36
}
37
41
static
const
char
*
VuoVideoInputDevice_getStringForMatchType
(
VuoVideoInputDevice_MatchType
type)
42
{
43
if
(type == VuoVideoInputDevice_MatchId)
44
return
"id"
;
45
46
return
"id-name"
;
47
}
48
59
VuoVideoInputDevice
VuoVideoInputDevice_makeFromJson
(json_object *js)
60
{
61
VuoVideoInputDevice
value = {VuoVideoInputDevice_MatchIdThenName,
""
,
""
};
62
json_object *o = NULL;
63
64
if
(json_object_object_get_ex(js,
"matchType"
, &o))
65
value.
matchType
=
VuoVideoInputDevice_getMatchTypeForString
(json_object_get_string(o));
66
67
if
(json_object_object_get_ex(js,
"id"
, &o))
68
value.
id
=
VuoText_makeFromJson
(o);
69
else
70
value.
id
=
VuoText_make
(
""
);
71
72
if
(json_object_object_get_ex(js,
"name"
, &o))
73
value.
name
=
VuoText_makeFromJson
(o);
74
else
75
value.
name
=
VuoText_make
(
""
);
76
77
return
value;
78
}
79
83
json_object *
VuoVideoInputDevice_getJson
(
const
VuoVideoInputDevice
value)
84
{
85
json_object *js = json_object_new_object();
86
87
json_object *matchTypeObject = json_object_new_string(
VuoVideoInputDevice_getStringForMatchType
(value.
matchType
));
88
json_object_object_add(js,
"matchType"
, matchTypeObject);
89
90
json_object *idObject =
VuoText_getJson
(value.
id
);
91
json_object_object_add(js,
"id"
, idObject);
92
93
json_object *nameObject =
VuoText_getJson
(value.
name
);
94
json_object_object_add(js,
"name"
, nameObject);
95
96
return
js;
97
}
98
102
char
*
VuoVideoInputDevice_getSummary
(
const
VuoVideoInputDevice
value)
103
{
104
if
(
VuoText_isEmpty
(value.
name
) &&
VuoText_isEmpty
(value.
id
))
105
return
strdup(
"Default device"
);
106
else
107
{
108
if
(value.
matchType
== VuoVideoInputDevice_MatchId)
109
return
VuoText_format
(
"Device with ID \"%s\" (\"%s\")"
, value.
id
, value.
name
);
110
else
111
return
VuoText_format
(
"Device with name \"%s\""
, value.
name
);
112
}
113
}
114
118
bool
VuoVideoInputDevice_areEqual
(
VuoVideoInputDevice
value1,
VuoVideoInputDevice
value2)
119
{
120
return
value1.
matchType
== value2.
matchType
121
&&
VuoText_areEqual
(value1.
id
, value2.
id
)
122
&&
VuoText_areEqual
(value1.
name
, value2.
name
);
123
}
124
129
bool
VuoVideoInputDevice_isLessThan
(
const
VuoVideoInputDevice
a,
const
VuoVideoInputDevice
b)
130
{
131
VuoType_returnInequality
(
VuoInteger
, a.
matchType
, b.
matchType
);
132
VuoType_returnInequality
(
VuoText
, a.
id
, b.
id
);
133
VuoType_returnInequality
(
VuoText
, a.
name
, b.
name
);
134
return
false
;
135
}
Generated on Thu Nov 9 2023 16:59:30 for Vuo by
1.9.8