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 union {
313#if defined(LWS_WITH_LIBUV) && defined(UV_ERRNO_MAP)
314#if (UV_VERSION_MAJOR > 0)
315 uv_lib_t lib;
316#endif
317#endif
318 void *l;
319 } u;
320};
321
322/*
323 * Event lib library plugin type (when LWS_WITH_EVLIB_PLUGINS)
324 * Public so new event libs can equally be supported outside lws itself
325 */
326
331
332typedef int (*each_plugin_cb_t)(struct lws_plugin *p, void *user);
333
356lws_plugins_init(struct lws_plugin **pplugin, const char * const *d,
357 const char *_class, const char *filter,
358 each_plugin_cb_t each, void *each_user);
359
375 void *each_user);
376
377
378struct pss_webrtc;
379struct vhd_webrtc;
380struct lws_webrtc_peer_media;
381
382typedef void (*lws_webrtc_on_media_cb)(struct lws *wsi_ws, int tid, const uint8_t *buf, size_t len, int marker, uint32_t timestamp);
383
384typedef int (*lws_webrtc_session_iter_cb)(struct pss_webrtc *pss, void *user);
385
390
391#define LWS_WEBRTC_OPS_ABI_VERSION 9
392
395
396 int (*send_video)(struct lws_webrtc_peer_media *media, const uint8_t *buf, size_t len, int codec, uint32_t pts);
397 int (*send_audio)(struct lws_webrtc_peer_media *media, const uint8_t *buf, size_t len, uint32_t timestamp);
398 int (*send_text)(struct pss_webrtc *pss, const char *buf, size_t len);
399 int (*send_pli)(struct pss_webrtc *pss);
400 void (*media_ref)(struct lws_webrtc_peer_media *media);
401 void (*media_unref)(struct lws_webrtc_peer_media **pmedia);
402 int (*foreach_session)(struct vhd_webrtc *vhd, lws_webrtc_session_iter_cb cb, void *user);
403 struct lws_webrtc_peer_media *(*get_media)(struct pss_webrtc *pss);
404 int (*shared_callback)(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len, struct vhd_webrtc *vhd);
405
406 void *(*get_user_data)(struct pss_webrtc *pss);
407 void (*set_user_data)(struct pss_webrtc *pss, void *data);
408 struct lws_vhost *(*get_vhost)(struct vhd_webrtc *vhd);
409 struct lws_context *(*get_context)(struct vhd_webrtc *vhd);
410 void (*set_on_media)(struct vhd_webrtc *vhd, lws_webrtc_on_media_cb cb);
411
412 uint8_t (*get_video_pt)(struct pss_webrtc *pss);
413 uint8_t (*get_audio_pt)(struct pss_webrtc *pss);
414
415 uint8_t (*get_video_pt_h264)(struct pss_webrtc *pss);
416 uint8_t (*get_video_pt_av1)(struct pss_webrtc *pss);
417 uint16_t (*get_seq_video)(struct pss_webrtc *pss);
418 int (*create_offer)(struct pss_webrtc *pss);
419};
420
421#if defined(LWS_WITH_PLUGINS_BUILTIN)
422
423/* provide exports for builtin plugin protocols */
424
425extern const struct lws_protocols post_demo_protocols[1];
426extern const struct lws_protocols lws_raw_proxy_protocols[1];
427extern const struct lws_protocols lws_status_protocols[1];
428extern const struct lws_protocols lws_mirror_protocols[1];
429extern const struct lws_protocols lws_ssh_base_protocols[2];
430extern const struct lws_protocols post_demo_protocols[1];
431extern const struct lws_protocols dumb_increment_protocols[1];
432extern const struct lws_protocols deaddrop_protocols[1];
433extern const struct lws_protocols lws_raw_test_protocols[1];
434extern const struct lws_protocols lws_sshd_demo_protocols[1];
435extern const struct lws_protocols lws_acme_client_protocols[1];
436extern const struct lws_protocols client_loopback_test_protocols[1];
437extern const struct lws_protocols fulltext_demo_protocols[1];
438extern const struct lws_protocols lws_openmetrics_export_protocols[
439#if defined(LWS_WITH_SERVER) && defined(LWS_WITH_CLIENT) && defined(LWS_ROLE_WS)
440 4
441#else
442#if defined(LWS_WITH_SERVER)
443 3
444#else
445 1
446#endif
447#endif
448 ];
449extern const struct lws_protocols lws_dht_object_store_protocols[];
450
451#define LWSOMPROIDX_DIRECT_HTTP_SERVER 0
452#define LWSOMPROIDX_PROX_HTTP_SERVER 1
453#define LWSOMPROIDX_PROX_WS_SERVER 2
454#define LWSOMPROIDX_PROX_WS_CLIENT 3
455
456#endif
457
458typedef void (*lws_dht_store_completion_cb_t)(void *closure, int result);
459
460
461
const lws_plugin_header_t * hdr
uint8_t(* get_video_pt_av1)(struct pss_webrtc *pss)
lws_plugin_header_t hdr
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)
struct lws_plugin * list
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)
const struct lws_event_loop_ops * ops
int(* send_text)(struct pss_webrtc *pss, const char *buf, size_t len)
lws_plugin_header_t hdr
int(* send_pli)(struct pss_webrtc *pss)
lws_callback_function * callback
const struct lws_protocols * protocols
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)
union lws_plugin::@212075251220221362023025000075256263262302222360 u
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