docs/html/classWebRTCServer.html
| | Jetson Inference
DNN Vision Library |
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
WebRTCServer Class Reference Utilities Library (jetson-utils) » Networking
WebRTC signalling server for establishing and negotiating connections with peers for bi-directional media streaming. More...
#include <WebRTCServer.h>
|
| | struct | HttpRoute | | | | struct | WebsocketRoute | | |
|
|
| typedef void(* | WebsocketListener) (WebRTCPeer *peer, const char *message, size_t message_size, void *user_data) |
| | Function pointer to a callback for handling websocket requests. More...
|
| |
| typedef SoupServerCallback | HttpListener |
| | Function pointer to a callback for handling HTTP requests. More...
|
| |
|
|
| void | Release () |
| | Release a reference to the server instance. More...
|
| |
| void | AddRoute (const char *path, HttpListener callback, void *user_data=NULL, uint32_t flags=0) |
| | Register a function to handle incoming http/www requests at the specified path. More...
|
| |
| void | AddRoute (const char *path, WebsocketListener callback, void *user_data=NULL, uint32_t flags=0) |
| | Register a function to handle incoming Websocket requests at the specified path. More...
|
| |
| const char * | GetSTUNServer () const |
| | Get the STUN server being used. More...
|
| |
| bool | HasHTTPS () const |
| | Return true if the server is using HTTPS. More...
|
| |
| bool | IsThreaded () const |
| | Return true if the server is running in it's own thread. More...
|
| |
| bool | ProcessRequests (bool blocking=false) |
| | Process incoming requests on the server. More...
|
| |
|
|
| static WebRTCServer * | Create (uint16_t port=WEBRTC_DEFAULT_PORT, const char *stun_server=WEBRTC_DEFAULT_STUN_SERVER, const char *ssl_cert=NULL, const char *ssl_key=NULL, bool threaded=true) |
| | Create a WebRTC server on this port. More...
|
| |
|
| | | WebRTCServer (uint16_t port, const char *stun_server, const char *ssl_cert_file, const char *ssl_key_file, bool threaded) | | | | | ~WebRTCServer () | | | | bool | init () | | | | HttpRoute * | findHttpRoute (const char *path) const | | | | WebsocketRoute * | findWebsocketRoute (const char *path) const | | | | void | freeRoute (HttpRoute *route) | | | | void | freeRoute (WebsocketRoute *route) | | | | std::string | printRouteInfo (WebsocketRoute *route) const | | |
|
| | static void * | runThread (void *user_data) | | | | static void | onHttpRequest (SoupServer *soup_server, SoupMessage *message, const char *path, GHashTable *query, SoupClientContext *client_context, void *user_data) | | | | static void | onHttpDefault (SoupServer *soup_server, SoupMessage *message, const char *path, GHashTable *query, SoupClientContext *client_context, void *user_data) | | | | static void | onWebsocketOpened (SoupServer *server, SoupWebsocketConnection *connection, const char *path, SoupClientContext *client_context, void *user_data) | | | | static void | onWebsocketMessage (SoupWebsocketConnection *connection, SoupWebsocketDataType data_type, GBytes *message, void *user_data) | | | | static void | onWebsocketClosed (SoupWebsocketConnection *connection, void *user_data) | | |
|
| | std::vector< HttpRoute * > | mHttpRoutes | | | | std::vector< WebsocketRoute * > | mWebsocketRoutes | | | | SoupServer * | mSoupServer | | | | std::string | mStunServer | | | | std::string | mSSLCertFile | | | | std::string | mSSLKeyFile | | | | bool | mHasHTTPS | | | | uint16_t | mPort | | | | uint32_t | mRefCount | | | | uint32_t | mPeerCount | | | | Thread * | mThread | | |
WebRTC signalling server for establishing and negotiating connections with peers for bi-directional media streaming.
Users can bind routing functions that configure their pipelines dynamically to handle incoming/outgoing streams.
It uses websockets to handle the communication with clients for SDP offers, ICE messages, ect.
By default it also serves simple HTML for viewing video streams in browsers, but for full hosting you'll want to run this alongside an actual webserver.
multi-stream :: multi-client :: full-duplex
| typedef SoupServerCallback WebRTCServer::HttpListener |
Function pointer to a callback for handling HTTP requests.
See alsohttps://developer-old.gnome.org/libsoup/stable/SoupServer.html#SoupServerCallback
| typedef void(* WebRTCServer::WebsocketListener) (WebRTCPeer *peer, const char *message, size_t message_size, void *user_data) |
Function pointer to a callback for handling websocket requests.
See alsoAddConnectionListener
|
| WebRTCServer::WebRTCServer | ( | uint16_t | port, | | | | const char * | stun_server, | | | | const char * | ssl_cert_file, | | | | const char * | ssl_key_file, | | | | bool | threaded | | | ) | | |
| protected |
|
| WebRTCServer::~WebRTCServer | ( | | ) | |
| protected |
| void WebRTCServer::AddRoute | ( | const char * | path, |
| | | HttpListener | callback, |
| | | void * | user_data = NULL, |
| | | uint32_t | flags = 0 |
| | ) | | |
Register a function to handle incoming http/www requests at the specified path.
These are for serving webpages, and should be on different paths than the websockets. If the path is "/" the callback will handle all routes. If the route for this path already exists, it will replace the existing route. To remove a route, set the callback to NULL.
| void WebRTCServer::AddRoute | ( | const char * | path, |
| | | WebsocketListener | callback, |
| | | void * | user_data = NULL, |
| | | uint32_t | flags = 0 |
| | ) | | |
Register a function to handle incoming Websocket requests at the specified path.
This path often represents a media stream that can be sent/recieved, or a function for dynamically configuring streams when new clients connect.
If the path is "/" the callback will handle all routes. If the route for this path already exists, it will replace the existing route. To remove a route, set the callback to NULL.
The optional flags are WebRTCFlags OR'd together and are used for describing the stream capabilities for purposes of discovery.
See alsoWebRTCFlags
|
| static WebRTCServer* WebRTCServer::Create | ( | uint16_t | port = WEBRTC_DEFAULT_PORT, |
| | | const char * | stun_server = WEBRTC_DEFAULT_STUN_SERVER, |
| | | const char * | ssl_cert = NULL, |
| | | const char * | ssl_key = NULL, |
| | | bool | threaded = true |
| | ) | | |
| static |
Create a WebRTC server on this port.
If this port is already in use, the existing server instance will be returned.
|
| HttpRoute* WebRTCServer::findHttpRoute | ( | const char * | path | ) | const |
| protected |
|
| WebsocketRoute* WebRTCServer::findWebsocketRoute | ( | const char * | path | ) | const |
| protected |
|
| void WebRTCServer::freeRoute | ( | HttpRoute * | route | ) | |
| protected |
|
| void WebRTCServer::freeRoute | ( | WebsocketRoute * | route | ) | |
| protected |
|
| const char* WebRTCServer::GetSTUNServer | ( | | ) | const |
| inline |
Get the STUN server being used.
STUN servers are used during ICE/NAT and allow a local device to determine its public IP address.
See alsoWEBRTC_DEFAULT_STUN_SERVER
|
| bool WebRTCServer::HasHTTPS | ( | | ) | const |
| inline |
Return true if the server is using HTTPS.
For HTTPS to be enabled, SSL cert/key files must have been provided to WebRTCServer::Create().
|
| bool WebRTCServer::init | ( | | ) | |
| protected |
|
| bool WebRTCServer::IsThreaded | ( | | ) | const |
| inline |
Return true if the server is running in it's own thread.
Otherwise, ProcessRequests() must be called periodically.
|
| static void WebRTCServer::onHttpDefault | ( | SoupServer * | soup_server, | | | | SoupMessage * | message, | | | | const char * | path, | | | | GHashTable * | query, | | | | SoupClientContext * | client_context, | | | | void * | user_data | | | ) | | |
| staticprotected |
|
| static void WebRTCServer::onHttpRequest | ( | SoupServer * | soup_server, | | | | SoupMessage * | message, | | | | const char * | path, | | | | GHashTable * | query, | | | | SoupClientContext * | client_context, | | | | void * | user_data | | | ) | | |
| staticprotected |
|
| static void WebRTCServer::onWebsocketClosed | ( | SoupWebsocketConnection * | connection, | | | | void * | user_data | | | ) | | |
| staticprotected |
|
| static void WebRTCServer::onWebsocketMessage | ( | SoupWebsocketConnection * | connection, | | | | SoupWebsocketDataType | data_type, | | | | GBytes * | message, | | | | void * | user_data | | | ) | | |
| staticprotected |
|
| static void WebRTCServer::onWebsocketOpened | ( | SoupServer * | server, | | | | SoupWebsocketConnection * | connection, | | | | const char * | path, | | | | SoupClientContext * | client_context, | | | | void * | user_data | | | ) | | |
| staticprotected |
|
| std::string WebRTCServer::printRouteInfo | ( | WebsocketRoute * | route | ) | const |
| protected |
| bool WebRTCServer::ProcessRequests | ( | bool | blocking = false | ) | |
Process incoming requests on the server.
If set to blocking, the function can wait indefinitely for requests. This should only be called externally if the server was created with threaded=false
| void WebRTCServer::Release | ( | | ) | |
Release a reference to the server instance.
Server will be shut down when the reference count reaches zero.
|
| static void* WebRTCServer::runThread | ( | void * | user_data | ) | |
| staticprotected |
|
| bool WebRTCServer::mHasHTTPS |
| protected |
|
| std::vector<HttpRoute*> WebRTCServer::mHttpRoutes |
| protected |
|
| uint32_t WebRTCServer::mPeerCount |
| protected |
|
| uint16_t WebRTCServer::mPort |
| protected |
|
| uint32_t WebRTCServer::mRefCount |
| protected |
|
| SoupServer* WebRTCServer::mSoupServer |
| protected |
|
| std::string WebRTCServer::mSSLCertFile |
| protected |
|
| std::string WebRTCServer::mSSLKeyFile |
| protected |
|
| std::string WebRTCServer::mStunServer |
| protected |
|
| Thread* WebRTCServer::mThread |
| protected |
|
| std::vector<WebsocketRoute*> WebRTCServer::mWebsocketRoutes |
| protected |
The documentation for this class was generated from the following file:
jetson-utils/WebRTCServer.h
Generated on Fri Mar 17 2023 14:29:30 for Jetson Inference by 1.8.17