Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

51 рядки
1.2KB

  1. #include "rtmp-client.h"
  2. #include <assert.h>
  3. #include <string.h>
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6. static int rtmp_client_send(void* /*param*/, const void* /*header*/, size_t len, const void* /*data*/, size_t bytes)
  7. {
  8. return len + bytes;
  9. }
  10. static int rtmp_client_onaudio(void* /*param*/, const void* /*data*/, size_t /*bytes*/, uint32_t /*timestamp*/)
  11. {
  12. return 0;
  13. }
  14. static int rtmp_client_onvideo(void* /*param*/, const void* /*data*/, size_t /*bytes*/, uint32_t /*timestamp*/)
  15. {
  16. return 0;
  17. }
  18. static int rtmp_client_onscript(void* /*param*/, const void* /*data*/, size_t /*bytes*/, uint32_t /*timestamp*/)
  19. {
  20. return 0;
  21. }
  22. void rtmp_input_test(const char* file)
  23. {
  24. static char packet[1024];
  25. struct rtmp_client_handler_t handler;
  26. memset(&handler, 0, sizeof(handler));
  27. handler.send = rtmp_client_send;
  28. handler.onaudio = rtmp_client_onaudio;
  29. handler.onvideo = rtmp_client_onvideo;
  30. handler.onscript = rtmp_client_onscript;
  31. rtmp_client_t* rtmp = rtmp_client_create("1", "1", "1", NULL, &handler);
  32. int r = rtmp_client_start(rtmp, 1);
  33. int n = 0;
  34. FILE* fp = fopen(file, "rb");
  35. while (fp && (n = fread(packet, 1, sizeof(packet), fp)) > 0)
  36. {
  37. assert(0 == rtmp_client_input(rtmp, packet, n));
  38. }
  39. fclose(fp);
  40. rtmp_client_stop(rtmp);
  41. rtmp_client_destroy(rtmp);
  42. }