- if (stream_range->set) {
- ret = add_range(group_info, stream_range, "range-ns");
- if (ret) {
- goto end;
- }
+ /*
+ * If any of the begin and end timestamps is not set it means that
+ * packets don't include `timestamp_begin` _and_ `timestamp_end` fields
+ * in their packet context so we can't set the range.
+ */
+ stream_range->set = stream_range->begin_ns != UINT64_C(-1) &&
+ stream_range->end_ns != UINT64_C(-1);
+
+ ret = add_range(group_info, stream_range, "range-ns");
+ if (ret) {
+ goto end;