tsdumper2 reads incoming mpeg transport stream over UDP/RTP and then records it to disk. The files names are generated based on preconfigured time interval. https://georgi.unixsol.org/programs/tsdumper2/
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.

tsdumper2.h 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Data definitions
  3. * Copyright (C) 2013 Unix Solutions Ltd.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2
  7. * as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License (COPYING file) for more details.
  13. *
  14. */
  15. #ifndef DATA_H
  16. #define DATA_H
  17. #include <pthread.h>
  18. #include <inttypes.h>
  19. #include <stdbool.h>
  20. #include "libfuncs/libfuncs.h"
  21. // Supported values 0, 1 and 2. Higher value equals more spam in the log.
  22. #define DEBUG 0
  23. // 7 * 188
  24. #define FRAME_SIZE 1316
  25. // 64k should be enough for everybody
  26. #define THREAD_STACK_SIZE (64 * 1024)
  27. enum io_type {
  28. UDP,
  29. RTP,
  30. };
  31. // 1.2MB = ~13Mbit/s
  32. #define PACKET_MAX_LENGTH (1316 * 1024)
  33. // Maximum packet fill time in ms
  34. #define PACKET_MAX_TIME 1000
  35. #define PREFIX_MAX_LENGTH 64
  36. // PREFIX-20130717_000900-1374008940.ts (PREFIX-YYYYMMDD_HHMMSS-0123456789.ts)
  37. #define OUTFILE_NAME_MAX (PREFIX_MAX_LENGTH + 128)
  38. #define NUM_PACKETS 16
  39. struct packet {
  40. int num;
  41. struct timeval ts; // packet start time
  42. int allocated; // set to true if the struct is dynamically allocated
  43. int in_use; // this packet is currently being used
  44. int data_len; // data length
  45. uint8_t data[PACKET_MAX_LENGTH]; // the data
  46. };
  47. struct io {
  48. int fd;
  49. enum io_type type;
  50. char *hostname;
  51. char *service;
  52. };
  53. struct ts {
  54. char *prefix;
  55. char *output_dir;
  56. int create_dirs;
  57. int rotate_secs;
  58. int ts_discont;
  59. struct io input;
  60. pthread_attr_t thread_attr;
  61. pthread_t write_thread;
  62. struct packet packets[NUM_PACKETS];
  63. int packet_ptr;
  64. struct packet *current_packet;
  65. QUEUE *packet_queue;
  66. int output_fd;
  67. time_t output_startts;
  68. char output_dirname[OUTFILE_NAME_MAX];
  69. char output_filename[OUTFILE_NAME_MAX];
  70. char output_full_filename[OUTFILE_NAME_MAX];
  71. };
  72. #include "util.h"
  73. // From tsdumper2.c
  74. struct packet *alloc_packet(struct ts *ts);
  75. void free_packet(struct packet *packet);
  76. // From process.c
  77. void *write_thread(void *_ts);
  78. void process_packets(struct ts *ts, uint8_t *ts_packet, ssize_t readen);
  79. // From udp.c
  80. int udp_connect_input(struct io *io);
  81. #endif