| 351 | int _tmain(int argc, _TCHAR* argv[]) |
| 352 | #else |
| 353 | int main(int argc, char **argv) |
| 354 | #endif |
| 355 | { |
| 356 | /* This is to test TLS and TLS Detect |
| 357 | struct util_cert selfcert; |
| 358 | struct util_cert selftlscert; |
| 359 | SSL_CTX* ctx; |
| 360 | */ |
| 361 | |
| 362 | #if defined(WIN32) |
| 363 | _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); |
| 364 | SetConsoleCtrlHandler((PHANDLER_ROUTINE)CtrlHandler, TRUE); // Set SIGNAL on windows to listen for Ctrl-C |
| 365 | #elif defined(_POSIX) |
| 366 | signal(SIGPIPE, SIG_IGN); // Set a SIGNAL on Linux to listen for Ctrl-C |
| 367 | |
| 368 | // Shutdown on Ctrl + C |
| 369 | signal(SIGINT, BreakSink); |
| 370 | { |
| 371 | struct sigaction act; |
| 372 | act.sa_handler = SIG_IGN; |
| 373 | sigemptyset(&act.sa_mask); |
| 374 | act.sa_flags = 0; |
| 375 | sigaction(SIGPIPE, &act, NULL); |
| 376 | } |
| 377 | #endif |
| 378 | |
| 379 | #if defined(WIN32) |
| 380 | if (argc>1 && _tcscmp(argv[1], L"STUN")==0) |
| 381 | #else |
| 382 | if (argc>1 && strcmp(argv[1],"STUN")==0) |
| 383 | #endif |
| 384 | { |
| 385 | useStun = 1; |
| 386 | printf("USING STUN!\r\n"); |
| 387 | } |
| 388 | |
| 389 | chain = ILibCreateChain(); // Create the MicrostackChain, to which we'll attach the WebRTC ConnectionFactory |
| 390 | mConnectionFactory = ILibWrapper_WebRTC_ConnectionFactory_CreateConnectionFactory(chain, 0); // Create the connection factory, and bind to port "0", to use a random port |
| 391 | mServer = SimpleRendezvousServer_Create(chain, 5350, &Rendezvous_OnGet, &Rendezvous_OnPost); // Create our simple Rendezvous/HTTP server we'll use to exchange SDP offers, and bind to port 5350 |
| 392 | |
| 393 | htmlBodyLength = ILibReadFileFromDiskEx(&htmlBody, "webrtcsample.html"); // This will be the HTML file served if you hit /ACTIVE |
| 394 | passiveHtmlBodyLength = ILibReadFileFromDiskEx(&passiveHtmlBody, "webrtcpassivesample.html"); // This will be the HTML file served if you hit /PASSIVE |
| 395 | wshtmlBodyLength = ILibReadFileFromDiskEx(&wshtmlbody, "websocketsample.html"); |
| 396 | |
| 397 | printf("Microstack WebRTC Sample Application started.\r\n\r\n"); |
| 398 | |
| 399 | // We're actually listening on all interfaces, not just 127.0.0.1 |
| 400 | printf("Browser-initiated connection: http://127.0.0.1:5350/active\r\n"); // This will cause the browser to initiate a WebRTC Connection |
| 401 | printf("Application-initiated connection: http://127.0.0.1:5350/passive\r\n"); // This will initiate a WebRTC Connection to the browser |
| 402 | printf("Web-Socket initiated connection: http://127.0.0.1:5350/websocket\r\n"); // This will cause the browser to initiate a websocket connection to exchange WebRTC offers. |
| 403 | printf("\r\n"); |
| 404 | #if defined(_REMOTELOGGING) && defined(_REMOTELOGGINGSERVER) |
| 405 | printf("Debug logging listening url: http://127.0.0.1:%u\r\n", ILibStartDefaultLogger(chain, 7775)); |
| 406 | #endif |
| 407 | printf("\r\n(Press Ctrl-C to exit)\r\n"); |
| 408 | /* This is to test TLS and TLS Detect |
| 409 | // Init Certs |
| 410 | util_mkCert(NULL, &selfcert, 2048, 10000, "localhost", CERTIFICATE_ROOT, NULL); |
nothing calls this directly
no test coverage detected