dump-vdr.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. #include <stdio.h>
  2. #include "dump-vdr.h"
  3. #include <linux/dvb/frontend.h>
  4. static const char *inv_name [] = {
  5. "0",
  6. "1",
  7. "999"
  8. };
  9. static const char *fec_name [] = {
  10. "0",
  11. "12",
  12. "23",
  13. "34",
  14. "45",
  15. "56",
  16. "67",
  17. "78",
  18. "89",
  19. "999"
  20. };
  21. static const char *qam_name [] = {
  22. "0",
  23. "16",
  24. "32",
  25. "64",
  26. "128",
  27. "256",
  28. "999"
  29. };
  30. static const char *bw_name [] = {
  31. "8",
  32. "7",
  33. "6",
  34. "999"
  35. };
  36. static const char *mode_name [] = {
  37. "2",
  38. "8",
  39. "999"
  40. };
  41. static const char *guard_name [] = {
  42. "32",
  43. "16",
  44. "8",
  45. "4",
  46. "999"
  47. };
  48. static const char *hierarchy_name [] = {
  49. "0",
  50. "1",
  51. "2",
  52. "4",
  53. "999"
  54. };
  55. static const char *west_east_flag_name [] = {
  56. "W",
  57. "E"
  58. };
  59. void vdr_dump_dvb_parameters (FILE *f, fe_type_t type,
  60. struct dvb_frontend_parameters *p,
  61. char polarity, int orbital_pos, int we_flag)
  62. {
  63. switch (type) {
  64. case FE_QPSK:
  65. fprintf (f, "%i:", p->frequency / 1000);
  66. fprintf (f, "%c:", polarity);
  67. fprintf (f, "S%i.%i%s:", orbital_pos/10,
  68. orbital_pos % 10, west_east_flag_name[we_flag]);
  69. fprintf (f, "%i:", p->u.qpsk.symbol_rate / 1000);
  70. break;
  71. case FE_QAM:
  72. fprintf (f, "%i:", p->frequency / 1000000);
  73. fprintf (f, "M%s:C:", qam_name[p->u.qam.modulation]);
  74. fprintf (f, "%i:", p->u.qam.symbol_rate / 1000);
  75. break;
  76. case FE_OFDM:
  77. fprintf (f, "%i:", p->frequency / 1000);
  78. fprintf (f, "I%s", inv_name[p->inversion]);
  79. fprintf (f, "B%s", bw_name[p->u.ofdm.bandwidth]);
  80. fprintf (f, "C%s", fec_name[p->u.ofdm.code_rate_HP]);
  81. fprintf (f, "D%s", fec_name[p->u.ofdm.code_rate_LP]);
  82. fprintf (f, "M%s", qam_name[p->u.ofdm.constellation]);
  83. fprintf (f, "T%s", mode_name[p->u.ofdm.transmission_mode]);
  84. fprintf (f, "G%s", guard_name[p->u.ofdm.guard_interval]);
  85. fprintf (f, "Y%s", hierarchy_name[p->u.ofdm.hierarchy_information]);
  86. fprintf (f, ":T:27500:");
  87. break;
  88. case FE_ATSC:
  89. fprintf (f, "%i:", p->frequency / 1000);
  90. fprintf (f, "VDR does not support ATSC at this time");
  91. break;
  92. default:
  93. ;
  94. };
  95. }
  96. void vdr_dump_service_parameter_set (FILE *f,
  97. const char *service_name,
  98. const char *provider_name,
  99. fe_type_t type,
  100. struct dvb_frontend_parameters *p,
  101. char polarity,
  102. int video_pid,
  103. int pcr_pid,
  104. uint16_t *audio_pid,
  105. char audio_lang[][4],
  106. int audio_num,
  107. int teletext_pid,
  108. int scrambled,
  109. int ac3_pid,
  110. int service_id,
  111. int network_id,
  112. int transport_stream_id,
  113. int orbital_pos,
  114. int we_flag,
  115. int dump_provider,
  116. int ca_select,
  117. int vdr_version,
  118. int dump_channum,
  119. int channel_num)
  120. {
  121. int i;
  122. if (video_pid || audio_pid[0]) {
  123. if (vdr_version <= 2) {
  124. audio_lang = NULL;
  125. network_id = 0;
  126. transport_stream_id = 0;
  127. }
  128. if ((dump_channum == 1) && (channel_num > 0))
  129. fprintf(f, ":@%i\n", channel_num);
  130. if (vdr_version >= 3)
  131. fprintf (f, "%s;%s:", service_name, provider_name);
  132. else
  133. {
  134. if (dump_provider == 1)
  135. fprintf (f, "%s - ", provider_name);
  136. fprintf (f, "%s:", service_name);
  137. }
  138. vdr_dump_dvb_parameters (f, type, p, polarity, orbital_pos, we_flag);
  139. if ((pcr_pid != video_pid) && (video_pid > 0))
  140. fprintf (f, "%i+%i:", video_pid, pcr_pid);
  141. else
  142. fprintf (f, "%i:", video_pid);
  143. fprintf (f, "%i", audio_pid[0]);
  144. if (audio_lang && audio_lang[0][0])
  145. fprintf (f, "=%.4s", audio_lang[0]);
  146. for (i = 1; i < audio_num; i++)
  147. {
  148. fprintf (f, ",%i", audio_pid[i]);
  149. if (audio_lang && audio_lang[i][0])
  150. fprintf (f, "=%.4s", audio_lang[i]);
  151. }
  152. if (ac3_pid)
  153. {
  154. fprintf (f, ";%i", ac3_pid);
  155. if (audio_lang && audio_lang[0][0])
  156. fprintf (f, "=%.4s", audio_lang[0]);
  157. }
  158. if (scrambled == 1) {
  159. if (ca_select == -1)
  160. if (vdr_version <= 2)
  161. scrambled = 1;
  162. else
  163. scrambled = 0;
  164. else
  165. scrambled = ca_select;
  166. }
  167. fprintf (f, ":%d:%d:%d:%d:%d:0", teletext_pid, scrambled,
  168. service_id, network_id, transport_stream_id);
  169. fprintf (f, "\n");
  170. }
  171. }