WebRTC signalling server for establishing and negotiating connections with peers for bi-directional media streaming.
More...
#include <WebRTCServer.h>
|
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 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) |
|
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.
- See also
- https://doc-kurento.readthedocs.io/en/stable/_static/client-javadoc/org/kurento/client/WebRtcEndpoint.html
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
◆ HttpListener
◆ WebsocketListener
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 also
- AddConnectionListener
◆ WebRTCServer()
WebRTCServer::WebRTCServer |
( |
uint16_t |
port, |
|
|
const char * |
stun_server, |
|
|
const char * |
ssl_cert_file, |
|
|
const char * |
ssl_key_file, |
|
|
bool |
threaded |
|
) |
| |
|
protected |
◆ ~WebRTCServer()
WebRTCServer::~WebRTCServer |
( |
| ) |
|
|
protected |
◆ AddRoute() [1/2]
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.
◆ AddRoute() [2/2]
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 also
- WebRTCFlags
◆ Create()
Create a WebRTC server on this port.
If this port is already in use, the existing server instance will be returned.
◆ findHttpRoute()
HttpRoute* WebRTCServer::findHttpRoute |
( |
const char * |
path | ) |
const |
|
protected |
◆ findWebsocketRoute()
WebsocketRoute* WebRTCServer::findWebsocketRoute |
( |
const char * |
path | ) |
const |
|
protected |
◆ freeRoute() [1/2]
void WebRTCServer::freeRoute |
( |
HttpRoute * |
route | ) |
|
|
protected |
◆ freeRoute() [2/2]
◆ GetSTUNServer()
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 also
- WEBRTC_DEFAULT_STUN_SERVER
◆ HasHTTPS()
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().
◆ init()
bool WebRTCServer::init |
( |
| ) |
|
|
protected |
◆ IsThreaded()
bool WebRTCServer::IsThreaded |
( |
| ) |
const |
|
inline |
Return true if the server is running in it's own thread.
Otherwise, ProcessRequests() must be called periodically.
◆ onHttpDefault()
static void WebRTCServer::onHttpDefault |
( |
SoupServer * |
soup_server, |
|
|
SoupMessage * |
message, |
|
|
const char * |
path, |
|
|
GHashTable * |
query, |
|
|
SoupClientContext * |
client_context, |
|
|
void * |
user_data |
|
) |
| |
|
staticprotected |
◆ onHttpRequest()
static void WebRTCServer::onHttpRequest |
( |
SoupServer * |
soup_server, |
|
|
SoupMessage * |
message, |
|
|
const char * |
path, |
|
|
GHashTable * |
query, |
|
|
SoupClientContext * |
client_context, |
|
|
void * |
user_data |
|
) |
| |
|
staticprotected |
◆ onWebsocketClosed()
static void WebRTCServer::onWebsocketClosed |
( |
SoupWebsocketConnection * |
connection, |
|
|
void * |
user_data |
|
) |
| |
|
staticprotected |
◆ onWebsocketMessage()
static void WebRTCServer::onWebsocketMessage |
( |
SoupWebsocketConnection * |
connection, |
|
|
SoupWebsocketDataType |
data_type, |
|
|
GBytes * |
message, |
|
|
void * |
user_data |
|
) |
| |
|
staticprotected |
◆ onWebsocketOpened()
static void WebRTCServer::onWebsocketOpened |
( |
SoupServer * |
server, |
|
|
SoupWebsocketConnection * |
connection, |
|
|
const char * |
path, |
|
|
SoupClientContext * |
client_context, |
|
|
void * |
user_data |
|
) |
| |
|
staticprotected |
◆ printRouteInfo()
std::string WebRTCServer::printRouteInfo |
( |
WebsocketRoute * |
route | ) |
const |
|
protected |
◆ ProcessRequests()
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
◆ Release()
void WebRTCServer::Release |
( |
| ) |
|
Release a reference to the server instance.
Server will be shut down when the reference count reaches zero.
◆ runThread()
static void* WebRTCServer::runThread |
( |
void * |
user_data | ) |
|
|
staticprotected |
◆ mHasHTTPS
bool WebRTCServer::mHasHTTPS |
|
protected |
◆ mHttpRoutes
std::vector<HttpRoute*> WebRTCServer::mHttpRoutes |
|
protected |
◆ mPeerCount
uint32_t WebRTCServer::mPeerCount |
|
protected |
◆ mPort
uint16_t WebRTCServer::mPort |
|
protected |
◆ mRefCount
uint32_t WebRTCServer::mRefCount |
|
protected |
◆ mSoupServer
SoupServer* WebRTCServer::mSoupServer |
|
protected |
◆ mSSLCertFile
std::string WebRTCServer::mSSLCertFile |
|
protected |
◆ mSSLKeyFile
std::string WebRTCServer::mSSLKeyFile |
|
protected |
◆ mStunServer
std::string WebRTCServer::mStunServer |
|
protected |
◆ mThread
◆ mWebsocketRoutes
The documentation for this class was generated from the following file: