2 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
3 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
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:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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
24 #define BT_LOG_TAG "LIB/STREAM-CLASS"
25 #include "lib/logging.h"
27 #include "lib/assert-pre.h"
28 #include <babeltrace2/trace-ir/trace.h>
29 #include "compat/compiler.h"
30 #include "common/align.h"
31 #include "compat/endian.h"
32 #include "common/assert.h"
33 #include "lib/property.h"
38 #include "clock-class.h"
39 #include "event-class.h"
40 #include "field-class.h"
42 #include "field-wrapper.h"
43 #include "resolve-field-path.h"
44 #include "stream-class.h"
47 #include "lib/value.h"
48 #include "lib/func-status.h"
50 #define BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(_sc) \
51 BT_ASSERT_PRE_DEV_HOT((_sc), "Stream class", ": %!+S", (_sc))
54 void destroy_stream_class(struct bt_object
*obj
)
56 struct bt_stream_class
*stream_class
= (void *) obj
;
58 BT_LIB_LOGD("Destroying stream class: %!+S", stream_class
);
59 BT_LOGD_STR("Putting default clock class.");
60 BT_OBJECT_PUT_REF_AND_RESET(stream_class
->user_attributes
);
61 BT_OBJECT_PUT_REF_AND_RESET(stream_class
->default_clock_class
);
63 if (stream_class
->event_classes
) {
64 BT_LOGD_STR("Destroying event classes.");
65 g_ptr_array_free(stream_class
->event_classes
, TRUE
);
66 stream_class
->event_classes
= NULL
;
69 if (stream_class
->name
.str
) {
70 g_string_free(stream_class
->name
.str
, TRUE
);
71 stream_class
->name
.str
= NULL
;
72 stream_class
->name
.value
= NULL
;
75 BT_LOGD_STR("Putting packet context field class.");
76 BT_OBJECT_PUT_REF_AND_RESET(stream_class
->packet_context_fc
);
77 BT_LOGD_STR("Putting event common context field class.");
78 BT_OBJECT_PUT_REF_AND_RESET(stream_class
->event_common_context_fc
);
79 bt_object_pool_finalize(&stream_class
->packet_context_field_pool
);
84 void free_field_wrapper(struct bt_field_wrapper
*field_wrapper
,
85 struct bt_stream_class
*stream_class
)
87 bt_field_wrapper_destroy((void *) field_wrapper
);
91 bool stream_class_id_is_unique(const struct bt_trace_class
*tc
, uint64_t id
)
94 bool is_unique
= true;
96 for (i
= 0; i
< tc
->stream_classes
->len
; i
++) {
97 const struct bt_stream_class
*sc
=
98 tc
->stream_classes
->pdata
[i
];
111 struct bt_stream_class
*create_stream_class_with_id(
112 struct bt_trace_class
*tc
, uint64_t id
)
114 struct bt_stream_class
*stream_class
= NULL
;
118 BT_ASSERT_PRE(stream_class_id_is_unique(tc
, id
),
119 "Duplicate stream class ID: %![tc-]+T, id=%" PRIu64
, tc
, id
);
120 BT_LIB_LOGD("Creating stream class object: %![tc-]+T, id=%" PRIu64
,
122 stream_class
= g_new0(struct bt_stream_class
, 1);
124 BT_LIB_LOGE_APPEND_CAUSE(
125 "Failed to allocate one stream class.");
129 bt_object_init_shared_with_parent(&stream_class
->base
,
130 destroy_stream_class
);
131 stream_class
->user_attributes
= bt_value_map_create();
132 if (!stream_class
->user_attributes
) {
133 BT_LIB_LOGE_APPEND_CAUSE(
134 "Failed to create a map value object.");
138 stream_class
->name
.str
= g_string_new(NULL
);
139 if (!stream_class
->name
.str
) {
140 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GString.");
144 stream_class
->id
= id
;
145 stream_class
->assigns_automatic_event_class_id
= true;
146 stream_class
->assigns_automatic_stream_id
= true;
147 stream_class
->event_classes
= g_ptr_array_new_with_free_func(
148 (GDestroyNotify
) bt_object_try_spec_release
);
149 if (!stream_class
->event_classes
) {
150 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GPtrArray.");
154 ret
= bt_object_pool_initialize(&stream_class
->packet_context_field_pool
,
155 (bt_object_pool_new_object_func
) bt_field_wrapper_new
,
156 (bt_object_pool_destroy_object_func
) free_field_wrapper
,
159 BT_LIB_LOGE_APPEND_CAUSE(
160 "Failed to initialize packet context field pool: ret=%d",
165 bt_object_set_parent(&stream_class
->base
, &tc
->base
);
166 g_ptr_array_add(tc
->stream_classes
, stream_class
);
167 bt_trace_class_freeze(tc
);
168 BT_LIB_LOGD("Created stream class object: %!+S", stream_class
);
172 BT_OBJECT_PUT_REF_AND_RESET(stream_class
);
178 struct bt_stream_class
*bt_stream_class_create(struct bt_trace_class
*tc
)
180 BT_ASSERT_PRE_NO_ERROR();
181 BT_ASSERT_PRE_NON_NULL(tc
, "Trace class");
182 BT_ASSERT_PRE(tc
->assigns_automatic_stream_class_id
,
183 "Trace class does not automatically assigns stream class IDs: "
185 return create_stream_class_with_id(tc
,
186 (uint64_t) tc
->stream_classes
->len
);
189 struct bt_stream_class
*bt_stream_class_create_with_id(
190 struct bt_trace_class
*tc
, uint64_t id
)
192 BT_ASSERT_PRE_NO_ERROR();
193 BT_ASSERT_PRE_NON_NULL(tc
, "Trace class");
194 BT_ASSERT_PRE(!tc
->assigns_automatic_stream_class_id
,
195 "Trace class automatically assigns stream class IDs: "
197 return create_stream_class_with_id(tc
, id
);
200 struct bt_trace_class
*bt_stream_class_borrow_trace_class(
201 struct bt_stream_class
*stream_class
)
203 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
204 return bt_stream_class_borrow_trace_class_inline(stream_class
);
207 const struct bt_trace_class
*bt_stream_class_borrow_trace_class_const(
208 const struct bt_stream_class
*stream_class
)
210 return bt_stream_class_borrow_trace_class((void *) stream_class
);
213 const char *bt_stream_class_get_name(const struct bt_stream_class
*stream_class
)
215 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
216 return stream_class
->name
.value
;
219 enum bt_stream_class_set_name_status
bt_stream_class_set_name(
220 struct bt_stream_class
*stream_class
,
223 BT_ASSERT_PRE_NO_ERROR();
224 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
225 BT_ASSERT_PRE_NON_NULL(name
, "Name");
226 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class
);
227 g_string_assign(stream_class
->name
.str
, name
);
228 stream_class
->name
.value
= stream_class
->name
.str
->str
;
229 BT_LIB_LOGD("Set stream class's name: %!+S", stream_class
);
230 return BT_FUNC_STATUS_OK
;
233 uint64_t bt_stream_class_get_id(const struct bt_stream_class
*stream_class
)
235 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
236 return stream_class
->id
;
239 uint64_t bt_stream_class_get_event_class_count(
240 const struct bt_stream_class
*stream_class
)
242 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
243 return (uint64_t) stream_class
->event_classes
->len
;
246 struct bt_event_class
*bt_stream_class_borrow_event_class_by_index(
247 struct bt_stream_class
*stream_class
, uint64_t index
)
249 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
250 BT_ASSERT_PRE_DEV_VALID_INDEX(index
, stream_class
->event_classes
->len
);
251 return g_ptr_array_index(stream_class
->event_classes
, index
);
254 const struct bt_event_class
*
255 bt_stream_class_borrow_event_class_by_index_const(
256 const struct bt_stream_class
*stream_class
, uint64_t index
)
258 return bt_stream_class_borrow_event_class_by_index(
259 (void *) stream_class
, index
);
262 struct bt_event_class
*bt_stream_class_borrow_event_class_by_id(
263 struct bt_stream_class
*stream_class
, uint64_t id
)
265 struct bt_event_class
*event_class
= NULL
;
268 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
270 for (i
= 0; i
< stream_class
->event_classes
->len
; i
++) {
271 struct bt_event_class
*event_class_candidate
=
272 g_ptr_array_index(stream_class
->event_classes
, i
);
274 if (event_class_candidate
->id
== id
) {
275 event_class
= event_class_candidate
;
284 const struct bt_event_class
*
285 bt_stream_class_borrow_event_class_by_id_const(
286 const struct bt_stream_class
*stream_class
, uint64_t id
)
288 return bt_stream_class_borrow_event_class_by_id(
289 (void *) stream_class
, id
);
292 const struct bt_field_class
*
293 bt_stream_class_borrow_packet_context_field_class_const(
294 const struct bt_stream_class
*stream_class
)
296 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
297 return stream_class
->packet_context_fc
;
300 struct bt_field_class
*
301 bt_stream_class_borrow_packet_context_field_class(
302 struct bt_stream_class
*stream_class
)
304 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
305 return stream_class
->packet_context_fc
;
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
)
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
,
321 BT_ASSERT_PRE_NO_ERROR();
322 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
323 BT_ASSERT_PRE(stream_class
->supports_packets
,
324 "Stream class does not support packets: %![sc-]+S",
326 BT_ASSERT_PRE_NON_NULL(field_class
, "Field class");
327 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class
);
328 BT_ASSERT_PRE(bt_field_class_get_type(field_class
) ==
329 BT_FIELD_CLASS_TYPE_STRUCTURE
,
330 "Packet context field class is not a structure field class: %!+F",
332 ret
= bt_resolve_field_paths(field_class
, &resolve_ctx
);
335 * This is the only reason for which
336 * bt_resolve_field_paths() can fail: anything else
337 * would be because a precondition is not satisfied.
339 ret
= BT_FUNC_STATUS_MEMORY_ERROR
;
343 bt_field_class_make_part_of_trace_class(field_class
);
344 bt_object_put_ref(stream_class
->packet_context_fc
);
345 stream_class
->packet_context_fc
= field_class
;
346 bt_object_get_ref_no_null_check(stream_class
->packet_context_fc
);
347 bt_field_class_freeze(field_class
);
348 BT_LIB_LOGD("Set stream class's packet context field class: %!+S",
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
)
359 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
360 return stream_class
->event_common_context_fc
;
363 struct bt_field_class
*
364 bt_stream_class_borrow_event_common_context_field_class(
365 struct bt_stream_class
*stream_class
)
367 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
368 return stream_class
->event_common_context_fc
;
371 enum bt_stream_class_set_field_class_status
372 bt_stream_class_set_event_common_context_field_class(
373 struct bt_stream_class
*stream_class
,
374 struct bt_field_class
*field_class
)
377 struct bt_resolve_field_path_context resolve_ctx
= {
378 .packet_context
= NULL
,
379 .event_common_context
= field_class
,
380 .event_specific_context
= NULL
,
381 .event_payload
= NULL
,
384 BT_ASSERT_PRE_NO_ERROR();
385 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
386 BT_ASSERT_PRE_NON_NULL(field_class
, "Field class");
387 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class
);
388 BT_ASSERT_PRE(bt_field_class_get_type(field_class
) ==
389 BT_FIELD_CLASS_TYPE_STRUCTURE
,
390 "Event common context field class is not a structure field class: %!+F",
392 resolve_ctx
.packet_context
= stream_class
->packet_context_fc
;
393 ret
= bt_resolve_field_paths(field_class
, &resolve_ctx
);
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.
400 ret
= BT_FUNC_STATUS_MEMORY_ERROR
;
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",
417 void _bt_stream_class_freeze(const struct bt_stream_class
*stream_class
)
419 /* The field classes and default clock class are already frozen */
420 BT_ASSERT(stream_class
);
421 BT_LIB_LOGD("Freezing stream class's user attributes: %!+v",
422 stream_class
->user_attributes
);
423 bt_value_freeze(stream_class
->user_attributes
);
424 BT_LIB_LOGD("Freezing stream class: %!+S", stream_class
);
425 ((struct bt_stream_class
*) stream_class
)->frozen
= true;
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
)
433 BT_ASSERT_PRE_NO_ERROR();
434 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
435 BT_ASSERT_PRE_NON_NULL(clock_class
, "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",
443 return BT_FUNC_STATUS_OK
;
446 struct bt_clock_class
*bt_stream_class_borrow_default_clock_class(
447 struct bt_stream_class
*stream_class
)
449 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
450 return stream_class
->default_clock_class
;
453 const struct bt_clock_class
*bt_stream_class_borrow_default_clock_class_const(
454 const struct bt_stream_class
*stream_class
)
456 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
457 return stream_class
->default_clock_class
;
460 bt_bool
bt_stream_class_assigns_automatic_event_class_id(
461 const struct bt_stream_class
*stream_class
)
463 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
464 return (bt_bool
) stream_class
->assigns_automatic_event_class_id
;
467 void bt_stream_class_set_assigns_automatic_event_class_id(
468 struct bt_stream_class
*stream_class
,
471 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
472 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class
);
473 stream_class
->assigns_automatic_event_class_id
= (bool) value
;
474 BT_LIB_LOGD("Set stream class's automatic event class ID "
475 "assignment property: %!+S", stream_class
);
478 bt_bool
bt_stream_class_assigns_automatic_stream_id(
479 const struct bt_stream_class
*stream_class
)
481 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
482 return (bt_bool
) stream_class
->assigns_automatic_stream_id
;
485 void bt_stream_class_set_supports_discarded_events(
486 struct bt_stream_class
*stream_class
,
487 bt_bool supports_discarded_events
,
488 bt_bool with_default_clock_snapshots
)
490 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
491 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class
);
492 BT_ASSERT_PRE(supports_discarded_events
||
493 !with_default_clock_snapshots
,
494 "Discarded events cannot have default clock snapshots when "
495 "not supported: %!+S", stream_class
);
496 BT_ASSERT_PRE(!with_default_clock_snapshots
||
497 stream_class
->default_clock_class
,
498 "Stream class has no default clock class: %!+S", stream_class
);
499 stream_class
->supports_discarded_events
=
500 (bool) supports_discarded_events
;
501 stream_class
->discarded_events_have_default_clock_snapshots
=
502 (bool) with_default_clock_snapshots
;
503 BT_LIB_LOGD("Set stream class's discarded events support property: "
504 "%!+S", stream_class
);
507 bt_bool
bt_stream_class_supports_discarded_events(
508 const struct bt_stream_class
*stream_class
)
510 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
511 return (bt_bool
) stream_class
->supports_discarded_events
;
514 bt_bool
bt_stream_class_discarded_events_have_default_clock_snapshots(
515 const struct bt_stream_class
*stream_class
)
517 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
518 return (bt_bool
) stream_class
->discarded_events_have_default_clock_snapshots
;
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
)
526 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
527 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class
);
528 BT_ASSERT_PRE(!supports_discarded_packets
||
529 stream_class
->supports_packets
,
530 "Stream class does not support packets: %!+S",
532 BT_ASSERT_PRE(supports_discarded_packets
||
533 !with_default_clock_snapshots
,
534 "Discarded packets cannot have default clock snapshots when "
535 "not supported: %!+S", stream_class
);
536 BT_ASSERT_PRE(!with_default_clock_snapshots
||
537 stream_class
->default_clock_class
,
538 "Stream class has no default clock class: %!+S", stream_class
);
539 stream_class
->supports_discarded_packets
=
540 (bool) supports_discarded_packets
;
541 stream_class
->discarded_packets_have_default_clock_snapshots
=
542 (bool) with_default_clock_snapshots
;
543 BT_LIB_LOGD("Set stream class's discarded packets support property: "
544 "%!+S", stream_class
);
547 bt_bool
bt_stream_class_supports_discarded_packets(
548 const struct bt_stream_class
*stream_class
)
550 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
551 return (bt_bool
) stream_class
->supports_discarded_packets
;
554 bt_bool
bt_stream_class_discarded_packets_have_default_clock_snapshots(
555 const struct bt_stream_class
*stream_class
)
557 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
558 return (bt_bool
) stream_class
->discarded_packets_have_default_clock_snapshots
;
561 void bt_stream_class_set_supports_packets(
562 struct bt_stream_class
*stream_class
,
563 bt_bool supports_packets
,
564 bt_bool with_beginning_default_clock_snapshot
,
565 bt_bool with_end_default_clock_snapshot
)
567 bt_bool with_default_clock_snapshot
=
568 with_beginning_default_clock_snapshot
||
569 with_end_default_clock_snapshot
;
570 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
571 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class
);
572 BT_ASSERT_PRE(supports_packets
||
573 !with_default_clock_snapshot
,
574 "Packets cannot have default clock snapshots when "
575 "not supported: %!+S", stream_class
);
576 BT_ASSERT_PRE(!with_default_clock_snapshot
||
577 stream_class
->default_clock_class
,
578 "Stream class has no default clock class: %!+S", stream_class
);
579 BT_ASSERT_PRE(supports_packets
|| !stream_class
->packet_context_fc
,
580 "Stream class already has a packet context field class: %!+S",
582 BT_ASSERT_PRE(supports_packets
||
583 !stream_class
->supports_discarded_packets
,
584 "Stream class already supports discarded packets: %!+S",
586 stream_class
->supports_packets
= (bool) supports_packets
;
587 stream_class
->packets_have_beginning_default_clock_snapshot
=
588 (bool) with_beginning_default_clock_snapshot
;
589 stream_class
->packets_have_end_default_clock_snapshot
=
590 (bool) with_end_default_clock_snapshot
;
591 BT_LIB_LOGD("Set stream class's packets support property: %!+S",
595 bt_bool
bt_stream_class_supports_packets(
596 const struct bt_stream_class
*stream_class
)
598 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
599 return (bt_bool
) stream_class
->supports_packets
;
602 bt_bool
bt_stream_class_packets_have_beginning_default_clock_snapshot(
603 const struct bt_stream_class
*stream_class
)
605 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
606 return (bt_bool
) stream_class
->packets_have_beginning_default_clock_snapshot
;
609 bt_bool
bt_stream_class_packets_have_end_default_clock_snapshot(
610 const struct bt_stream_class
*stream_class
)
612 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
613 return (bt_bool
) stream_class
->packets_have_end_default_clock_snapshot
;
616 void bt_stream_class_set_assigns_automatic_stream_id(
617 struct bt_stream_class
*stream_class
,
620 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
621 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class
);
622 stream_class
->assigns_automatic_stream_id
= (bool) value
;
623 BT_LIB_LOGD("Set stream class's automatic stream ID "
624 "assignment property: %!+S", stream_class
);
627 const struct bt_value
*bt_stream_class_borrow_user_attributes_const(
628 const struct bt_stream_class
*stream_class
)
630 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
631 return stream_class
->user_attributes
;
634 struct bt_value
*bt_stream_class_borrow_user_attributes(
635 struct bt_stream_class
*stream_class
)
637 return (void *) bt_stream_class_borrow_user_attributes_const(
638 (void *) stream_class
);
641 void bt_stream_class_set_user_attributes(
642 struct bt_stream_class
*stream_class
,
643 const struct bt_value
*user_attributes
)
645 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
646 BT_ASSERT_PRE_NON_NULL(user_attributes
, "User attributes");
647 BT_ASSERT_PRE(user_attributes
->type
== BT_VALUE_TYPE_MAP
,
648 "User attributes object is not a map value object.");
649 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class
);
650 bt_object_put_ref_no_null_check(stream_class
->user_attributes
);
651 stream_class
->user_attributes
= (void *) user_attributes
;
652 bt_object_get_ref_no_null_check(stream_class
->user_attributes
);
655 void bt_stream_class_get_ref(const struct bt_stream_class
*stream_class
)
657 bt_object_get_ref(stream_class
);
660 void bt_stream_class_put_ref(const struct bt_stream_class
*stream_class
)
662 bt_object_put_ref(stream_class
);