Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

52 rindas
1.7KB

  1. #include "amf0.h"
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <assert.h>
  5. #define AMF_OBJECT_ITEM_VALUE(v, amf_type, amf_name, amf_value, amf_size) { v.type=amf_type; v.name=amf_name; v.value=amf_value; v.size=amf_size; }
  6. struct rtmp_result_t
  7. {
  8. char code[64]; // NetStream.Play.Start
  9. char level[8]; // warning/status/error
  10. char description[256];
  11. };
  12. static int amf0_get(const char* file, void* amf0, size_t bytes)
  13. {
  14. int r;
  15. FILE* fp;
  16. fp = fopen(file, "rb");
  17. if (NULL == fp)
  18. return 0;
  19. r = fread(amf0, 1, bytes, fp);
  20. fclose(fp);
  21. return r;
  22. }
  23. void amf0_test2(void)
  24. {
  25. int r;
  26. uint8_t* end;
  27. static uint8_t amf0[2 * 1024];
  28. struct rtmp_result_t result;
  29. struct amf_object_item_t info[3];
  30. struct amf_object_item_t items[2];
  31. AMF_OBJECT_ITEM_VALUE(info[0], AMF_STRING, "code", result.code, sizeof(result.code));
  32. AMF_OBJECT_ITEM_VALUE(info[1], AMF_STRING, "level", result.level, sizeof(result.level));
  33. AMF_OBJECT_ITEM_VALUE(info[2], AMF_STRING, "description", result.description, sizeof(result.description));
  34. AMF_OBJECT_ITEM_VALUE(items[0], AMF_OBJECT, "command", NULL, 0); // Command object
  35. AMF_OBJECT_ITEM_VALUE(items[1], AMF_OBJECT, "information", info, sizeof(info) / sizeof(info[0])); // Information object
  36. r = amf0_get("../libflv/test/rtmp.onStatus.amf0", amf0, sizeof(amf0));
  37. end = amf0 + r;
  38. assert(end == amf_read_items(amf0, end, items, sizeof(items) / sizeof(items[0])));
  39. assert(0 == strcmp(result.code, "NetStream.Play.Reset"));
  40. assert(0 == strcmp(result.level, "status"));
  41. assert(0 == strcmp(result.description, "Playing and resetting 92f509c10c112171f935?token=3129bc162ee05a1353f7&secret=15b1bca0997ab790656c903493cada3b&ckey=17e23e4fd0bb5b54a2434fd1514343ee"));
  42. }