aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils.h
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2014-04-25 11:19:11 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2014-04-25 11:19:11 +0200
commit8fadb4940c9fcbde6a00b2b78badfcb1269382ba (patch)
treeb15eae0f0d4a3178ec6bea825dfd2e50be649b8f /src/utils.h
parentf6ecc100eccc424bacfa877c136bc97a87c66eaf (diff)
downloadODR-AudioEnc-8fadb4940c9fcbde6a00b2b78badfcb1269382ba.tar.gz
ODR-AudioEnc-8fadb4940c9fcbde6a00b2b78badfcb1269382ba.tar.bz2
ODR-AudioEnc-8fadb4940c9fcbde6a00b2b78badfcb1269382ba.zip
Use new zmq message format version 1
Diffstat (limited to 'src/utils.h')
-rw-r--r--src/utils.h31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/utils.h b/src/utils.h
index c7ddc1e..aa8dc8a 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -2,6 +2,7 @@
#define UTILS_H_
#include <math.h>
+#include <stdint.h>
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
@@ -10,8 +11,36 @@
#define linear_to_dB(x) (log10(x) * 20)
-
+/* Calculate the little string containing a bargraph
+ * 'VU-meter' from the peak value measured
+ */
const char* level(int channel, int* peak);
+/* This defines the on-wire representation of a ZMQ message header.
+ *
+ * The data follows right after this header */
+struct zmq_frame_header_t
+{
+ uint16_t version; // we support version=1 now
+ uint16_t encoder; // see ZMQ_ENCODER_XYZ
+
+ /* length of the 'data' field */
+ uint32_t datasize;
+
+ /* Audio level, peak, linear PCM */
+ int16_t audiolevel_left;
+ int16_t audiolevel_right;
+
+ /* Data follows this header */
+} __attribute__ ((packed));
+
+#define ZMQ_ENCODER_FDK 1
+
+/* The expected frame size incl data of the given frame */
+#define ZMQ_FRAME_SIZE(f) (sizeof(zmq_frame_header_t) + f->datasize)
+
+#define ZMQ_FRAME_DATA(f) ( ((uint8_t*)f)+sizeof(zmq_frame_header_t) )
+
+
#endif