+int get_ds_file_packet_bounds_clock_classes(struct ctf_fs_ds_file *ds_file,
+ struct bt_ctf_clock_class **_timestamp_begin_cc,
+ struct bt_ctf_clock_class **_timestamp_end_cc)
+{
+ int ret;
+ struct bt_ctf_field *timestamp_field = NULL;
+ struct bt_ctf_field *packet_context_field = NULL;
+ struct bt_ctf_clock_class *timestamp_begin_cc = NULL;
+ struct bt_ctf_clock_class *timestamp_end_cc = NULL;
+
+ ret = ctf_fs_ds_file_get_packet_header_context_fields(ds_file,
+ NULL, &packet_context_field);
+ if (ret || !packet_context_field) {
+ BT_LOGD("Cannot retrieve packet context field of stream \'%s\'",
+ ds_file->file->path->str);
+ ret = -1;
+ goto end;
+ }
+
+ timestamp_field = bt_ctf_field_structure_get_field_by_name(
+ packet_context_field, "timestamp_begin");
+ if (!timestamp_field) {
+ BT_LOGD("Cannot retrieve timestamp_begin field in packet context of stream \'%s\'",
+ ds_file->file->path->str);
+ ret = -1;
+ goto end;
+ }
+
+ timestamp_begin_cc = get_field_mapped_clock_class(timestamp_field);
+ if (!timestamp_begin_cc) {
+ BT_LOGD("Cannot retrieve the clock mapped to timestamp_begin of stream \'%s\'",
+ ds_file->file->path->str);
+ }
+ BT_PUT(timestamp_field);
+
+ timestamp_field = bt_ctf_field_structure_get_field_by_name(
+ packet_context_field, "timestamp_end");
+ if (!timestamp_field) {
+ BT_LOGD("Cannot retrieve timestamp_end field in packet context of stream \'%s\'",
+ ds_file->file->path->str);
+ ret = -1;
+ goto end;
+ }
+
+ timestamp_end_cc = get_field_mapped_clock_class(timestamp_field);
+ if (!timestamp_end_cc) {
+ BT_LOGD("Cannot retrieve the clock mapped to timestamp_end in stream \'%s\'",
+ ds_file->file->path->str);
+ }
+
+ if (_timestamp_begin_cc) {
+ *_timestamp_begin_cc = bt_get(timestamp_begin_cc);
+ }
+ if (_timestamp_end_cc) {
+ *_timestamp_end_cc = bt_get(timestamp_end_cc);
+ }
+end:
+ bt_put(packet_context_field);
+ bt_put(timestamp_field);
+ bt_put(timestamp_begin_cc);
+ bt_put(timestamp_end_cc);
+ return ret;
+}
+
+static
+int convert_cycles_to_ns(struct bt_ctf_clock_class *clock_class,
+ uint64_t cycles, int64_t *ns)