-static
-uint64_t get_packet_header_stream_instance_id(struct ctf_fs_trace *ctf_fs_trace,
- struct bt_field *packet_header_field)
-{
- struct bt_field *stream_instance_id_field = NULL;
- uint64_t stream_instance_id = -1ULL;
- int ret;
-
- if (!packet_header_field) {
- goto end;
- }
-
- stream_instance_id_field = bt_field_structure_borrow_field_by_name(
- packet_header_field, "stream_instance_id");
- if (!stream_instance_id_field) {
- goto end;
- }
-
- ret = bt_field_integer_unsigned_get_value(stream_instance_id_field,
- &stream_instance_id);
- if (ret) {
- stream_instance_id = -1ULL;
- goto end;
- }
-
-end:
- bt_put(stream_instance_id_field);
- return stream_instance_id;
-}
-
-uint64_t get_packet_context_timestamp_begin_ns(
- struct ctf_fs_trace *ctf_fs_trace,
- struct bt_field *packet_context_field)
-{
- int ret;
- struct bt_field *timestamp_begin_field = NULL;
- struct bt_field_type *timestamp_begin_ft = NULL;
- uint64_t timestamp_begin_raw_value = -1ULL;
- uint64_t timestamp_begin_ns = -1ULL;
- int64_t timestamp_begin_ns_signed;
- struct bt_clock_class *timestamp_begin_clock_class = NULL;
- struct bt_clock_value *clock_value = NULL;
-
- if (!packet_context_field) {
- goto end;
- }
-
- timestamp_begin_field = bt_field_structure_borrow_field_by_name(
- packet_context_field, "timestamp_begin");
- if (!timestamp_begin_field) {
- goto end;
- }
-
- timestamp_begin_ft = bt_field_borrow_type(timestamp_begin_field);
- BT_ASSERT(timestamp_begin_ft);
- timestamp_begin_clock_class =
- bt_field_type_integer_borrow_mapped_clock_class(timestamp_begin_ft);
- if (!timestamp_begin_clock_class) {
- goto end;
- }
-
- ret = bt_field_integer_unsigned_get_value(timestamp_begin_field,
- ×tamp_begin_raw_value);
- if (ret) {
- goto end;
- }
-
- clock_value = bt_clock_value_create(timestamp_begin_clock_class,
- timestamp_begin_raw_value);
- if (!clock_value) {
- goto end;
- }
-
- ret = bt_clock_value_get_value_ns_from_epoch(clock_value,
- ×tamp_begin_ns_signed);
- if (ret) {
- goto end;
- }
-
- timestamp_begin_ns = (uint64_t) timestamp_begin_ns_signed;
-
-end:
- bt_put(clock_value);
- return timestamp_begin_ns;
-}
-