cpp-common/bt2c/fmt.hpp: use `wise_enum::string_type` in `EnableIfIsWiseEnum` definition
[babeltrace.git] / src / lib / trace-ir / stream-class.c
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
5 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 */
7
8 #define BT_LOG_TAG "LIB/STREAM-CLASS"
9 #include "lib/logging.h"
10
11 #include "lib/assert-cond.h"
12 #include <babeltrace2/trace-ir/trace.h>
13 #include "compat/compiler.h"
14 #include "compat/endian.h"
15 #include "common/assert.h"
16 #include <inttypes.h>
17 #include <stdint.h>
18 #include <stdbool.h>
19
20 #include "clock-class.h"
21 #include "event-class.h"
22 #include "field-class.h"
23 #include "field-wrapper.h"
24 #include "resolve-field-path.h"
25 #include "stream-class.h"
26 #include "lib/value.h"
27 #include "lib/func-status.h"
28 #include "trace-class.h"
29
30 #define BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(_sc) \
31 BT_ASSERT_PRE_DEV_HOT("stream-class", (_sc), "Stream class", \
32 ": %!+S", (_sc))
33
34 static
35 void destroy_stream_class(struct bt_object *obj)
36 {
37 struct bt_stream_class *stream_class = (void *) obj;
38
39 BT_LIB_LOGD("Destroying stream class: %!+S", stream_class);
40 BT_LOGD_STR("Putting default clock class.");
41 BT_OBJECT_PUT_REF_AND_RESET(stream_class->user_attributes);
42 BT_OBJECT_PUT_REF_AND_RESET(stream_class->default_clock_class);
43
44 if (stream_class->event_classes) {
45 BT_LOGD_STR("Destroying event classes.");
46 g_ptr_array_free(stream_class->event_classes, TRUE);
47 stream_class->event_classes = NULL;
48 }
49
50 if (stream_class->name.str) {
51 g_string_free(stream_class->name.str, TRUE);
52 stream_class->name.str = NULL;
53 stream_class->name.value = NULL;
54 }
55
56 BT_LOGD_STR("Putting packet context field class.");
57 BT_OBJECT_PUT_REF_AND_RESET(stream_class->packet_context_fc);
58 BT_LOGD_STR("Putting event common context field class.");
59 BT_OBJECT_PUT_REF_AND_RESET(stream_class->event_common_context_fc);
60 bt_object_pool_finalize(&stream_class->packet_context_field_pool);
61 g_free(stream_class);
62 }
63
64 static
65 void free_field_wrapper(struct bt_field_wrapper *field_wrapper,
66 struct bt_stream_class *stream_class __attribute__((unused)))
67 {
68 bt_field_wrapper_destroy((void *) field_wrapper);
69 }
70
71 static
72 bool stream_class_id_is_unique(const struct bt_trace_class *tc, uint64_t id)
73 {
74 uint64_t i;
75 bool is_unique = true;
76
77 for (i = 0; i < tc->stream_classes->len; i++) {
78 const struct bt_stream_class *sc =
79 tc->stream_classes->pdata[i];
80
81 if (sc->id == id) {
82 is_unique = false;
83 goto end;
84 }
85 }
86
87 end:
88 return is_unique;
89 }
90
91 static
92 struct bt_stream_class *create_stream_class_with_id(
93 struct bt_trace_class *tc, uint64_t id)
94 {
95 struct bt_stream_class *stream_class = NULL;
96 int ret;
97
98 BT_ASSERT(tc);
99 BT_ASSERT_PRE("stream-class-id-is-unique",
100 stream_class_id_is_unique(tc, id),
101 "Duplicate stream class ID: %![tc-]+T, id=%" PRIu64, tc, id);
102 BT_LIB_LOGD("Creating stream class object: %![tc-]+T, id=%" PRIu64,
103 tc, id);
104 stream_class = g_new0(struct bt_stream_class, 1);
105 if (!stream_class) {
106 BT_LIB_LOGE_APPEND_CAUSE(
107 "Failed to allocate one stream class.");
108 goto error;
109 }
110
111 bt_object_init_shared_with_parent(&stream_class->base,
112 destroy_stream_class);
113 stream_class->user_attributes = bt_value_map_create();
114 if (!stream_class->user_attributes) {
115 BT_LIB_LOGE_APPEND_CAUSE(
116 "Failed to create a map value object.");
117 goto error;
118 }
119
120 stream_class->name.str = g_string_new(NULL);
121 if (!stream_class->name.str) {
122 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GString.");
123 goto error;
124 }
125
126 stream_class->id = id;
127 stream_class->assigns_automatic_event_class_id = true;
128 stream_class->assigns_automatic_stream_id = true;
129 stream_class->event_classes = g_ptr_array_new_with_free_func(
130 (GDestroyNotify) bt_object_try_spec_release);
131 if (!stream_class->event_classes) {
132 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GPtrArray.");
133 goto error;
134 }
135
136 ret = bt_object_pool_initialize(&stream_class->packet_context_field_pool,
137 (bt_object_pool_new_object_func) bt_field_wrapper_new,
138 (bt_object_pool_destroy_object_func) free_field_wrapper,
139 stream_class);
140 if (ret) {
141 BT_LIB_LOGE_APPEND_CAUSE(
142 "Failed to initialize packet context field pool: ret=%d",
143 ret);
144 goto error;
145 }
146
147 bt_object_set_parent(&stream_class->base, &tc->base);
148 g_ptr_array_add(tc->stream_classes, stream_class);
149 bt_trace_class_freeze(tc);
150 BT_LIB_LOGD("Created stream class object: %!+S", stream_class);
151 goto end;
152
153 error:
154 BT_OBJECT_PUT_REF_AND_RESET(stream_class);
155
156 end:
157 return stream_class;
158 }
159
160 BT_EXPORT
161 struct bt_stream_class *bt_stream_class_create(struct bt_trace_class *tc)
162 {
163 BT_ASSERT_PRE_NO_ERROR();
164 BT_ASSERT_PRE_TC_NON_NULL(tc);
165 BT_ASSERT_PRE("trace-class-automatically-assigns-stream-class-ids",
166 tc->assigns_automatic_stream_class_id,
167 "Trace class does not automatically assigns stream class IDs: "
168 "%![sc-]+T", tc);
169 return create_stream_class_with_id(tc,
170 (uint64_t) tc->stream_classes->len);
171 }
172
173 BT_EXPORT
174 struct bt_stream_class *bt_stream_class_create_with_id(
175 struct bt_trace_class *tc, uint64_t id)
176 {
177 BT_ASSERT_PRE_NO_ERROR();
178 BT_ASSERT_PRE_TC_NON_NULL(tc);
179 BT_ASSERT_PRE(
180 "trace-class-does-not-automatically-assigns-stream-class-ids",
181 !tc->assigns_automatic_stream_class_id,
182 "Trace class automatically assigns stream class IDs: "
183 "%![sc-]+T", tc);
184 return create_stream_class_with_id(tc, id);
185 }
186
187 BT_EXPORT
188 struct bt_trace_class *bt_stream_class_borrow_trace_class(
189 struct bt_stream_class *stream_class)
190 {
191 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
192 return bt_stream_class_borrow_trace_class_inline(stream_class);
193 }
194
195 BT_EXPORT
196 const struct bt_trace_class *bt_stream_class_borrow_trace_class_const(
197 const struct bt_stream_class *stream_class)
198 {
199 return bt_stream_class_borrow_trace_class((void *) stream_class);
200 }
201
202 BT_EXPORT
203 const char *bt_stream_class_get_name(const struct bt_stream_class *stream_class)
204 {
205 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
206 return stream_class->name.value;
207 }
208
209 BT_EXPORT
210 enum bt_stream_class_set_name_status bt_stream_class_set_name(
211 struct bt_stream_class *stream_class,
212 const char *name)
213 {
214 BT_ASSERT_PRE_NO_ERROR();
215 BT_ASSERT_PRE_SC_NON_NULL(stream_class);
216 BT_ASSERT_PRE_NAME_NON_NULL(name);
217 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
218 g_string_assign(stream_class->name.str, name);
219 stream_class->name.value = stream_class->name.str->str;
220 BT_LIB_LOGD("Set stream class's name: %!+S", stream_class);
221 return BT_FUNC_STATUS_OK;
222 }
223
224 BT_EXPORT
225 uint64_t bt_stream_class_get_id(const struct bt_stream_class *stream_class)
226 {
227 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
228 return stream_class->id;
229 }
230
231 BT_EXPORT
232 uint64_t bt_stream_class_get_event_class_count(
233 const struct bt_stream_class *stream_class)
234 {
235 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
236 return (uint64_t) stream_class->event_classes->len;
237 }
238
239 BT_EXPORT
240 struct bt_event_class *bt_stream_class_borrow_event_class_by_index(
241 struct bt_stream_class *stream_class, uint64_t index)
242 {
243 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
244 BT_ASSERT_PRE_DEV_VALID_INDEX(index, stream_class->event_classes->len);
245 return g_ptr_array_index(stream_class->event_classes, index);
246 }
247
248 BT_EXPORT
249 const struct bt_event_class *
250 bt_stream_class_borrow_event_class_by_index_const(
251 const struct bt_stream_class *stream_class, uint64_t index)
252 {
253 return bt_stream_class_borrow_event_class_by_index(
254 (void *) stream_class, index);
255 }
256
257 BT_EXPORT
258 struct bt_event_class *bt_stream_class_borrow_event_class_by_id(
259 struct bt_stream_class *stream_class, uint64_t id)
260 {
261 struct bt_event_class *event_class = NULL;
262 uint64_t i;
263
264 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
265
266 for (i = 0; i < stream_class->event_classes->len; i++) {
267 struct bt_event_class *event_class_candidate =
268 g_ptr_array_index(stream_class->event_classes, i);
269
270 if (event_class_candidate->id == id) {
271 event_class = event_class_candidate;
272 goto end;
273 }
274 }
275
276 end:
277 return event_class;
278 }
279
280 BT_EXPORT
281 const struct bt_event_class *
282 bt_stream_class_borrow_event_class_by_id_const(
283 const struct bt_stream_class *stream_class, uint64_t id)
284 {
285 return bt_stream_class_borrow_event_class_by_id(
286 (void *) stream_class, id);
287 }
288
289 BT_EXPORT
290 const struct bt_field_class *
291 bt_stream_class_borrow_packet_context_field_class_const(
292 const struct bt_stream_class *stream_class)
293 {
294 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
295 return stream_class->packet_context_fc;
296 }
297
298 BT_EXPORT
299 struct bt_field_class *
300 bt_stream_class_borrow_packet_context_field_class(
301 struct bt_stream_class *stream_class)
302 {
303 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
304 return stream_class->packet_context_fc;
305 }
306
307 BT_EXPORT
308 enum bt_stream_class_set_field_class_status
309 bt_stream_class_set_packet_context_field_class(
310 struct bt_stream_class *stream_class,
311 struct bt_field_class *field_class)
312 {
313 int ret;
314 struct bt_resolve_field_path_context resolve_ctx = {
315 .packet_context = field_class,
316 .event_common_context = NULL,
317 .event_specific_context = NULL,
318 .event_payload = NULL,
319 };
320
321 BT_ASSERT_PRE_NO_ERROR();
322 BT_ASSERT_PRE_SC_NON_NULL(stream_class);
323 BT_ASSERT_PRE("supports-packets",
324 stream_class->supports_packets,
325 "Stream class does not support packets: %![sc-]+S",
326 stream_class);
327 BT_ASSERT_PRE_FC_NON_NULL(field_class);
328 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
329 BT_ASSERT_PRE_FC_IS_STRUCT("field-class", field_class,
330 "Packet context field class");
331 ret = bt_resolve_field_paths(field_class, &resolve_ctx, __func__);
332 if (ret) {
333 /*
334 * This is the only reason for which
335 * bt_resolve_field_paths() can fail: anything else
336 * would be because a precondition is not satisfied.
337 */
338 ret = BT_FUNC_STATUS_MEMORY_ERROR;
339 goto end;
340 }
341
342 bt_field_class_make_part_of_trace_class(field_class);
343 bt_object_put_ref(stream_class->packet_context_fc);
344 stream_class->packet_context_fc = field_class;
345 bt_object_get_ref_no_null_check(stream_class->packet_context_fc);
346 bt_field_class_freeze(field_class);
347 BT_LIB_LOGD("Set stream class's packet context field class: %!+S",
348 stream_class);
349
350 end:
351 return ret;
352 }
353
354 BT_EXPORT
355 const struct bt_field_class *
356 bt_stream_class_borrow_event_common_context_field_class_const(
357 const struct bt_stream_class *stream_class)
358 {
359 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
360 return stream_class->event_common_context_fc;
361 }
362
363 BT_EXPORT
364 struct bt_field_class *
365 bt_stream_class_borrow_event_common_context_field_class(
366 struct bt_stream_class *stream_class)
367 {
368 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
369 return stream_class->event_common_context_fc;
370 }
371
372 BT_EXPORT
373 enum bt_stream_class_set_field_class_status
374 bt_stream_class_set_event_common_context_field_class(
375 struct bt_stream_class *stream_class,
376 struct bt_field_class *field_class)
377 {
378 int ret;
379 struct bt_resolve_field_path_context resolve_ctx = {
380 .packet_context = NULL,
381 .event_common_context = field_class,
382 .event_specific_context = NULL,
383 .event_payload = NULL,
384 };
385
386 BT_ASSERT_PRE_NO_ERROR();
387 BT_ASSERT_PRE_SC_NON_NULL(stream_class);
388 BT_ASSERT_PRE_FC_NON_NULL(field_class);
389 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
390 BT_ASSERT_PRE_FC_IS_STRUCT("field-class", field_class,
391 "Event common context field class");
392 resolve_ctx.packet_context = stream_class->packet_context_fc;
393 ret = bt_resolve_field_paths(field_class, &resolve_ctx, __func__);
394 if (ret) {
395 /*
396 * This is the only reason for which
397 * bt_resolve_field_paths() can fail: anything else
398 * would be because a precondition is not satisfied.
399 */
400 ret = BT_FUNC_STATUS_MEMORY_ERROR;
401 goto end;
402 }
403
404 bt_field_class_make_part_of_trace_class(field_class);
405 bt_object_put_ref(stream_class->event_common_context_fc);
406 stream_class->event_common_context_fc = field_class;
407 bt_object_get_ref_no_null_check(stream_class->event_common_context_fc);
408 bt_field_class_freeze(field_class);
409 BT_LIB_LOGD("Set stream class's event common context field class: %!+S",
410 stream_class);
411
412 end:
413 return ret;
414 }
415
416 void _bt_stream_class_freeze(const struct bt_stream_class *stream_class)
417 {
418 /* The field classes and default clock class are already frozen */
419 BT_ASSERT(stream_class);
420 BT_LIB_LOGD("Freezing stream class's user attributes: %!+v",
421 stream_class->user_attributes);
422 bt_value_freeze(stream_class->user_attributes);
423 BT_LIB_LOGD("Freezing stream class: %!+S", stream_class);
424 ((struct bt_stream_class *) stream_class)->frozen = true;
425 }
426
427 BT_EXPORT
428 enum bt_stream_class_set_default_clock_class_status
429 bt_stream_class_set_default_clock_class(
430 struct bt_stream_class *stream_class,
431 struct bt_clock_class *clock_class)
432 {
433 BT_ASSERT_PRE_NO_ERROR();
434 BT_ASSERT_PRE_SC_NON_NULL(stream_class);
435 BT_ASSERT_PRE_CLK_CLS_NON_NULL(clock_class);
436 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
437 bt_object_put_ref(stream_class->default_clock_class);
438 stream_class->default_clock_class = clock_class;
439 bt_object_get_ref_no_null_check(stream_class->default_clock_class);
440 bt_clock_class_freeze(clock_class);
441 BT_LIB_LOGD("Set stream class's default clock class: %!+S",
442 stream_class);
443 return BT_FUNC_STATUS_OK;
444 }
445
446 BT_EXPORT
447 struct bt_clock_class *bt_stream_class_borrow_default_clock_class(
448 struct bt_stream_class *stream_class)
449 {
450 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
451 return stream_class->default_clock_class;
452 }
453
454 BT_EXPORT
455 const struct bt_clock_class *bt_stream_class_borrow_default_clock_class_const(
456 const struct bt_stream_class *stream_class)
457 {
458 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
459 return stream_class->default_clock_class;
460 }
461
462 BT_EXPORT
463 bt_bool bt_stream_class_assigns_automatic_event_class_id(
464 const struct bt_stream_class *stream_class)
465 {
466 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
467 return (bt_bool) stream_class->assigns_automatic_event_class_id;
468 }
469
470 BT_EXPORT
471 void bt_stream_class_set_assigns_automatic_event_class_id(
472 struct bt_stream_class *stream_class,
473 bt_bool value)
474 {
475 BT_ASSERT_PRE_SC_NON_NULL(stream_class);
476 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
477 stream_class->assigns_automatic_event_class_id = (bool) value;
478 BT_LIB_LOGD("Set stream class's automatic event class ID "
479 "assignment property: %!+S", stream_class);
480 }
481
482 BT_EXPORT
483 bt_bool bt_stream_class_assigns_automatic_stream_id(
484 const struct bt_stream_class *stream_class)
485 {
486 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
487 return (bt_bool) stream_class->assigns_automatic_stream_id;
488 }
489
490 BT_EXPORT
491 void bt_stream_class_set_supports_discarded_events(
492 struct bt_stream_class *stream_class,
493 bt_bool supports_discarded_events,
494 bt_bool with_default_clock_snapshots)
495 {
496 BT_ASSERT_PRE_SC_NON_NULL(stream_class);
497 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
498 BT_ASSERT_PRE("supports-discarded-events-for-default-clock-snapshots",
499 supports_discarded_events ||
500 !with_default_clock_snapshots,
501 "Discarded events cannot have default clock snapshots when "
502 "not supported: %!+S", stream_class);
503 BT_ASSERT_PRE("has-default-clock-class-for-default-clock-snapshots",
504 !with_default_clock_snapshots ||
505 stream_class->default_clock_class,
506 "Stream class has no default clock class: %!+S", stream_class);
507 stream_class->supports_discarded_events =
508 (bool) supports_discarded_events;
509 stream_class->discarded_events_have_default_clock_snapshots =
510 (bool) with_default_clock_snapshots;
511 BT_LIB_LOGD("Set stream class's discarded events support property: "
512 "%!+S", stream_class);
513 }
514
515 BT_EXPORT
516 bt_bool bt_stream_class_supports_discarded_events(
517 const struct bt_stream_class *stream_class)
518 {
519 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
520 return (bt_bool) stream_class->supports_discarded_events;
521 }
522
523 BT_EXPORT
524 bt_bool bt_stream_class_discarded_events_have_default_clock_snapshots(
525 const struct bt_stream_class *stream_class)
526 {
527 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
528 return (bt_bool) stream_class->discarded_events_have_default_clock_snapshots;
529 }
530
531 BT_EXPORT
532 void bt_stream_class_set_supports_discarded_packets(
533 struct bt_stream_class *stream_class,
534 bt_bool supports_discarded_packets,
535 bt_bool with_default_clock_snapshots)
536 {
537 BT_ASSERT_PRE_SC_NON_NULL(stream_class);
538 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
539 BT_ASSERT_PRE("supports-packets-for-discarded-packets-support",
540 !supports_discarded_packets ||
541 stream_class->supports_packets,
542 "Stream class does not support packets: %!+S",
543 stream_class);
544 BT_ASSERT_PRE("supports-discarded-packets-for-default-clock-snapshots",
545 supports_discarded_packets ||
546 !with_default_clock_snapshots,
547 "Discarded packets cannot have default clock snapshots when "
548 "not supported: %!+S", stream_class);
549 BT_ASSERT_PRE("has-default-clock-class-for-default-clock-snapshots",
550 !with_default_clock_snapshots ||
551 stream_class->default_clock_class,
552 "Stream class has no default clock class: %!+S", stream_class);
553 stream_class->supports_discarded_packets =
554 (bool) supports_discarded_packets;
555 stream_class->discarded_packets_have_default_clock_snapshots =
556 (bool) with_default_clock_snapshots;
557 BT_LIB_LOGD("Set stream class's discarded packets support property: "
558 "%!+S", stream_class);
559 }
560
561 BT_EXPORT
562 bt_bool bt_stream_class_supports_discarded_packets(
563 const struct bt_stream_class *stream_class)
564 {
565 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
566 return (bt_bool) stream_class->supports_discarded_packets;
567 }
568
569 BT_EXPORT
570 bt_bool bt_stream_class_discarded_packets_have_default_clock_snapshots(
571 const struct bt_stream_class *stream_class)
572 {
573 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
574 return (bt_bool) stream_class->discarded_packets_have_default_clock_snapshots;
575 }
576
577 BT_EXPORT
578 void bt_stream_class_set_supports_packets(
579 struct bt_stream_class *stream_class,
580 bt_bool supports_packets,
581 bt_bool with_beginning_default_clock_snapshot,
582 bt_bool with_end_default_clock_snapshot)
583 {
584 bt_bool with_default_clock_snapshot =
585 with_beginning_default_clock_snapshot ||
586 with_end_default_clock_snapshot;
587 BT_ASSERT_PRE_SC_NON_NULL(stream_class);
588 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
589 BT_ASSERT_PRE("supports-packets-for-default-clock-snapshot",
590 supports_packets ||
591 !with_default_clock_snapshot,
592 "Packets cannot have default clock snapshots when "
593 "not supported: %!+S", stream_class);
594 BT_ASSERT_PRE("has-default-clock-class-for-default-clock-snapshot",
595 !with_default_clock_snapshot ||
596 stream_class->default_clock_class,
597 "Stream class has no default clock class: %!+S", stream_class);
598 BT_ASSERT_PRE("supports-packets-for-packet-context-field-class",
599 supports_packets || !stream_class->packet_context_fc,
600 "Stream class already has a packet context field class: %!+S",
601 stream_class);
602 BT_ASSERT_PRE("supports-packets-for-discarded-packets-support",
603 supports_packets || !stream_class->supports_discarded_packets,
604 "Stream class already supports discarded packets: %!+S",
605 stream_class);
606 stream_class->supports_packets = (bool) supports_packets;
607 stream_class->packets_have_beginning_default_clock_snapshot =
608 (bool) with_beginning_default_clock_snapshot;
609 stream_class->packets_have_end_default_clock_snapshot =
610 (bool) with_end_default_clock_snapshot;
611 BT_LIB_LOGD("Set stream class's packets support property: %!+S",
612 stream_class);
613 }
614
615 BT_EXPORT
616 bt_bool bt_stream_class_supports_packets(
617 const struct bt_stream_class *stream_class)
618 {
619 BT_ASSERT_PRE_SC_NON_NULL(stream_class);
620 return (bt_bool) stream_class->supports_packets;
621 }
622
623 BT_EXPORT
624 bt_bool bt_stream_class_packets_have_beginning_default_clock_snapshot(
625 const struct bt_stream_class *stream_class)
626 {
627 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
628 return (bt_bool) stream_class->packets_have_beginning_default_clock_snapshot;
629 }
630
631 BT_EXPORT
632 bt_bool bt_stream_class_packets_have_end_default_clock_snapshot(
633 const struct bt_stream_class *stream_class)
634 {
635 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
636 return (bt_bool) stream_class->packets_have_end_default_clock_snapshot;
637 }
638
639 BT_EXPORT
640 void bt_stream_class_set_assigns_automatic_stream_id(
641 struct bt_stream_class *stream_class,
642 bt_bool value)
643 {
644 BT_ASSERT_PRE_SC_NON_NULL(stream_class);
645 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
646 stream_class->assigns_automatic_stream_id = (bool) value;
647 BT_LIB_LOGD("Set stream class's automatic stream ID "
648 "assignment property: %!+S", stream_class);
649 }
650
651 BT_EXPORT
652 const struct bt_value *bt_stream_class_borrow_user_attributes_const(
653 const struct bt_stream_class *stream_class)
654 {
655 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
656 return stream_class->user_attributes;
657 }
658
659 BT_EXPORT
660 struct bt_value *bt_stream_class_borrow_user_attributes(
661 struct bt_stream_class *stream_class)
662 {
663 return (void *) bt_stream_class_borrow_user_attributes_const(
664 (void *) stream_class);
665 }
666
667 BT_EXPORT
668 void bt_stream_class_set_user_attributes(
669 struct bt_stream_class *stream_class,
670 const struct bt_value *user_attributes)
671 {
672 BT_ASSERT_PRE_SC_NON_NULL(stream_class);
673 BT_ASSERT_PRE_USER_ATTRS_NON_NULL(user_attributes);
674 BT_ASSERT_PRE_USER_ATTRS_IS_MAP(user_attributes);
675 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
676 bt_object_put_ref_no_null_check(stream_class->user_attributes);
677 stream_class->user_attributes = (void *) user_attributes;
678 bt_object_get_ref_no_null_check(stream_class->user_attributes);
679 }
680
681 BT_EXPORT
682 void bt_stream_class_get_ref(const struct bt_stream_class *stream_class)
683 {
684 bt_object_get_ref(stream_class);
685 }
686
687 BT_EXPORT
688 void bt_stream_class_put_ref(const struct bt_stream_class *stream_class)
689 {
690 bt_object_put_ref(stream_class);
691 }
This page took 0.055661 seconds and 4 git commands to generate.