| 1 | /* |
| 2 | * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 3 | * |
| 4 | * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to deal |
| 8 | * in the Software without restriction, including without limitation the rights |
| 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | * copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in |
| 14 | * all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | |
| 25 | #define BT_LOG_TAG "STREAM-CLASS" |
| 26 | #include <babeltrace/lib-logging-internal.h> |
| 27 | |
| 28 | #include <babeltrace/assert-pre-internal.h> |
| 29 | #include <babeltrace/trace-ir/clock-class-internal.h> |
| 30 | #include <babeltrace/trace-ir/event-class-internal.h> |
| 31 | #include <babeltrace/trace-ir/field-classes-internal.h> |
| 32 | #include <babeltrace/trace-ir/fields-internal.h> |
| 33 | #include <babeltrace/trace-ir/stream-class-internal.h> |
| 34 | #include <babeltrace/trace-ir/trace-const.h> |
| 35 | #include <babeltrace/trace-ir/trace-internal.h> |
| 36 | #include <babeltrace/trace-ir/utils-internal.h> |
| 37 | #include <babeltrace/trace-ir/field-wrapper-internal.h> |
| 38 | #include <babeltrace/trace-ir/resolve-field-path-internal.h> |
| 39 | #include <babeltrace/object.h> |
| 40 | #include <babeltrace/compiler-internal.h> |
| 41 | #include <babeltrace/align-internal.h> |
| 42 | #include <babeltrace/endian-internal.h> |
| 43 | #include <babeltrace/assert-internal.h> |
| 44 | #include <babeltrace/property-internal.h> |
| 45 | #include <inttypes.h> |
| 46 | #include <stdint.h> |
| 47 | #include <stdbool.h> |
| 48 | |
| 49 | #define BT_ASSERT_PRE_STREAM_CLASS_HOT(_sc) \ |
| 50 | BT_ASSERT_PRE_HOT((_sc), "Stream class", ": %!+S", (_sc)) |
| 51 | |
| 52 | static |
| 53 | void destroy_stream_class(struct bt_object *obj) |
| 54 | { |
| 55 | struct bt_stream_class *stream_class = (void *) obj; |
| 56 | |
| 57 | BT_LIB_LOGD("Destroying stream class: %!+S", stream_class); |
| 58 | BT_LOGD_STR("Putting default clock class."); |
| 59 | BT_OBJECT_PUT_REF_AND_RESET(stream_class->default_clock_class); |
| 60 | |
| 61 | if (stream_class->event_classes) { |
| 62 | BT_LOGD_STR("Destroying event classes."); |
| 63 | g_ptr_array_free(stream_class->event_classes, TRUE); |
| 64 | stream_class->event_classes = NULL; |
| 65 | } |
| 66 | |
| 67 | if (stream_class->name.str) { |
| 68 | g_string_free(stream_class->name.str, TRUE); |
| 69 | stream_class->name.str = NULL; |
| 70 | stream_class->name.value = NULL; |
| 71 | } |
| 72 | |
| 73 | BT_LOGD_STR("Putting event header field classe."); |
| 74 | BT_OBJECT_PUT_REF_AND_RESET(stream_class->event_header_fc); |
| 75 | BT_LOGD_STR("Putting packet context field classe."); |
| 76 | BT_OBJECT_PUT_REF_AND_RESET(stream_class->packet_context_fc); |
| 77 | BT_LOGD_STR("Putting event common context field classe."); |
| 78 | BT_OBJECT_PUT_REF_AND_RESET(stream_class->event_common_context_fc); |
| 79 | bt_object_pool_finalize(&stream_class->event_header_field_pool); |
| 80 | bt_object_pool_finalize(&stream_class->packet_context_field_pool); |
| 81 | g_free(stream_class); |
| 82 | } |
| 83 | |
| 84 | static |
| 85 | void free_field_wrapper(struct bt_field_wrapper *field_wrapper, |
| 86 | struct bt_stream_class *stream_class) |
| 87 | { |
| 88 | bt_field_wrapper_destroy((void *) field_wrapper); |
| 89 | } |
| 90 | |
| 91 | BT_ASSERT_PRE_FUNC |
| 92 | static |
| 93 | bool stream_class_id_is_unique(const struct bt_trace *trace, uint64_t id) |
| 94 | { |
| 95 | uint64_t i; |
| 96 | bool is_unique = true; |
| 97 | |
| 98 | for (i = 0; i < trace->stream_classes->len; i++) { |
| 99 | const struct bt_stream_class *sc = |
| 100 | trace->stream_classes->pdata[i]; |
| 101 | |
| 102 | if (sc->id == id) { |
| 103 | is_unique = false; |
| 104 | goto end; |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | end: |
| 109 | return is_unique; |
| 110 | } |
| 111 | |
| 112 | static |
| 113 | struct bt_stream_class *create_stream_class_with_id(struct bt_trace *trace, |
| 114 | uint64_t id) |
| 115 | { |
| 116 | struct bt_stream_class *stream_class = NULL; |
| 117 | int ret; |
| 118 | |
| 119 | BT_ASSERT(trace); |
| 120 | BT_ASSERT_PRE(stream_class_id_is_unique(trace, id), |
| 121 | "Duplicate stream class ID: %![trace-]+t, id=%" PRIu64, |
| 122 | trace, id); |
| 123 | BT_LIB_LOGD("Creating stream class object: %![trace-]+t, id=%" PRIu64, |
| 124 | trace, id); |
| 125 | stream_class = g_new0(struct bt_stream_class, 1); |
| 126 | if (!stream_class) { |
| 127 | BT_LOGE_STR("Failed to allocate one stream class."); |
| 128 | goto error; |
| 129 | } |
| 130 | |
| 131 | bt_object_init_shared_with_parent(&stream_class->base, |
| 132 | destroy_stream_class); |
| 133 | |
| 134 | stream_class->name.str = g_string_new(NULL); |
| 135 | if (!stream_class->name.str) { |
| 136 | BT_LOGE_STR("Failed to allocate a GString."); |
| 137 | ret = -1; |
| 138 | goto end; |
| 139 | } |
| 140 | |
| 141 | stream_class->id = id; |
| 142 | stream_class->assigns_automatic_event_class_id = true; |
| 143 | stream_class->assigns_automatic_stream_id = true; |
| 144 | stream_class->event_classes = g_ptr_array_new_with_free_func( |
| 145 | (GDestroyNotify) bt_object_try_spec_release); |
| 146 | if (!stream_class->event_classes) { |
| 147 | BT_LOGE_STR("Failed to allocate a GPtrArray."); |
| 148 | goto error; |
| 149 | } |
| 150 | |
| 151 | ret = bt_object_pool_initialize(&stream_class->event_header_field_pool, |
| 152 | (bt_object_pool_new_object_func) bt_field_wrapper_new, |
| 153 | (bt_object_pool_destroy_object_func) free_field_wrapper, |
| 154 | stream_class); |
| 155 | if (ret) { |
| 156 | BT_LOGE("Failed to initialize event header field pool: ret=%d", |
| 157 | ret); |
| 158 | goto error; |
| 159 | } |
| 160 | |
| 161 | ret = bt_object_pool_initialize(&stream_class->packet_context_field_pool, |
| 162 | (bt_object_pool_new_object_func) bt_field_wrapper_new, |
| 163 | (bt_object_pool_destroy_object_func) free_field_wrapper, |
| 164 | stream_class); |
| 165 | if (ret) { |
| 166 | BT_LOGE("Failed to initialize packet context field pool: ret=%d", |
| 167 | ret); |
| 168 | goto error; |
| 169 | } |
| 170 | |
| 171 | bt_object_set_parent(&stream_class->base, &trace->base); |
| 172 | g_ptr_array_add(trace->stream_classes, stream_class); |
| 173 | bt_trace_freeze(trace); |
| 174 | BT_LIB_LOGD("Created stream class object: %!+S", stream_class); |
| 175 | goto end; |
| 176 | |
| 177 | error: |
| 178 | BT_OBJECT_PUT_REF_AND_RESET(stream_class); |
| 179 | |
| 180 | end: |
| 181 | return stream_class; |
| 182 | } |
| 183 | |
| 184 | struct bt_stream_class *bt_stream_class_create(struct bt_trace *trace) |
| 185 | { |
| 186 | BT_ASSERT_PRE_NON_NULL(trace, "Trace"); |
| 187 | BT_ASSERT_PRE(trace->assigns_automatic_stream_class_id, |
| 188 | "Trace does not automatically assigns stream class IDs: " |
| 189 | "%![sc-]+t", trace); |
| 190 | return create_stream_class_with_id(trace, |
| 191 | (uint64_t) trace->stream_classes->len); |
| 192 | } |
| 193 | |
| 194 | struct bt_stream_class *bt_stream_class_create_with_id( |
| 195 | struct bt_trace *trace, uint64_t id) |
| 196 | { |
| 197 | BT_ASSERT_PRE_NON_NULL(trace, "Trace"); |
| 198 | BT_ASSERT_PRE(!trace->assigns_automatic_stream_class_id, |
| 199 | "Trace automatically assigns stream class IDs: " |
| 200 | "%![sc-]+t", trace); |
| 201 | return create_stream_class_with_id(trace, id); |
| 202 | } |
| 203 | |
| 204 | struct bt_trace *bt_stream_class_borrow_trace( |
| 205 | struct bt_stream_class *stream_class) |
| 206 | { |
| 207 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 208 | return bt_stream_class_borrow_trace_inline(stream_class); |
| 209 | } |
| 210 | |
| 211 | const struct bt_trace *bt_stream_class_borrow_trace_const( |
| 212 | const struct bt_stream_class *stream_class) |
| 213 | { |
| 214 | return bt_stream_class_borrow_trace((void *) stream_class); |
| 215 | } |
| 216 | |
| 217 | const char *bt_stream_class_get_name(const struct bt_stream_class *stream_class) |
| 218 | { |
| 219 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 220 | return stream_class->name.value; |
| 221 | } |
| 222 | |
| 223 | int bt_stream_class_set_name( |
| 224 | struct bt_stream_class *stream_class, |
| 225 | const char *name) |
| 226 | { |
| 227 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 228 | BT_ASSERT_PRE_NON_NULL(name, "Name"); |
| 229 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
| 230 | g_string_assign(stream_class->name.str, name); |
| 231 | stream_class->name.value = stream_class->name.str->str; |
| 232 | BT_LIB_LOGV("Set stream class's name: %!+S", stream_class); |
| 233 | return 0; |
| 234 | } |
| 235 | |
| 236 | uint64_t bt_stream_class_get_id(const struct bt_stream_class *stream_class) |
| 237 | { |
| 238 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 239 | return stream_class->id; |
| 240 | } |
| 241 | |
| 242 | uint64_t bt_stream_class_get_event_class_count( |
| 243 | const struct bt_stream_class *stream_class) |
| 244 | { |
| 245 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 246 | return (uint64_t) stream_class->event_classes->len; |
| 247 | } |
| 248 | |
| 249 | struct bt_event_class *bt_stream_class_borrow_event_class_by_index( |
| 250 | struct bt_stream_class *stream_class, uint64_t index) |
| 251 | { |
| 252 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 253 | BT_ASSERT_PRE_VALID_INDEX(index, stream_class->event_classes->len); |
| 254 | return g_ptr_array_index(stream_class->event_classes, index); |
| 255 | } |
| 256 | |
| 257 | const struct bt_event_class * |
| 258 | bt_stream_class_borrow_event_class_by_index_const( |
| 259 | const struct bt_stream_class *stream_class, uint64_t index) |
| 260 | { |
| 261 | return bt_stream_class_borrow_event_class_by_index( |
| 262 | (void *) stream_class, index); |
| 263 | } |
| 264 | |
| 265 | struct bt_event_class *bt_stream_class_borrow_event_class_by_id( |
| 266 | struct bt_stream_class *stream_class, uint64_t id) |
| 267 | { |
| 268 | struct bt_event_class *event_class = NULL; |
| 269 | uint64_t i; |
| 270 | |
| 271 | BT_ASSERT_PRE_NON_NULL(stream_class, "Trace"); |
| 272 | |
| 273 | for (i = 0; i < stream_class->event_classes->len; i++) { |
| 274 | struct bt_event_class *event_class_candidate = |
| 275 | g_ptr_array_index(stream_class->event_classes, i); |
| 276 | |
| 277 | if (event_class_candidate->id == id) { |
| 278 | event_class = event_class_candidate; |
| 279 | goto end; |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | end: |
| 284 | return event_class; |
| 285 | } |
| 286 | |
| 287 | const struct bt_event_class * |
| 288 | bt_stream_class_borrow_event_class_by_id_const( |
| 289 | const struct bt_stream_class *stream_class, uint64_t id) |
| 290 | { |
| 291 | return bt_stream_class_borrow_event_class_by_id( |
| 292 | (void *) stream_class, id); |
| 293 | } |
| 294 | |
| 295 | const struct bt_field_class * |
| 296 | bt_stream_class_borrow_packet_context_field_class_const( |
| 297 | const struct bt_stream_class *stream_class) |
| 298 | { |
| 299 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 300 | return stream_class->packet_context_fc; |
| 301 | } |
| 302 | |
| 303 | int bt_stream_class_set_packet_context_field_class( |
| 304 | struct bt_stream_class *stream_class, |
| 305 | struct bt_field_class *field_class) |
| 306 | { |
| 307 | int ret; |
| 308 | struct bt_resolve_field_path_context resolve_ctx = { |
| 309 | .packet_header = NULL, |
| 310 | .packet_context = field_class, |
| 311 | .event_header = NULL, |
| 312 | .event_common_context = NULL, |
| 313 | .event_specific_context = NULL, |
| 314 | .event_payload = NULL, |
| 315 | }; |
| 316 | |
| 317 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 318 | BT_ASSERT_PRE_NON_NULL(field_class, "Field class"); |
| 319 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
| 320 | BT_ASSERT_PRE(bt_field_class_get_type(field_class) == |
| 321 | BT_FIELD_CLASS_TYPE_STRUCTURE, |
| 322 | "Packet context field classe is not a structure field classe: %!+F", |
| 323 | field_class); |
| 324 | resolve_ctx.packet_header = |
| 325 | bt_stream_class_borrow_trace_inline(stream_class)->packet_header_fc; |
| 326 | ret = bt_resolve_field_paths(field_class, &resolve_ctx); |
| 327 | if (ret) { |
| 328 | goto end; |
| 329 | } |
| 330 | |
| 331 | bt_field_class_make_part_of_trace(field_class); |
| 332 | bt_object_put_ref(stream_class->packet_context_fc); |
| 333 | stream_class->packet_context_fc = field_class; |
| 334 | bt_object_get_no_null_check(stream_class->packet_context_fc); |
| 335 | bt_field_class_freeze(field_class); |
| 336 | BT_LIB_LOGV("Set stream class's packet context field classe: %!+S", |
| 337 | stream_class); |
| 338 | |
| 339 | end: |
| 340 | return ret; |
| 341 | } |
| 342 | |
| 343 | const struct bt_field_class *bt_stream_class_borrow_event_header_field_class_const( |
| 344 | const struct bt_stream_class *stream_class) |
| 345 | { |
| 346 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 347 | return stream_class->event_header_fc; |
| 348 | } |
| 349 | |
| 350 | int bt_stream_class_set_event_header_field_class( |
| 351 | struct bt_stream_class *stream_class, |
| 352 | struct bt_field_class *field_class) |
| 353 | { |
| 354 | int ret; |
| 355 | struct bt_resolve_field_path_context resolve_ctx = { |
| 356 | .packet_header = NULL, |
| 357 | .packet_context = NULL, |
| 358 | .event_header = field_class, |
| 359 | .event_common_context = NULL, |
| 360 | .event_specific_context = NULL, |
| 361 | .event_payload = NULL, |
| 362 | }; |
| 363 | |
| 364 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 365 | BT_ASSERT_PRE_NON_NULL(field_class, "Field class"); |
| 366 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
| 367 | BT_ASSERT_PRE(bt_field_class_get_type(field_class) == |
| 368 | BT_FIELD_CLASS_TYPE_STRUCTURE, |
| 369 | "Event header field classe is not a structure field classe: %!+F", |
| 370 | field_class); |
| 371 | resolve_ctx.packet_header = |
| 372 | bt_stream_class_borrow_trace_inline(stream_class)->packet_header_fc; |
| 373 | resolve_ctx.packet_context = stream_class->packet_context_fc; |
| 374 | ret = bt_resolve_field_paths(field_class, &resolve_ctx); |
| 375 | if (ret) { |
| 376 | goto end; |
| 377 | } |
| 378 | |
| 379 | bt_field_class_make_part_of_trace(field_class); |
| 380 | bt_object_put_ref(stream_class->event_header_fc); |
| 381 | stream_class->event_header_fc = field_class; |
| 382 | bt_object_get_no_null_check(stream_class->event_header_fc); |
| 383 | bt_field_class_freeze(field_class); |
| 384 | BT_LIB_LOGV("Set stream class's event header field classe: %!+S", |
| 385 | stream_class); |
| 386 | |
| 387 | end: |
| 388 | return ret; |
| 389 | } |
| 390 | |
| 391 | const struct bt_field_class * |
| 392 | bt_stream_class_borrow_event_common_context_field_class_const( |
| 393 | const struct bt_stream_class *stream_class) |
| 394 | { |
| 395 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 396 | return stream_class->event_common_context_fc; |
| 397 | } |
| 398 | |
| 399 | int bt_stream_class_set_event_common_context_field_class( |
| 400 | struct bt_stream_class *stream_class, |
| 401 | struct bt_field_class *field_class) |
| 402 | { |
| 403 | int ret; |
| 404 | struct bt_resolve_field_path_context resolve_ctx = { |
| 405 | .packet_header = NULL, |
| 406 | .packet_context = NULL, |
| 407 | .event_header = NULL, |
| 408 | .event_common_context = field_class, |
| 409 | .event_specific_context = NULL, |
| 410 | .event_payload = NULL, |
| 411 | }; |
| 412 | |
| 413 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 414 | BT_ASSERT_PRE_NON_NULL(field_class, "Field class"); |
| 415 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
| 416 | BT_ASSERT_PRE(bt_field_class_get_type(field_class) == |
| 417 | BT_FIELD_CLASS_TYPE_STRUCTURE, |
| 418 | "Event common context field classe is not a structure field classe: %!+F", |
| 419 | field_class); |
| 420 | resolve_ctx.packet_header = |
| 421 | bt_stream_class_borrow_trace_inline(stream_class)->packet_header_fc; |
| 422 | resolve_ctx.packet_context = stream_class->packet_context_fc; |
| 423 | resolve_ctx.event_header = stream_class->event_header_fc; |
| 424 | ret = bt_resolve_field_paths(field_class, &resolve_ctx); |
| 425 | if (ret) { |
| 426 | goto end; |
| 427 | } |
| 428 | |
| 429 | bt_field_class_make_part_of_trace(field_class); |
| 430 | bt_object_put_ref(stream_class->event_common_context_fc); |
| 431 | stream_class->event_common_context_fc = field_class; |
| 432 | bt_object_get_no_null_check(stream_class->event_common_context_fc); |
| 433 | bt_field_class_freeze(field_class); |
| 434 | BT_LIB_LOGV("Set stream class's event common context field classe: %!+S", |
| 435 | stream_class); |
| 436 | |
| 437 | end: |
| 438 | return ret; |
| 439 | } |
| 440 | |
| 441 | BT_HIDDEN |
| 442 | void _bt_stream_class_freeze(const struct bt_stream_class *stream_class) |
| 443 | { |
| 444 | /* The field classes and default clock class are already frozen */ |
| 445 | BT_ASSERT(stream_class); |
| 446 | BT_LIB_LOGD("Freezing stream class: %!+S", stream_class); |
| 447 | ((struct bt_stream_class *) stream_class)->frozen = true; |
| 448 | } |
| 449 | |
| 450 | int bt_stream_class_set_default_clock_class( |
| 451 | struct bt_stream_class *stream_class, |
| 452 | struct bt_clock_class *clock_class) |
| 453 | { |
| 454 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 455 | BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class"); |
| 456 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
| 457 | bt_object_put_ref(stream_class->default_clock_class); |
| 458 | stream_class->default_clock_class = clock_class; |
| 459 | bt_object_get_no_null_check(stream_class->default_clock_class); |
| 460 | bt_clock_class_freeze(clock_class); |
| 461 | BT_LIB_LOGV("Set stream class's default clock class: %!+S", |
| 462 | stream_class); |
| 463 | return 0; |
| 464 | } |
| 465 | |
| 466 | struct bt_clock_class *bt_stream_class_borrow_default_clock_class( |
| 467 | struct bt_stream_class *stream_class) |
| 468 | { |
| 469 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 470 | return stream_class->default_clock_class; |
| 471 | } |
| 472 | |
| 473 | const struct bt_clock_class *bt_stream_class_borrow_default_clock_class_const( |
| 474 | const struct bt_stream_class *stream_class) |
| 475 | { |
| 476 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 477 | return stream_class->default_clock_class; |
| 478 | } |
| 479 | |
| 480 | bt_bool bt_stream_class_assigns_automatic_event_class_id( |
| 481 | const struct bt_stream_class *stream_class) |
| 482 | { |
| 483 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 484 | return (bt_bool) stream_class->assigns_automatic_event_class_id; |
| 485 | } |
| 486 | |
| 487 | void bt_stream_class_set_assigns_automatic_event_class_id( |
| 488 | struct bt_stream_class *stream_class, |
| 489 | bt_bool value) |
| 490 | { |
| 491 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 492 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
| 493 | stream_class->assigns_automatic_event_class_id = (bool) value; |
| 494 | BT_LIB_LOGV("Set stream class's automatic event class ID " |
| 495 | "assignment property: %!+S", stream_class); |
| 496 | } |
| 497 | |
| 498 | bt_bool bt_stream_class_assigns_automatic_stream_id( |
| 499 | const struct bt_stream_class *stream_class) |
| 500 | { |
| 501 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 502 | return (bt_bool) stream_class->assigns_automatic_stream_id; |
| 503 | } |
| 504 | |
| 505 | void bt_stream_class_set_assigns_automatic_stream_id( |
| 506 | struct bt_stream_class *stream_class, |
| 507 | bt_bool value) |
| 508 | { |
| 509 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 510 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
| 511 | stream_class->assigns_automatic_stream_id = (bool) value; |
| 512 | BT_LIB_LOGV("Set stream class's automatic stream ID " |
| 513 | "assignment property: %!+S", stream_class); |
| 514 | } |
| 515 | |
| 516 | bt_bool bt_stream_class_packets_have_discarded_event_counter_snapshot( |
| 517 | const struct bt_stream_class *stream_class) |
| 518 | { |
| 519 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 520 | return (bt_bool) stream_class->packets_have_discarded_event_counter_snapshot; |
| 521 | } |
| 522 | |
| 523 | void bt_stream_class_set_packets_have_discarded_event_counter_snapshot( |
| 524 | struct bt_stream_class *stream_class, |
| 525 | bt_bool value) |
| 526 | { |
| 527 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 528 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
| 529 | stream_class->packets_have_discarded_event_counter_snapshot = |
| 530 | (bool) value; |
| 531 | BT_LIB_LOGV("Set stream class's " |
| 532 | "\"packets have discarded event counter snapshot\" property: " |
| 533 | "%!+S", stream_class); |
| 534 | } |
| 535 | |
| 536 | bt_bool bt_stream_class_packets_have_packet_counter_snapshot( |
| 537 | const struct bt_stream_class *stream_class) |
| 538 | { |
| 539 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 540 | return (bt_bool) stream_class->packets_have_packet_counter_snapshot; |
| 541 | } |
| 542 | |
| 543 | void bt_stream_class_set_packets_have_packet_counter_snapshot( |
| 544 | struct bt_stream_class *stream_class, |
| 545 | bt_bool value) |
| 546 | { |
| 547 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 548 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
| 549 | stream_class->packets_have_packet_counter_snapshot = |
| 550 | (bool) value; |
| 551 | BT_LIB_LOGV("Set stream class's " |
| 552 | "\"packets have packet counter snapshot\" property: " |
| 553 | "%!+S", stream_class); |
| 554 | } |
| 555 | |
| 556 | bt_bool bt_stream_class_packets_have_default_beginning_clock_value( |
| 557 | const struct bt_stream_class *stream_class) |
| 558 | { |
| 559 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 560 | return (bt_bool) stream_class->packets_have_default_beginning_cv; |
| 561 | } |
| 562 | |
| 563 | void bt_stream_class_set_packets_have_default_beginning_clock_value( |
| 564 | struct bt_stream_class *stream_class, |
| 565 | bt_bool value) |
| 566 | { |
| 567 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 568 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
| 569 | BT_ASSERT_PRE(!value || stream_class->default_clock_class, |
| 570 | "Stream class does not have a default clock class: %!+S", |
| 571 | stream_class); |
| 572 | stream_class->packets_have_default_beginning_cv = (bool) value; |
| 573 | BT_LIB_LOGV("Set stream class's " |
| 574 | "\"packets have default beginning clock value\" property: " |
| 575 | "%!+S", stream_class); |
| 576 | } |
| 577 | |
| 578 | bt_bool bt_stream_class_packets_have_default_end_clock_value( |
| 579 | const struct bt_stream_class *stream_class) |
| 580 | { |
| 581 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 582 | return (bt_bool) stream_class->packets_have_default_end_cv; |
| 583 | } |
| 584 | |
| 585 | void bt_stream_class_set_packets_have_default_end_clock_value( |
| 586 | struct bt_stream_class *stream_class, |
| 587 | bt_bool value) |
| 588 | { |
| 589 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
| 590 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
| 591 | BT_ASSERT_PRE(!value || stream_class->default_clock_class, |
| 592 | "Stream class does not have a default clock class: %!+S", |
| 593 | stream_class); |
| 594 | stream_class->packets_have_default_end_cv = (bool) value; |
| 595 | BT_LIB_LOGV("Set stream class's " |
| 596 | "\"packets have default end clock value\" property: " |
| 597 | "%!+S", stream_class); |
| 598 | } |
| 599 | |
| 600 | bt_bool bt_stream_class_default_clock_is_always_known( |
| 601 | const struct bt_stream_class *stream_class) |
| 602 | { |
| 603 | /* BT_CLOCK_VALUE_STATUS_UNKNOWN is not supported as of 2.0 */ |
| 604 | return BT_TRUE; |
| 605 | } |