Commit | Line | Data |
---|---|---|
11b0cdc8 | 1 | /* |
f2b0325d | 2 | * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com> |
de9dd397 | 3 | * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
11b0cdc8 | 4 | * |
11b0cdc8 JG |
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
6 | * of this software and associated documentation files (the "Software"), to deal | |
7 | * in the Software without restriction, including without limitation the rights | |
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
9 | * copies of the Software, and to permit persons to whom the Software is | |
10 | * furnished to do so, subject to the following conditions: | |
11 | * | |
12 | * The above copyright notice and this permission notice shall be included in | |
13 | * all copies or substantial portions of the Software. | |
14 | * | |
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
21 | * SOFTWARE. | |
22 | */ | |
23 | ||
d2f71f12 PP |
24 | #define BT_LOG_TAG "STREAM-CLASS" |
25 | #include <babeltrace/lib-logging-internal.h> | |
26 | ||
8deee039 | 27 | #include <babeltrace/assert-pre-internal.h> |
108b91d0 PP |
28 | #include <babeltrace/trace-ir/clock-class-internal.h> |
29 | #include <babeltrace/trace-ir/event-class-internal.h> | |
0f15f666 PP |
30 | #include <babeltrace/trace-ir/field-class-internal.h> |
31 | #include <babeltrace/trace-ir/field-internal.h> | |
108b91d0 | 32 | #include <babeltrace/trace-ir/stream-class-internal.h> |
78cf9df6 | 33 | #include <babeltrace/trace-ir/trace-const.h> |
9e550e5f | 34 | #include <babeltrace/trace-ir/trace-internal.h> |
108b91d0 PP |
35 | #include <babeltrace/trace-ir/utils-internal.h> |
36 | #include <babeltrace/trace-ir/field-wrapper-internal.h> | |
37 | #include <babeltrace/trace-ir/resolve-field-path-internal.h> | |
3d9990ac PP |
38 | #include <babeltrace/compiler-internal.h> |
39 | #include <babeltrace/align-internal.h> | |
40 | #include <babeltrace/endian-internal.h> | |
8b45963b | 41 | #include <babeltrace/assert-internal.h> |
7b33a0e0 | 42 | #include <babeltrace/property-internal.h> |
dc3fffef | 43 | #include <inttypes.h> |
544d0515 | 44 | #include <stdint.h> |
e011d2c1 | 45 | #include <stdbool.h> |
11b0cdc8 | 46 | |
7b33a0e0 PP |
47 | #define BT_ASSERT_PRE_STREAM_CLASS_HOT(_sc) \ |
48 | BT_ASSERT_PRE_HOT((_sc), "Stream class", ": %!+S", (_sc)) | |
142c5610 | 49 | |
18acc6f8 | 50 | static |
7b33a0e0 | 51 | void destroy_stream_class(struct bt_object *obj) |
3ea33115 | 52 | { |
18acc6f8 PP |
53 | struct bt_stream_class *stream_class = (void *) obj; |
54 | ||
7b33a0e0 PP |
55 | BT_LIB_LOGD("Destroying stream class: %!+S", stream_class); |
56 | BT_LOGD_STR("Putting default clock class."); | |
1248f5ea | 57 | BT_OBJECT_PUT_REF_AND_RESET(stream_class->default_clock_class); |
3ea33115 | 58 | |
8deee039 PP |
59 | if (stream_class->event_classes) { |
60 | BT_LOGD_STR("Destroying event classes."); | |
61 | g_ptr_array_free(stream_class->event_classes, TRUE); | |
1248f5ea | 62 | stream_class->event_classes = NULL; |
d2f71f12 PP |
63 | } |
64 | ||
7b33a0e0 PP |
65 | if (stream_class->name.str) { |
66 | g_string_free(stream_class->name.str, TRUE); | |
1248f5ea PP |
67 | stream_class->name.str = NULL; |
68 | stream_class->name.value = NULL; | |
3ea33115 JG |
69 | } |
70 | ||
66fd07a5 | 71 | BT_LOGD_STR("Putting packet context field class."); |
1248f5ea | 72 | BT_OBJECT_PUT_REF_AND_RESET(stream_class->packet_context_fc); |
66fd07a5 | 73 | BT_LOGD_STR("Putting event common context field class."); |
1248f5ea | 74 | BT_OBJECT_PUT_REF_AND_RESET(stream_class->event_common_context_fc); |
a6918753 | 75 | bt_object_pool_finalize(&stream_class->packet_context_field_pool); |
8deee039 | 76 | g_free(stream_class); |
3ea33115 JG |
77 | } |
78 | ||
a6918753 PP |
79 | static |
80 | void free_field_wrapper(struct bt_field_wrapper *field_wrapper, | |
81 | struct bt_stream_class *stream_class) | |
82 | { | |
83 | bt_field_wrapper_destroy((void *) field_wrapper); | |
84 | } | |
85 | ||
7b33a0e0 PP |
86 | BT_ASSERT_PRE_FUNC |
87 | static | |
10b7a2e4 | 88 | bool stream_class_id_is_unique(const struct bt_trace_class *tc, uint64_t id) |
7b33a0e0 PP |
89 | { |
90 | uint64_t i; | |
91 | bool is_unique = true; | |
92 | ||
10b7a2e4 | 93 | for (i = 0; i < tc->stream_classes->len; i++) { |
78cf9df6 | 94 | const struct bt_stream_class *sc = |
10b7a2e4 | 95 | tc->stream_classes->pdata[i]; |
7b33a0e0 PP |
96 | |
97 | if (sc->id == id) { | |
98 | is_unique = false; | |
99 | goto end; | |
100 | } | |
101 | } | |
102 | ||
103 | end: | |
104 | return is_unique; | |
105 | } | |
106 | ||
107 | static | |
10b7a2e4 PP |
108 | struct bt_stream_class *create_stream_class_with_id( |
109 | struct bt_trace_class *tc, uint64_t id) | |
2f100782 | 110 | { |
8deee039 PP |
111 | struct bt_stream_class *stream_class = NULL; |
112 | int ret; | |
2f100782 | 113 | |
10b7a2e4 PP |
114 | BT_ASSERT(tc); |
115 | BT_ASSERT_PRE(stream_class_id_is_unique(tc, id), | |
116 | "Duplicate stream class ID: %![tc-]+T, id=%" PRIu64, tc, id); | |
117 | BT_LIB_LOGD("Creating stream class object: %![tc-]+T, id=%" PRIu64, | |
118 | tc, id); | |
8deee039 | 119 | stream_class = g_new0(struct bt_stream_class, 1); |
d2f71f12 | 120 | if (!stream_class) { |
8deee039 PP |
121 | BT_LOGE_STR("Failed to allocate one stream class."); |
122 | goto error; | |
d2f71f12 PP |
123 | } |
124 | ||
7b33a0e0 PP |
125 | bt_object_init_shared_with_parent(&stream_class->base, |
126 | destroy_stream_class); | |
127 | ||
128 | stream_class->name.str = g_string_new(NULL); | |
129 | if (!stream_class->name.str) { | |
130 | BT_LOGE_STR("Failed to allocate a GString."); | |
131 | ret = -1; | |
132 | goto end; | |
133 | } | |
134 | ||
135 | stream_class->id = id; | |
136 | stream_class->assigns_automatic_event_class_id = true; | |
137 | stream_class->assigns_automatic_stream_id = true; | |
138 | stream_class->event_classes = g_ptr_array_new_with_free_func( | |
139 | (GDestroyNotify) bt_object_try_spec_release); | |
140 | if (!stream_class->event_classes) { | |
141 | BT_LOGE_STR("Failed to allocate a GPtrArray."); | |
8deee039 | 142 | goto error; |
2f100782 JG |
143 | } |
144 | ||
a6918753 PP |
145 | ret = bt_object_pool_initialize(&stream_class->packet_context_field_pool, |
146 | (bt_object_pool_new_object_func) bt_field_wrapper_new, | |
147 | (bt_object_pool_destroy_object_func) free_field_wrapper, | |
148 | stream_class); | |
149 | if (ret) { | |
150 | BT_LOGE("Failed to initialize packet context field pool: ret=%d", | |
151 | ret); | |
152 | goto error; | |
153 | } | |
154 | ||
10b7a2e4 PP |
155 | bt_object_set_parent(&stream_class->base, &tc->base); |
156 | g_ptr_array_add(tc->stream_classes, stream_class); | |
157 | bt_trace_class_freeze(tc); | |
7b33a0e0 | 158 | BT_LIB_LOGD("Created stream class object: %!+S", stream_class); |
a6918753 PP |
159 | goto end; |
160 | ||
161 | error: | |
8138bfe1 | 162 | BT_OBJECT_PUT_REF_AND_RESET(stream_class); |
a6918753 PP |
163 | |
164 | end: | |
7b33a0e0 | 165 | return stream_class; |
a6918753 PP |
166 | } |
167 | ||
10b7a2e4 | 168 | struct bt_stream_class *bt_stream_class_create(struct bt_trace_class *tc) |
a6918753 | 169 | { |
10b7a2e4 PP |
170 | BT_ASSERT_PRE_NON_NULL(tc, "Trace class"); |
171 | BT_ASSERT_PRE(tc->assigns_automatic_stream_class_id, | |
172 | "Trace class does not automatically assigns stream class IDs: " | |
173 | "%![sc-]+T", tc); | |
174 | return create_stream_class_with_id(tc, | |
175 | (uint64_t) tc->stream_classes->len); | |
7b33a0e0 | 176 | } |
a6918753 | 177 | |
78cf9df6 | 178 | struct bt_stream_class *bt_stream_class_create_with_id( |
10b7a2e4 | 179 | struct bt_trace_class *tc, uint64_t id) |
7b33a0e0 | 180 | { |
10b7a2e4 PP |
181 | BT_ASSERT_PRE_NON_NULL(tc, "Trace class"); |
182 | BT_ASSERT_PRE(!tc->assigns_automatic_stream_class_id, | |
183 | "Trace class automatically assigns stream class IDs: " | |
184 | "%![sc-]+T", tc); | |
185 | return create_stream_class_with_id(tc, id); | |
a6918753 PP |
186 | } |
187 | ||
10b7a2e4 | 188 | struct bt_trace_class *bt_stream_class_borrow_trace_class( |
78cf9df6 | 189 | struct bt_stream_class *stream_class) |
11b0cdc8 | 190 | { |
7b33a0e0 | 191 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
10b7a2e4 | 192 | return bt_stream_class_borrow_trace_class_inline(stream_class); |
11b0cdc8 JG |
193 | } |
194 | ||
10b7a2e4 | 195 | const struct bt_trace_class *bt_stream_class_borrow_trace_class_const( |
78cf9df6 | 196 | const struct bt_stream_class *stream_class) |
9e550e5f | 197 | { |
10b7a2e4 | 198 | return bt_stream_class_borrow_trace_class((void *) stream_class); |
9e550e5f PP |
199 | } |
200 | ||
78cf9df6 | 201 | const char *bt_stream_class_get_name(const struct bt_stream_class *stream_class) |
2f100782 | 202 | { |
18acc6f8 | 203 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
7b33a0e0 | 204 | return stream_class->name.value; |
2f100782 JG |
205 | } |
206 | ||
36a28778 | 207 | enum bt_stream_class_status bt_stream_class_set_name( |
78cf9df6 | 208 | struct bt_stream_class *stream_class, |
8deee039 | 209 | const char *name) |
5ca83563 | 210 | { |
7b33a0e0 PP |
211 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
212 | BT_ASSERT_PRE_NON_NULL(name, "Name"); | |
213 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); | |
214 | g_string_assign(stream_class->name.str, name); | |
215 | stream_class->name.value = stream_class->name.str->str; | |
216 | BT_LIB_LOGV("Set stream class's name: %!+S", stream_class); | |
36a28778 | 217 | return BT_STREAM_CLASS_STATUS_OK; |
5ca83563 JG |
218 | } |
219 | ||
78cf9df6 | 220 | uint64_t bt_stream_class_get_id(const struct bt_stream_class *stream_class) |
2f100782 | 221 | { |
18acc6f8 | 222 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
7b33a0e0 | 223 | return stream_class->id; |
2f100782 JG |
224 | } |
225 | ||
7b33a0e0 | 226 | uint64_t bt_stream_class_get_event_class_count( |
78cf9df6 | 227 | const struct bt_stream_class *stream_class) |
29664b2a | 228 | { |
7b33a0e0 PP |
229 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
230 | return (uint64_t) stream_class->event_classes->len; | |
29664b2a PP |
231 | } |
232 | ||
7b33a0e0 PP |
233 | struct bt_event_class *bt_stream_class_borrow_event_class_by_index( |
234 | struct bt_stream_class *stream_class, uint64_t index) | |
0d23acbe | 235 | { |
7b33a0e0 PP |
236 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
237 | BT_ASSERT_PRE_VALID_INDEX(index, stream_class->event_classes->len); | |
238 | return g_ptr_array_index(stream_class->event_classes, index); | |
0d23acbe PP |
239 | } |
240 | ||
78cf9df6 PP |
241 | const struct bt_event_class * |
242 | bt_stream_class_borrow_event_class_by_index_const( | |
243 | const struct bt_stream_class *stream_class, uint64_t index) | |
9e550e5f | 244 | { |
78cf9df6 | 245 | return bt_stream_class_borrow_event_class_by_index( |
9e550e5f PP |
246 | (void *) stream_class, index); |
247 | } | |
248 | ||
7b33a0e0 | 249 | struct bt_event_class *bt_stream_class_borrow_event_class_by_id( |
9e550e5f | 250 | struct bt_stream_class *stream_class, uint64_t id) |
11b0cdc8 | 251 | { |
7b33a0e0 PP |
252 | struct bt_event_class *event_class = NULL; |
253 | uint64_t i; | |
0b9ce69f | 254 | |
10b7a2e4 | 255 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
11b0cdc8 | 256 | |
9e550e5f | 257 | for (i = 0; i < stream_class->event_classes->len; i++) { |
7b33a0e0 | 258 | struct bt_event_class *event_class_candidate = |
9e550e5f | 259 | g_ptr_array_index(stream_class->event_classes, i); |
e6a8e8e4 | 260 | |
7b33a0e0 PP |
261 | if (event_class_candidate->id == id) { |
262 | event_class = event_class_candidate; | |
09840de5 PP |
263 | goto end; |
264 | } | |
69dc4535 JG |
265 | } |
266 | ||
69dc4535 | 267 | end: |
7b33a0e0 | 268 | return event_class; |
0863f950 PP |
269 | } |
270 | ||
78cf9df6 PP |
271 | const struct bt_event_class * |
272 | bt_stream_class_borrow_event_class_by_id_const( | |
273 | const struct bt_stream_class *stream_class, uint64_t id) | |
9e550e5f | 274 | { |
78cf9df6 | 275 | return bt_stream_class_borrow_event_class_by_id( |
9e550e5f PP |
276 | (void *) stream_class, id); |
277 | } | |
278 | ||
78cf9df6 PP |
279 | const struct bt_field_class * |
280 | bt_stream_class_borrow_packet_context_field_class_const( | |
281 | const struct bt_stream_class *stream_class) | |
12c8a1a3 | 282 | { |
18acc6f8 | 283 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
939190b3 | 284 | return stream_class->packet_context_fc; |
12c8a1a3 JG |
285 | } |
286 | ||
36a28778 | 287 | enum bt_stream_class_status bt_stream_class_set_packet_context_field_class( |
78cf9df6 PP |
288 | struct bt_stream_class *stream_class, |
289 | struct bt_field_class *field_class) | |
12c8a1a3 | 290 | { |
7b33a0e0 PP |
291 | int ret; |
292 | struct bt_resolve_field_path_context resolve_ctx = { | |
939190b3 | 293 | .packet_context = field_class, |
7b33a0e0 PP |
294 | .event_common_context = NULL, |
295 | .event_specific_context = NULL, | |
296 | .event_payload = NULL, | |
297 | }; | |
18acc6f8 | 298 | |
7b33a0e0 | 299 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
939190b3 | 300 | BT_ASSERT_PRE_NON_NULL(field_class, "Field class"); |
7b33a0e0 | 301 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
af0c18e3 PP |
302 | BT_ASSERT_PRE(bt_field_class_get_type(field_class) == |
303 | BT_FIELD_CLASS_TYPE_STRUCTURE, | |
66fd07a5 | 304 | "Packet context field class is not a structure field class: %!+F", |
939190b3 | 305 | field_class); |
939190b3 | 306 | ret = bt_resolve_field_paths(field_class, &resolve_ctx); |
7b33a0e0 | 307 | if (ret) { |
36a28778 PP |
308 | /* |
309 | * This is the only reason for which | |
310 | * bt_resolve_field_paths() can fail: anything else | |
311 | * would be because a precondition is not satisfied. | |
312 | */ | |
313 | ret = BT_STREAM_CLASS_STATUS_NOMEM; | |
18acc6f8 PP |
314 | goto end; |
315 | } | |
316 | ||
10b7a2e4 | 317 | bt_field_class_make_part_of_trace_class(field_class); |
8138bfe1 | 318 | bt_object_put_ref(stream_class->packet_context_fc); |
4b70020d PP |
319 | stream_class->packet_context_fc = field_class; |
320 | bt_object_get_no_null_check(stream_class->packet_context_fc); | |
939190b3 | 321 | bt_field_class_freeze(field_class); |
66fd07a5 | 322 | BT_LIB_LOGV("Set stream class's packet context field class: %!+S", |
7b33a0e0 | 323 | stream_class); |
18acc6f8 PP |
324 | |
325 | end: | |
326 | return ret; | |
12c8a1a3 JG |
327 | } |
328 | ||
78cf9df6 PP |
329 | const struct bt_field_class * |
330 | bt_stream_class_borrow_event_common_context_field_class_const( | |
331 | const struct bt_stream_class *stream_class) | |
af181248 | 332 | { |
18acc6f8 | 333 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
939190b3 | 334 | return stream_class->event_common_context_fc; |
af181248 JG |
335 | } |
336 | ||
36a28778 PP |
337 | enum bt_stream_class_status |
338 | bt_stream_class_set_event_common_context_field_class( | |
78cf9df6 PP |
339 | struct bt_stream_class *stream_class, |
340 | struct bt_field_class *field_class) | |
af181248 | 341 | { |
7b33a0e0 PP |
342 | int ret; |
343 | struct bt_resolve_field_path_context resolve_ctx = { | |
7b33a0e0 | 344 | .packet_context = NULL, |
939190b3 | 345 | .event_common_context = field_class, |
7b33a0e0 PP |
346 | .event_specific_context = NULL, |
347 | .event_payload = NULL, | |
348 | }; | |
18acc6f8 | 349 | |
7b33a0e0 | 350 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
939190b3 | 351 | BT_ASSERT_PRE_NON_NULL(field_class, "Field class"); |
7b33a0e0 | 352 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
af0c18e3 PP |
353 | BT_ASSERT_PRE(bt_field_class_get_type(field_class) == |
354 | BT_FIELD_CLASS_TYPE_STRUCTURE, | |
66fd07a5 | 355 | "Event common context field class is not a structure field class: %!+F", |
939190b3 | 356 | field_class); |
939190b3 | 357 | resolve_ctx.packet_context = stream_class->packet_context_fc; |
939190b3 | 358 | ret = bt_resolve_field_paths(field_class, &resolve_ctx); |
7b33a0e0 | 359 | if (ret) { |
36a28778 PP |
360 | /* |
361 | * This is the only reason for which | |
362 | * bt_resolve_field_paths() can fail: anything else | |
363 | * would be because a precondition is not satisfied. | |
364 | */ | |
365 | ret = BT_STREAM_CLASS_STATUS_NOMEM; | |
18acc6f8 PP |
366 | goto end; |
367 | } | |
368 | ||
10b7a2e4 | 369 | bt_field_class_make_part_of_trace_class(field_class); |
8138bfe1 | 370 | bt_object_put_ref(stream_class->event_common_context_fc); |
4b70020d PP |
371 | stream_class->event_common_context_fc = field_class; |
372 | bt_object_get_no_null_check(stream_class->event_common_context_fc); | |
939190b3 | 373 | bt_field_class_freeze(field_class); |
66fd07a5 | 374 | BT_LIB_LOGV("Set stream class's event common context field class: %!+S", |
7b33a0e0 | 375 | stream_class); |
18acc6f8 | 376 | |
18acc6f8 PP |
377 | end: |
378 | return ret; | |
11b0cdc8 JG |
379 | } |
380 | ||
7b33a0e0 | 381 | BT_HIDDEN |
78cf9df6 | 382 | void _bt_stream_class_freeze(const struct bt_stream_class *stream_class) |
8bf65fbd | 383 | { |
939190b3 | 384 | /* The field classes and default clock class are already frozen */ |
7b33a0e0 PP |
385 | BT_ASSERT(stream_class); |
386 | BT_LIB_LOGD("Freezing stream class: %!+S", stream_class); | |
78cf9df6 | 387 | ((struct bt_stream_class *) stream_class)->frozen = true; |
8bf65fbd JG |
388 | } |
389 | ||
36a28778 | 390 | enum bt_stream_class_status bt_stream_class_set_default_clock_class( |
78cf9df6 | 391 | struct bt_stream_class *stream_class, |
7b33a0e0 | 392 | struct bt_clock_class *clock_class) |
8bf65fbd | 393 | { |
7b33a0e0 PP |
394 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
395 | BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class"); | |
396 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); | |
8138bfe1 | 397 | bt_object_put_ref(stream_class->default_clock_class); |
4b70020d PP |
398 | stream_class->default_clock_class = clock_class; |
399 | bt_object_get_no_null_check(stream_class->default_clock_class); | |
7b33a0e0 PP |
400 | bt_clock_class_freeze(clock_class); |
401 | BT_LIB_LOGV("Set stream class's default clock class: %!+S", | |
402 | stream_class); | |
36a28778 | 403 | return BT_STREAM_CLASS_STATUS_OK; |
8bf65fbd JG |
404 | } |
405 | ||
7b33a0e0 PP |
406 | struct bt_clock_class *bt_stream_class_borrow_default_clock_class( |
407 | struct bt_stream_class *stream_class) | |
8bf65fbd | 408 | { |
7b33a0e0 PP |
409 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
410 | return stream_class->default_clock_class; | |
411 | } | |
8bf65fbd | 412 | |
78cf9df6 PP |
413 | const struct bt_clock_class *bt_stream_class_borrow_default_clock_class_const( |
414 | const struct bt_stream_class *stream_class) | |
415 | { | |
416 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); | |
417 | return stream_class->default_clock_class; | |
418 | } | |
419 | ||
7b33a0e0 | 420 | bt_bool bt_stream_class_assigns_automatic_event_class_id( |
78cf9df6 | 421 | const struct bt_stream_class *stream_class) |
7b33a0e0 PP |
422 | { |
423 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); | |
424 | return (bt_bool) stream_class->assigns_automatic_event_class_id; | |
8bf65fbd JG |
425 | } |
426 | ||
78cf9df6 PP |
427 | void bt_stream_class_set_assigns_automatic_event_class_id( |
428 | struct bt_stream_class *stream_class, | |
9e550e5f | 429 | bt_bool value) |
8bf65fbd | 430 | { |
7b33a0e0 PP |
431 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
432 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); | |
433 | stream_class->assigns_automatic_event_class_id = (bool) value; | |
434 | BT_LIB_LOGV("Set stream class's automatic event class ID " | |
435 | "assignment property: %!+S", stream_class); | |
7b33a0e0 | 436 | } |
8bf65fbd | 437 | |
7b33a0e0 | 438 | bt_bool bt_stream_class_assigns_automatic_stream_id( |
78cf9df6 | 439 | const struct bt_stream_class *stream_class) |
7b33a0e0 PP |
440 | { |
441 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); | |
442 | return (bt_bool) stream_class->assigns_automatic_stream_id; | |
443 | } | |
8bf65fbd | 444 | |
78cf9df6 PP |
445 | void bt_stream_class_set_assigns_automatic_stream_id( |
446 | struct bt_stream_class *stream_class, | |
9e550e5f | 447 | bt_bool value) |
7b33a0e0 PP |
448 | { |
449 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); | |
450 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); | |
451 | stream_class->assigns_automatic_stream_id = (bool) value; | |
452 | BT_LIB_LOGV("Set stream class's automatic stream ID " | |
453 | "assignment property: %!+S", stream_class); | |
7b33a0e0 | 454 | } |
8deee039 | 455 | |
7b33a0e0 | 456 | bt_bool bt_stream_class_default_clock_is_always_known( |
78cf9df6 | 457 | const struct bt_stream_class *stream_class) |
7b33a0e0 | 458 | { |
a13b98e1 | 459 | /* BT_CLOCK_SNAPSHOT_STATE_UNKNOWN is not supported as of 2.0 */ |
7b33a0e0 | 460 | return BT_TRUE; |
8c4a29ba | 461 | } |
8c6884d9 PP |
462 | |
463 | void bt_stream_class_get_ref(const struct bt_stream_class *stream_class) | |
464 | { | |
465 | bt_object_get_ref(stream_class); | |
466 | } | |
467 | ||
468 | void bt_stream_class_put_ref(const struct bt_stream_class *stream_class) | |
469 | { | |
470 | bt_object_put_ref(stream_class); | |
471 | } |