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