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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. #include "util.h"
  22. // Supported values 0, 1 and 2. Higher value equals more spam in the log.
  23. #define DEBUG 0
  24. // 7 * 188
  25. #define FRAME_SIZE 1316
  26. // 64k should be enough for everybody
  27. #define THREAD_STACK_SIZE (64 * 1024)
  28. enum io_type {
  29. FILE_IO,
  30. NET_IO,
  31. WTF_IO
  32. };
  33. // 1.2MB = ~13Mbit/s
  34. #define PACKET_MAX_LENGTH (1316 * 1024)
  35. // Maximum packet fill time in ms
  36. #define PACKET_MAX_TIME 1000
  37. #define PREFIX_MAX_LENGTH 64
  38. // PREFIX-20130717_000900-1374008940.ts (PREFIX-YYYYMMDD_HHMMSS-0123456789.ts)
  39. #define OUTFILE_NAME_MAX (PREFIX_MAX_LENGTH + 128)
  40. #define NUM_PACKETS 16
  41. struct packet {
  42. int num;
  43. struct timeval ts; // packet start time
  44. int allocated; // set to true if the struct is dynamically allocated
  45. int in_use; // this packet is currently being used
  46. int data_len; // data length
  47. uint8_t data[PACKET_MAX_LENGTH]; // the data
  48. };
  49. struct io {
  50. int fd;
  51. enum io_type type;
  52. char *hostname;
  53. char *service;
  54. };
  55. struct ts {
  56. char *prefix;
  57. char *output_dir;
  58. int create_dirs;
  59. int rotate_secs;
  60. int ts_discont;
  61. int rtp_input;
  62. struct io input;
  63. pthread_attr_t thread_attr;
  64. pthread_t write_thread;
  65. struct packet packets[NUM_PACKETS];
  66. int packet_ptr;
  67. struct packet *current_packet;
  68. QUEUE *packet_queue;
  69. int output_fd;
  70. time_t output_startts;
  71. char output_dirname[OUTFILE_NAME_MAX];
  72. char output_filename[OUTFILE_NAME_MAX];
  73. char output_full_filename[OUTFILE_NAME_MAX];
  74. };
  75. // From tsdumper2.c
  76. struct packet *alloc_packet(struct ts *ts);
  77. void free_packet(struct packet *packet);
  78. // From process.c
  79. void *write_thread(void *_ts);
  80. void process_packets(struct ts *ts, uint8_t *ts_packet, ssize_t readen);
  81. // From udp.c
  82. int udp_connect_input(struct io *io);
  83. #endif