+ int ret = 0;
+
+ if (!stream_class) {
+ BT_LOGW_STR("Invalid parameter: stream class is NULL.");
+ ret = -1;
+ goto end;
+ }
+
+ if (stream_class->frozen) {
+ BT_LOGW("Invalid parameter: stream class is frozen: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ stream_class, bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class));
+ ret = -1;
+ goto end;
+ }
+
+ if (packet_context_type &&
+ bt_field_type_get_type_id(packet_context_type) !=
+ BT_FIELD_TYPE_ID_STRUCT) {
+ /* A packet context must be a structure. */
+ BT_LOGW("Invalid parameter: stream class's packet context field type must be a structure: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", "
+ "packet-context-ft-addr=%p, packet-context-ft-id=%s",
+ stream_class, bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class),
+ packet_context_type,
+ bt_common_field_type_id_string(
+ bt_field_type_get_type_id(packet_context_type)));
+ ret = -1;
+ goto end;
+ }
+
+ bt_put(stream_class->packet_context_field_type);
+ bt_get(packet_context_type);
+ stream_class->packet_context_field_type = packet_context_type;
+ BT_LOGV("Set stream class's packet context field type: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", "
+ "packet-context-ft-addr=%p",
+ stream_class, bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class),
+ packet_context_type);
+
+end:
+ return ret;