Vuo 2.4.4
Loading...
Searching...
No Matches
VuoVideoInputDevice.c
Go to the documentation of this file.
1
10#include <string.h>
11#include "VuoVideoInputDevice.h"
12
14#ifdef VUO_COMPILER
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
31{
32 if (strcmp(string, "id") == 0)
33 return VuoVideoInputDevice_MatchId;
34
35 return VuoVideoInputDevice_MatchIdThenName;
36}
37
42{
43 if (type == VuoVideoInputDevice_MatchId)
44 return "id";
45
46 return "id-name";
47}
48
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
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
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
119{
120 return value1.matchType == value2.matchType
121 && VuoText_areEqual(value1.id, value2.id)
122 && VuoText_areEqual(value1.name, value2.name);
123}
124