libwebsockets
Lightweight C library for HTML5 websockets
Loading...
Searching...
No Matches
lws-protocols-plugins.h
Go to the documentation of this file.
1/*
2 * libwebsockets - small server side websockets and web server implementation
3 *
4 * Copyright (C) 2010 - 2019 Andy Green <andy@warmcat.com>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 * IN THE SOFTWARE.
23 */
24
41
43
45 const char *name;
66 unsigned int id;
73 void *user;
84
85 /* Add new things just above here ---^
86 * This is part of the ABI, don't needlessly break compatibility */
87};
88
89#define LWS_PROTOCOL_LIST_TERM { NULL, NULL, 0, 0, 0, NULL, 0 }
90
100lws_vhost_name_to_protocol(struct lws_vhost *vh, const char *name);
101
112lws_get_protocol(struct lws *wsi);
113
117
129lws_protocol_vh_priv_zalloc(struct lws_vhost *vhost,
130 const struct lws_protocols *prot, int size);
131
142lws_protocol_vh_priv_get(struct lws_vhost *vhost,
143 const struct lws_protocols *prot);
144
176lws_vhd_find_by_pvo(struct lws_context *cx, const char *protname,
177 const char *pvo_name, const char *pvo_value);
178
179
195lws_adjust_protocol_psds(struct lws *wsi, size_t new_size);
196
206lws_finalize_startup(struct lws_context *context, const char *where);
207
217lws_pvo_search(const struct lws_protocol_vhost_options *pvo, const char *name);
218
229lws_pvo_get_str(void *in, const char *name, const char **result);
230
231struct lws_http_mount;
232
242lws_pmo_search(const struct lws_http_mount *mount, const char *name);
243
254lws_pmo_get_str(const struct lws_http_mount *mount, const char *name,
255 const char **result);
256
258lws_protocol_init(struct lws_context *context);
259
260#define LWS_PLUGIN_API_MAGIC 192
261
262/*
263 * Abstract plugin header for any kind of plugin class, always at top of
264 * actual class plugin export type.
265 *
266 * The export type object must be exported with the same name as the plugin
267 * file, eg, libmyplugin.so must export a const one of these as the symbol
268 * "myplugin".
269 *
270 * That is the only expected export from the plugin.
271 */
272
273typedef struct lws_plugin_header {
274 const char *name;
275 const char *_class;
276 const char *lws_build_hash; /* set to LWS_BUILD_HASH */
277
278 unsigned int api_magic;
279 /* set to LWS_PLUGIN_API_MAGIC at plugin build time */
280
281 unsigned int priority;
284
285 /* plugin-class specific superclass data follows */
287
288/*
289 * "lws_protocol_plugin" class export, for lws_protocol implementations done
290 * as plugins
291 */
300
301
302/*
303 * This is the dynamic, runtime created part of the plugin instantiation.
304 * These are kept in a linked-list and destroyed with the context.
305 */
306
308 struct lws_plugin *list;
309
311
312 char basename[64];
315
316 union {
317#if defined(LWS_WITH_LIBUV) && defined(UV_ERRNO_MAP)
318#if (UV_VERSION_MAJOR > 0)
319 uv_lib_t lib;
320#endif
321#endif
322 void *l;
323 } u;
324};
325
326/*
327 * Event lib library plugin type (when LWS_WITH_EVLIB_PLUGINS)
328 * Public so new event libs can equally be supported outside lws itself
329 */
330
335
336typedef int (*each_plugin_cb_t)(struct lws_plugin *p, void *user);
337
360lws_plugins_init(struct lws_plugin **pplugin, const char * const *d,
361 const char *_class, const char *filter,
362 each_plugin_cb_t each, void *each_user);
363
379 void *each_user);
380
381
382struct pss_webrtc;
383struct vhd_webrtc;
384struct lws_webrtc_peer_media;
385
386typedef void (*lws_webrtc_on_media_cb)(struct lws *wsi_ws, int tid, const uint8_t *buf, size_t len, int marker, uint32_t timestamp);
387
388typedef int (*lws_webrtc_session_iter_cb)(struct pss_webrtc *pss, void *user);
389
394
395#define LWS_WEBRTC_OPS_ABI_VERSION 9
396
399
400 int (*send_video)(struct lws_webrtc_peer_media *media, const uint8_t *buf, size_t len, int codec, uint32_t pts);
401 int (*send_audio)(struct lws_webrtc_peer_media *media, const uint8_t *buf, size_t len, uint32_t timestamp);
402 int (*send_text)(struct pss_webrtc *pss, const char *buf, size_t len);
403 int (*send_pli)(struct pss_webrtc *pss);
404 void (*media_ref)(struct lws_webrtc_peer_media *media);
405 void (*media_unref)(struct lws_webrtc_peer_media **pmedia);
406 int (*foreach_session)(struct vhd_webrtc *vhd, lws_webrtc_session_iter_cb cb, void *user);
407 struct lws_webrtc_peer_media *(*get_media)(struct pss_webrtc *pss);
408 int (*shared_callback)(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len, struct vhd_webrtc *vhd);
409
410 void *(*get_user_data)(struct pss_webrtc *pss);
411 void (*set_user_data)(struct pss_webrtc *pss, void *data);
412 struct lws_vhost *(*get_vhost)(struct vhd_webrtc *vhd);
413 struct lws_context *(*get_context)(struct vhd_webrtc *vhd);
414 void (*set_on_media)(struct vhd_webrtc *vhd, lws_webrtc_on_media_cb cb);
415
416 uint8_t (*get_video_pt)(struct pss_webrtc *pss);
417 uint8_t (*get_audio_pt)(struct pss_webrtc *pss);
418
419 uint8_t (*get_video_pt_h264)(struct pss_webrtc *pss);
420 uint8_t (*get_video_pt_av1)(struct pss_webrtc *pss);
421 uint16_t (*get_seq_video)(struct pss_webrtc *pss);
422 int (*create_offer)(struct pss_webrtc *pss);
423};
424
425#if defined(LWS_WITH_PLUGINS_BUILTIN)
426
427/* provide exports for builtin plugin protocols */
428
429extern const struct lws_protocols post_demo_protocols[1];
430extern const struct lws_protocols lws_raw_proxy_protocols[1];
431extern const struct lws_protocols lws_status_protocols[1];
432extern const struct lws_protocols lws_mirror_protocols[1];
433extern const struct lws_protocols lws_ssh_base_protocols[2];
434extern const struct lws_protocols post_demo_protocols[1];
435extern const struct lws_protocols dumb_increment_protocols[1];
436extern const struct lws_protocols deaddrop_protocols[1];
437extern const struct lws_protocols lws_raw_test_protocols[1];
438extern const struct lws_protocols lws_sshd_demo_protocols[1];
439extern const struct lws_protocols lws_acme_client_protocols[1];
440extern const struct lws_protocols client_loopback_test_protocols[1];
441extern const struct lws_protocols fulltext_demo_protocols[1];
442extern const struct lws_protocols lws_openmetrics_export_protocols[
443#if defined(LWS_WITH_SERVER) && defined(LWS_WITH_CLIENT) && defined(LWS_ROLE_WS)
444 4
445#else
446#if defined(LWS_WITH_SERVER)
447 3
448#else
449 1
450#endif
451#endif
452 ];
453extern const struct lws_protocols lws_dht_object_store_protocols[];
454
455#define LWSOMPROIDX_DIRECT_HTTP_SERVER 0
456#define LWSOMPROIDX_PROX_HTTP_SERVER 1
457#define LWSOMPROIDX_PROX_WS_SERVER 2
458#define LWSOMPROIDX_PROX_WS_CLIENT 3
459
460#endif
461
462typedef void (*lws_dht_store_completion_cb_t)(void *closure, int result);
463
464
465
lws_plugin_header_t hdr
const struct lws_event_loop_ops * ops
lws_plugin_header_t hdr
lws_callback_function * callback
const struct lws_protocols * protocols
const struct lws_extension * extensions
LWS_VISIBLE LWS_EXTERN const struct lws_protocols * lws_protocol_get(struct lws *wsi) LWS_WARN_DEPRECATED
LWS_VISIBLE LWS_EXTERN int lws_pmo_get_str(const struct lws_http_mount *mount, const char *name, const char **result)
void(* lws_dht_store_completion_cb_t)(void *closure, int result)
LWS_VISIBLE LWS_EXTERN int lws_pvo_get_str(void *in, const char *name, const char **result)
int(* lws_webrtc_session_iter_cb)(struct pss_webrtc *pss, void *user)
LWS_VISIBLE LWS_EXTERN const struct lws_protocols * lws_vhost_name_to_protocol(struct lws_vhost *vh, const char *name)
struct lws_plugin_header lws_plugin_header_t
LWS_VISIBLE LWS_EXTERN void * lws_adjust_protocol_psds(struct lws *wsi, size_t new_size)
LWS_VISIBLE LWS_EXTERN int lws_protocol_init(struct lws_context *context)
void(* lws_webrtc_on_media_cb)(struct lws *wsi_ws, int tid, const uint8_t *buf, size_t len, int marker, uint32_t timestamp)
struct lws_plugin_evlib lws_plugin_evlib_t
LWS_VISIBLE LWS_EXTERN const struct lws_protocols * lws_get_protocol(struct lws *wsi)
LWS_VISIBLE LWS_EXTERN void * lws_protocol_vh_priv_get(struct lws_vhost *vhost, const struct lws_protocols *prot)
struct lws_plugin_protocol lws_plugin_protocol_t
LWS_VISIBLE LWS_EXTERN const struct lws_protocol_vhost_options * lws_pmo_search(const struct lws_http_mount *mount, const char *name)
int(* each_plugin_cb_t)(struct lws_plugin *p, void *user)
LWS_VISIBLE LWS_EXTERN void * lws_vhd_find_by_pvo(struct lws_context *cx, const char *protname, const char *pvo_name, const char *pvo_value)
LWS_VISIBLE LWS_EXTERN const struct lws_protocol_vhost_options * lws_pvo_search(const struct lws_protocol_vhost_options *pvo, const char *name)
LWS_VISIBLE LWS_EXTERN int lws_plugins_init(struct lws_plugin **pplugin, const char *const *d, const char *_class, const char *filter, each_plugin_cb_t each, void *each_user)
LWS_VISIBLE LWS_EXTERN int lws_finalize_startup(struct lws_context *context, const char *where)
LWS_VISIBLE LWS_EXTERN void * lws_protocol_vh_priv_zalloc(struct lws_vhost *vhost, const struct lws_protocols *prot, int size)
LWS_VISIBLE LWS_EXTERN int lws_plugins_destroy(struct lws_plugin **pplugin, each_plugin_cb_t each, void *each_user)
@ LWS_WEBRTC_CODEC_H264
@ LWS_WEBRTC_CODEC_AV1
int lws_callback_function(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len)
lws_callback_reasons
unsigned short uint16_t
unsigned int uint32_t
#define LWS_WARN_DEPRECATED
#define LWS_EXTERN
unsigned char uint8_t
#define LWS_VISIBLE
const lws_plugin_header_t * hdr
struct lws_plugin * list
union lws_plugin::@212075251220221362023025000075256263262302222360 u
uint8_t(* get_video_pt_av1)(struct pss_webrtc *pss)
int(* send_video)(struct lws_webrtc_peer_media *media, const uint8_t *buf, size_t len, int codec, uint32_t pts)
void(* set_user_data)(struct pss_webrtc *pss, void *data)
int(* send_audio)(struct lws_webrtc_peer_media *media, const uint8_t *buf, size_t len, uint32_t timestamp)
uint8_t(* get_audio_pt)(struct pss_webrtc *pss)
int(* foreach_session)(struct vhd_webrtc *vhd, lws_webrtc_session_iter_cb cb, void *user)
void(* media_unref)(struct lws_webrtc_peer_media **pmedia)
int(* shared_callback)(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len, struct vhd_webrtc *vhd)
uint16_t(* get_seq_video)(struct pss_webrtc *pss)
uint8_t(* get_video_pt)(struct pss_webrtc *pss)
int(* send_text)(struct pss_webrtc *pss, const char *buf, size_t len)
int(* send_pli)(struct pss_webrtc *pss)
void(* set_on_media)(struct vhd_webrtc *vhd, lws_webrtc_on_media_cb cb)
int(* create_offer)(struct pss_webrtc *pss)
uint8_t(* get_video_pt_h264)(struct pss_webrtc *pss)
void(* media_ref)(struct lws_webrtc_peer_media *media)