| 279 | } |
| 280 | |
| 281 | internal_context_t* internal_init(internal_callbacks_t* callbacks) { |
| 282 | internal_context_t* ctx = new internal_context_t(); |
| 283 | |
| 284 | if( callbacks ) |
| 285 | ctx->callbacks= *callbacks; |
| 286 | |
| 287 | sanitize_callbacks( ctx->callbacks ); |
| 288 | |
| 289 | struct lws_context_creation_info info; |
| 290 | memset(&info, 0, sizeof(info)); |
| 291 | info.protocols = protocols; |
| 292 | info.port = CONTEXT_PORT_NO_LISTEN; |
| 293 | info.gid = -1; |
| 294 | info.uid = -1; |
| 295 | #if 0 |
| 296 | #if defined __APPLE__ || defined(__linux__) |
| 297 | // test a few wll known locations |
| 298 | const char* certs[] = { "./cert.pem", "/etc/openssl/cert.pem", "/opt/local/etc/openssl/cert.pem", "/etc/pki/tls/cert.pem" , NULL }; |
| 299 | for( const char** test = certs; *test; test++ ) { |
| 300 | if( access( *test, F_OK ) != -1 ) { |
| 301 | info.ssl_ca_filepath = *test; |
| 302 | break; |
| 303 | } |
| 304 | } |
| 305 | #elif defined(WIN32) |
| 306 | info.ssl_ca_filepath = "cert.pem"; |
| 307 | #endif |
| 308 | #endif |
| 309 | |
| 310 | ctx->websocket = libwebsocket_create_context_extended(&info); |
| 311 | ctx->webrtc = libwebrtc_create_context(&webrtc_protocol); |
| 312 | |
| 313 | g_context = ctx; |
| 314 | |
| 315 | return ctx; |
| 316 | } |
| 317 | |
| 318 | bool internal_supports_webRTC(internal_context_t* ctx) { |
| 319 | return ctx->webrtc != NULL; |