test_stc.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* test_stc.c - Test for DMX_GET_STC.
  2. * usage: DEMUX=/dev/dvb/adapterX/demuxX test_stc
  3. *
  4. * Copyright (C) 2003 convergence GmbH
  5. * Johannes Stezenbach <js@convergence.de>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public License
  9. * as published by the Free Software Foundation; either version 2.1
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. */
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. #include <string.h>
  24. #include <unistd.h>
  25. #include <sys/types.h>
  26. #include <sys/stat.h>
  27. #include <fcntl.h>
  28. #include <sys/ioctl.h>
  29. #include <errno.h>
  30. #include <linux/dvb/dmx.h>
  31. void usage(void)
  32. {
  33. fprintf(stderr, "usage: test_stc\n");
  34. fprintf(stderr, " The default demux device used can be changed\n");
  35. fprintf(stderr, " using the DEMUX environment variable;\n");
  36. fprintf(stderr, "\n");
  37. exit(1);
  38. }
  39. int main(int argc, char *argv[])
  40. {
  41. int dmxfd;
  42. char * dmxdev = "/dev/dvb/adapter0/demux0";
  43. struct dmx_stc stc;
  44. if (argc != 1 || argv[1])
  45. usage();
  46. if (getenv("DEMUX"))
  47. dmxdev = getenv("DEMUX");
  48. fprintf(stderr, "test_stc: using '%s'\n", dmxdev);
  49. if ((dmxfd = open(dmxdev, O_RDWR)) < 0) {
  50. perror("open");
  51. return 1;
  52. }
  53. stc.num = 0;
  54. if (ioctl(dmxfd, DMX_GET_STC, &stc) == -1) {
  55. perror("DMX_GET_STC");
  56. return 1;
  57. }
  58. printf("STC = %llu (%llu / %u)\n", stc.stc / stc.base, stc.stc, stc.base);
  59. close(dmxfd);
  60. return 0;
  61. }