Commit | Line | Data |
---|---|---|
46bdd3e0 PP |
1 | #ifndef BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_STREAM_H |
2 | #define BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_STREAM_H | |
3 | ||
4 | /* | |
5 | * Copyright 2019 Philippe Proulx <pproulx@efficios.com> | |
6 | * | |
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: | |
13 | * | |
14 | * The above copyright notice and this permission notice shall be included in | |
15 | * all copies or substantial portions of the Software. | |
16 | * | |
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 | |
23 | * SOFTWARE. | |
24 | */ | |
25 | ||
26 | #include <babeltrace/babeltrace-internal.h> | |
27 | #include <babeltrace/babeltrace.h> | |
28 | #include <babeltrace/ctfser-internal.h> | |
29 | #include <glib.h> | |
30 | #include <stdbool.h> | |
31 | #include <stdint.h> | |
32 | ||
33 | #include "fs-sink-ctf-meta.h" | |
34 | ||
35 | struct fs_sink_trace; | |
36 | ||
37 | struct fs_sink_stream { | |
38 | struct fs_sink_trace *trace; | |
39 | struct bt_ctfser ctfser; | |
40 | ||
41 | /* Stream's file name */ | |
42 | GString *file_name; | |
43 | ||
44 | /* Weak */ | |
45 | const bt_stream *ir_stream; | |
46 | ||
47 | struct fs_sink_ctf_stream_class *sc; | |
48 | ||
49 | struct { | |
50 | bool is_open; | |
51 | uint64_t beginning_cs; | |
52 | uint64_t end_cs; | |
53 | uint64_t content_size; | |
54 | uint64_t total_size; | |
55 | uint64_t discarded_events_counter; | |
56 | uint64_t seq_num; | |
57 | uint64_t context_offset_bits; | |
58 | ||
59 | /* Owned by this */ | |
60 | const bt_packet *packet; | |
61 | } packet_state; | |
62 | ||
63 | struct { | |
64 | uint64_t end_cs; | |
65 | uint64_t discarded_events_counter; | |
66 | uint64_t seq_num; | |
67 | } prev_packet_state; | |
68 | ||
69 | struct { | |
70 | bool in_range; | |
71 | uint64_t beginning_cs; | |
72 | uint64_t end_cs; | |
73 | } discarded_events_state; | |
74 | ||
75 | struct { | |
76 | bool in_range; | |
77 | uint64_t beginning_cs; | |
78 | uint64_t end_cs; | |
79 | } discarded_packets_state; | |
80 | ||
81 | bool in_discarded_events_range; | |
82 | }; | |
83 | ||
84 | BT_HIDDEN | |
85 | struct fs_sink_stream *fs_sink_stream_create(struct fs_sink_trace *trace, | |
86 | const bt_stream *ir_stream); | |
87 | ||
88 | BT_HIDDEN | |
89 | void fs_sink_stream_destroy(struct fs_sink_stream *stream); | |
90 | ||
91 | BT_HIDDEN | |
92 | int fs_sink_stream_write_event(struct fs_sink_stream *stream, | |
93 | const bt_clock_snapshot *cs, const bt_event *event, | |
94 | struct fs_sink_ctf_event_class *ec); | |
95 | ||
96 | BT_HIDDEN | |
97 | int fs_sink_stream_open_packet(struct fs_sink_stream *stream, | |
98 | const bt_clock_snapshot *cs, const bt_packet *packet); | |
99 | ||
100 | BT_HIDDEN | |
101 | int fs_sink_stream_close_packet(struct fs_sink_stream *stream, | |
102 | const bt_clock_snapshot *cs); | |
103 | ||
104 | #endif /* BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_STREAM_H */ |