tsdecrypt reads and decrypts CSA encrypted incoming mpeg transport stream over UDP/RTP using code words obtained from OSCAM or similar CAM server. tsdecrypt communicates with CAM server using cs378x (camd35 over tcp) protocol or newcamd protocol. https://georgi.unixsol.org/programs/tsdecrypt/
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.

csa.c 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * CSA functions
  3. * Copyright (C) 2011-2012 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 for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  17. */
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21. #include <inttypes.h>
  22. #include <sys/time.h>
  23. #include <dvbcsa/dvbcsa.h>
  24. #include "libfuncs/libfuncs.h"
  25. /* The following routine is taken from benchbitslice in libdvbcsa */
  26. void csa_benchmark(void) {
  27. struct timeval t0, t1;
  28. struct dvbcsa_bs_key_s *key = dvbcsa_bs_key_alloc();
  29. unsigned int n, i, npackets = 0;
  30. unsigned int batch_size = dvbcsa_bs_batch_size();
  31. uint8_t data[batch_size + 1][188];
  32. struct dvbcsa_bs_batch_s pcks[batch_size + 1];
  33. uint8_t cw[8] = { 0x12, 0x34, 0x56, 0x78, 0x89, 0xab, 0xcd, 0xef, };
  34. srand(time(0));
  35. puts("Single threaded CSA decoding benchmark");
  36. dvbcsa_bs_key_set (cw, key);
  37. printf("Batch size %d packets.\n\n", batch_size);
  38. for (i = 0; i < batch_size; i++) {
  39. pcks[i].data = data[i];
  40. pcks[i].len = 184;
  41. memset(data[i], rand(), pcks[i].len);
  42. }
  43. pcks[i].data = NULL;
  44. gettimeofday(&t0, NULL);
  45. for (n = (1 << 12) / batch_size; n < (1 << 19) / batch_size; n *= 2) {
  46. printf(" Decrypting %6u mpegts packets\r", n * batch_size);
  47. fflush(stdout);
  48. for (i = 0; i < n; i++) {
  49. dvbcsa_bs_decrypt(key, pcks, 184);
  50. }
  51. npackets += n * batch_size;
  52. }
  53. gettimeofday(&t1, NULL);
  54. unsigned long long usec = timeval_diff_usec(&t0, &t1);
  55. printf("DONE: %u packets (%u bytes) decrypted in %llu ms = %.1f Mbits/s\n\n",
  56. npackets,
  57. npackets * 188,
  58. usec / 1000,
  59. (double)(npackets * 188 * 8) / (double)usec
  60. );
  61. dvbcsa_bs_key_free(key);
  62. }