2 * Copyright 2019 - Philippe Proulx <pproulx@efficios.com>
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
15 #define BT_LOG_TAG "PLUGIN-CTF-METADATA-META-UPDATE-SC-CONFIG"
18 #include <babeltrace2/babeltrace.h>
19 #include "common/babeltrace.h"
20 #include "common/assert.h"
26 #include "ctf-meta-visitors.h"
29 int ctf_trace_class_update_stream_class_config(struct ctf_trace_class
*ctf_tc
)
31 struct ctf_field_class_int
*int_fc
;
34 for (i
= 0; i
< ctf_tc
->stream_classes
->len
; i
++) {
35 struct ctf_stream_class
*sc
=
36 ctf_tc
->stream_classes
->pdata
[i
];
38 if (sc
->is_translated
) {
42 if (!sc
->packet_context_fc
) {
46 int_fc
= ctf_field_class_struct_borrow_member_int_field_class_by_name(
47 (void *) sc
->packet_context_fc
, "timestamp_begin");
48 if (int_fc
&& int_fc
->meaning
==
49 CTF_FIELD_CLASS_MEANING_PACKET_BEGINNING_TIME
) {
50 sc
->packets_have_ts_begin
= true;
53 int_fc
= ctf_field_class_struct_borrow_member_int_field_class_by_name(
54 (void *) sc
->packet_context_fc
, "timestamp_end");
55 if (int_fc
&& int_fc
->meaning
==
56 CTF_FIELD_CLASS_MEANING_PACKET_END_TIME
) {
57 sc
->packets_have_ts_end
= true;
60 int_fc
= ctf_field_class_struct_borrow_member_int_field_class_by_name(
61 (void *) sc
->packet_context_fc
, "events_discarded");
62 if (int_fc
&& int_fc
->meaning
==
63 CTF_FIELD_CLASS_MEANING_DISC_EV_REC_COUNTER_SNAPSHOT
) {
64 sc
->has_discarded_events
= true;
67 sc
->discarded_events_have_default_cs
=
68 sc
->has_discarded_events
&& sc
->packets_have_ts_begin
&&
69 sc
->packets_have_ts_end
;
70 int_fc
= ctf_field_class_struct_borrow_member_int_field_class_by_name(
71 (void *) sc
->packet_context_fc
, "packet_seq_num");
72 if (int_fc
&& int_fc
->meaning
==
73 CTF_FIELD_CLASS_MEANING_PACKET_COUNTER_SNAPSHOT
) {
74 sc
->has_discarded_packets
= true;
77 sc
->discarded_packets_have_default_cs
=
78 sc
->has_discarded_packets
&&
79 sc
->packets_have_ts_begin
&& sc
->packets_have_ts_end
;