+struct bt_event_header_field *bt_stream_class_create_event_header_field(
+ struct bt_stream_class *stream_class)
+{
+ struct bt_field_wrapper *field_wrapper;
+
+ BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+ BT_ASSERT_PRE(stream_class->common.frozen,
+ "Stream class is not part of a trace: %!+S", stream_class);
+ BT_ASSERT_PRE(stream_class->common.event_header_field_type,
+ "Stream class has no event header field type: %!+S",
+ stream_class);
+ field_wrapper = bt_field_wrapper_create(
+ &stream_class->event_header_field_pool,
+ (void *) stream_class->common.event_header_field_type);
+ if (!field_wrapper) {
+ BT_LIB_LOGE("Cannot allocate one event header field from stream class: "
+ "%![sc-]+S", stream_class);
+ goto error;
+ }
+
+ BT_ASSERT(field_wrapper->field);
+ goto end;
+
+error:
+ if (field_wrapper) {
+ bt_field_wrapper_destroy(field_wrapper);
+ field_wrapper = NULL;
+ }
+
+end:
+ return (void *) field_wrapper;
+}
+
+struct bt_packet_context_field *bt_stream_class_create_packet_context_field(
+ struct bt_stream_class *stream_class)
+{
+ struct bt_field_wrapper *field_wrapper;
+
+ BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+ BT_ASSERT_PRE(stream_class->common.frozen,
+ "Stream class is not part of a trace: %!+S", stream_class);
+ BT_ASSERT_PRE(stream_class->common.packet_context_field_type,
+ "Stream class has no packet context field type: %!+S",
+ stream_class);
+ field_wrapper = bt_field_wrapper_create(
+ &stream_class->packet_context_field_pool,
+ (void *) stream_class->common.packet_context_field_type);
+ if (!field_wrapper) {
+ BT_LIB_LOGE("Cannot allocate one packet context field from stream class: "
+ "%![sc-]+S", stream_class);
+ goto error;
+ }
+
+ BT_ASSERT(field_wrapper->field);
+ goto end;
+
+error:
+ if (field_wrapper) {
+ bt_field_wrapper_destroy(field_wrapper);
+ field_wrapper = NULL;
+ }
+
+end:
+ return (void *) field_wrapper;
+}
+