Vuo 2.4.2
Loading...
Searching...
No Matches
VuoVideoInputDevice.c
Go to the documentation of this file.
1
10#include <string.h>
11#include "type.h"
12#include "VuoVideoInputDevice.h"
13
15#ifdef VUO_COMPILER
17 "title" : "Video Input Device",
18 "description" : "Information about a video input device.",
19 "keywords" : [ ],
20 "version" : "1.0.0",
21 "dependencies" : [
22 "VuoText"
23 ]
24 });
25#endif
27
32{
33 if (strcmp(string, "id") == 0)
34 return VuoVideoInputDevice_MatchId;
35
36 return VuoVideoInputDevice_MatchIdThenName;
37}
38
43{
44 if (type == VuoVideoInputDevice_MatchId)
45 return "id";
46
47 return "id-name";
48}
49
61{
62 VuoVideoInputDevice value = {VuoVideoInputDevice_MatchIdThenName, "", ""};
63 json_object *o = NULL;
64
65 if (json_object_object_get_ex(js, "matchType", &o))
66 value.matchType = VuoVideoInputDevice_getMatchTypeForString(json_object_get_string(o));
67
68 if (json_object_object_get_ex(js, "id", &o))
69 value.id = VuoText_makeFromJson(o);
70 else
71 value.id = VuoText_make("");
72
73 if (json_object_object_get_ex(js, "name", &o))
74 value.name = VuoText_makeFromJson(o);
75 else
76 value.name = VuoText_make("");
77
78 return value;
79}
80
85{
86 json_object *js = json_object_new_object();
87
88 json_object *matchTypeObject = json_object_new_string(VuoVideoInputDevice_getStringForMatchType(value.matchType));
89 json_object_object_add(js, "matchType", matchTypeObject);
90
91 json_object *idObject = VuoText_getJson(value.id);
92 json_object_object_add(js, "id", idObject);
93
94 json_object *nameObject = VuoText_getJson(value.name);
95 json_object_object_add(js, "name", nameObject);
96
97 return js;
98}
99
104{
105 if (VuoText_isEmpty(value.name) && VuoText_isEmpty(value.id))
106 return strdup("Default device");
107 else
108 {
109 if (value.matchType == VuoVideoInputDevice_MatchId)
110 return VuoText_format("Device with ID \"%s\" (\"%s\")", value.id, value.name);
111 else
112 return VuoText_format("Device with name \"%s\"", value.name);
113 }
114}
115
120{
121 return value1.matchType == value2.matchType
122 && VuoText_areEqual(value1.id, value2.id)
123 && VuoText_areEqual(value1.name, value2.name);
124}
125
131{
135 return false;
136}