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