]> rtime.felk.cvut.cz Git - frescor/streamer.git/commitdiff
Aquosa support
authorLuca Abeni <luca@nowhere.science.unitn.it>
Mon, 2 Feb 2009 08:25:17 +0000 (09:25 +0100)
committerLuca Abeni <luca@nowhere.science.unitn.it>
Mon, 2 Feb 2009 08:25:17 +0000 (09:25 +0100)
Makefile
rt_qosmgr.c [new file with mode: 0644]

index a5ab46931fc1004397562fe61c18f869cf91b74f..57ae86b83fa6a79dcde42ec471c7845a782cc206 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -10,7 +10,17 @@ LDLIBS = -lavdevice -lavformat -lavcodec -lavutil
 LDLIBS += -lm -lz
 CFLAGS += -g
 
-OBJS = input.o codec.o output.o rt.o
+OBJS = input.o codec.o output.o
+
+ifdef AQUOSA
+CPPFLAGS += -I$(AQUOSA)/include
+LDFLAGS += -L$(AQUOSA)/lib
+LDLIBS += -lqreslib -lqmgrlib -lrt
+OBJS += rt_qosmgr.o
+else
+OBJS += rt.o
+endif
+
 
 all: streamer
 
diff --git a/rt_qosmgr.c b/rt_qosmgr.c
new file mode 100644 (file)
index 0000000..ba2984f
--- /dev/null
@@ -0,0 +1,68 @@
+#include <stdio.h>
+#include <ffmpeg/avformat.h>
+
+#define QOS_DEBUG_LEVEL QOS_LEVEL_DEBUG
+#include <linux/aquosa/qos_debug.h>
+
+#include <aquosa/qmgr_lib.h>
+#include <aquosa/percpred_lib.h>
+#include <aquosa/stochdb_lib.h>
+
+#define SERV_PERIOD 10000lu    /* us */
+#define TASK_PERIOD 40000lu    /* us */
+#define SAMPLE_SZ 3
+#define DISCARDED 1    /* discard 1 out of 3 ==> percentile = 66.66% */
+
+static uint64_t start_time, start_time1;
+
+void rt_job_start(uint64_t t)
+{
+  static int started = 0;
+
+  if (! started) {
+    started = 1;
+    qos_log_debug("Initializing qmgr library\n");
+    qos_chk_ok_exit(qmgr_init());
+
+    qos_log_debug("Setting predictor\n");
+    /* Defaults to 3 samples and forgetting factor = 1 */
+    qos_chk_ok_exit(qmgr_set_predictor(QMGR_PRED_PERC));
+
+    qos_log_debug("Setting sample size to %d\n", SAMPLE_SZ);
+    /* Sets sample size */
+    qos_chk_ok_exit(percpred_set_sample_size(SAMPLE_SZ));
+
+    qos_log_debug("Setting discarded to %d\n", DISCARDED);
+    /* Sets discarded */
+    qos_chk_ok_exit(percpred_set_discarded(DISCARDED));
+
+    qos_log_debug("Setting controller\n");
+    /* Defaults to null target s.e. */
+    qos_chk_ok_exit(qmgr_set_controller(QMGR_CTRL_STOCHDB));
+
+    qos_log_debug("Setting controller parameters\n");
+    /* Assign task period and granularity */
+    qmgr_set_task_period(TASK_PERIOD);
+    qmgr_set_server_period(SERV_PERIOD);
+    qmgr_set_max_bandwidth(0.95);
+
+    qos_log_debug("Starting control loop");
+    qos_chk_ok_exit(qmgr_start());
+  }
+
+  qos_chk_ok_exit(qmgr_begin_cycle());
+  start_time = t;
+  start_time1 = av_gettime();
+}
+
+void rt_job_end(void)
+{
+  uint64_t t;
+  qres_time_t sched_err;
+
+  t = av_gettime();
+  qos_log_debug("%lu %lu %lu\t%lu %lu\n", start_time, start_time1, t, t - start_time, t - start_time1);
+
+  qmgr_end_cycle(&sched_err);
+  qos_log_debug("Ending job: " QRES_TIME_FMT "\n", sched_err);
+}