test_sdp.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include "agent.h"
  5. void on_agent_state_changed(AgentState state, void* user_data) {
  6. printf("Agent state changed: %d\n", state);
  7. }
  8. int main(int argc, char* argv[]) {
  9. #if 0
  10. Agent agent;
  11. char remote_description[AGENT_MAX_DESCRIPTION];
  12. char remote_description_base64[AGENT_MAX_DESCRIPTION];
  13. char local_description[AGENT_MAX_DESCRIPTION];
  14. char local_description_base64[AGENT_MAX_DESCRIPTION];
  15. if (argc < 2) {
  16. printf("Usage: %s peer_id\n", argv[0]);
  17. return 0;
  18. }
  19. memset(remote_description, 0, sizeof(remote_description));
  20. memset(remote_description_base64, 0, sizeof(remote_description_base64));
  21. memset(local_description, 0, sizeof(local_description));
  22. memset(local_description_base64, 0, sizeof(local_description_base64));
  23. memset(&agent, 0, sizeof(agent));
  24. agent_gather_candidates(&agent);
  25. snprintf(local_description, sizeof(local_description), "m=text 50327 ICE/SDP\nc=IN IP4 0.0.0.0\n");
  26. agent_get_local_description(&agent, local_description + strlen(local_description), sizeof(local_description));
  27. base64_encode(local_description, strlen(local_description), local_description_base64, sizeof(local_description_base64));
  28. printf("Local description: \n%s\n", local_description);
  29. printf("Local description base64: \n%s\n", local_description_base64);
  30. printf("Enter remote description base64: \n");
  31. scanf("%s", remote_description_base64);
  32. base64_decode(remote_description_base64, strlen(remote_description_base64), remote_description, sizeof(remote_description));
  33. printf("Remote description: \n%s", remote_description);
  34. agent.mode = AGENT_MODE_CONTROLLING;
  35. //agent.mode = AGENT_MODE_CONTROLLED;
  36. agent_set_remote_description(&agent, remote_description);
  37. #endif
  38. return 0;
  39. }