1 #ifndef BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_STREAM_H
2 #define BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_STREAM_H
5 * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 #include "common/macros.h"
27 #include <babeltrace2/babeltrace.h>
28 #include "ctfser/ctfser.h"
33 #include "fs-sink-ctf-meta.h"
37 struct fs_sink_stream
{
38 struct fs_sink_trace
*trace
;
39 struct bt_ctfser ctfser
;
41 /* Stream's file name */
45 const bt_stream
*ir_stream
;
47 struct fs_sink_ctf_stream_class
*sc
;
49 /* Current packet's state */
52 * True if we're, for this stream, within an opened
53 * packet (got a packet beginning message, but no
54 * packet end message yet).
59 * Current beginning default clock snapshot for the
60 * current packet (`UINT64_C(-1)` if not set).
62 uint64_t beginning_cs
;
65 * Current end default clock snapshot for the current
66 * packet (`UINT64_C(-1)` if not set).
71 * Current packet's content size (bits) for the current
74 uint64_t content_size
;
77 * Current packet's total size (bits) for the current
83 * Discarded events (free running) counter for the
86 uint64_t discarded_events_counter
;
88 /* Sequence number (free running) of the current packet */
92 * Offset of the packet context structure within the
93 * current packet (bits).
95 uint64_t context_offset_bits
;
98 const bt_packet
*packet
;
101 /* Previous packet's state */
103 /* End default clock snapshot (`UINT64_C(-1)` if not set) */
106 /* Discarded events (free running) counter */
107 uint64_t discarded_events_counter
;
109 /* Sequence number (free running) */
113 /* State to handle discarded events */
116 * True if we're in the time range given by a previously
117 * received discarded events message. In this case,
118 * `beginning_cs` and `end_cs` below contain the
119 * beginning and end clock snapshots for this range.
121 * This is used to validate that, when receiving a
122 * packet end message, the current discarded events time
123 * range matches what's expected for CTF 1.8, that is:
125 * * Its beginning time is the previous packet's end
126 * time (or the current packet's beginning time if
127 * this is the first packet).
129 * * Its end time is the current packet's end time.
134 * Beginning and end times of the time range given by a
135 * previously received discarded events message.
137 uint64_t beginning_cs
;
139 } discarded_events_state
;
141 /* State to handle discarded packets */
144 * True if we're in the time range given by a previously
145 * received discarded packets message. In this case,
146 * `beginning_cs` and `end_cs` below contain the
147 * beginning and end clock snapshots for this range.
149 * This is used to validate that, when receiving a
150 * packet beginning message, the current discarded
151 * packets time range matches what's expected for CTF
154 * * Its beginning time is the previous packet's end
157 * * Its end time is the current packet's beginning
163 * Beginning and end times of the time range given by a
164 * previously received discarded packets message.
166 uint64_t beginning_cs
;
168 } discarded_packets_state
;
172 struct fs_sink_stream
*fs_sink_stream_create(struct fs_sink_trace
*trace
,
173 const bt_stream
*ir_stream
);
176 void fs_sink_stream_destroy(struct fs_sink_stream
*stream
);
179 int fs_sink_stream_write_event(struct fs_sink_stream
*stream
,
180 const bt_clock_snapshot
*cs
, const bt_event
*event
,
181 struct fs_sink_ctf_event_class
*ec
);
184 int fs_sink_stream_open_packet(struct fs_sink_stream
*stream
,
185 const bt_clock_snapshot
*cs
, const bt_packet
*packet
);
188 int fs_sink_stream_close_packet(struct fs_sink_stream
*stream
,
189 const bt_clock_snapshot
*cs
);
191 #endif /* BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_STREAM_H */
This page took 0.03346 seconds and 5 git commands to generate.