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
232lws_protocol_init(struct lws_context *context);
233
234#define LWS_PLUGIN_API_MAGIC 192
235
236/*
237 * Abstract plugin header for any kind of plugin class, always at top of
238 * actual class plugin export type.
239 *
240 * The export type object must be exported with the same name as the plugin
241 * file, eg, libmyplugin.so must export a const one of these as the symbol
242 * "myplugin".
243 *
244 * That is the only expected export from the plugin.
245 */
246
247typedef struct lws_plugin_header {
248 const char *name;
249 const char *_class;
250 const char *lws_build_hash; /* set to LWS_BUILD_HASH */
251
252 unsigned int api_magic;
253 /* set to LWS_PLUGIN_API_MAGIC at plugin build time */
254
255 unsigned int priority;
258
259 /* plugin-class specific superclass data follows */
261
262/*
263 * "lws_protocol_plugin" class export, for lws_protocol implementations done
264 * as plugins
265 */
274
275
276/*
277 * This is the dynamic, runtime created part of the plugin instantiation.
278 * These are kept in a linked-list and destroyed with the context.
279 */
280
282 struct lws_plugin *list;
283
285
286 union {
287#if defined(LWS_WITH_LIBUV) && defined(UV_ERRNO_MAP)
288#if (UV_VERSION_MAJOR > 0)
289 uv_lib_t lib;
290#endif
291#endif
292 void *l;
293 } u;
294};
295
296/*
297 * Event lib library plugin type (when LWS_WITH_EVLIB_PLUGINS)
298 * Public so new event libs can equally be supported outside lws itself
299 */
300
305
306typedef int (*each_plugin_cb_t)(struct lws_plugin *p, void *user);
307
330lws_plugins_init(struct lws_plugin **pplugin, const char * const *d,
331 const char *_class, const char *filter,
332 each_plugin_cb_t each, void *each_user);
333
349 void *each_user);
350
351
352struct pss_webrtc;
353struct vhd_webrtc;
354struct lws_webrtc_peer_media;
355
356typedef void (*lws_webrtc_on_media_cb)(struct lws *wsi_ws, int tid, const uint8_t *buf, size_t len, int marker, uint32_t timestamp);
357
358typedef int (*lws_webrtc_session_iter_cb)(struct pss_webrtc *pss, void *user);
359
364
365#define LWS_WEBRTC_OPS_ABI_VERSION 9
366
369
370 int (*send_video)(struct lws_webrtc_peer_media *media, const uint8_t *buf, size_t len, int codec, uint32_t pts);
371 int (*send_audio)(struct lws_webrtc_peer_media *media, const uint8_t *buf, size_t len, uint32_t timestamp);
372 int (*send_text)(struct pss_webrtc *pss, const char *buf, size_t len);
373 int (*send_pli)(struct pss_webrtc *pss);
374 void (*media_ref)(struct lws_webrtc_peer_media *media);
375 void (*media_unref)(struct lws_webrtc_peer_media **pmedia);
376 int (*foreach_session)(struct vhd_webrtc *vhd, lws_webrtc_session_iter_cb cb, void *user);
377 struct lws_webrtc_peer_media *(*get_media)(struct pss_webrtc *pss);
378 int (*shared_callback)(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len, struct vhd_webrtc *vhd);
379
380 void *(*get_user_data)(struct pss_webrtc *pss);
381 void (*set_user_data)(struct pss_webrtc *pss, void *data);
382 struct lws_vhost *(*get_vhost)(struct vhd_webrtc *vhd);
383 struct lws_context *(*get_context)(struct vhd_webrtc *vhd);
384 void (*set_on_media)(struct vhd_webrtc *vhd, lws_webrtc_on_media_cb cb);
385
386 uint8_t (*get_video_pt)(struct pss_webrtc *pss);
387 uint8_t (*get_audio_pt)(struct pss_webrtc *pss);
388
389 uint8_t (*get_video_pt_h264)(struct pss_webrtc *pss);
390 uint8_t (*get_video_pt_av1)(struct pss_webrtc *pss);
391 uint16_t (*get_seq_video)(struct pss_webrtc *pss);
392 int (*create_offer)(struct pss_webrtc *pss);
393};
394
395#if defined(LWS_WITH_PLUGINS_BUILTIN)
396
397/* provide exports for builtin plugin protocols */
398
399extern const struct lws_protocols post_demo_protocols[1];
400extern const struct lws_protocols lws_raw_proxy_protocols[1];
401extern const struct lws_protocols lws_status_protocols[1];
402extern const struct lws_protocols lws_mirror_protocols[1];
403extern const struct lws_protocols lws_ssh_base_protocols[2];
404extern const struct lws_protocols post_demo_protocols[1];
405extern const struct lws_protocols dumb_increment_protocols[1];
406extern const struct lws_protocols deaddrop_protocols[1];
407extern const struct lws_protocols lws_raw_test_protocols[1];
408extern const struct lws_protocols lws_sshd_demo_protocols[1];
409extern const struct lws_protocols lws_acme_client_protocols[1];
410extern const struct lws_protocols client_loopback_test_protocols[1];
411extern const struct lws_protocols fulltext_demo_protocols[1];
412extern const struct lws_protocols lws_openmetrics_export_protocols[
413#if defined(LWS_WITH_SERVER) && defined(LWS_WITH_CLIENT) && defined(LWS_ROLE_WS)
414 4
415#else
416#if defined(LWS_WITH_SERVER)
417 3
418#else
419 1
420#endif
421#endif
422 ];
423extern const struct lws_protocols lws_dht_object_store_protocols[];
424
425#define LWSOMPROIDX_DIRECT_HTTP_SERVER 0
426#define LWSOMPROIDX_PROX_HTTP_SERVER 1
427#define LWSOMPROIDX_PROX_WS_SERVER 2
428#define LWSOMPROIDX_PROX_WS_CLIENT 3
429
430#endif
431
432typedef void (*lws_dht_store_completion_cb_t)(void *closure, int result);
433
434
435
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
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
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