Add files via upload
authorFrançois Grondin <Francois.Grondin2@USherbrooke.ca>
Mon, 3 Jul 2017 19:20:42 +0000 (15:20 -0400)
committerGitHub <noreply@github.com>
Mon, 3 Jul 2017 19:20:42 +0000 (15:20 -0400)
src/sink/snk_hops.c [new file with mode: 0644]
src/sink/snk_hops.h [new file with mode: 0644]
src/sink/snk_pots.c [new file with mode: 0644]
src/sink/snk_pots.h [new file with mode: 0644]
src/sink/snk_spectra.c [new file with mode: 0644]
src/sink/snk_spectra.h [new file with mode: 0644]
src/sink/snk_tracks.c [new file with mode: 0644]
src/sink/snk_tracks.h [new file with mode: 0644]

diff --git a/src/sink/snk_hops.c b/src/sink/snk_hops.c
new file mode 100644 (file)
index 0000000..6b05f74
--- /dev/null
@@ -0,0 +1,260 @@
+    
+    #include "snk_hops.h"
+
+    snk_hops_obj * snk_hops_construct(const snk_hops_cfg * snk_hops_config, const msg_hops_cfg * msg_hops_config) {
+
+        snk_hops_obj * obj;
+
+        obj = (snk_hops_obj *) malloc(sizeof(snk_hops_obj));
+
+        obj->timeStamp = 0;
+
+        obj->hopSize = msg_hops_config->hopSize;
+        obj->nChannels = msg_hops_config->nChannels;
+        obj->fS = snk_hops_config->fS;
+        
+        obj->format = format_clone(snk_hops_config->format);
+        obj->interface = interface_clone(snk_hops_config->interface);
+
+        memset(obj->bytes, 0x00, 4 * sizeof(char));
+
+        obj->in = (msg_hops_obj *) NULL;
+
+        return obj;
+
+    }
+
+    void snk_hops_destroy(snk_hops_obj * obj) {
+
+        format_destroy(obj->format);
+        interface_destroy(obj->interface);
+
+        free((void *) obj);
+
+    }
+
+    void snk_hops_connect(snk_hops_obj * obj, msg_hops_obj * in) {
+
+        obj->in = in;
+
+    }
+
+    void snk_hops_disconnect(snk_hops_obj * obj) {
+
+        obj->in = (msg_hops_obj *) NULL;
+
+    }
+
+    int snk_hops_open(snk_hops_obj * obj) {
+
+        switch(obj->interface->type) {
+
+            case interface_file:
+
+                obj->fp = fopen(obj->interface->fileName, "wb");
+
+            break;
+
+            case interface_socket:
+
+                printf("Not implemented yet.\n");
+                exit(EXIT_FAILURE);
+
+            break;
+
+            case interface_soundcard:
+
+                printf("Not implemented yet.\n");
+                exit(EXIT_FAILURE);
+
+            break;
+
+            default:
+
+                printf("Invalid interface type.\n");
+                exit(EXIT_FAILURE);
+
+            break;           
+
+        }
+
+    }
+
+    int snk_hops_close(snk_hops_obj * obj) {
+
+        switch(obj->interface->type) {
+
+            case interface_file:
+
+                fclose(obj->fp);
+
+            break;
+
+            case interface_socket:
+
+                printf("Not implemented yet.\n");
+                exit(EXIT_FAILURE);
+
+            break;
+
+            case interface_soundcard:
+
+                printf("Not implemented yet.\n");
+                exit(EXIT_FAILURE);
+
+            break;
+
+            default:
+
+                printf("Invalid interface type.\n");
+                exit(EXIT_FAILURE);
+
+            break;
+
+        }
+
+    }
+
+    int snk_hops_process(snk_hops_obj * obj) {
+
+        int rtnValue;
+
+        switch(obj->interface->type) {
+
+            case interface_file:
+
+                rtnValue = snk_hops_process_file(obj);
+
+            break;
+
+            case interface_socket:
+
+                rtnValue = snk_hops_process_socket(obj);
+
+            break;
+
+            case interface_soundcard:
+
+                rtnValue = snk_hops_process_soundcard(obj);
+
+            break;
+
+            default:
+
+                printf("Invalid interface type.\n");
+                exit(EXIT_FAILURE);
+
+            break;
+
+        }
+
+        return rtnValue;
+
+    }
+
+    int snk_hops_process_file(snk_hops_obj * obj) {
+
+        unsigned int iSample;
+        unsigned int iChannel;
+        signed char sampleChar;
+        signed short sampleShort;
+        signed int sampleInt;
+        float sample;
+        int rtnValue;
+
+        if (obj->in->timeStamp != 0) {
+
+            for (iSample = 0; iSample < obj->hopSize; iSample++) {
+                
+                for (iChannel = 0; iChannel < obj->nChannels; iChannel++) {
+
+                    sample = obj->in->hops->array[iChannel][iSample];
+
+                    switch (obj->format->type) {
+                        
+                        case format_bin08:
+
+                            pcm_normalized2signed08bits(sample, obj->bytes);
+                            fwrite(&(obj->bytes[3]), sizeof(char), 1, obj->fp);
+
+                        break;
+
+                        case format_bin16:
+
+                            pcm_normalized2signed16bits(sample, obj->bytes);
+                            fwrite(&(obj->bytes[2]), sizeof(char), 2, obj->fp);
+
+                        break;
+
+                        case format_bin24:
+
+                            pcm_normalized2signed24bits(sample, obj->bytes);
+                            fwrite(&(obj->bytes[1]), sizeof(char), 3, obj->fp);
+
+                        break;
+                        
+                        case format_bin32:
+                        
+                            pcm_normalized2signed32bits(sample, obj->bytes);
+                            fwrite(&(obj->bytes[0]), sizeof(char), 4, obj->fp);
+                        
+                        break;
+                    }
+
+                }
+
+            }
+
+            rtnValue = 0;
+
+        }
+        else {
+
+            rtnValue = -1;
+
+        }
+
+        return rtnValue;
+
+    }
+
+    int snk_hops_process_socket(snk_hops_obj * obj) {
+
+        printf("Not implemented\n");
+        exit(EXIT_FAILURE);
+
+    }
+
+    int snk_hops_process_soundcard(snk_hops_obj * obj) {
+
+        printf("Not implemented\n");
+        exit(EXIT_FAILURE);
+
+    }
+
+    snk_hops_cfg * snk_hops_cfg_construct(void) {
+
+        snk_hops_cfg * cfg;
+
+        cfg = (snk_hops_cfg *) malloc(sizeof(snk_hops_cfg));
+
+        cfg->fS = 0;
+        cfg->format = (format_obj *) NULL;
+        cfg->interface = (interface_obj *) NULL;
+
+        return cfg;
+
+    }
+
+    void snk_hops_cfg_destroy(snk_hops_cfg * snk_hops_config) {
+
+        if (snk_hops_config->format != NULL) {
+            format_destroy(snk_hops_config->format);
+        }
+        if (snk_hops_config->interface != NULL) {
+            interface_destroy(snk_hops_config->interface);
+        }
+
+        free((void *) snk_hops_config);
+
+    }
\ No newline at end of file
diff --git a/src/sink/snk_hops.h b/src/sink/snk_hops.h
new file mode 100644 (file)
index 0000000..1e8eded
--- /dev/null
@@ -0,0 +1,64 @@
+#ifndef __ODAS_SINK_HOPS
+#define __ODAS_SINK_HOPS
+
+    #include <stdlib.h>
+    #include <stdio.h>
+    #include <string.h>
+
+    #include "../general/format.h"
+    #include "../general/interface.h"
+    #include "../message/msg_hops.h"
+    #include "../utils/pcm.h"
+
+    typedef struct snk_hops_obj {
+
+        unsigned long long timeStamp;
+
+        unsigned int hopSize;
+        unsigned int nChannels;
+        unsigned int fS;
+
+        format_obj * format;
+        interface_obj * interface;
+
+        FILE * fp;
+
+        char bytes[4];
+
+        msg_hops_obj * in;
+
+    } snk_hops_obj;
+
+    typedef struct snk_hops_cfg {
+
+        unsigned int fS;
+        format_obj * format;
+        interface_obj * interface;
+
+    } snk_hops_cfg;
+
+    snk_hops_obj * snk_hops_construct(const snk_hops_cfg * snk_hops_config, const msg_hops_cfg * msg_hops_config);
+
+    void snk_hops_destroy(snk_hops_obj * obj);
+
+    void snk_hops_connect(snk_hops_obj * obj, msg_hops_obj * in);
+
+    void snk_hops_disconnect(snk_hops_obj * obj);
+
+    int snk_hops_open(snk_hops_obj * obj);
+
+    int snk_hops_close(snk_hops_obj * obj);
+
+    int snk_hops_process(snk_hops_obj * obj);
+
+    int snk_hops_process_file(snk_hops_obj * obj);
+
+    int snk_hops_process_socket(snk_hops_obj * obj);
+
+    int snk_hops_process_soundcard(snk_hops_obj * obj);
+
+    snk_hops_cfg * snk_hops_cfg_construct(void);
+
+    void snk_hops_cfg_destroy(snk_hops_cfg * snk_hops_config);
+
+#endif
\ No newline at end of file
diff --git a/src/sink/snk_pots.c b/src/sink/snk_pots.c
new file mode 100644 (file)
index 0000000..caa1a98
--- /dev/null
@@ -0,0 +1,199 @@
+    
+    #include "snk_pots.h"
+
+    snk_pots_obj * snk_pots_construct(const snk_pots_cfg * snk_pots_config, const msg_pots_cfg * msg_pots_config) {
+
+        snk_pots_obj * obj;
+
+        obj = (snk_pots_obj *) malloc(sizeof(snk_pots_obj));
+
+        obj->timeStamp = 0;
+
+        obj->nPots = msg_pots_config->nPots;
+        obj->fS = snk_pots_config->fS;
+        
+        obj->format = format_clone(snk_pots_config->format);
+        obj->interface = interface_clone(snk_pots_config->interface);
+
+        obj->in = (msg_pots_obj *) NULL;
+
+        return obj;
+
+    }
+
+    void snk_pots_destroy(snk_pots_obj * obj) {
+
+        format_destroy(obj->format);
+        interface_destroy(obj->interface);
+
+        free((void *) obj);
+
+    }
+
+    void snk_pots_connect(snk_pots_obj * obj, msg_pots_obj * in) {
+
+        obj->in = in;
+
+    }
+
+    void snk_pots_disconnect(snk_pots_obj * obj) {
+
+        obj->in = (msg_pots_obj *) NULL;
+
+    }
+
+    int snk_pots_open(snk_pots_obj * obj) {
+
+        switch(obj->interface->type) {
+
+            case interface_file:
+
+                obj->fp = fopen(obj->interface->fileName, "wb");
+
+            break;
+
+            case interface_socket:
+
+                printf("Not implemented yet.\n");
+                exit(EXIT_FAILURE);
+
+            break;
+
+            default:
+
+                printf("Invalid interface type.\n");
+                exit(EXIT_FAILURE);
+
+            break;           
+
+        }
+
+    }
+
+    int snk_pots_close(snk_pots_obj * obj) {
+
+        switch(obj->interface->type) {
+
+            case interface_file:
+
+                fclose(obj->fp);
+
+            break;
+
+            case interface_socket:
+
+                printf("Not implemented yet.\n");
+                exit(EXIT_FAILURE);
+
+            break;
+
+            default:
+
+                printf("Invalid interface type.\n");
+                exit(EXIT_FAILURE);
+
+            break;
+
+        }
+
+    }
+
+    int snk_pots_process(snk_pots_obj * obj) {
+
+        int rtnValue;
+
+        switch(obj->interface->type) {
+
+            case interface_file:
+
+                rtnValue = snk_pots_process_file(obj);
+
+            break;
+
+            case interface_socket:
+
+                rtnValue = snk_pots_process_socket(obj);
+
+            break;
+
+            default:
+
+                printf("Invalid interface type.\n");
+                exit(EXIT_FAILURE);
+
+            break;
+
+        }
+
+        return rtnValue;
+
+    }
+
+    int snk_pots_process_file(snk_pots_obj * obj) {
+
+        int rtnValue;
+        //unsigned int iPot;
+
+        if (obj->in->timeStamp != 0) {
+
+            switch(obj->format->type) {
+
+                case format_float:
+
+                    fwrite(obj->in->pots->array, sizeof(float), 4 * obj->in->pots->nPots, obj->fp);
+
+                    /*for (iPot = 0; iPot < obj->in->pots->nPots; iPot++) {
+                        printf("(%f,%f,%f)\n",obj->in->pots->array[iPot*4+0],obj->in->pots->array[iPot*4+1],obj->in->pots->array[iPot*4+2]);
+                    }
+                    printf("\n");*/
+
+                break;
+
+            }
+
+            rtnValue = 0;
+
+        }
+        else {
+
+            rtnValue = -1;
+
+        }
+
+        return rtnValue;
+
+    }
+
+    int snk_pots_process_socket(snk_pots_obj * obj) {
+
+        printf("Not implemented\n");
+        exit(EXIT_FAILURE);
+
+    }
+
+    snk_pots_cfg * snk_pots_cfg_construct(void) {
+
+        snk_pots_cfg * cfg;
+
+        cfg = (snk_pots_cfg *) malloc(sizeof(snk_pots_cfg));
+
+        cfg->fS = 0;
+        cfg->format = (format_obj *) NULL;
+        cfg->interface = (interface_obj *) NULL;
+
+        return cfg;
+
+    }
+
+    void snk_pots_cfg_destroy(snk_pots_cfg * snk_pots_config) {
+
+        if (snk_pots_config->format != NULL) {
+            format_destroy(snk_pots_config->format);
+        }
+        if (snk_pots_config->interface != NULL) {
+            interface_destroy(snk_pots_config->interface);
+        }
+
+        free((void *) snk_pots_config);
+
+    }
\ No newline at end of file
diff --git a/src/sink/snk_pots.h b/src/sink/snk_pots.h
new file mode 100644 (file)
index 0000000..0582ffd
--- /dev/null
@@ -0,0 +1,58 @@
+#ifndef __ODAS_SINK_POTS
+#define __ODAS_SINK_POTS
+
+    #include <stdlib.h>
+    #include <stdio.h>
+    #include <string.h>
+
+    #include "../general/format.h"
+    #include "../general/interface.h"
+    #include "../message/msg_pots.h"
+
+    typedef struct snk_pots_obj {
+
+        unsigned long long timeStamp;
+
+        unsigned int nPots;
+        unsigned int fS;
+
+        format_obj * format;
+        interface_obj * interface;
+
+        FILE * fp;
+
+        msg_pots_obj * in;
+
+    } snk_pots_obj;
+
+    typedef struct snk_pots_cfg {
+
+        unsigned int fS;
+        format_obj * format;
+        interface_obj * interface;
+
+    } snk_pots_cfg;
+
+    snk_pots_obj * snk_pots_construct(const snk_pots_cfg * snk_pots_config, const msg_pots_cfg * msg_pots_config);
+
+    void snk_pots_destroy(snk_pots_obj * obj);
+
+    void snk_pots_connect(snk_pots_obj * obj, msg_pots_obj * in);
+
+    void snk_pots_disconnect(snk_pots_obj * obj);
+
+    int snk_pots_open(snk_pots_obj * obj);
+
+    int snk_pots_close(snk_pots_obj * obj);
+
+    int snk_pots_process(snk_pots_obj * obj);
+
+    int snk_pots_process_file(snk_pots_obj * obj);
+
+    int snk_pots_process_socket(snk_pots_obj * obj);
+
+    snk_pots_cfg * snk_pots_cfg_construct(void);
+
+    void snk_pots_cfg_destroy(snk_pots_cfg * snk_pots_config);
+
+#endif
\ No newline at end of file
diff --git a/src/sink/snk_spectra.c b/src/sink/snk_spectra.c
new file mode 100644 (file)
index 0000000..dfad190
--- /dev/null
@@ -0,0 +1,208 @@
+    
+    #include "snk_spectra.h"
+
+    snk_spectra_obj * snk_spectra_construct(const snk_spectra_cfg * snk_spectra_config, const msg_spectra_cfg * msg_spectra_config) {
+
+        snk_spectra_obj * obj;
+
+        obj = (snk_spectra_obj *) malloc(sizeof(snk_spectra_obj));
+
+        obj->halfFrameSize = msg_spectra_config->halfFrameSize;
+        obj->nChannels = msg_spectra_config->nChannels;
+        obj->fS = msg_spectra_config->fS;
+        
+        obj->format = format_clone(snk_spectra_config->format);
+        obj->interface = interface_clone(snk_spectra_config->interface);
+
+        obj->in = (msg_spectra_obj *) NULL;
+
+        return obj;
+
+    }
+
+    void snk_spectra_destroy(snk_spectra_obj * obj) {
+
+        format_destroy(obj->format);
+        interface_destroy(obj->interface);
+
+        free((void *) obj);
+
+    }
+
+    void snk_spectra_connect(snk_spectra_obj * obj, msg_spectra_obj * in) {
+
+        obj->in = in;
+
+    }
+
+    void snk_spectra_disconnect(snk_spectra_obj * obj) {
+
+        obj->in = (msg_spectra_obj *) NULL;
+
+    }
+
+    int snk_spectra_open(snk_spectra_obj * obj) {
+
+        switch(obj->interface->type) {
+
+            case interface_file:
+
+                obj->fp = fopen(obj->interface->fileName, "wb");
+
+            break;
+
+            case interface_socket:
+
+                printf("Not implemented yet.\n");
+                exit(EXIT_FAILURE);
+
+            break;
+
+            default:
+
+                printf("Invalid interface type.\n");
+                exit(EXIT_FAILURE);
+
+            break;           
+
+        }
+
+    }
+
+    int snk_spectra_close(snk_spectra_obj * obj) {
+
+        switch(obj->interface->type) {
+
+            case interface_file:
+
+                fclose(obj->fp);
+
+            break;
+
+            case interface_socket:
+
+                printf("Not implemented yet.\n");
+                exit(EXIT_FAILURE);
+
+            break;
+
+            default:
+
+                printf("Invalid interface type.\n");
+                exit(EXIT_FAILURE);
+
+            break;
+
+        }
+
+    }
+
+    int snk_spectra_process(snk_spectra_obj * obj) {
+
+        int rtnValue;
+
+        switch(obj->interface->type) {
+
+            case interface_file:
+
+                rtnValue = snk_spectra_process_file(obj);
+
+            break;
+
+            case interface_socket:
+
+                rtnValue = snk_spectra_process_socket(obj);
+
+            break;
+
+            default:
+
+                printf("Invalid interface type.\n");
+                exit(EXIT_FAILURE);
+
+            break;
+
+        }
+
+        return rtnValue;
+
+    }
+
+    int snk_spectra_process_file(snk_spectra_obj * obj) {
+
+        unsigned int iSample;
+        unsigned int iChannel;
+        float sampleReal;
+        float sampleImag;
+        int rtnValue;
+
+        if (obj->in->timeStamp != 0) {
+
+            for (iSample = 0; iSample < obj->halfFrameSize; iSample++) {
+                
+                for (iChannel = 0; iChannel < obj->nChannels; iChannel++) {
+
+                    sampleReal = obj->in->freqs->array[iChannel][iSample*2+0];
+                    sampleImag = obj->in->freqs->array[iChannel][iSample*2+1];
+
+                    switch (obj->format->type) {
+                        
+                        case format_float:
+
+                            fwrite(&sampleReal, sizeof(float), 1, obj->fp);
+                            fwrite(&sampleImag, sizeof(float), 1, obj->fp);
+
+                        break;
+
+                    }
+
+                }
+
+            }
+
+            rtnValue = 0;
+
+        }
+        else {
+
+            rtnValue = -1;
+
+        }
+
+        return rtnValue;
+
+    }
+
+    int snk_spectra_process_socket(snk_spectra_obj * obj) {
+
+        printf("Not implemented\n");
+        exit(EXIT_FAILURE);
+
+    }
+
+    snk_spectra_cfg * snk_spectra_cfg_construct(void) {
+
+        snk_spectra_cfg * cfg;
+
+        cfg = (snk_spectra_cfg *) malloc(sizeof(snk_spectra_cfg));
+
+        cfg->fS = 0;
+        cfg->format = (format_obj *) NULL;
+        cfg->interface = (interface_obj *) NULL;
+
+        return cfg;
+
+    }
+
+    void snk_spectra_cfg_destroy(snk_spectra_cfg * snk_spectra_config) {
+
+        if (snk_spectra_config->format != NULL) {
+            format_destroy(snk_spectra_config->format);
+        }
+        if (snk_spectra_config->interface != NULL) {
+            interface_destroy(snk_spectra_config->interface);
+        }
+
+        free((void *) snk_spectra_config);
+
+    }
\ No newline at end of file
diff --git a/src/sink/snk_spectra.h b/src/sink/snk_spectra.h
new file mode 100644 (file)
index 0000000..2190b83
--- /dev/null
@@ -0,0 +1,59 @@
+#ifndef __ODAS_SINK_SPECTRA
+#define __ODAS_SINK_SPECTRA
+
+    #include <stdlib.h>
+    #include <stdio.h>
+    #include <string.h>
+
+    #include "../general/format.h"
+    #include "../general/interface.h"
+    #include "../message/msg_spectra.h"
+
+    typedef struct snk_spectra_obj {
+
+        unsigned long long timeStamp;
+
+        unsigned int halfFrameSize;
+        unsigned int nChannels;
+        unsigned int fS;
+
+        format_obj * format;
+        interface_obj * interface;
+
+        FILE * fp;
+
+        msg_spectra_obj * in;
+
+    } snk_spectra_obj;
+
+    typedef struct snk_spectra_cfg {
+
+        unsigned int fS;
+        format_obj * format;
+        interface_obj * interface;
+
+    } snk_spectra_cfg;
+
+    snk_spectra_obj * snk_spectra_construct(const snk_spectra_cfg * snk_spectra_config, const msg_spectra_cfg * msg_spectra_config);
+
+    void snk_spectra_destroy(snk_spectra_obj * obj);
+
+    void snk_spectra_connect(snk_spectra_obj * obj, msg_spectra_obj * in);
+
+    void snk_spectra_disconnect(snk_spectra_obj * obj);
+
+    int snk_spectra_open(snk_spectra_obj * obj);
+
+    int snk_spectra_close(snk_spectra_obj * obj);
+
+    int snk_spectra_process(snk_spectra_obj * obj);
+
+    int snk_spectra_process_file(snk_spectra_obj * obj);
+
+    int snk_spectra_process_socket(snk_spectra_obj * obj);
+
+    snk_spectra_cfg * snk_spectra_cfg_construct(void);
+
+    void snk_spectra_cfg_destroy(snk_spectra_cfg * snk_spectra_config);
+
+#endif
\ No newline at end of file
diff --git a/src/sink/snk_tracks.c b/src/sink/snk_tracks.c
new file mode 100644 (file)
index 0000000..18c116c
--- /dev/null
@@ -0,0 +1,200 @@
+    
+    #include "snk_tracks.h"
+
+    snk_tracks_obj * snk_tracks_construct(const snk_tracks_cfg * snk_tracks_config, const msg_tracks_cfg * msg_tracks_config) {
+
+        snk_tracks_obj * obj;
+
+        obj = (snk_tracks_obj *) malloc(sizeof(snk_tracks_obj));
+
+        obj->timeStamp = 0;
+
+        obj->nTracks = msg_tracks_config->nTracks;
+        obj->fS = snk_tracks_config->fS;
+        
+        obj->format = format_clone(snk_tracks_config->format);
+        obj->interface = interface_clone(snk_tracks_config->interface);
+
+        obj->in = (msg_tracks_obj *) NULL;
+
+        return obj;
+
+    }
+
+    void snk_tracks_destroy(snk_tracks_obj * obj) {
+
+        format_destroy(obj->format);
+        interface_destroy(obj->interface);
+
+        free((void *) obj);
+
+    }
+
+    void snk_tracks_connect(snk_tracks_obj * obj, msg_tracks_obj * in) {
+
+        obj->in = in;
+
+    }
+
+    void snk_tracks_disconnect(snk_tracks_obj * obj) {
+
+        obj->in = (msg_tracks_obj *) NULL;
+
+    }
+
+    int snk_tracks_open(snk_tracks_obj * obj) {
+
+        switch(obj->interface->type) {
+
+            case interface_file:
+
+                obj->fp = fopen(obj->interface->fileName, "wb");
+
+            break;
+
+            case interface_socket:
+
+                printf("Not implemented yet.\n");
+                exit(EXIT_FAILURE);
+
+            break;
+
+            default:
+
+                printf("Invalid interface type.\n");
+                exit(EXIT_FAILURE);
+
+            break;           
+
+        }
+
+    }
+
+    int snk_tracks_close(snk_tracks_obj * obj) {
+
+        switch(obj->interface->type) {
+
+            case interface_file:
+
+                fclose(obj->fp);
+
+            break;
+
+            case interface_socket:
+
+                printf("Not implemented yet.\n");
+                exit(EXIT_FAILURE);
+
+            break;
+
+            default:
+
+                printf("Invalid interface type.\n");
+                exit(EXIT_FAILURE);
+
+            break;
+
+        }
+
+    }
+
+    int snk_tracks_process(snk_tracks_obj * obj) {
+
+        int rtnValue;
+
+        switch(obj->interface->type) {
+
+            case interface_file:
+
+                rtnValue = snk_tracks_process_file(obj);
+
+            break;
+
+            case interface_socket:
+
+                rtnValue = snk_tracks_process_socket(obj);
+
+            break;
+
+            default:
+
+                printf("Invalid interface type.\n");
+                exit(EXIT_FAILURE);
+
+            break;
+
+        }
+
+        return rtnValue;
+
+    }
+
+    int snk_tracks_process_file(snk_tracks_obj * obj) {
+
+        int rtnValue;
+        //unsigned int iTrack;
+
+        if (obj->in->timeStamp != 0) {
+
+            switch(obj->format->type) {
+
+                case format_float:
+
+                    fwrite(obj->in->tracks->ids, sizeof(unsigned long long), obj->in->tracks->nTracks, obj->fp);
+                    fwrite(obj->in->tracks->array, sizeof(float), 3 * obj->in->tracks->nTracks, obj->fp);
+
+                    /*for (iTrack = 0; iTrack < obj->nTracks; iTrack++) {
+                        printf("(%03llu): (%f,%f,%f)\n",obj->in->tracks->ids[iTrack],obj->in->tracks->array[iTrack*3+0],obj->in->tracks->array[iTrack*3+1],obj->in->tracks->array[iTrack*3+2]);
+                    }
+                    printf("\n");*/
+
+                break;
+
+            }
+
+            rtnValue = 0;
+
+        }
+        else {
+
+            rtnValue = -1;
+
+        }
+
+        return rtnValue;
+
+    }
+
+    int snk_tracks_process_socket(snk_tracks_obj * obj) {
+
+        printf("Not implemented\n");
+        exit(EXIT_FAILURE);
+
+    }
+
+    snk_tracks_cfg * snk_tracks_cfg_construct(void) {
+
+        snk_tracks_cfg * cfg;
+
+        cfg = (snk_tracks_cfg *) malloc(sizeof(snk_tracks_cfg));
+
+        cfg->fS = 0;
+        cfg->format = (format_obj *) NULL;
+        cfg->interface = (interface_obj *) NULL;
+
+        return cfg;
+
+    }
+
+    void snk_tracks_cfg_destroy(snk_tracks_cfg * snk_tracks_config) {
+
+        if (snk_tracks_config->format != NULL) {
+            format_destroy(snk_tracks_config->format);
+        }
+        if (snk_tracks_config->interface != NULL) {
+            interface_destroy(snk_tracks_config->interface);
+        }
+
+        free((void *) snk_tracks_config);
+
+    }
\ No newline at end of file
diff --git a/src/sink/snk_tracks.h b/src/sink/snk_tracks.h
new file mode 100644 (file)
index 0000000..6d9a907
--- /dev/null
@@ -0,0 +1,58 @@
+#ifndef __ODAS_SINK_TRACKS
+#define __ODAS_SINK_TRACKS
+
+    #include <stdlib.h>
+    #include <stdio.h>
+    #include <string.h>
+
+    #include "../general/format.h"
+    #include "../general/interface.h"
+    #include "../message/msg_tracks.h"
+
+    typedef struct snk_tracks_obj {
+
+        unsigned long long timeStamp;
+
+        unsigned int nTracks;
+        unsigned int fS;
+
+        format_obj * format;
+        interface_obj * interface;
+
+        FILE * fp;
+
+        msg_tracks_obj * in;
+
+    } snk_tracks_obj;
+
+    typedef struct snk_tracks_cfg {
+
+        unsigned int fS;
+        format_obj * format;
+        interface_obj * interface;
+
+    } snk_tracks_cfg;
+
+    snk_tracks_obj * snk_tracks_construct(const snk_tracks_cfg * snk_tracks_config, const msg_tracks_cfg * msg_tracks_config);
+
+    void snk_tracks_destroy(snk_tracks_obj * obj);
+
+    void snk_tracks_connect(snk_tracks_obj * obj, msg_tracks_obj * in);
+
+    void snk_tracks_disconnect(snk_tracks_obj * obj);
+
+    int snk_tracks_open(snk_tracks_obj * obj);
+
+    int snk_tracks_close(snk_tracks_obj * obj);
+
+    int snk_tracks_process(snk_tracks_obj * obj);
+
+    int snk_tracks_process_file(snk_tracks_obj * obj);
+
+    int snk_tracks_process_socket(snk_tracks_obj * obj);
+
+    snk_tracks_cfg * snk_tracks_cfg_construct(void);
+
+    void snk_tracks_cfg_destroy(snk_tracks_cfg * snk_tracks_config);
+
+#endif
\ No newline at end of file