t35_tests.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * SpanDSP - a series of DSP components for telephony
  3. *
  4. * t35_tests.c - Tests for T.35.
  5. *
  6. * Written by Steve Underwood <steveu@coppice.org>
  7. *
  8. * Copyright (C) 2012 Steve Underwood
  9. *
  10. * All rights reserved.
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License version 2, as
  14. * published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24. */
  25. /*! \file */
  26. /*! \page t35_tests_page T.35 tests
  27. \section t35_tests_page_sec_1 What does it do?
  28. */
  29. #if defined(HAVE_CONFIG_H)
  30. #include "config.h"
  31. #endif
  32. #include <stdlib.h>
  33. #include <stdio.h>
  34. #include <fcntl.h>
  35. #include <unistd.h>
  36. #include <string.h>
  37. #include <assert.h>
  38. #include <sndfile.h>
  39. #include "spandsp.h"
  40. int main(int argc, char *argv[])
  41. {
  42. int i;
  43. int j;
  44. uint8_t msg[50];
  45. const char *vendor;
  46. const char *country;
  47. const char *model;
  48. const char *real_country;
  49. bool first_hit;
  50. printf("Sweep through all the possible countries\n");
  51. for (i = 0; i < 256; i++)
  52. {
  53. country = t35_country_code_to_str(i, 0);
  54. real_country = t35_real_country_code_to_str(i, 0);
  55. if (country || real_country)
  56. {
  57. printf("%3d '%s' %d '%s'\n",
  58. i,
  59. (country) ? country : "???",
  60. t35_real_country_code(i, 0),
  61. (real_country) ? real_country : "???");
  62. }
  63. }
  64. printf("\nSweep through all the possible vendors within each country\n");
  65. for (i = 0; i < 256; i++)
  66. {
  67. msg[0] = i;
  68. msg[1] = '\x00';
  69. msg[2] = '\x00';
  70. first_hit = true;
  71. for (j = 0; j < 65536; j++)
  72. {
  73. msg[1] = (j >> 8) & 0xFF;
  74. msg[2] = j & 0xFF;
  75. if ((vendor = t35_vendor_to_str(msg, 3)))
  76. {
  77. if (first_hit)
  78. {
  79. if ((real_country = t35_real_country_code_to_str(i, 0)))
  80. printf("%s\n", real_country);
  81. else
  82. printf("???\n");
  83. first_hit = false;
  84. }
  85. printf(" 0x%02x 0x%02x 0x%02x '%s'\n", msg[0], msg[1], msg[2], vendor);
  86. }
  87. }
  88. }
  89. printf("\nTry a decode of a full NSF string\n");
  90. t35_decode((uint8_t *) "\x00\x00\x0E\x00\x00\x00\x96\x0F\x01\x02\x00\x10\x05\x02\x95\xC8\x08\x01\x49\x02\x41\x53\x54\x47",
  91. 13,
  92. &country,
  93. &vendor,
  94. &model);
  95. printf("Decoded as %s %s %s\n", (country) ? country : "???", (vendor) ? vendor : "???", (model) ? model : "???");
  96. printf("Tests passed\n");
  97. return 0;
  98. }
  99. /*- End of function --------------------------------------------------------*/
  100. /*- End of file ------------------------------------------------------------*/