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;
88
89 /* Add new things just above here ---^
90 * This is part of the ABI, don't needlessly break compatibility */
91};
92
93#define LWS_PROTOCOL_LIST_TERM { NULL, NULL, 0, 0, 0, NULL, 0 }
94
104lws_vhost_name_to_protocol(struct lws_vhost *vh, const char *name);
105
116lws_get_protocol(struct lws *wsi);
117
121
133lws_protocol_vh_priv_zalloc(struct lws_vhost *vhost,
134 const struct lws_protocols *prot, int size);
135
146lws_protocol_vh_priv_get(struct lws_vhost *vhost,
147 const struct lws_protocols *prot);
148
180lws_vhd_find_by_pvo(struct lws_context *cx, const char *protname,
181 const char *pvo_name, const char *pvo_value);
182
183
199lws_adjust_protocol_psds(struct lws *wsi, size_t new_size);
200
217lws_finalize_startup(struct lws_context *context, const char *where);
218
228lws_pvo_search(const struct lws_protocol_vhost_options *pvo, const char *name);
229
240lws_pvo_get_str(void *in, const char *name, const char **result);
241
242struct lws_http_mount;
243
253lws_pmo_search(const struct lws_http_mount *mount, const char *name);
254
265lws_pmo_get_str(const struct lws_http_mount *mount, const char *name,
266 const char **result);
267
269lws_protocol_init(struct lws_context *context);
270
271/*
272 * 192: lws_plugin_header_t .priority
273 * 193: lws_plugin_protocol_t .init / .deinit
274 */
275#define LWS_PLUGIN_API_MAGIC 193
276
277/*
278 * Abstract plugin header for any kind of plugin class, always at top of
279 * actual class plugin export type.
280 *
281 * The export type object must be exported with the same name as the plugin
282 * file, eg, libmyplugin.so must export a const one of these as the symbol
283 * "myplugin".
284 *
285 * That is the only expected export from the plugin.
286 */
287
288typedef struct lws_plugin_header {
289 const char *name;
290 const char *_class;
291 const char *lws_build_hash; /* set to LWS_BUILD_HASH */
292
293 unsigned int api_magic;
294 /* set to LWS_PLUGIN_API_MAGIC at plugin build time */
295
296 unsigned int priority;
299
300 /* plugin-class specific superclass data follows */
302
303/*
304 * "lws_protocol_plugin" class export, for lws_protocol implementations done
305 * as plugins
306 */
307typedef struct lws_plugin_protocol {
309
310 const struct lws_protocols *protocols;
311 const struct lws_extension *extensions;
314
315 /* the members below are only read from plugins built with
316 * api_magic >= 193 */
317
318 int (*init)(struct lws_context *cx);
327 void (*deinit)(struct lws_context *cx);
332
333
334/*
335 * This is the dynamic, runtime created part of the plugin instantiation.
336 * These are kept in a linked-list and destroyed with the context.
337 */
338
340 struct lws_plugin *list;
341
343
344 char basename[64];
347
348 union {
349#if defined(LWS_WITH_LIBUV) && defined(UV_ERRNO_MAP)
350#if (UV_VERSION_MAJOR > 0)
351 uv_lib_t lib;
352#endif
353#endif
354 void *l;
355 } u;
356};
357
358/*
359 * Event lib library plugin type (when LWS_WITH_EVLIB_PLUGINS)
360 * Public so new event libs can equally be supported outside lws itself
361 */
362
367
368typedef int (*each_plugin_cb_t)(struct lws_plugin *p, void *user);
369
392lws_plugins_init(struct lws_plugin **pplugin, const char * const *d,
393 const char *_class, const char *filter,
394 each_plugin_cb_t each, void *each_user);
395
411 void *each_user);
412
413
414struct pss_webrtc;
415struct vhd_webrtc;
416struct lws_webrtc_peer_media;
417
418typedef void (*lws_webrtc_on_media_cb)(struct lws *wsi_ws, int tid, const uint8_t *buf, size_t len, int marker, uint32_t timestamp);
419
420typedef int (*lws_webrtc_session_iter_cb)(struct pss_webrtc *pss, void *user);
421
426
427#define LWS_WEBRTC_OPS_ABI_VERSION 9
428
431
432 int (*send_video)(struct lws_webrtc_peer_media *media, const uint8_t *buf, size_t len, int codec, uint32_t pts);
433 int (*send_audio)(struct lws_webrtc_peer_media *media, const uint8_t *buf, size_t len, uint32_t timestamp);
434 int (*send_text)(struct pss_webrtc *pss, const char *buf, size_t len);
435 int (*send_pli)(struct pss_webrtc *pss);
436 void (*media_ref)(struct lws_webrtc_peer_media *media);
437 void (*media_unref)(struct lws_webrtc_peer_media **pmedia);
438 int (*foreach_session)(struct vhd_webrtc *vhd, lws_webrtc_session_iter_cb cb, void *user);
439 struct lws_webrtc_peer_media *(*get_media)(struct pss_webrtc *pss);
440 int (*shared_callback)(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len, struct vhd_webrtc *vhd);
441
442 void *(*get_user_data)(struct pss_webrtc *pss);
443 void (*set_user_data)(struct pss_webrtc *pss, void *data);
444 struct lws_vhost *(*get_vhost)(struct vhd_webrtc *vhd);
445 struct lws_context *(*get_context)(struct vhd_webrtc *vhd);
446 void (*set_on_media)(struct vhd_webrtc *vhd, lws_webrtc_on_media_cb cb);
447
448 uint8_t (*get_video_pt)(struct pss_webrtc *pss);
449 uint8_t (*get_audio_pt)(struct pss_webrtc *pss);
450
451 uint8_t (*get_video_pt_h264)(struct pss_webrtc *pss);
452 uint8_t (*get_video_pt_av1)(struct pss_webrtc *pss);
453 uint16_t (*get_seq_video)(struct pss_webrtc *pss);
454 int (*create_offer)(struct pss_webrtc *pss);
455};
456
457#if defined(LWS_WITH_PLUGINS_BUILTIN)
458
459/* provide exports for builtin plugin protocols */
460
461extern const struct lws_protocols post_demo_protocols[1];
462extern const struct lws_protocols lws_raw_proxy_protocols[1];
463extern const struct lws_protocols lws_status_protocols[1];
464extern const struct lws_protocols lws_mirror_protocols[1];
465extern const struct lws_protocols lws_ssh_base_protocols[2];
466extern const struct lws_protocols post_demo_protocols[1];
467extern const struct lws_protocols dumb_increment_protocols[1];
468extern const struct lws_protocols deaddrop_protocols[1];
469extern const struct lws_protocols lws_raw_test_protocols[1];
470extern const struct lws_protocols lws_sshd_demo_protocols[1];
471extern const struct lws_protocols lws_acme_client_protocols[1];
472extern const struct lws_protocols client_loopback_test_protocols[1];
473extern const struct lws_protocols fulltext_demo_protocols[1];
474extern const struct lws_protocols lws_openmetrics_export_protocols[
475#if defined(LWS_WITH_SERVER) && defined(LWS_WITH_CLIENT) && defined(LWS_ROLE_WS)
476 4
477#else
478#if defined(LWS_WITH_SERVER)
479 3
480#else
481 1
482#endif
483#endif
484 ];
485extern const struct lws_protocols lws_dht_object_store_protocols[];
486extern const struct lws_protocols lws_log_ingest_protocols[1];
487
488#define LWSOMPROIDX_DIRECT_HTTP_SERVER 0
489#define LWSOMPROIDX_PROX_HTTP_SERVER 1
490#define LWSOMPROIDX_PROX_WS_SERVER 2
491#define LWSOMPROIDX_PROX_WS_CLIENT 3
492
493#endif
494
495typedef void (*lws_dht_store_completion_cb_t)(void *closure, int result);
496
497
498
lws_plugin_header_t hdr
const struct lws_event_loop_ops * ops
lws_plugin_header_t hdr
void(* deinit)(struct lws_context *cx)
int(* init)(struct lws_context *cx)
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)