+struct bt_ctf_stream *bt_ctf_stream_create_with_id(
+ struct bt_ctf_stream_class *stream_class,
+ const char *name, uint64_t id_param)
+{
+ struct bt_ctf_trace *trace;
+ struct bt_ctf_stream *stream = NULL;
+ int64_t id = (int64_t) id_param;
+
+ if (!stream_class) {
+ BT_LOGW_STR("Invalid parameter: stream class is NULL.");
+ goto end;
+ }
+
+ if (id < 0) {
+ BT_LOGW("Invalid parameter: invalid stream's ID: "
+ "name=\"%s\", id=%" PRIu64,
+ name, id_param);
+ goto end;
+ }
+
+ trace = bt_ctf_stream_class_borrow_trace(stream_class);
+ if (!trace) {
+ BT_LOGW("Invalid parameter: cannot create stream from a stream class which is not part of trace: "
+ "stream-class-addr=%p, stream-class-name=\"%s\", "
+ "stream-name=\"%s\", stream-id=%" PRIu64,
+ stream_class, bt_ctf_stream_class_get_name(stream_class),
+ name, id_param);
+ goto end;
+ }
+
+ if (trace->is_created_by_writer) {
+ BT_LOGW("Invalid parameter: cannot create a CTF writer stream with this function; use bt_ctf_stream_create(): "
+ "stream-class-addr=%p, stream-class-name=\"%s\", "
+ "stream-name=\"%s\", stream-id=%" PRIu64,
+ stream_class, bt_ctf_stream_class_get_name(stream_class),
+ name, id_param);
+ goto end;
+ }
+
+ stream = bt_ctf_stream_create_with_id_no_check(stream_class,
+ name, id_param);
+
+end:
+ return stream;
+}
+
+struct bt_ctf_stream *bt_ctf_stream_create(
+ struct bt_ctf_stream_class *stream_class,
+ const char *name)
+{
+ return bt_ctf_stream_create_with_id_no_check(stream_class,
+ name, -1ULL);
+}
+