| 1 | /* |
| 2 | * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com> |
| 3 | * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 4 | * |
| 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 | |
| 24 | #define BT_LOG_TAG "STREAM-CLASS" |
| 25 | #include <babeltrace/lib-logging-internal.h> |
| 26 | |
| 27 | #include <babeltrace/assert-pre-internal.h> |
| 28 | #include <babeltrace/trace-ir/clock-class-internal.h> |
| 29 | #include <babeltrace/trace-ir/event-class-internal.h> |
| 30 | #include <babeltrace/trace-ir/field-class-internal.h> |
| 31 | #include <babeltrace/trace-ir/field-internal.h> |
| 32 | #include <babeltrace/trace-ir/stream-class-internal.h> |
| 33 | #include <babeltrace/trace-ir/trace-const.h> |
| 34 | #include <babeltrace/trace-ir/trace-internal.h> |
| 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> |
| 38 | #include <babeltrace/compiler-internal.h> |
| 39 | #include <babeltrace/align-internal.h> |
| 40 | #include <babeltrace/endian-internal.h> |
| 41 | #include <babeltrace/assert-internal.h> |
| 42 | #include <babeltrace/property-internal.h> |
| 43 | #include <inttypes.h> |
| 44 | #include <stdint.h> |
| 45 | #include <stdbool.h> |
| 46 | |
| 47 | #define BT_ASSERT_PRE_STREAM_CLASS_HOT(_sc) \ |
| 48 | BT_ASSERT_PRE_HOT((_sc), "Stream class", ": %!+S", (_sc)) |
| 49 | |
| 50 | static |
| 51 | void destroy_stream_class(struct bt_object *obj) |
| 52 | { |
| 53 | struct bt_stream_class *stream_class = (void *) obj; |
| 54 | |
| 55 | BT_LIB_LOGD("Destroying stream class: %!+S", stream_class); |
| 56 | BT_LOGD_STR("Putting default clock class."); |
| 57 | BT_OBJECT_PUT_REF_AND_RESET(stream_class->default_clock_class); |
| 58 | |
| 59 | if (stream_class->event_classes) { |
| 60 | BT_LOGD_STR("Destroying event classes."); |
| 61 | g_ptr_array_free(stream_class->event_classes, TRUE); |
| 62 | stream_class->event_classes = NULL; |
| 63 | } |
| 64 | |
| 65 | if (stream_class->name.str) { |
| 66 | g_string_free(stream_class->name.str, TRUE); |
| 67 | stream_class->name.str = NULL; |
| 68 | stream_class->name.value = NULL; |
| 69 | } |
| 70 | |
| 71 | BT_LOGD_STR("Putting event header field class."); |
| 72 | BT_OBJECT_PUT_REF_AND_RESET(stream_class->event_header_fc); |
| 73 | BT_LOGD_STR("Putting packet context field class."); |
| 74 | BT_OBJECT_PUT_REF_AND_RESET(stream_class->packet_context_fc); |
| 75 | BT_LOGD_STR("Putting event common context field class."); |
| 76 | BT_OBJECT_PUT_REF_AND_RESET(stream_class->event_common_context_fc); |
| 77 | bt_object_pool_finalize(&stream_class->event_header_field_pool); |
| 78 | bt_object_pool_finalize(&stream_class->packet_context_field_pool); |
| 79 | g_free(stream_class); |
| 80 | } |
| 81 | |
| 82 | static |
| 83 | void free_field_wrapper(struct bt_field_wrapper *field_wrapper, |
| 84 | struct bt_stream_class *stream_class) |
| 85 | { |
| 86 | bt_field_wrapper_destroy((void *) field_wrapper); |
| 87 | } |
| 88 | |
| 89 | BT_ASSERT_PRE_FUNC |
| 90 | static |
| 91 | bool stream_class_id_is_unique(const struct bt_trace_class *tc, uint64_t id) |
| 92 | { |
| 93 | uint64_t i; |
| 94 | bool is_unique = true; |
| 95 | |
| 96 | for (i = 0; i < tc->stream_classes->len; i++) { |
| 97 | const struct bt_stream_class *sc = |
| 98 | tc->stream_classes->pdata[i]; |
| 99 | |
| 100 | if (sc->id == id) { |
| 101 | is_unique = false; |
| 102 | goto end; |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | end: |
| 107 | return is_unique; |
| 108 | } |
| 109 | |
| 110 | static |
| 111 | struct bt_stream_class *create_stream_class_with_id( |
| 112 | struct bt_trace_class *tc, uint64_t id) |
| 113 | { |
| 114 | struct bt_stream_class *stream_class = NULL; |
| 115 | int ret; |
| 116 | |
| 117 | BT_ASSERT(tc); |
| 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, |
| 121 | tc, id); |
| 122 | stream_class = g_new0(struct bt_stream_class, 1); |
| 123 | if (!stream_class) { |
| 124 | BT_LOGE_STR("Failed to allocate one stream class."); |
| 125 | goto error; |
| 126 | } |
| 127 | |
| 128 | bt_object_init_shared_with_parent(&stream_class->base, |
| 129 | destroy_stream_class); |
| 130 | |
| 131 | stream_class->name.str = g_string_new(NULL); |
| 132 | if (!stream_class->name.str) { |
| 133 | BT_LOGE_STR("Failed to allocate a GString."); |
| 134 | ret = -1; |
| 135 | goto end; |
| 136 | } |
| 137 | |
| 138 | stream_class->id = id; |
| 139 | stream_class->assigns_automatic_event_class_id = true; |
| 140 | stream_class->assigns_automatic_stream_id = true; |
| 141 | stream_class->event_classes = g_ptr_array_new_with_free_func( |
| 142 | (GDestroyNotify) bt_object_try_spec_release); |
| 143 | if (!stream_class->event_classes) { |
| 144 | BT_LOGE_STR("Failed to allocate a GPtrArray."); |
| 145 | goto error; |
| 146 | } |
| 147 | |
| 148 | ret = bt_object_pool_initialize(&stream_class->event_header_field_pool, |
| 149 | (bt_object_pool_new_object_func) bt_field_wrapper_new, |
| 150 | (bt_object_pool_destroy_object_func) free_field_wrapper, |
| 151 | stream_class); |
| 152 | if (ret) { |
| 153 | BT_LOGE("Failed to initialize event header field pool: ret=%d", |
| 154 | ret); |
| 155 | goto error; |
| 156 | } |
| 157 | |
| 158 | ret = bt_object_pool_initialize(&stream_class->packet_context_field_pool, |
| 159 | (bt_object_pool_new_object_func) bt_field_wrapper_new, |
| 160 | (bt_object_pool_destroy_object_func) free_field_wrapper, |
| 161 | stream_class); |
| 162 | if (ret) { |
| 163 | BT_LOGE("Failed to initialize packet context field pool: ret=%d", |
| 164 | ret); |
| 165 | goto error; |
| 166 | } |
| 167 | |
| 168 | bt_object_set_parent(&stream_class->base, &tc->base); |
| 169 | g_ptr_array_add(tc->stream_classes, stream_class); |
| 170 | bt_trace_class_freeze(tc); |
| 171 | BT_LIB_LOGD("Created stream class object: %!+S", stream_class); |
| 172 | goto end; |
| 173 | |
| 174 | error: |
| 175 | BT_OBJECT_PUT_REF_AND_RESET(stream_class); |
| 176 | |
| 177 | end: |
| 178 | return stream_class; |
| 179 | } |
| 180 | |
| 181 | struct bt_stream_class *bt_stream_class_create(struct bt_trace_class *tc) |
| 182 | { |
| 183 | BT_ASSERT_PRE_NON_NULL(tc, "Trace class"); |
| 184 | BT_ASSERT_PRE(tc->assigns_automatic_stream_class_id, |
| 185 | "Trace class does not automatically assigns stream class IDs: " |
| 186 | "%![sc-]+T", tc); |
| 187 | return create_stream_class_with_id(tc, |
| 188 | (uint64_t) tc->stream_classes->len); |
| 189 | } |
| 190 | |
| 191 | struct bt_stream_class *bt_stream_class_create_with_id( |
| 192 | struct bt_trace_class *tc, uint64_t id) |
| 193 | { |
| 194 | BT_ASSERT_PRE_NON_NULL(tc, "Trace class"); |
| 195 | BT_ASSERT_PRE(!tc->assigns_automatic_stream_class_id, |
| 196 | "Trace class automatically assigns stream class IDs: " |
| 197 | "%![sc-]+T", tc); |
| 198 | return create_stream_class_with_id(tc, id); |
| 199 | } |
| 200 | |
| 201 | struct bt_trace_class *bt_stream_class_borrow_trace_class( |
| 202 | struct bt_stream_class *stream_class) |
| 203 | { |
| 204 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 205 | return bt_stream_class_borrow_trace_class_inline(stream_class); |
| 206 | } |
| 207 | |
| 208 | const struct bt_trace_class *bt_stream_class_borrow_trace_class_const( |
| 209 | const struct bt_stream_class *stream_class) |
| 210 | { |
| 211 | return bt_stream_class_borrow_trace_class((void *) stream_class); |
| 212 | } |
| 213 | |
| 214 | const char *bt_stream_class_get_name(const struct bt_stream_class *stream_class) |
| 215 | { |
| 216 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 217 | return stream_class->name.value; |
| 218 | } |
| 219 | |
| 220 | int bt_stream_class_set_name( |
| 221 | struct bt_stream_class *stream_class, |
| 222 | const char *name) |
| 223 | { |
| 224 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 225 | BT_ASSERT_PRE_NON_NULL(name, "Name"); |
| 226 | BT_ASSERT_PRE_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_LOGV("Set stream class's name: %!+S", stream_class); |
| 230 | return 0; |
| 231 | } |
| 232 | |
| 233 | uint64_t bt_stream_class_get_id(const struct bt_stream_class *stream_class) |
| 234 | { |
| 235 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 236 | return stream_class->id; |
| 237 | } |
| 238 | |
| 239 | uint64_t bt_stream_class_get_event_class_count( |
| 240 | const struct bt_stream_class *stream_class) |
| 241 | { |
| 242 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 243 | return (uint64_t) stream_class->event_classes->len; |
| 244 | } |
| 245 | |
| 246 | struct bt_event_class *bt_stream_class_borrow_event_class_by_index( |
| 247 | struct bt_stream_class *stream_class, uint64_t index) |
| 248 | { |
| 249 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 250 | BT_ASSERT_PRE_VALID_INDEX(index, stream_class->event_classes->len); |
| 251 | return g_ptr_array_index(stream_class->event_classes, index); |
| 252 | } |
| 253 | |
| 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) |
| 257 | { |
| 258 | return bt_stream_class_borrow_event_class_by_index( |
| 259 | (void *) stream_class, index); |
| 260 | } |
| 261 | |
| 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_NON_NULL(stream_class, "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 | 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) |
| 287 | { |
| 288 | return bt_stream_class_borrow_event_class_by_id( |
| 289 | (void *) stream_class, id); |
| 290 | } |
| 291 | |
| 292 | const struct bt_field_class * |
| 293 | bt_stream_class_borrow_packet_context_field_class_const( |
| 294 | const struct bt_stream_class *stream_class) |
| 295 | { |
| 296 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 297 | return stream_class->packet_context_fc; |
| 298 | } |
| 299 | |
| 300 | int bt_stream_class_set_packet_context_field_class( |
| 301 | struct bt_stream_class *stream_class, |
| 302 | struct bt_field_class *field_class) |
| 303 | { |
| 304 | int ret; |
| 305 | struct bt_resolve_field_path_context resolve_ctx = { |
| 306 | .packet_header = NULL, |
| 307 | .packet_context = field_class, |
| 308 | .event_header = NULL, |
| 309 | .event_common_context = NULL, |
| 310 | .event_specific_context = NULL, |
| 311 | .event_payload = NULL, |
| 312 | }; |
| 313 | |
| 314 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 315 | BT_ASSERT_PRE_NON_NULL(field_class, "Field class"); |
| 316 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
| 317 | BT_ASSERT_PRE(bt_field_class_get_type(field_class) == |
| 318 | BT_FIELD_CLASS_TYPE_STRUCTURE, |
| 319 | "Packet context field class is not a structure field class: %!+F", |
| 320 | field_class); |
| 321 | resolve_ctx.packet_header = |
| 322 | bt_stream_class_borrow_trace_class_inline(stream_class)->packet_header_fc; |
| 323 | ret = bt_resolve_field_paths(field_class, &resolve_ctx); |
| 324 | if (ret) { |
| 325 | goto end; |
| 326 | } |
| 327 | |
| 328 | bt_field_class_make_part_of_trace_class(field_class); |
| 329 | bt_object_put_ref(stream_class->packet_context_fc); |
| 330 | stream_class->packet_context_fc = field_class; |
| 331 | bt_object_get_no_null_check(stream_class->packet_context_fc); |
| 332 | bt_field_class_freeze(field_class); |
| 333 | BT_LIB_LOGV("Set stream class's packet context field class: %!+S", |
| 334 | stream_class); |
| 335 | |
| 336 | end: |
| 337 | return ret; |
| 338 | } |
| 339 | |
| 340 | const struct bt_field_class *bt_stream_class_borrow_event_header_field_class_const( |
| 341 | const struct bt_stream_class *stream_class) |
| 342 | { |
| 343 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 344 | return stream_class->event_header_fc; |
| 345 | } |
| 346 | |
| 347 | int bt_stream_class_set_event_header_field_class( |
| 348 | struct bt_stream_class *stream_class, |
| 349 | struct bt_field_class *field_class) |
| 350 | { |
| 351 | int ret; |
| 352 | struct bt_resolve_field_path_context resolve_ctx = { |
| 353 | .packet_header = NULL, |
| 354 | .packet_context = NULL, |
| 355 | .event_header = field_class, |
| 356 | .event_common_context = NULL, |
| 357 | .event_specific_context = NULL, |
| 358 | .event_payload = NULL, |
| 359 | }; |
| 360 | |
| 361 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 362 | BT_ASSERT_PRE_NON_NULL(field_class, "Field class"); |
| 363 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
| 364 | BT_ASSERT_PRE(bt_field_class_get_type(field_class) == |
| 365 | BT_FIELD_CLASS_TYPE_STRUCTURE, |
| 366 | "Event header field class is not a structure field class: %!+F", |
| 367 | field_class); |
| 368 | resolve_ctx.packet_header = |
| 369 | bt_stream_class_borrow_trace_class_inline(stream_class)->packet_header_fc; |
| 370 | resolve_ctx.packet_context = stream_class->packet_context_fc; |
| 371 | ret = bt_resolve_field_paths(field_class, &resolve_ctx); |
| 372 | if (ret) { |
| 373 | goto end; |
| 374 | } |
| 375 | |
| 376 | bt_field_class_make_part_of_trace_class(field_class); |
| 377 | bt_object_put_ref(stream_class->event_header_fc); |
| 378 | stream_class->event_header_fc = field_class; |
| 379 | bt_object_get_no_null_check(stream_class->event_header_fc); |
| 380 | bt_field_class_freeze(field_class); |
| 381 | BT_LIB_LOGV("Set stream class's event header field class: %!+S", |
| 382 | stream_class); |
| 383 | |
| 384 | end: |
| 385 | return ret; |
| 386 | } |
| 387 | |
| 388 | const struct bt_field_class * |
| 389 | bt_stream_class_borrow_event_common_context_field_class_const( |
| 390 | const struct bt_stream_class *stream_class) |
| 391 | { |
| 392 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 393 | return stream_class->event_common_context_fc; |
| 394 | } |
| 395 | |
| 396 | int bt_stream_class_set_event_common_context_field_class( |
| 397 | struct bt_stream_class *stream_class, |
| 398 | struct bt_field_class *field_class) |
| 399 | { |
| 400 | int ret; |
| 401 | struct bt_resolve_field_path_context resolve_ctx = { |
| 402 | .packet_header = NULL, |
| 403 | .packet_context = NULL, |
| 404 | .event_header = NULL, |
| 405 | .event_common_context = field_class, |
| 406 | .event_specific_context = NULL, |
| 407 | .event_payload = NULL, |
| 408 | }; |
| 409 | |
| 410 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 411 | BT_ASSERT_PRE_NON_NULL(field_class, "Field class"); |
| 412 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
| 413 | BT_ASSERT_PRE(bt_field_class_get_type(field_class) == |
| 414 | BT_FIELD_CLASS_TYPE_STRUCTURE, |
| 415 | "Event common context field class is not a structure field class: %!+F", |
| 416 | field_class); |
| 417 | resolve_ctx.packet_header = |
| 418 | bt_stream_class_borrow_trace_class_inline(stream_class)->packet_header_fc; |
| 419 | resolve_ctx.packet_context = stream_class->packet_context_fc; |
| 420 | resolve_ctx.event_header = stream_class->event_header_fc; |
| 421 | ret = bt_resolve_field_paths(field_class, &resolve_ctx); |
| 422 | if (ret) { |
| 423 | goto end; |
| 424 | } |
| 425 | |
| 426 | bt_field_class_make_part_of_trace_class(field_class); |
| 427 | bt_object_put_ref(stream_class->event_common_context_fc); |
| 428 | stream_class->event_common_context_fc = field_class; |
| 429 | bt_object_get_no_null_check(stream_class->event_common_context_fc); |
| 430 | bt_field_class_freeze(field_class); |
| 431 | BT_LIB_LOGV("Set stream class's event common context field class: %!+S", |
| 432 | stream_class); |
| 433 | |
| 434 | end: |
| 435 | return ret; |
| 436 | } |
| 437 | |
| 438 | BT_HIDDEN |
| 439 | void _bt_stream_class_freeze(const struct bt_stream_class *stream_class) |
| 440 | { |
| 441 | /* The field classes and default clock class are already frozen */ |
| 442 | BT_ASSERT(stream_class); |
| 443 | BT_LIB_LOGD("Freezing stream class: %!+S", stream_class); |
| 444 | ((struct bt_stream_class *) stream_class)->frozen = true; |
| 445 | } |
| 446 | |
| 447 | int bt_stream_class_set_default_clock_class( |
| 448 | struct bt_stream_class *stream_class, |
| 449 | struct bt_clock_class *clock_class) |
| 450 | { |
| 451 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 452 | BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class"); |
| 453 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
| 454 | bt_object_put_ref(stream_class->default_clock_class); |
| 455 | stream_class->default_clock_class = clock_class; |
| 456 | bt_object_get_no_null_check(stream_class->default_clock_class); |
| 457 | bt_clock_class_freeze(clock_class); |
| 458 | BT_LIB_LOGV("Set stream class's default clock class: %!+S", |
| 459 | stream_class); |
| 460 | return 0; |
| 461 | } |
| 462 | |
| 463 | struct bt_clock_class *bt_stream_class_borrow_default_clock_class( |
| 464 | struct bt_stream_class *stream_class) |
| 465 | { |
| 466 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 467 | return stream_class->default_clock_class; |
| 468 | } |
| 469 | |
| 470 | const struct bt_clock_class *bt_stream_class_borrow_default_clock_class_const( |
| 471 | const struct bt_stream_class *stream_class) |
| 472 | { |
| 473 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 474 | return stream_class->default_clock_class; |
| 475 | } |
| 476 | |
| 477 | bt_bool bt_stream_class_assigns_automatic_event_class_id( |
| 478 | const struct bt_stream_class *stream_class) |
| 479 | { |
| 480 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 481 | return (bt_bool) stream_class->assigns_automatic_event_class_id; |
| 482 | } |
| 483 | |
| 484 | void bt_stream_class_set_assigns_automatic_event_class_id( |
| 485 | struct bt_stream_class *stream_class, |
| 486 | bt_bool value) |
| 487 | { |
| 488 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 489 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
| 490 | stream_class->assigns_automatic_event_class_id = (bool) value; |
| 491 | BT_LIB_LOGV("Set stream class's automatic event class ID " |
| 492 | "assignment property: %!+S", stream_class); |
| 493 | } |
| 494 | |
| 495 | bt_bool bt_stream_class_assigns_automatic_stream_id( |
| 496 | const struct bt_stream_class *stream_class) |
| 497 | { |
| 498 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 499 | return (bt_bool) stream_class->assigns_automatic_stream_id; |
| 500 | } |
| 501 | |
| 502 | void bt_stream_class_set_assigns_automatic_stream_id( |
| 503 | struct bt_stream_class *stream_class, |
| 504 | bt_bool value) |
| 505 | { |
| 506 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 507 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
| 508 | stream_class->assigns_automatic_stream_id = (bool) value; |
| 509 | BT_LIB_LOGV("Set stream class's automatic stream ID " |
| 510 | "assignment property: %!+S", stream_class); |
| 511 | } |
| 512 | |
| 513 | bt_bool bt_stream_class_packets_have_discarded_event_counter_snapshot( |
| 514 | const struct bt_stream_class *stream_class) |
| 515 | { |
| 516 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 517 | return (bt_bool) stream_class->packets_have_discarded_event_counter_snapshot; |
| 518 | } |
| 519 | |
| 520 | void bt_stream_class_set_packets_have_discarded_event_counter_snapshot( |
| 521 | struct bt_stream_class *stream_class, |
| 522 | bt_bool value) |
| 523 | { |
| 524 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 525 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
| 526 | stream_class->packets_have_discarded_event_counter_snapshot = |
| 527 | (bool) value; |
| 528 | BT_LIB_LOGV("Set stream class's " |
| 529 | "\"packets have discarded event counter snapshot\" property: " |
| 530 | "%!+S", stream_class); |
| 531 | } |
| 532 | |
| 533 | bt_bool bt_stream_class_packets_have_packet_counter_snapshot( |
| 534 | const struct bt_stream_class *stream_class) |
| 535 | { |
| 536 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 537 | return (bt_bool) stream_class->packets_have_packet_counter_snapshot; |
| 538 | } |
| 539 | |
| 540 | void bt_stream_class_set_packets_have_packet_counter_snapshot( |
| 541 | struct bt_stream_class *stream_class, |
| 542 | bt_bool value) |
| 543 | { |
| 544 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 545 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
| 546 | stream_class->packets_have_packet_counter_snapshot = |
| 547 | (bool) value; |
| 548 | BT_LIB_LOGV("Set stream class's " |
| 549 | "\"packets have packet counter snapshot\" property: " |
| 550 | "%!+S", stream_class); |
| 551 | } |
| 552 | |
| 553 | bt_bool bt_stream_class_packets_have_default_beginning_clock_snapshot( |
| 554 | const struct bt_stream_class *stream_class) |
| 555 | { |
| 556 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 557 | return (bt_bool) stream_class->packets_have_default_beginning_cs; |
| 558 | } |
| 559 | |
| 560 | void bt_stream_class_set_packets_have_default_beginning_clock_snapshot( |
| 561 | struct bt_stream_class *stream_class, |
| 562 | bt_bool value) |
| 563 | { |
| 564 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 565 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
| 566 | BT_ASSERT_PRE(!value || stream_class->default_clock_class, |
| 567 | "Stream class does not have a default clock class: %!+S", |
| 568 | stream_class); |
| 569 | stream_class->packets_have_default_beginning_cs = (bool) value; |
| 570 | BT_LIB_LOGV("Set stream class's " |
| 571 | "\"packets have default beginning clock snapshot\" property: " |
| 572 | "%!+S", stream_class); |
| 573 | } |
| 574 | |
| 575 | bt_bool bt_stream_class_packets_have_default_end_clock_snapshot( |
| 576 | const struct bt_stream_class *stream_class) |
| 577 | { |
| 578 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 579 | return (bt_bool) stream_class->packets_have_default_end_cs; |
| 580 | } |
| 581 | |
| 582 | void bt_stream_class_set_packets_have_default_end_clock_snapshot( |
| 583 | struct bt_stream_class *stream_class, |
| 584 | bt_bool value) |
| 585 | { |
| 586 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 587 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
| 588 | BT_ASSERT_PRE(!value || stream_class->default_clock_class, |
| 589 | "Stream class does not have a default clock class: %!+S", |
| 590 | stream_class); |
| 591 | stream_class->packets_have_default_end_cs = (bool) value; |
| 592 | BT_LIB_LOGV("Set stream class's " |
| 593 | "\"packets have default end clock snapshot\" property: " |
| 594 | "%!+S", stream_class); |
| 595 | } |
| 596 | |
| 597 | bt_bool bt_stream_class_default_clock_is_always_known( |
| 598 | const struct bt_stream_class *stream_class) |
| 599 | { |
| 600 | /* BT_CLOCK_SNAPSHOT_STATUS_UNKNOWN is not supported as of 2.0 */ |
| 601 | return BT_TRUE; |
| 602 | } |
| 603 | |
| 604 | void bt_stream_class_get_ref(const struct bt_stream_class *stream_class) |
| 605 | { |
| 606 | bt_object_get_ref(stream_class); |
| 607 | } |
| 608 | |
| 609 | void bt_stream_class_put_ref(const struct bt_stream_class *stream_class) |
| 610 | { |
| 611 | bt_object_put_ref(stream_class); |
| 612 | } |