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.

pidref.c 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #include <stdlib.h>
  2. #include "libfuncs/log.h"
  3. #include "libtsfuncs/tsfuncs.h"
  4. #include "pidref.h"
  5. PIDREF *pidref_init(int num, uint16_t base_pid) {
  6. PIDREF *ref = calloc(1, sizeof(PIDREF));
  7. ref->num = num;
  8. ref->base_pid = base_pid;
  9. ref->entries = calloc(ref->num, sizeof(PIDREF_ENTRY));
  10. return ref;
  11. }
  12. void pidref_free(PIDREF **pref) {
  13. PIDREF *ref = *pref;
  14. if (!ref)
  15. return;
  16. FREE(ref->entries);
  17. FREE(*pref);
  18. }
  19. int pidref_add(PIDREF *ref, uint16_t org_pid, uint16_t new_pid) {
  20. int i;
  21. if (!org_pid)
  22. return 0;
  23. for (i=0;i<ref->num;i++) {
  24. PIDREF_ENTRY *entry = &ref->entries[i];
  25. if (!entry->org_pid) {
  26. entry->org_pid = org_pid;
  27. entry->new_pid = new_pid;
  28. return 1;
  29. }
  30. }
  31. return 0;
  32. }
  33. int pidref_del(PIDREF *ref, uint16_t org_pid) {
  34. int i;
  35. if (!org_pid)
  36. return 0;
  37. for (i=0;i<ref->num;i++) {
  38. PIDREF_ENTRY *entry = &ref->entries[i];
  39. if (entry->org_pid == org_pid) {
  40. entry->org_pid = 0;
  41. entry->new_pid = 0;
  42. return 1;
  43. }
  44. }
  45. return 0;
  46. }
  47. uint16_t pidref_get_new_pid(PIDREF *ref, uint16_t org_pid) {
  48. int i;
  49. if (!org_pid)
  50. return 0;
  51. for (i=0;i<ref->num;i++) {
  52. PIDREF_ENTRY *entry = &ref->entries[i];
  53. if (entry->org_pid == org_pid) {
  54. return entry->new_pid;
  55. }
  56. }
  57. return 0;
  58. }
  59. int pidref_change_packet_pid(uint8_t *ts_packet, uint16_t packet_pid, PIDREF *ref) {
  60. uint16_t new_pid = pidref_get_new_pid(ref, packet_pid);
  61. if (new_pid) {
  62. ts_packet_set_pid(ts_packet, new_pid);
  63. return new_pid;
  64. }
  65. return 0;
  66. }
  67. void pidref_dump(PIDREF *ref) {
  68. int i;
  69. LOGf("pidref->base_pid = 0x%04x\n", ref->base_pid);
  70. LOGf("pidref->num = %d\n" , ref->num);
  71. LOG ("pidref->entries org_pid new_pid\n");
  72. for (i=0;i<ref->num;i++) {
  73. PIDREF_ENTRY *entry = &ref->entries[i];
  74. if (entry->org_pid)
  75. LOGf("pidref->entry[%02d] = 0x%04x 0x%04x\n", i, entry->org_pid, entry->new_pid);
  76. }
  77. }