mptsd reads mpegts streams from udp/multicast or http and combines them into one multiple program stream that is suitable for outputting to DVB-C modulator. Tested with Dektec DTE-3114 Quad QAM Modulator and used in production in small DVB-C networks. https://georgi.unixsol.org/programs/mptsd/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sleep.c 968B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include <unistd.h>
  2. #include <string.h>
  3. #include <signal.h>
  4. #include <sys/time.h>
  5. #include <errno.h>
  6. #include <math.h>
  7. #include "libfuncs/log.h"
  8. #include "config.h"
  9. void * calibrate_sleep(void *_config) {
  10. struct timeval tv1, tv2;
  11. unsigned long diff = 0, loops = 0;
  12. CONFIG *conf = _config;
  13. if (!conf->quiet) {
  14. LOGf("\tCalibrating sleep timeout...\n");
  15. LOGf("\tRequest timeout : %ld us\n", conf->output_tmout);
  16. }
  17. do {
  18. gettimeofday(&tv1, NULL);
  19. usleep(1);
  20. gettimeofday(&tv2, NULL);
  21. diff += timeval_diff_usec(&tv1, &tv2) - 1;
  22. } while (loops++ != 3000);
  23. conf->usleep_overhead = diff / loops;
  24. conf->output_tmout -= conf->usleep_overhead;
  25. if (!conf->quiet) {
  26. LOGf("\tusleep(1) overhead: %ld us\n", conf->usleep_overhead);
  27. LOGf("\tOutput pkt tmout : %ld us\n", conf->output_tmout);
  28. }
  29. if (conf->output_tmout < 0) {
  30. LOGf("usleep overhead is to much!! Disabling output rate control.\n");
  31. conf->output_tmout = 0;
  32. }
  33. pthread_exit(0);
  34. }