Set private port's user data on creation
[babeltrace.git] / plugins / ctf / fs / fs.c
index ea33974bde4045609ece5e481b483e538970cbe7..669d2daa906d259dd586be96dcd6963cc46da524 100644 (file)
@@ -43,6 +43,7 @@
 #include "metadata.h"
 #include "data-stream.h"
 #include "file.h"
+#include "../common/metadata/decoder.h"
 
 #define PRINT_ERR_STREAM       ctf_fs->error_fp
 #define PRINT_PREFIX           "ctf-fs"
@@ -85,13 +86,13 @@ enum bt_notification_iterator_status ctf_fs_iterator_init(
 
        ctf_fs = bt_private_component_get_user_data(priv_comp);
        if (!ctf_fs) {
-               ret = BT_NOTIFICATION_ITERATOR_STATUS_INVAL;
+               ret = BT_NOTIFICATION_ITERATOR_STATUS_INVALID;
                goto error;
        }
 
        port_data = bt_private_port_get_user_data(port);
        if (!port_data) {
-               ret = BT_NOTIFICATION_ITERATOR_STATUS_INVAL;
+               ret = BT_NOTIFICATION_ITERATOR_STATUS_INVALID;
                goto error;
        }
 
@@ -188,12 +189,6 @@ int create_one_port(struct ctf_fs_component *ctf_fs,
                port_name->str, stream_path);
 
        /* Create output port for this file */
-       port = bt_private_component_source_add_output_private_port(
-               ctf_fs->priv_comp, port_name->str);
-       if (!port) {
-               goto error;
-       }
-
        port_data = g_new0(struct ctf_fs_port_data, 1);
        if (!port_data) {
                goto error;
@@ -204,8 +199,9 @@ int create_one_port(struct ctf_fs_component *ctf_fs,
                goto error;
        }
 
-       ret = bt_private_port_set_user_data(port, port_data);
-       if (ret) {
+       port = bt_private_component_source_add_output_private_port(
+               ctf_fs->priv_comp, port_name->str, port_data);
+       if (!port) {
                goto error;
        }
 
@@ -346,8 +342,8 @@ int create_cc_prio_map(struct ctf_fs_component *ctf_fs)
 
        for (i = 0; i < count; i++) {
                struct bt_ctf_clock_class *clock_class =
-                       bt_ctf_trace_get_clock_class(ctf_fs->metadata->trace,
-                               i);
+                       bt_ctf_trace_get_clock_class_by_index(
+                               ctf_fs->metadata->trace, i);
 
                assert(clock_class);
                ret = bt_clock_class_priority_map_add_clock_class(
@@ -402,8 +398,49 @@ struct ctf_fs_component *ctf_fs_create(struct bt_private_component *priv_comp,
 
        ctf_fs->trace_path = g_string_new(path);
        if (!ctf_fs->trace_path) {
+               BT_PUT(value);
                goto error;
        }
+       bt_put(value);
+
+       value = bt_value_map_get(params, "offset-s");
+       if (value) {
+               int64_t offset;
+
+               if (!bt_value_is_integer(value)) {
+                       fprintf(stderr,
+                               "offset-s should be an integer\n");
+                       goto error;
+               }
+               ret = bt_value_integer_get(value, &offset);
+               if (ret != BT_VALUE_STATUS_OK) {
+                       fprintf(stderr,
+                               "Failed to get offset-s value\n");
+                       goto error;
+               }
+               ctf_fs->options.clock_offset = offset;
+               bt_put(value);
+       }
+
+       value = bt_value_map_get(params, "offset-ns");
+       if (value) {
+               int64_t offset;
+
+               if (!bt_value_is_integer(value)) {
+                       fprintf(stderr,
+                               "offset-ns should be an integer\n");
+                       goto error;
+               }
+               ret = bt_value_integer_get(value, &offset);
+               if (ret != BT_VALUE_STATUS_OK) {
+                       fprintf(stderr,
+                               "Failed to get offset-ns value\n");
+                       goto error;
+               }
+               ctf_fs->options.clock_offset_ns = offset;
+               bt_put(value);
+       }
+
        ctf_fs->error_fp = stderr;
        ctf_fs->page_size = (size_t) getpagesize();
 
@@ -434,7 +471,6 @@ error:
        ctf_fs_destroy_data(ctf_fs);
        ctf_fs = NULL;
 end:
-       BT_PUT(value);
        return ctf_fs;
 }
 
@@ -508,11 +544,12 @@ struct bt_value *ctf_fs_query(struct bt_component_class *comp_class,
                        goto error;
                }
 
-               is_packetized = ctf_metadata_is_packetized(metadata_fp, &bo);
+               is_packetized = ctf_metadata_decoder_is_packetized(metadata_fp,
+                       &bo);
 
                if (is_packetized) {
-                       ret = ctf_metadata_packetized_file_to_buf(NULL,
-                               metadata_fp, (uint8_t **) &metadata_text, bo);
+                       ret = ctf_metadata_decoder_packetized_file_stream_to_buf(
+                               metadata_fp, &metadata_text, bo);
                        if (ret) {
                                fprintf(stderr,
                                        "Cannot decode packetized metadata file\n");
This page took 0.0268040000000001 seconds and 4 git commands to generate.