+ bt_put(field_type);
+ return ret;
+}
+
+struct bt_ctf_field *bt_ctf_stream_get_packet_header(
+ struct bt_ctf_stream *stream)
+{
+ struct bt_ctf_field *packet_header = NULL;
+
+ if (!stream) {
+ goto end;
+ }
+
+ packet_header = stream->packet_header;
+ if (packet_header) {
+ bt_get(packet_header);
+ }
+end:
+ return packet_header;
+}
+
+int bt_ctf_stream_set_packet_header(struct bt_ctf_stream *stream,
+ struct bt_ctf_field *field)
+{
+ int ret = 0;
+ struct bt_ctf_field_type *field_type = NULL;
+
+ if (!stream || !field) {
+ ret = -1;
+ goto end;
+ }
+
+ field_type = bt_ctf_field_get_type(field);
+ if (field_type != stream->trace->packet_header_type) {
+ ret = -1;
+ goto end;
+ }
+
+ bt_get(field);
+ bt_put(stream->packet_header);
+ stream->packet_header = field;
+end:
+ bt_put(field_type);
+ return ret;
+}
+
+static
+int get_event_header_timestamp(struct bt_ctf_field *event_header, uint64_t *timestamp)
+{
+ int ret = 0;
+ struct bt_ctf_field *timestamp_field = NULL;
+ struct bt_ctf_field_type *timestamp_field_type = NULL;
+
+ timestamp_field = bt_ctf_field_structure_get_field(event_header,
+ "timestamp");
+ if (!timestamp_field) {
+ ret = -1;
+ goto end;
+ }
+
+ timestamp_field_type = bt_ctf_field_get_type(timestamp_field);
+ assert(timestamp_field_type);
+ if (bt_ctf_field_type_get_type_id(timestamp_field_type) !=
+ CTF_TYPE_INTEGER) {
+ ret = -1;
+ goto end;