add audio render to sync vidoe render
This commit is contained in:
parent
103b3101e5
commit
5d96f91a26
2
Thirdparty/zeromq/BUILD_INFO
vendored
Normal file
2
Thirdparty/zeromq/BUILD_INFO
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
CRTLinkage: dynamic
|
||||
LibraryLinkage: dynamic
|
8
Thirdparty/zeromq/CONTROL
vendored
Normal file
8
Thirdparty/zeromq/CONTROL
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
Package: zeromq
|
||||
Version: 4.3.5
|
||||
Port-Version: 1
|
||||
Depends: vcpkg-cmake, vcpkg-cmake-config
|
||||
Architecture: x64-windows
|
||||
Multi-Arch: same
|
||||
Abi: 48055f4994a97a653c3cbc44973eeba770ab272f83c012f810b1343e1b945c7a
|
||||
Description: The ZeroMQ lightweight messaging kernel is a library which extends the standard socket interfaces with features traditionally provided by specialised messaging middleware products
|
BIN
Thirdparty/zeromq/debug/lib/libzmq-mt-gd-4_3_5.lib
vendored
Normal file
BIN
Thirdparty/zeromq/debug/lib/libzmq-mt-gd-4_3_5.lib
vendored
Normal file
Binary file not shown.
13
Thirdparty/zeromq/debug/lib/pkgconfig/libzmq.pc
vendored
Normal file
13
Thirdparty/zeromq/debug/lib/pkgconfig/libzmq.pc
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
prefix=${pcfiledir}/../..
|
||||
exec_prefix=${prefix}
|
||||
libdir=${prefix}/lib
|
||||
includedir=${prefix}/../include
|
||||
|
||||
Name: libzmq
|
||||
Description: 0MQ c++ library
|
||||
Version: 4.3.5
|
||||
Libs: "-L${libdir}" -lzmq
|
||||
Libs.private: -lstdc++
|
||||
Requires.private:
|
||||
Cflags: "-I${includedir}"
|
||||
|
787
Thirdparty/zeromq/include/zmq.h
vendored
Normal file
787
Thirdparty/zeromq/include/zmq.h
vendored
Normal file
@ -0,0 +1,787 @@
|
||||
/* SPDX-License-Identifier: MPL-2.0 */
|
||||
/* *************************************************************************
|
||||
NOTE to contributors. This file comprises the principal public contract
|
||||
for ZeroMQ API users. Any change to this file supplied in a stable
|
||||
release SHOULD not break existing applications.
|
||||
In practice this means that the value of constants must not change, and
|
||||
that old values may not be reused for new constants.
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __ZMQ_H_INCLUDED__
|
||||
#define __ZMQ_H_INCLUDED__
|
||||
|
||||
/* Version macros for compile-time API version detection */
|
||||
#define ZMQ_VERSION_MAJOR 4
|
||||
#define ZMQ_VERSION_MINOR 3
|
||||
#define ZMQ_VERSION_PATCH 5
|
||||
|
||||
#define ZMQ_MAKE_VERSION(major, minor, patch) \
|
||||
((major) *10000 + (minor) *100 + (patch))
|
||||
#define ZMQ_VERSION \
|
||||
ZMQ_MAKE_VERSION (ZMQ_VERSION_MAJOR, ZMQ_VERSION_MINOR, ZMQ_VERSION_PATCH)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if !defined _WIN32_WCE
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* Handle DSO symbol visibility */
|
||||
#if defined ZMQ_NO_EXPORT
|
||||
#define ZMQ_EXPORT
|
||||
#else
|
||||
#if defined _WIN32
|
||||
#if defined ZMQ_STATIC
|
||||
#define ZMQ_EXPORT
|
||||
#elif defined DLL_EXPORT
|
||||
#define ZMQ_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define ZMQ_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#if defined __SUNPRO_C || defined __SUNPRO_CC
|
||||
#define ZMQ_EXPORT __global
|
||||
#elif (defined __GNUC__ && __GNUC__ >= 4) || defined __INTEL_COMPILER
|
||||
#define ZMQ_EXPORT __attribute__ ((visibility ("default")))
|
||||
#else
|
||||
#define ZMQ_EXPORT
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Define integer types needed for event interface */
|
||||
#define ZMQ_DEFINED_STDINT 1
|
||||
#if defined ZMQ_HAVE_SOLARIS || defined ZMQ_HAVE_OPENVMS
|
||||
#include <inttypes.h>
|
||||
#elif defined _MSC_VER && _MSC_VER < 1600
|
||||
#ifndef uint64_t
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#endif
|
||||
#ifndef int32_t
|
||||
typedef __int32 int32_t;
|
||||
#endif
|
||||
#ifndef uint32_t
|
||||
typedef unsigned __int32 uint32_t;
|
||||
#endif
|
||||
#ifndef uint16_t
|
||||
typedef unsigned __int16 uint16_t;
|
||||
#endif
|
||||
#ifndef uint8_t
|
||||
typedef unsigned __int8 uint8_t;
|
||||
#endif
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#if !defined _WIN32
|
||||
// needed for sigset_t definition in zmq_ppoll
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
// 32-bit AIX's pollfd struct members are called reqevents and rtnevents so it
|
||||
// defines compatibility macros for them. Need to include that header first to
|
||||
// stop build failures since zmq_pollset_t defines them as events and revents.
|
||||
#ifdef ZMQ_HAVE_AIX
|
||||
#include <poll.h>
|
||||
#endif
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* 0MQ errors. */
|
||||
/******************************************************************************/
|
||||
|
||||
/* A number random enough not to collide with different errno ranges on */
|
||||
/* different OSes. The assumption is that error_t is at least 32-bit type. */
|
||||
#define ZMQ_HAUSNUMERO 156384712
|
||||
|
||||
/* On Windows platform some of the standard POSIX errnos are not defined. */
|
||||
#ifndef ENOTSUP
|
||||
#define ENOTSUP (ZMQ_HAUSNUMERO + 1)
|
||||
#endif
|
||||
#ifndef EPROTONOSUPPORT
|
||||
#define EPROTONOSUPPORT (ZMQ_HAUSNUMERO + 2)
|
||||
#endif
|
||||
#ifndef ENOBUFS
|
||||
#define ENOBUFS (ZMQ_HAUSNUMERO + 3)
|
||||
#endif
|
||||
#ifndef ENETDOWN
|
||||
#define ENETDOWN (ZMQ_HAUSNUMERO + 4)
|
||||
#endif
|
||||
#ifndef EADDRINUSE
|
||||
#define EADDRINUSE (ZMQ_HAUSNUMERO + 5)
|
||||
#endif
|
||||
#ifndef EADDRNOTAVAIL
|
||||
#define EADDRNOTAVAIL (ZMQ_HAUSNUMERO + 6)
|
||||
#endif
|
||||
#ifndef ECONNREFUSED
|
||||
#define ECONNREFUSED (ZMQ_HAUSNUMERO + 7)
|
||||
#endif
|
||||
#ifndef EINPROGRESS
|
||||
#define EINPROGRESS (ZMQ_HAUSNUMERO + 8)
|
||||
#endif
|
||||
#ifndef ENOTSOCK
|
||||
#define ENOTSOCK (ZMQ_HAUSNUMERO + 9)
|
||||
#endif
|
||||
#ifndef EMSGSIZE
|
||||
#define EMSGSIZE (ZMQ_HAUSNUMERO + 10)
|
||||
#endif
|
||||
#ifndef EAFNOSUPPORT
|
||||
#define EAFNOSUPPORT (ZMQ_HAUSNUMERO + 11)
|
||||
#endif
|
||||
#ifndef ENETUNREACH
|
||||
#define ENETUNREACH (ZMQ_HAUSNUMERO + 12)
|
||||
#endif
|
||||
#ifndef ECONNABORTED
|
||||
#define ECONNABORTED (ZMQ_HAUSNUMERO + 13)
|
||||
#endif
|
||||
#ifndef ECONNRESET
|
||||
#define ECONNRESET (ZMQ_HAUSNUMERO + 14)
|
||||
#endif
|
||||
#ifndef ENOTCONN
|
||||
#define ENOTCONN (ZMQ_HAUSNUMERO + 15)
|
||||
#endif
|
||||
#ifndef ETIMEDOUT
|
||||
#define ETIMEDOUT (ZMQ_HAUSNUMERO + 16)
|
||||
#endif
|
||||
#ifndef EHOSTUNREACH
|
||||
#define EHOSTUNREACH (ZMQ_HAUSNUMERO + 17)
|
||||
#endif
|
||||
#ifndef ENETRESET
|
||||
#define ENETRESET (ZMQ_HAUSNUMERO + 18)
|
||||
#endif
|
||||
|
||||
/* Native 0MQ error codes. */
|
||||
#define EFSM (ZMQ_HAUSNUMERO + 51)
|
||||
#define ENOCOMPATPROTO (ZMQ_HAUSNUMERO + 52)
|
||||
#define ETERM (ZMQ_HAUSNUMERO + 53)
|
||||
#define EMTHREAD (ZMQ_HAUSNUMERO + 54)
|
||||
|
||||
/* This function retrieves the errno as it is known to 0MQ library. The goal */
|
||||
/* of this function is to make the code 100% portable, including where 0MQ */
|
||||
/* compiled with certain CRT library (on Windows) is linked to an */
|
||||
/* application that uses different CRT library. */
|
||||
ZMQ_EXPORT int zmq_errno (void);
|
||||
|
||||
/* Resolves system errors and 0MQ errors to human-readable string. */
|
||||
ZMQ_EXPORT const char *zmq_strerror (int errnum_);
|
||||
|
||||
/* Run-time API version detection */
|
||||
ZMQ_EXPORT void zmq_version (int *major_, int *minor_, int *patch_);
|
||||
|
||||
/******************************************************************************/
|
||||
/* 0MQ infrastructure (a.k.a. context) initialisation & termination. */
|
||||
/******************************************************************************/
|
||||
|
||||
/* Context options */
|
||||
#define ZMQ_IO_THREADS 1
|
||||
#define ZMQ_MAX_SOCKETS 2
|
||||
#define ZMQ_SOCKET_LIMIT 3
|
||||
#define ZMQ_THREAD_PRIORITY 3
|
||||
#define ZMQ_THREAD_SCHED_POLICY 4
|
||||
#define ZMQ_MAX_MSGSZ 5
|
||||
#define ZMQ_MSG_T_SIZE 6
|
||||
#define ZMQ_THREAD_AFFINITY_CPU_ADD 7
|
||||
#define ZMQ_THREAD_AFFINITY_CPU_REMOVE 8
|
||||
#define ZMQ_THREAD_NAME_PREFIX 9
|
||||
|
||||
/* Default for new contexts */
|
||||
#define ZMQ_IO_THREADS_DFLT 1
|
||||
#define ZMQ_MAX_SOCKETS_DFLT 1023
|
||||
#define ZMQ_THREAD_PRIORITY_DFLT -1
|
||||
#define ZMQ_THREAD_SCHED_POLICY_DFLT -1
|
||||
|
||||
ZMQ_EXPORT void *zmq_ctx_new (void);
|
||||
ZMQ_EXPORT int zmq_ctx_term (void *context_);
|
||||
ZMQ_EXPORT int zmq_ctx_shutdown (void *context_);
|
||||
ZMQ_EXPORT int zmq_ctx_set (void *context_, int option_, int optval_);
|
||||
ZMQ_EXPORT int zmq_ctx_get (void *context_, int option_);
|
||||
|
||||
/* Old (legacy) API */
|
||||
ZMQ_EXPORT void *zmq_init (int io_threads_);
|
||||
ZMQ_EXPORT int zmq_term (void *context_);
|
||||
ZMQ_EXPORT int zmq_ctx_destroy (void *context_);
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* 0MQ message definition. */
|
||||
/******************************************************************************/
|
||||
|
||||
/* Some architectures, like sparc64 and some variants of aarch64, enforce pointer
|
||||
* alignment and raise sigbus on violations. Make sure applications allocate
|
||||
* zmq_msg_t on addresses aligned on a pointer-size boundary to avoid this issue.
|
||||
*/
|
||||
typedef struct zmq_msg_t
|
||||
{
|
||||
#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_ARM64))
|
||||
__declspec(align (8)) unsigned char _[64];
|
||||
#elif defined(_MSC_VER) \
|
||||
&& (defined(_M_IX86) || defined(_M_ARM_ARMV7VE) || defined(_M_ARM))
|
||||
__declspec(align (4)) unsigned char _[64];
|
||||
#elif defined(__GNUC__) || defined(__INTEL_COMPILER) \
|
||||
|| (defined(__SUNPRO_C) && __SUNPRO_C >= 0x590) \
|
||||
|| (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x590)
|
||||
unsigned char _[64] __attribute__ ((aligned (sizeof (void *))));
|
||||
#else
|
||||
unsigned char _[64];
|
||||
#endif
|
||||
} zmq_msg_t;
|
||||
|
||||
typedef void (zmq_free_fn) (void *data_, void *hint_);
|
||||
|
||||
ZMQ_EXPORT int zmq_msg_init (zmq_msg_t *msg_);
|
||||
ZMQ_EXPORT int zmq_msg_init_size (zmq_msg_t *msg_, size_t size_);
|
||||
ZMQ_EXPORT int zmq_msg_init_data (
|
||||
zmq_msg_t *msg_, void *data_, size_t size_, zmq_free_fn *ffn_, void *hint_);
|
||||
ZMQ_EXPORT int zmq_msg_send (zmq_msg_t *msg_, void *s_, int flags_);
|
||||
ZMQ_EXPORT int zmq_msg_recv (zmq_msg_t *msg_, void *s_, int flags_);
|
||||
ZMQ_EXPORT int zmq_msg_close (zmq_msg_t *msg_);
|
||||
ZMQ_EXPORT int zmq_msg_move (zmq_msg_t *dest_, zmq_msg_t *src_);
|
||||
ZMQ_EXPORT int zmq_msg_copy (zmq_msg_t *dest_, zmq_msg_t *src_);
|
||||
ZMQ_EXPORT void *zmq_msg_data (zmq_msg_t *msg_);
|
||||
ZMQ_EXPORT size_t zmq_msg_size (const zmq_msg_t *msg_);
|
||||
ZMQ_EXPORT int zmq_msg_more (const zmq_msg_t *msg_);
|
||||
ZMQ_EXPORT int zmq_msg_get (const zmq_msg_t *msg_, int property_);
|
||||
ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg_, int property_, int optval_);
|
||||
ZMQ_EXPORT const char *zmq_msg_gets (const zmq_msg_t *msg_,
|
||||
const char *property_);
|
||||
|
||||
/******************************************************************************/
|
||||
/* 0MQ socket definition. */
|
||||
/******************************************************************************/
|
||||
|
||||
/* Socket types. */
|
||||
#define ZMQ_PAIR 0
|
||||
#define ZMQ_PUB 1
|
||||
#define ZMQ_SUB 2
|
||||
#define ZMQ_REQ 3
|
||||
#define ZMQ_REP 4
|
||||
#define ZMQ_DEALER 5
|
||||
#define ZMQ_ROUTER 6
|
||||
#define ZMQ_PULL 7
|
||||
#define ZMQ_PUSH 8
|
||||
#define ZMQ_XPUB 9
|
||||
#define ZMQ_XSUB 10
|
||||
#define ZMQ_STREAM 11
|
||||
|
||||
/* Deprecated aliases */
|
||||
#define ZMQ_XREQ ZMQ_DEALER
|
||||
#define ZMQ_XREP ZMQ_ROUTER
|
||||
|
||||
/* Socket options. */
|
||||
#define ZMQ_AFFINITY 4
|
||||
#define ZMQ_ROUTING_ID 5
|
||||
#define ZMQ_SUBSCRIBE 6
|
||||
#define ZMQ_UNSUBSCRIBE 7
|
||||
#define ZMQ_RATE 8
|
||||
#define ZMQ_RECOVERY_IVL 9
|
||||
#define ZMQ_SNDBUF 11
|
||||
#define ZMQ_RCVBUF 12
|
||||
#define ZMQ_RCVMORE 13
|
||||
#define ZMQ_FD 14
|
||||
#define ZMQ_EVENTS 15
|
||||
#define ZMQ_TYPE 16
|
||||
#define ZMQ_LINGER 17
|
||||
#define ZMQ_RECONNECT_IVL 18
|
||||
#define ZMQ_BACKLOG 19
|
||||
#define ZMQ_RECONNECT_IVL_MAX 21
|
||||
#define ZMQ_MAXMSGSIZE 22
|
||||
#define ZMQ_SNDHWM 23
|
||||
#define ZMQ_RCVHWM 24
|
||||
#define ZMQ_MULTICAST_HOPS 25
|
||||
#define ZMQ_RCVTIMEO 27
|
||||
#define ZMQ_SNDTIMEO 28
|
||||
#define ZMQ_LAST_ENDPOINT 32
|
||||
#define ZMQ_ROUTER_MANDATORY 33
|
||||
#define ZMQ_TCP_KEEPALIVE 34
|
||||
#define ZMQ_TCP_KEEPALIVE_CNT 35
|
||||
#define ZMQ_TCP_KEEPALIVE_IDLE 36
|
||||
#define ZMQ_TCP_KEEPALIVE_INTVL 37
|
||||
#define ZMQ_IMMEDIATE 39
|
||||
#define ZMQ_XPUB_VERBOSE 40
|
||||
#define ZMQ_ROUTER_RAW 41
|
||||
#define ZMQ_IPV6 42
|
||||
#define ZMQ_MECHANISM 43
|
||||
#define ZMQ_PLAIN_SERVER 44
|
||||
#define ZMQ_PLAIN_USERNAME 45
|
||||
#define ZMQ_PLAIN_PASSWORD 46
|
||||
#define ZMQ_CURVE_SERVER 47
|
||||
#define ZMQ_CURVE_PUBLICKEY 48
|
||||
#define ZMQ_CURVE_SECRETKEY 49
|
||||
#define ZMQ_CURVE_SERVERKEY 50
|
||||
#define ZMQ_PROBE_ROUTER 51
|
||||
#define ZMQ_REQ_CORRELATE 52
|
||||
#define ZMQ_REQ_RELAXED 53
|
||||
#define ZMQ_CONFLATE 54
|
||||
#define ZMQ_ZAP_DOMAIN 55
|
||||
#define ZMQ_ROUTER_HANDOVER 56
|
||||
#define ZMQ_TOS 57
|
||||
#define ZMQ_CONNECT_ROUTING_ID 61
|
||||
#define ZMQ_GSSAPI_SERVER 62
|
||||
#define ZMQ_GSSAPI_PRINCIPAL 63
|
||||
#define ZMQ_GSSAPI_SERVICE_PRINCIPAL 64
|
||||
#define ZMQ_GSSAPI_PLAINTEXT 65
|
||||
#define ZMQ_HANDSHAKE_IVL 66
|
||||
#define ZMQ_SOCKS_PROXY 68
|
||||
#define ZMQ_XPUB_NODROP 69
|
||||
#define ZMQ_BLOCKY 70
|
||||
#define ZMQ_XPUB_MANUAL 71
|
||||
#define ZMQ_XPUB_WELCOME_MSG 72
|
||||
#define ZMQ_STREAM_NOTIFY 73
|
||||
#define ZMQ_INVERT_MATCHING 74
|
||||
#define ZMQ_HEARTBEAT_IVL 75
|
||||
#define ZMQ_HEARTBEAT_TTL 76
|
||||
#define ZMQ_HEARTBEAT_TIMEOUT 77
|
||||
#define ZMQ_XPUB_VERBOSER 78
|
||||
#define ZMQ_CONNECT_TIMEOUT 79
|
||||
#define ZMQ_TCP_MAXRT 80
|
||||
#define ZMQ_THREAD_SAFE 81
|
||||
#define ZMQ_MULTICAST_MAXTPDU 84
|
||||
#define ZMQ_VMCI_BUFFER_SIZE 85
|
||||
#define ZMQ_VMCI_BUFFER_MIN_SIZE 86
|
||||
#define ZMQ_VMCI_BUFFER_MAX_SIZE 87
|
||||
#define ZMQ_VMCI_CONNECT_TIMEOUT 88
|
||||
#define ZMQ_USE_FD 89
|
||||
#define ZMQ_GSSAPI_PRINCIPAL_NAMETYPE 90
|
||||
#define ZMQ_GSSAPI_SERVICE_PRINCIPAL_NAMETYPE 91
|
||||
#define ZMQ_BINDTODEVICE 92
|
||||
|
||||
/* Message options */
|
||||
#define ZMQ_MORE 1
|
||||
#define ZMQ_SHARED 3
|
||||
|
||||
/* Send/recv options. */
|
||||
#define ZMQ_DONTWAIT 1
|
||||
#define ZMQ_SNDMORE 2
|
||||
|
||||
/* Security mechanisms */
|
||||
#define ZMQ_NULL 0
|
||||
#define ZMQ_PLAIN 1
|
||||
#define ZMQ_CURVE 2
|
||||
#define ZMQ_GSSAPI 3
|
||||
|
||||
/* RADIO-DISH protocol */
|
||||
#define ZMQ_GROUP_MAX_LENGTH 255
|
||||
|
||||
/* Deprecated options and aliases */
|
||||
#define ZMQ_IDENTITY ZMQ_ROUTING_ID
|
||||
#define ZMQ_CONNECT_RID ZMQ_CONNECT_ROUTING_ID
|
||||
#define ZMQ_TCP_ACCEPT_FILTER 38
|
||||
#define ZMQ_IPC_FILTER_PID 58
|
||||
#define ZMQ_IPC_FILTER_UID 59
|
||||
#define ZMQ_IPC_FILTER_GID 60
|
||||
#define ZMQ_IPV4ONLY 31
|
||||
#define ZMQ_DELAY_ATTACH_ON_CONNECT ZMQ_IMMEDIATE
|
||||
#define ZMQ_NOBLOCK ZMQ_DONTWAIT
|
||||
#define ZMQ_FAIL_UNROUTABLE ZMQ_ROUTER_MANDATORY
|
||||
#define ZMQ_ROUTER_BEHAVIOR ZMQ_ROUTER_MANDATORY
|
||||
|
||||
/* Deprecated Message options */
|
||||
#define ZMQ_SRCFD 2
|
||||
|
||||
/******************************************************************************/
|
||||
/* GSSAPI definitions */
|
||||
/******************************************************************************/
|
||||
|
||||
/* GSSAPI principal name types */
|
||||
#define ZMQ_GSSAPI_NT_HOSTBASED 0
|
||||
#define ZMQ_GSSAPI_NT_USER_NAME 1
|
||||
#define ZMQ_GSSAPI_NT_KRB5_PRINCIPAL 2
|
||||
|
||||
/******************************************************************************/
|
||||
/* 0MQ socket events and monitoring */
|
||||
/******************************************************************************/
|
||||
|
||||
/* Socket transport events (TCP, IPC and TIPC only) */
|
||||
|
||||
#define ZMQ_EVENT_CONNECTED 0x0001
|
||||
#define ZMQ_EVENT_CONNECT_DELAYED 0x0002
|
||||
#define ZMQ_EVENT_CONNECT_RETRIED 0x0004
|
||||
#define ZMQ_EVENT_LISTENING 0x0008
|
||||
#define ZMQ_EVENT_BIND_FAILED 0x0010
|
||||
#define ZMQ_EVENT_ACCEPTED 0x0020
|
||||
#define ZMQ_EVENT_ACCEPT_FAILED 0x0040
|
||||
#define ZMQ_EVENT_CLOSED 0x0080
|
||||
#define ZMQ_EVENT_CLOSE_FAILED 0x0100
|
||||
#define ZMQ_EVENT_DISCONNECTED 0x0200
|
||||
#define ZMQ_EVENT_MONITOR_STOPPED 0x0400
|
||||
#define ZMQ_EVENT_ALL 0xFFFF
|
||||
/* Unspecified system errors during handshake. Event value is an errno. */
|
||||
#define ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL 0x0800
|
||||
/* Handshake complete successfully with successful authentication (if *
|
||||
* enabled). Event value is unused. */
|
||||
#define ZMQ_EVENT_HANDSHAKE_SUCCEEDED 0x1000
|
||||
/* Protocol errors between ZMTP peers or between server and ZAP handler. *
|
||||
* Event value is one of ZMQ_PROTOCOL_ERROR_* */
|
||||
#define ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL 0x2000
|
||||
/* Failed authentication requests. Event value is the numeric ZAP status *
|
||||
* code, i.e. 300, 400 or 500. */
|
||||
#define ZMQ_EVENT_HANDSHAKE_FAILED_AUTH 0x4000
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_UNSPECIFIED 0x10000000
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_UNEXPECTED_COMMAND 0x10000001
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_SEQUENCE 0x10000002
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_KEY_EXCHANGE 0x10000003
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_UNSPECIFIED 0x10000011
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_MESSAGE 0x10000012
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_HELLO 0x10000013
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_INITIATE 0x10000014
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_ERROR 0x10000015
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_READY 0x10000016
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_WELCOME 0x10000017
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_METADATA 0x10000018
|
||||
// the following two may be due to erroneous configuration of a peer
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_CRYPTOGRAPHIC 0x11000001
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MECHANISM_MISMATCH 0x11000002
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_UNSPECIFIED 0x20000000
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_MALFORMED_REPLY 0x20000001
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_BAD_REQUEST_ID 0x20000002
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_BAD_VERSION 0x20000003
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_INVALID_STATUS_CODE 0x20000004
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_INVALID_METADATA 0x20000005
|
||||
#define ZMQ_PROTOCOL_ERROR_WS_UNSPECIFIED 0x30000000
|
||||
|
||||
ZMQ_EXPORT void *zmq_socket (void *, int type_);
|
||||
ZMQ_EXPORT int zmq_close (void *s_);
|
||||
ZMQ_EXPORT int
|
||||
zmq_setsockopt (void *s_, int option_, const void *optval_, size_t optvallen_);
|
||||
ZMQ_EXPORT int
|
||||
zmq_getsockopt (void *s_, int option_, void *optval_, size_t *optvallen_);
|
||||
ZMQ_EXPORT int zmq_bind (void *s_, const char *addr_);
|
||||
ZMQ_EXPORT int zmq_connect (void *s_, const char *addr_);
|
||||
ZMQ_EXPORT int zmq_unbind (void *s_, const char *addr_);
|
||||
ZMQ_EXPORT int zmq_disconnect (void *s_, const char *addr_);
|
||||
ZMQ_EXPORT int zmq_send (void *s_, const void *buf_, size_t len_, int flags_);
|
||||
ZMQ_EXPORT int
|
||||
zmq_send_const (void *s_, const void *buf_, size_t len_, int flags_);
|
||||
ZMQ_EXPORT int zmq_recv (void *s_, void *buf_, size_t len_, int flags_);
|
||||
ZMQ_EXPORT int zmq_socket_monitor (void *s_, const char *addr_, int events_);
|
||||
|
||||
/******************************************************************************/
|
||||
/* Hide socket fd type; this was before zmq_poller_event_t typedef below */
|
||||
/******************************************************************************/
|
||||
|
||||
#if defined _WIN32
|
||||
// Windows uses a pointer-sized unsigned integer to store the socket fd.
|
||||
#if defined _WIN64
|
||||
typedef unsigned __int64 zmq_fd_t;
|
||||
#else
|
||||
typedef unsigned int zmq_fd_t;
|
||||
#endif
|
||||
#else
|
||||
typedef int zmq_fd_t;
|
||||
#endif
|
||||
|
||||
/******************************************************************************/
|
||||
/* Deprecated I/O multiplexing. Prefer using zmq_poller API */
|
||||
/******************************************************************************/
|
||||
|
||||
#define ZMQ_POLLIN 1
|
||||
#define ZMQ_POLLOUT 2
|
||||
#define ZMQ_POLLERR 4
|
||||
#define ZMQ_POLLPRI 8
|
||||
|
||||
typedef struct zmq_pollitem_t
|
||||
{
|
||||
void *socket;
|
||||
zmq_fd_t fd;
|
||||
short events;
|
||||
short revents;
|
||||
} zmq_pollitem_t;
|
||||
|
||||
#define ZMQ_POLLITEMS_DFLT 16
|
||||
|
||||
ZMQ_EXPORT int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_);
|
||||
|
||||
/******************************************************************************/
|
||||
/* Message proxying */
|
||||
/******************************************************************************/
|
||||
|
||||
ZMQ_EXPORT int zmq_proxy (void *frontend_, void *backend_, void *capture_);
|
||||
ZMQ_EXPORT int zmq_proxy_steerable (void *frontend_,
|
||||
void *backend_,
|
||||
void *capture_,
|
||||
void *control_);
|
||||
|
||||
/******************************************************************************/
|
||||
/* Probe library capabilities */
|
||||
/******************************************************************************/
|
||||
|
||||
#define ZMQ_HAS_CAPABILITIES 1
|
||||
ZMQ_EXPORT int zmq_has (const char *capability_);
|
||||
|
||||
/* Deprecated aliases */
|
||||
#define ZMQ_STREAMER 1
|
||||
#define ZMQ_FORWARDER 2
|
||||
#define ZMQ_QUEUE 3
|
||||
|
||||
/* Deprecated methods */
|
||||
ZMQ_EXPORT int zmq_device (int type_, void *frontend_, void *backend_);
|
||||
ZMQ_EXPORT int zmq_sendmsg (void *s_, zmq_msg_t *msg_, int flags_);
|
||||
ZMQ_EXPORT int zmq_recvmsg (void *s_, zmq_msg_t *msg_, int flags_);
|
||||
struct iovec;
|
||||
ZMQ_EXPORT int
|
||||
zmq_sendiov (void *s_, struct iovec *iov_, size_t count_, int flags_);
|
||||
ZMQ_EXPORT int
|
||||
zmq_recviov (void *s_, struct iovec *iov_, size_t *count_, int flags_);
|
||||
|
||||
/******************************************************************************/
|
||||
/* Encryption functions */
|
||||
/******************************************************************************/
|
||||
|
||||
/* Encode data with Z85 encoding. Returns encoded data */
|
||||
ZMQ_EXPORT char *
|
||||
zmq_z85_encode (char *dest_, const uint8_t *data_, size_t size_);
|
||||
|
||||
/* Decode data with Z85 encoding. Returns decoded data */
|
||||
ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest_, const char *string_);
|
||||
|
||||
/* Generate z85-encoded public and private keypair with libsodium. */
|
||||
/* Returns 0 on success. */
|
||||
ZMQ_EXPORT int zmq_curve_keypair (char *z85_public_key_, char *z85_secret_key_);
|
||||
|
||||
/* Derive the z85-encoded public key from the z85-encoded secret key. */
|
||||
/* Returns 0 on success. */
|
||||
ZMQ_EXPORT int zmq_curve_public (char *z85_public_key_,
|
||||
const char *z85_secret_key_);
|
||||
|
||||
/******************************************************************************/
|
||||
/* Atomic utility methods */
|
||||
/******************************************************************************/
|
||||
|
||||
ZMQ_EXPORT void *zmq_atomic_counter_new (void);
|
||||
ZMQ_EXPORT void zmq_atomic_counter_set (void *counter_, int value_);
|
||||
ZMQ_EXPORT int zmq_atomic_counter_inc (void *counter_);
|
||||
ZMQ_EXPORT int zmq_atomic_counter_dec (void *counter_);
|
||||
ZMQ_EXPORT int zmq_atomic_counter_value (void *counter_);
|
||||
ZMQ_EXPORT void zmq_atomic_counter_destroy (void **counter_p_);
|
||||
|
||||
/******************************************************************************/
|
||||
/* Scheduling timers */
|
||||
/******************************************************************************/
|
||||
|
||||
#define ZMQ_HAVE_TIMERS
|
||||
|
||||
typedef void (zmq_timer_fn) (int timer_id, void *arg);
|
||||
|
||||
ZMQ_EXPORT void *zmq_timers_new (void);
|
||||
ZMQ_EXPORT int zmq_timers_destroy (void **timers_p);
|
||||
ZMQ_EXPORT int
|
||||
zmq_timers_add (void *timers, size_t interval, zmq_timer_fn handler, void *arg);
|
||||
ZMQ_EXPORT int zmq_timers_cancel (void *timers, int timer_id);
|
||||
ZMQ_EXPORT int
|
||||
zmq_timers_set_interval (void *timers, int timer_id, size_t interval);
|
||||
ZMQ_EXPORT int zmq_timers_reset (void *timers, int timer_id);
|
||||
ZMQ_EXPORT long zmq_timers_timeout (void *timers);
|
||||
ZMQ_EXPORT int zmq_timers_execute (void *timers);
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* These functions are not documented by man pages -- use at your own risk. */
|
||||
/* If you need these to be part of the formal ZMQ API, then (a) write a man */
|
||||
/* page, and (b) write a test case in tests. */
|
||||
/******************************************************************************/
|
||||
|
||||
/* Helper functions are used by perf tests so that they don't have to care */
|
||||
/* about minutiae of time-related functions on different OS platforms. */
|
||||
|
||||
/* Starts the stopwatch. Returns the handle to the watch. */
|
||||
ZMQ_EXPORT void *zmq_stopwatch_start (void);
|
||||
|
||||
/* Returns the number of microseconds elapsed since the stopwatch was */
|
||||
/* started, but does not stop or deallocate the stopwatch. */
|
||||
ZMQ_EXPORT unsigned long zmq_stopwatch_intermediate (void *watch_);
|
||||
|
||||
/* Stops the stopwatch. Returns the number of microseconds elapsed since */
|
||||
/* the stopwatch was started, and deallocates that watch. */
|
||||
ZMQ_EXPORT unsigned long zmq_stopwatch_stop (void *watch_);
|
||||
|
||||
/* Sleeps for specified number of seconds. */
|
||||
ZMQ_EXPORT void zmq_sleep (int seconds_);
|
||||
|
||||
typedef void (zmq_thread_fn) (void *);
|
||||
|
||||
/* Start a thread. Returns a handle to the thread. */
|
||||
ZMQ_EXPORT void *zmq_threadstart (zmq_thread_fn *func_, void *arg_);
|
||||
|
||||
/* Wait for thread to complete then free up resources. */
|
||||
ZMQ_EXPORT void zmq_threadclose (void *thread_);
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* These functions are DRAFT and disabled in stable releases, and subject to */
|
||||
/* change at ANY time until declared stable. */
|
||||
/******************************************************************************/
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
|
||||
/* DRAFT Socket types. */
|
||||
#define ZMQ_SERVER 12
|
||||
#define ZMQ_CLIENT 13
|
||||
#define ZMQ_RADIO 14
|
||||
#define ZMQ_DISH 15
|
||||
#define ZMQ_GATHER 16
|
||||
#define ZMQ_SCATTER 17
|
||||
#define ZMQ_DGRAM 18
|
||||
#define ZMQ_PEER 19
|
||||
#define ZMQ_CHANNEL 20
|
||||
|
||||
/* DRAFT Socket options. */
|
||||
#define ZMQ_ZAP_ENFORCE_DOMAIN 93
|
||||
#define ZMQ_LOOPBACK_FASTPATH 94
|
||||
#define ZMQ_METADATA 95
|
||||
#define ZMQ_MULTICAST_LOOP 96
|
||||
#define ZMQ_ROUTER_NOTIFY 97
|
||||
#define ZMQ_XPUB_MANUAL_LAST_VALUE 98
|
||||
#define ZMQ_SOCKS_USERNAME 99
|
||||
#define ZMQ_SOCKS_PASSWORD 100
|
||||
#define ZMQ_IN_BATCH_SIZE 101
|
||||
#define ZMQ_OUT_BATCH_SIZE 102
|
||||
#define ZMQ_WSS_KEY_PEM 103
|
||||
#define ZMQ_WSS_CERT_PEM 104
|
||||
#define ZMQ_WSS_TRUST_PEM 105
|
||||
#define ZMQ_WSS_HOSTNAME 106
|
||||
#define ZMQ_WSS_TRUST_SYSTEM 107
|
||||
#define ZMQ_ONLY_FIRST_SUBSCRIBE 108
|
||||
#define ZMQ_RECONNECT_STOP 109
|
||||
#define ZMQ_HELLO_MSG 110
|
||||
#define ZMQ_DISCONNECT_MSG 111
|
||||
#define ZMQ_PRIORITY 112
|
||||
#define ZMQ_BUSY_POLL 113
|
||||
#define ZMQ_HICCUP_MSG 114
|
||||
#define ZMQ_XSUB_VERBOSE_UNSUBSCRIBE 115
|
||||
#define ZMQ_TOPICS_COUNT 116
|
||||
#define ZMQ_NORM_MODE 117
|
||||
#define ZMQ_NORM_UNICAST_NACK 118
|
||||
#define ZMQ_NORM_BUFFER_SIZE 119
|
||||
#define ZMQ_NORM_SEGMENT_SIZE 120
|
||||
#define ZMQ_NORM_BLOCK_SIZE 121
|
||||
#define ZMQ_NORM_NUM_PARITY 122
|
||||
#define ZMQ_NORM_NUM_AUTOPARITY 123
|
||||
#define ZMQ_NORM_PUSH 124
|
||||
|
||||
/* DRAFT ZMQ_NORM_MODE options */
|
||||
#define ZMQ_NORM_FIXED 0
|
||||
#define ZMQ_NORM_CC 1
|
||||
#define ZMQ_NORM_CCL 2
|
||||
#define ZMQ_NORM_CCE 3
|
||||
#define ZMQ_NORM_CCE_ECNONLY 4
|
||||
|
||||
/* DRAFT ZMQ_RECONNECT_STOP options */
|
||||
#define ZMQ_RECONNECT_STOP_CONN_REFUSED 0x1
|
||||
#define ZMQ_RECONNECT_STOP_HANDSHAKE_FAILED 0x2
|
||||
#define ZMQ_RECONNECT_STOP_AFTER_DISCONNECT 0x4
|
||||
|
||||
/* DRAFT Context options */
|
||||
#define ZMQ_ZERO_COPY_RECV 10
|
||||
|
||||
/* DRAFT Context methods. */
|
||||
ZMQ_EXPORT int zmq_ctx_set_ext (void *context_,
|
||||
int option_,
|
||||
const void *optval_,
|
||||
size_t optvallen_);
|
||||
ZMQ_EXPORT int zmq_ctx_get_ext (void *context_,
|
||||
int option_,
|
||||
void *optval_,
|
||||
size_t *optvallen_);
|
||||
|
||||
/* DRAFT Socket methods. */
|
||||
ZMQ_EXPORT int zmq_join (void *s, const char *group);
|
||||
ZMQ_EXPORT int zmq_leave (void *s, const char *group);
|
||||
ZMQ_EXPORT uint32_t zmq_connect_peer (void *s_, const char *addr_);
|
||||
|
||||
/* DRAFT Msg methods. */
|
||||
ZMQ_EXPORT int zmq_msg_set_routing_id (zmq_msg_t *msg, uint32_t routing_id);
|
||||
ZMQ_EXPORT uint32_t zmq_msg_routing_id (zmq_msg_t *msg);
|
||||
ZMQ_EXPORT int zmq_msg_set_group (zmq_msg_t *msg, const char *group);
|
||||
ZMQ_EXPORT const char *zmq_msg_group (zmq_msg_t *msg);
|
||||
ZMQ_EXPORT int
|
||||
zmq_msg_init_buffer (zmq_msg_t *msg_, const void *buf_, size_t size_);
|
||||
|
||||
/* DRAFT Msg property names. */
|
||||
#define ZMQ_MSG_PROPERTY_ROUTING_ID "Routing-Id"
|
||||
#define ZMQ_MSG_PROPERTY_SOCKET_TYPE "Socket-Type"
|
||||
#define ZMQ_MSG_PROPERTY_USER_ID "User-Id"
|
||||
#define ZMQ_MSG_PROPERTY_PEER_ADDRESS "Peer-Address"
|
||||
|
||||
/* Router notify options */
|
||||
#define ZMQ_NOTIFY_CONNECT 1
|
||||
#define ZMQ_NOTIFY_DISCONNECT 2
|
||||
|
||||
/******************************************************************************/
|
||||
/* Poller polling on sockets,fd and thread-safe sockets */
|
||||
/******************************************************************************/
|
||||
|
||||
#define ZMQ_HAVE_POLLER
|
||||
|
||||
typedef struct zmq_poller_event_t
|
||||
{
|
||||
void *socket;
|
||||
zmq_fd_t fd;
|
||||
void *user_data;
|
||||
short events;
|
||||
} zmq_poller_event_t;
|
||||
|
||||
ZMQ_EXPORT void *zmq_poller_new (void);
|
||||
ZMQ_EXPORT int zmq_poller_destroy (void **poller_p);
|
||||
ZMQ_EXPORT int zmq_poller_size (void *poller);
|
||||
ZMQ_EXPORT int
|
||||
zmq_poller_add (void *poller, void *socket, void *user_data, short events);
|
||||
ZMQ_EXPORT int zmq_poller_modify (void *poller, void *socket, short events);
|
||||
ZMQ_EXPORT int zmq_poller_remove (void *poller, void *socket);
|
||||
ZMQ_EXPORT int
|
||||
zmq_poller_wait (void *poller, zmq_poller_event_t *event, long timeout);
|
||||
ZMQ_EXPORT int zmq_poller_wait_all (void *poller,
|
||||
zmq_poller_event_t *events,
|
||||
int n_events,
|
||||
long timeout);
|
||||
ZMQ_EXPORT int zmq_poller_fd (void *poller, zmq_fd_t *fd);
|
||||
|
||||
ZMQ_EXPORT int
|
||||
zmq_poller_add_fd (void *poller, zmq_fd_t fd, void *user_data, short events);
|
||||
ZMQ_EXPORT int zmq_poller_modify_fd (void *poller, zmq_fd_t fd, short events);
|
||||
ZMQ_EXPORT int zmq_poller_remove_fd (void *poller, zmq_fd_t fd);
|
||||
|
||||
ZMQ_EXPORT int zmq_socket_get_peer_state (void *socket,
|
||||
const void *routing_id,
|
||||
size_t routing_id_size);
|
||||
|
||||
/* DRAFT Socket monitoring events */
|
||||
#define ZMQ_EVENT_PIPES_STATS 0x10000
|
||||
|
||||
#define ZMQ_CURRENT_EVENT_VERSION 1
|
||||
#define ZMQ_CURRENT_EVENT_VERSION_DRAFT 2
|
||||
|
||||
#define ZMQ_EVENT_ALL_V1 ZMQ_EVENT_ALL
|
||||
#define ZMQ_EVENT_ALL_V2 ZMQ_EVENT_ALL_V1 | ZMQ_EVENT_PIPES_STATS
|
||||
|
||||
ZMQ_EXPORT int zmq_socket_monitor_versioned (
|
||||
void *s_, const char *addr_, uint64_t events_, int event_version_, int type_);
|
||||
ZMQ_EXPORT int zmq_socket_monitor_pipes_stats (void *s);
|
||||
|
||||
#if !defined _WIN32
|
||||
ZMQ_EXPORT int zmq_ppoll (zmq_pollitem_t *items_,
|
||||
int nitems_,
|
||||
long timeout_,
|
||||
const sigset_t *sigmask_);
|
||||
#else
|
||||
// Windows has no sigset_t
|
||||
ZMQ_EXPORT int zmq_ppoll (zmq_pollitem_t *items_,
|
||||
int nitems_,
|
||||
long timeout_,
|
||||
const void *sigmask_);
|
||||
#endif
|
||||
|
||||
#endif // ZMQ_BUILD_DRAFT_API
|
||||
|
||||
|
||||
#undef ZMQ_EXPORT
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
2762
Thirdparty/zeromq/include/zmq.hpp
vendored
Normal file
2762
Thirdparty/zeromq/include/zmq.hpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
753
Thirdparty/zeromq/include/zmq_addon.hpp
vendored
Normal file
753
Thirdparty/zeromq/include/zmq_addon.hpp
vendored
Normal file
@ -0,0 +1,753 @@
|
||||
/*
|
||||
Copyright (c) 2016-2017 ZeroMQ community
|
||||
Copyright (c) 2016 VOCA AS / Harald Nøkland
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to
|
||||
deal in the Software without restriction, including without limitation the
|
||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __ZMQ_ADDON_HPP_INCLUDED__
|
||||
#define __ZMQ_ADDON_HPP_INCLUDED__
|
||||
|
||||
#include "zmq.hpp"
|
||||
|
||||
#include <deque>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#ifdef ZMQ_CPP11
|
||||
#include <limits>
|
||||
#include <functional>
|
||||
#include <unordered_map>
|
||||
#endif
|
||||
|
||||
namespace zmq
|
||||
{
|
||||
#ifdef ZMQ_CPP11
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template<bool CheckN, class OutputIt>
|
||||
recv_result_t
|
||||
recv_multipart_n(socket_ref s, OutputIt out, size_t n, recv_flags flags)
|
||||
{
|
||||
size_t msg_count = 0;
|
||||
message_t msg;
|
||||
while (true) {
|
||||
if ZMQ_CONSTEXPR_IF (CheckN) {
|
||||
if (msg_count >= n)
|
||||
throw std::runtime_error(
|
||||
"Too many message parts in recv_multipart_n");
|
||||
}
|
||||
if (!s.recv(msg, flags)) {
|
||||
// zmq ensures atomic delivery of messages
|
||||
assert(msg_count == 0);
|
||||
return {};
|
||||
}
|
||||
++msg_count;
|
||||
const bool more = msg.more();
|
||||
*out++ = std::move(msg);
|
||||
if (!more)
|
||||
break;
|
||||
}
|
||||
return msg_count;
|
||||
}
|
||||
|
||||
inline bool is_little_endian()
|
||||
{
|
||||
const uint16_t i = 0x01;
|
||||
return *reinterpret_cast<const uint8_t *>(&i) == 0x01;
|
||||
}
|
||||
|
||||
inline void write_network_order(unsigned char *buf, const uint32_t value)
|
||||
{
|
||||
if (is_little_endian()) {
|
||||
ZMQ_CONSTEXPR_VAR uint32_t mask = (std::numeric_limits<std::uint8_t>::max)();
|
||||
*buf++ = static_cast<unsigned char>((value >> 24) & mask);
|
||||
*buf++ = static_cast<unsigned char>((value >> 16) & mask);
|
||||
*buf++ = static_cast<unsigned char>((value >> 8) & mask);
|
||||
*buf++ = static_cast<unsigned char>(value & mask);
|
||||
} else {
|
||||
std::memcpy(buf, &value, sizeof(value));
|
||||
}
|
||||
}
|
||||
|
||||
inline uint32_t read_u32_network_order(const unsigned char *buf)
|
||||
{
|
||||
if (is_little_endian()) {
|
||||
return (static_cast<uint32_t>(buf[0]) << 24)
|
||||
+ (static_cast<uint32_t>(buf[1]) << 16)
|
||||
+ (static_cast<uint32_t>(buf[2]) << 8)
|
||||
+ static_cast<uint32_t>(buf[3]);
|
||||
} else {
|
||||
uint32_t value;
|
||||
std::memcpy(&value, buf, sizeof(value));
|
||||
return value;
|
||||
}
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
/* Receive a multipart message.
|
||||
|
||||
Writes the zmq::message_t objects to OutputIterator out.
|
||||
The out iterator must handle an unspecified number of writes,
|
||||
e.g. by using std::back_inserter.
|
||||
|
||||
Returns: the number of messages received or nullopt (on EAGAIN).
|
||||
Throws: if recv throws. Any exceptions thrown
|
||||
by the out iterator will be propagated and the message
|
||||
may have been only partially received with pending
|
||||
message parts. It is adviced to close this socket in that event.
|
||||
*/
|
||||
template<class OutputIt>
|
||||
ZMQ_NODISCARD recv_result_t recv_multipart(socket_ref s,
|
||||
OutputIt out,
|
||||
recv_flags flags = recv_flags::none)
|
||||
{
|
||||
return detail::recv_multipart_n<false>(s, std::move(out), 0, flags);
|
||||
}
|
||||
|
||||
/* Receive a multipart message.
|
||||
|
||||
Writes at most n zmq::message_t objects to OutputIterator out.
|
||||
If the number of message parts of the incoming message exceeds n
|
||||
then an exception will be thrown.
|
||||
|
||||
Returns: the number of messages received or nullopt (on EAGAIN).
|
||||
Throws: if recv throws. Throws std::runtime_error if the number
|
||||
of message parts exceeds n (exactly n messages will have been written
|
||||
to out). Any exceptions thrown
|
||||
by the out iterator will be propagated and the message
|
||||
may have been only partially received with pending
|
||||
message parts. It is adviced to close this socket in that event.
|
||||
*/
|
||||
template<class OutputIt>
|
||||
ZMQ_NODISCARD recv_result_t recv_multipart_n(socket_ref s,
|
||||
OutputIt out,
|
||||
size_t n,
|
||||
recv_flags flags = recv_flags::none)
|
||||
{
|
||||
return detail::recv_multipart_n<true>(s, std::move(out), n, flags);
|
||||
}
|
||||
|
||||
/* Send a multipart message.
|
||||
|
||||
The range must be a ForwardRange of zmq::message_t,
|
||||
zmq::const_buffer or zmq::mutable_buffer.
|
||||
The flags may be zmq::send_flags::sndmore if there are
|
||||
more message parts to be sent after the call to this function.
|
||||
|
||||
Returns: the number of messages sent (exactly msgs.size()) or nullopt (on EAGAIN).
|
||||
Throws: if send throws. Any exceptions thrown
|
||||
by the msgs range will be propagated and the message
|
||||
may have been only partially sent. It is adviced to close this socket in that event.
|
||||
*/
|
||||
template<class Range
|
||||
#ifndef ZMQ_CPP11_PARTIAL
|
||||
,
|
||||
typename = typename std::enable_if<
|
||||
detail::is_range<Range>::value
|
||||
&& (std::is_same<detail::range_value_t<Range>, message_t>::value
|
||||
|| detail::is_buffer<detail::range_value_t<Range>>::value)>::type
|
||||
#endif
|
||||
>
|
||||
send_result_t
|
||||
send_multipart(socket_ref s, Range &&msgs, send_flags flags = send_flags::none)
|
||||
{
|
||||
using std::begin;
|
||||
using std::end;
|
||||
auto it = begin(msgs);
|
||||
const auto end_it = end(msgs);
|
||||
size_t msg_count = 0;
|
||||
while (it != end_it) {
|
||||
const auto next = std::next(it);
|
||||
const auto msg_flags =
|
||||
flags | (next == end_it ? send_flags::none : send_flags::sndmore);
|
||||
if (!s.send(*it, msg_flags)) {
|
||||
// zmq ensures atomic delivery of messages
|
||||
assert(it == begin(msgs));
|
||||
return {};
|
||||
}
|
||||
++msg_count;
|
||||
it = next;
|
||||
}
|
||||
return msg_count;
|
||||
}
|
||||
|
||||
/* Encode a multipart message.
|
||||
|
||||
The range must be a ForwardRange of zmq::message_t. A
|
||||
zmq::multipart_t or STL container may be passed for encoding.
|
||||
|
||||
Returns: a zmq::message_t holding the encoded multipart data.
|
||||
|
||||
Throws: std::range_error is thrown if the size of any single part
|
||||
can not fit in an unsigned 32 bit integer.
|
||||
|
||||
The encoding is compatible with that used by the CZMQ function
|
||||
zmsg_encode(), see https://rfc.zeromq.org/spec/50/.
|
||||
Each part consists of a size followed by the data.
|
||||
These are placed contiguously into the output message. A part of
|
||||
size less than 255 bytes will have a single byte size value.
|
||||
Larger parts will have a five byte size value with the first byte
|
||||
set to 0xFF and the remaining four bytes holding the size of the
|
||||
part's data.
|
||||
*/
|
||||
template<class Range
|
||||
#ifndef ZMQ_CPP11_PARTIAL
|
||||
,
|
||||
typename = typename std::enable_if<
|
||||
detail::is_range<Range>::value
|
||||
&& (std::is_same<detail::range_value_t<Range>, message_t>::value
|
||||
|| detail::is_buffer<detail::range_value_t<Range>>::value)>::type
|
||||
#endif
|
||||
>
|
||||
message_t encode(const Range &parts)
|
||||
{
|
||||
size_t mmsg_size = 0;
|
||||
|
||||
// First pass check sizes
|
||||
for (const auto &part : parts) {
|
||||
const size_t part_size = part.size();
|
||||
if (part_size > (std::numeric_limits<std::uint32_t>::max)()) {
|
||||
// Size value must fit into uint32_t.
|
||||
throw std::range_error("Invalid size, message part too large");
|
||||
}
|
||||
const size_t count_size =
|
||||
part_size < (std::numeric_limits<std::uint8_t>::max)() ? 1 : 5;
|
||||
mmsg_size += part_size + count_size;
|
||||
}
|
||||
|
||||
message_t encoded(mmsg_size);
|
||||
unsigned char *buf = encoded.data<unsigned char>();
|
||||
for (const auto &part : parts) {
|
||||
const uint32_t part_size = static_cast<uint32_t>(part.size());
|
||||
const unsigned char *part_data =
|
||||
static_cast<const unsigned char *>(part.data());
|
||||
|
||||
if (part_size < (std::numeric_limits<std::uint8_t>::max)()) {
|
||||
// small part
|
||||
*buf++ = (unsigned char) part_size;
|
||||
} else {
|
||||
// big part
|
||||
*buf++ = (std::numeric_limits<uint8_t>::max)();
|
||||
detail::write_network_order(buf, part_size);
|
||||
buf += sizeof(part_size);
|
||||
}
|
||||
std::memcpy(buf, part_data, part_size);
|
||||
buf += part_size;
|
||||
}
|
||||
|
||||
assert(static_cast<size_t>(buf - encoded.data<unsigned char>()) == mmsg_size);
|
||||
return encoded;
|
||||
}
|
||||
|
||||
/* Decode an encoded message to multiple parts.
|
||||
|
||||
The given output iterator must be a ForwardIterator to a container
|
||||
holding zmq::message_t such as a zmq::multipart_t or various STL
|
||||
containers.
|
||||
|
||||
Returns the ForwardIterator advanced once past the last decoded
|
||||
part.
|
||||
|
||||
Throws: a std::out_of_range is thrown if the encoded part sizes
|
||||
lead to exceeding the message data bounds.
|
||||
|
||||
The decoding assumes the message is encoded in the manner
|
||||
performed by zmq::encode(), see https://rfc.zeromq.org/spec/50/.
|
||||
*/
|
||||
template<class OutputIt> OutputIt decode(const message_t &encoded, OutputIt out)
|
||||
{
|
||||
const unsigned char *source = encoded.data<unsigned char>();
|
||||
const unsigned char *const limit = source + encoded.size();
|
||||
|
||||
while (source < limit) {
|
||||
size_t part_size = *source++;
|
||||
if (part_size == (std::numeric_limits<std::uint8_t>::max)()) {
|
||||
if (static_cast<size_t>(limit - source) < sizeof(uint32_t)) {
|
||||
throw std::out_of_range(
|
||||
"Malformed encoding, overflow in reading size");
|
||||
}
|
||||
part_size = detail::read_u32_network_order(source);
|
||||
// the part size is allowed to be less than 0xFF
|
||||
source += sizeof(uint32_t);
|
||||
}
|
||||
|
||||
if (static_cast<size_t>(limit - source) < part_size) {
|
||||
throw std::out_of_range("Malformed encoding, overflow in reading part");
|
||||
}
|
||||
*out = message_t(source, part_size);
|
||||
++out;
|
||||
source += part_size;
|
||||
}
|
||||
|
||||
assert(source == limit);
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ZMQ_HAS_RVALUE_REFS
|
||||
|
||||
/*
|
||||
This class handles multipart messaging. It is the C++ equivalent of zmsg.h,
|
||||
which is part of CZMQ (the high-level C binding). Furthermore, it is a major
|
||||
improvement compared to zmsg.hpp, which is part of the examples in the ØMQ
|
||||
Guide. Unnecessary copying is avoided by using move semantics to efficiently
|
||||
add/remove parts.
|
||||
*/
|
||||
class multipart_t
|
||||
{
|
||||
private:
|
||||
std::deque<message_t> m_parts;
|
||||
|
||||
public:
|
||||
typedef std::deque<message_t>::value_type value_type;
|
||||
|
||||
typedef std::deque<message_t>::iterator iterator;
|
||||
typedef std::deque<message_t>::const_iterator const_iterator;
|
||||
|
||||
typedef std::deque<message_t>::reverse_iterator reverse_iterator;
|
||||
typedef std::deque<message_t>::const_reverse_iterator const_reverse_iterator;
|
||||
|
||||
// Default constructor
|
||||
multipart_t() {}
|
||||
|
||||
// Construct from socket receive
|
||||
multipart_t(socket_ref socket) { recv(socket); }
|
||||
|
||||
// Construct from memory block
|
||||
multipart_t(const void *src, size_t size) { addmem(src, size); }
|
||||
|
||||
// Construct from string
|
||||
multipart_t(const std::string &string) { addstr(string); }
|
||||
|
||||
// Construct from message part
|
||||
multipart_t(message_t &&message) { add(std::move(message)); }
|
||||
|
||||
// Move constructor
|
||||
multipart_t(multipart_t &&other) ZMQ_NOTHROW { m_parts = std::move(other.m_parts); }
|
||||
|
||||
// Move assignment operator
|
||||
multipart_t &operator=(multipart_t &&other) ZMQ_NOTHROW
|
||||
{
|
||||
m_parts = std::move(other.m_parts);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
virtual ~multipart_t() { clear(); }
|
||||
|
||||
message_t &operator[](size_t n) { return m_parts[n]; }
|
||||
|
||||
const message_t &operator[](size_t n) const { return m_parts[n]; }
|
||||
|
||||
message_t &at(size_t n) { return m_parts.at(n); }
|
||||
|
||||
const message_t &at(size_t n) const { return m_parts.at(n); }
|
||||
|
||||
iterator begin() { return m_parts.begin(); }
|
||||
|
||||
const_iterator begin() const { return m_parts.begin(); }
|
||||
|
||||
const_iterator cbegin() const { return m_parts.cbegin(); }
|
||||
|
||||
reverse_iterator rbegin() { return m_parts.rbegin(); }
|
||||
|
||||
const_reverse_iterator rbegin() const { return m_parts.rbegin(); }
|
||||
|
||||
iterator end() { return m_parts.end(); }
|
||||
|
||||
const_iterator end() const { return m_parts.end(); }
|
||||
|
||||
const_iterator cend() const { return m_parts.cend(); }
|
||||
|
||||
reverse_iterator rend() { return m_parts.rend(); }
|
||||
|
||||
const_reverse_iterator rend() const { return m_parts.rend(); }
|
||||
|
||||
// Delete all parts
|
||||
void clear() { m_parts.clear(); }
|
||||
|
||||
// Get number of parts
|
||||
size_t size() const { return m_parts.size(); }
|
||||
|
||||
// Check if number of parts is zero
|
||||
bool empty() const { return m_parts.empty(); }
|
||||
|
||||
// Receive multipart message from socket
|
||||
bool recv(socket_ref socket, int flags = 0)
|
||||
{
|
||||
clear();
|
||||
bool more = true;
|
||||
while (more) {
|
||||
message_t message;
|
||||
#ifdef ZMQ_CPP11
|
||||
if (!socket.recv(message, static_cast<recv_flags>(flags)))
|
||||
return false;
|
||||
#else
|
||||
if (!socket.recv(&message, flags))
|
||||
return false;
|
||||
#endif
|
||||
more = message.more();
|
||||
add(std::move(message));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Send multipart message to socket
|
||||
bool send(socket_ref socket, int flags = 0)
|
||||
{
|
||||
flags &= ~(ZMQ_SNDMORE);
|
||||
bool more = size() > 0;
|
||||
while (more) {
|
||||
message_t message = pop();
|
||||
more = size() > 0;
|
||||
#ifdef ZMQ_CPP11
|
||||
if (!socket.send(message, static_cast<send_flags>(
|
||||
(more ? ZMQ_SNDMORE : 0) | flags)))
|
||||
return false;
|
||||
#else
|
||||
if (!socket.send(message, (more ? ZMQ_SNDMORE : 0) | flags))
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Concatenate other multipart to front
|
||||
void prepend(multipart_t &&other)
|
||||
{
|
||||
while (!other.empty())
|
||||
push(other.remove());
|
||||
}
|
||||
|
||||
// Concatenate other multipart to back
|
||||
void append(multipart_t &&other)
|
||||
{
|
||||
while (!other.empty())
|
||||
add(other.pop());
|
||||
}
|
||||
|
||||
// Push memory block to front
|
||||
void pushmem(const void *src, size_t size)
|
||||
{
|
||||
m_parts.push_front(message_t(src, size));
|
||||
}
|
||||
|
||||
// Push memory block to back
|
||||
void addmem(const void *src, size_t size)
|
||||
{
|
||||
m_parts.push_back(message_t(src, size));
|
||||
}
|
||||
|
||||
// Push string to front
|
||||
void pushstr(const std::string &string)
|
||||
{
|
||||
m_parts.push_front(message_t(string.data(), string.size()));
|
||||
}
|
||||
|
||||
// Push string to back
|
||||
void addstr(const std::string &string)
|
||||
{
|
||||
m_parts.push_back(message_t(string.data(), string.size()));
|
||||
}
|
||||
|
||||
// Push type (fixed-size) to front
|
||||
template<typename T> void pushtyp(const T &type)
|
||||
{
|
||||
static_assert(!std::is_same<T, std::string>::value,
|
||||
"Use pushstr() instead of pushtyp<std::string>()");
|
||||
m_parts.push_front(message_t(&type, sizeof(type)));
|
||||
}
|
||||
|
||||
// Push type (fixed-size) to back
|
||||
template<typename T> void addtyp(const T &type)
|
||||
{
|
||||
static_assert(!std::is_same<T, std::string>::value,
|
||||
"Use addstr() instead of addtyp<std::string>()");
|
||||
m_parts.push_back(message_t(&type, sizeof(type)));
|
||||
}
|
||||
|
||||
// Push message part to front
|
||||
void push(message_t &&message) { m_parts.push_front(std::move(message)); }
|
||||
|
||||
// Push message part to back
|
||||
void add(message_t &&message) { m_parts.push_back(std::move(message)); }
|
||||
|
||||
// Alias to allow std::back_inserter()
|
||||
void push_back(message_t &&message) { m_parts.push_back(std::move(message)); }
|
||||
|
||||
// Pop string from front
|
||||
std::string popstr()
|
||||
{
|
||||
std::string string(m_parts.front().data<char>(), m_parts.front().size());
|
||||
m_parts.pop_front();
|
||||
return string;
|
||||
}
|
||||
|
||||
// Pop type (fixed-size) from front
|
||||
template<typename T> T poptyp()
|
||||
{
|
||||
static_assert(!std::is_same<T, std::string>::value,
|
||||
"Use popstr() instead of poptyp<std::string>()");
|
||||
if (sizeof(T) != m_parts.front().size())
|
||||
throw std::runtime_error(
|
||||
"Invalid type, size does not match the message size");
|
||||
T type = *m_parts.front().data<T>();
|
||||
m_parts.pop_front();
|
||||
return type;
|
||||
}
|
||||
|
||||
// Pop message part from front
|
||||
message_t pop()
|
||||
{
|
||||
message_t message = std::move(m_parts.front());
|
||||
m_parts.pop_front();
|
||||
return message;
|
||||
}
|
||||
|
||||
// Pop message part from back
|
||||
message_t remove()
|
||||
{
|
||||
message_t message = std::move(m_parts.back());
|
||||
m_parts.pop_back();
|
||||
return message;
|
||||
}
|
||||
|
||||
// get message part from front
|
||||
const message_t &front() { return m_parts.front(); }
|
||||
|
||||
// get message part from back
|
||||
const message_t &back() { return m_parts.back(); }
|
||||
|
||||
// Get pointer to a specific message part
|
||||
const message_t *peek(size_t index) const { return &m_parts[index]; }
|
||||
|
||||
// Get a string copy of a specific message part
|
||||
std::string peekstr(size_t index) const
|
||||
{
|
||||
std::string string(m_parts[index].data<char>(), m_parts[index].size());
|
||||
return string;
|
||||
}
|
||||
|
||||
// Peek type (fixed-size) from front
|
||||
template<typename T> T peektyp(size_t index) const
|
||||
{
|
||||
static_assert(!std::is_same<T, std::string>::value,
|
||||
"Use peekstr() instead of peektyp<std::string>()");
|
||||
if (sizeof(T) != m_parts[index].size())
|
||||
throw std::runtime_error(
|
||||
"Invalid type, size does not match the message size");
|
||||
T type = *m_parts[index].data<T>();
|
||||
return type;
|
||||
}
|
||||
|
||||
// Create multipart from type (fixed-size)
|
||||
template<typename T> static multipart_t create(const T &type)
|
||||
{
|
||||
multipart_t multipart;
|
||||
multipart.addtyp(type);
|
||||
return multipart;
|
||||
}
|
||||
|
||||
// Copy multipart
|
||||
multipart_t clone() const
|
||||
{
|
||||
multipart_t multipart;
|
||||
for (size_t i = 0; i < size(); i++)
|
||||
multipart.addmem(m_parts[i].data(), m_parts[i].size());
|
||||
return multipart;
|
||||
}
|
||||
|
||||
// Dump content to string
|
||||
std::string str() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
for (size_t i = 0; i < m_parts.size(); i++) {
|
||||
const unsigned char *data = m_parts[i].data<unsigned char>();
|
||||
size_t size = m_parts[i].size();
|
||||
|
||||
// Dump the message as text or binary
|
||||
bool isText = true;
|
||||
for (size_t j = 0; j < size; j++) {
|
||||
if (data[j] < 32 || data[j] > 127) {
|
||||
isText = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ss << "\n[" << std::dec << std::setw(3) << std::setfill('0') << size
|
||||
<< "] ";
|
||||
if (size >= 1000) {
|
||||
ss << "... (too big to print)";
|
||||
continue;
|
||||
}
|
||||
for (size_t j = 0; j < size; j++) {
|
||||
if (isText)
|
||||
ss << static_cast<char>(data[j]);
|
||||
else
|
||||
ss << std::hex << std::setw(2) << std::setfill('0')
|
||||
<< static_cast<short>(data[j]);
|
||||
}
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
// Check if equal to other multipart
|
||||
bool equal(const multipart_t *other) const ZMQ_NOTHROW
|
||||
{
|
||||
return *this == *other;
|
||||
}
|
||||
|
||||
bool operator==(const multipart_t &other) const ZMQ_NOTHROW
|
||||
{
|
||||
if (size() != other.size())
|
||||
return false;
|
||||
for (size_t i = 0; i < size(); i++)
|
||||
if (at(i) != other.at(i))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator!=(const multipart_t &other) const ZMQ_NOTHROW
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
#ifdef ZMQ_CPP11
|
||||
|
||||
// Return single part message_t encoded from this multipart_t.
|
||||
message_t encode() const { return zmq::encode(*this); }
|
||||
|
||||
// Decode encoded message into multiple parts and append to self.
|
||||
void decode_append(const message_t &encoded)
|
||||
{
|
||||
zmq::decode(encoded, std::back_inserter(*this));
|
||||
}
|
||||
|
||||
// Return a new multipart_t containing the decoded message_t.
|
||||
static multipart_t decode(const message_t &encoded)
|
||||
{
|
||||
multipart_t tmp;
|
||||
zmq::decode(encoded, std::back_inserter(tmp));
|
||||
return tmp;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
private:
|
||||
// Disable implicit copying (moving is more efficient)
|
||||
multipart_t(const multipart_t &other) ZMQ_DELETED_FUNCTION;
|
||||
void operator=(const multipart_t &other) ZMQ_DELETED_FUNCTION;
|
||||
}; // class multipart_t
|
||||
|
||||
inline std::ostream &operator<<(std::ostream &os, const multipart_t &msg)
|
||||
{
|
||||
return os << msg.str();
|
||||
}
|
||||
|
||||
#endif // ZMQ_HAS_RVALUE_REFS
|
||||
|
||||
#if defined(ZMQ_BUILD_DRAFT_API) && defined(ZMQ_CPP11) && defined(ZMQ_HAVE_POLLER)
|
||||
class active_poller_t
|
||||
{
|
||||
public:
|
||||
active_poller_t() = default;
|
||||
~active_poller_t() = default;
|
||||
|
||||
active_poller_t(const active_poller_t &) = delete;
|
||||
active_poller_t &operator=(const active_poller_t &) = delete;
|
||||
|
||||
active_poller_t(active_poller_t &&src) = default;
|
||||
active_poller_t &operator=(active_poller_t &&src) = default;
|
||||
|
||||
using handler_type = std::function<void(event_flags)>;
|
||||
|
||||
void add(zmq::socket_ref socket, event_flags events, handler_type handler)
|
||||
{
|
||||
if (!handler)
|
||||
throw std::invalid_argument("null handler in active_poller_t::add");
|
||||
auto ret = handlers.emplace(
|
||||
socket, std::make_shared<handler_type>(std::move(handler)));
|
||||
if (!ret.second)
|
||||
throw error_t(EINVAL); // already added
|
||||
try {
|
||||
base_poller.add(socket, events, ret.first->second.get());
|
||||
need_rebuild = true;
|
||||
}
|
||||
catch (...) {
|
||||
// rollback
|
||||
handlers.erase(socket);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void remove(zmq::socket_ref socket)
|
||||
{
|
||||
base_poller.remove(socket);
|
||||
handlers.erase(socket);
|
||||
need_rebuild = true;
|
||||
}
|
||||
|
||||
void modify(zmq::socket_ref socket, event_flags events)
|
||||
{
|
||||
base_poller.modify(socket, events);
|
||||
}
|
||||
|
||||
size_t wait(std::chrono::milliseconds timeout)
|
||||
{
|
||||
if (need_rebuild) {
|
||||
poller_events.resize(handlers.size());
|
||||
poller_handlers.clear();
|
||||
poller_handlers.reserve(handlers.size());
|
||||
for (const auto &handler : handlers) {
|
||||
poller_handlers.push_back(handler.second);
|
||||
}
|
||||
need_rebuild = false;
|
||||
}
|
||||
const auto count = base_poller.wait_all(poller_events, timeout);
|
||||
std::for_each(poller_events.begin(),
|
||||
poller_events.begin() + static_cast<ptrdiff_t>(count),
|
||||
[](decltype(base_poller)::event_type &event) {
|
||||
assert(event.user_data != nullptr);
|
||||
(*event.user_data)(event.events);
|
||||
});
|
||||
return count;
|
||||
}
|
||||
|
||||
ZMQ_NODISCARD bool empty() const noexcept { return handlers.empty(); }
|
||||
|
||||
size_t size() const noexcept { return handlers.size(); }
|
||||
|
||||
private:
|
||||
bool need_rebuild{false};
|
||||
|
||||
poller_t<handler_type> base_poller{};
|
||||
std::unordered_map<socket_ref, std::shared_ptr<handler_type>> handlers{};
|
||||
std::vector<decltype(base_poller)::event_type> poller_events{};
|
||||
std::vector<std::shared_ptr<handler_type>> poller_handlers{};
|
||||
}; // class active_poller_t
|
||||
#endif // defined(ZMQ_BUILD_DRAFT_API) && defined(ZMQ_CPP11) && defined(ZMQ_HAVE_POLLER)
|
||||
|
||||
|
||||
} // namespace zmq
|
||||
|
||||
#endif // __ZMQ_ADDON_HPP_INCLUDED__
|
23
Thirdparty/zeromq/include/zmq_utils.h
vendored
Normal file
23
Thirdparty/zeromq/include/zmq_utils.h
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
/* SPDX-License-Identifier: MPL-2.0 */
|
||||
|
||||
/* This file is deprecated, and all its functionality provided by zmq.h */
|
||||
/* Note that -Wpedantic compilation requires GCC to avoid using its custom
|
||||
extensions such as #warning, hence the trick below. Also, pragmas for
|
||||
warnings or other messages are not standard, not portable, and not all
|
||||
compilers even have an equivalent concept.
|
||||
So in the worst case, this include file is treated as silently empty. */
|
||||
|
||||
#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) \
|
||||
|| defined(_MSC_VER)
|
||||
#if defined(__GNUC__) || defined(__GNUG__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic warning "-Wcpp"
|
||||
#pragma GCC diagnostic ignored "-Werror"
|
||||
#pragma GCC diagnostic ignored "-Wall"
|
||||
#endif
|
||||
#pragma message( \
|
||||
"Warning: zmq_utils.h is deprecated. All its functionality is provided by zmq.h.")
|
||||
#if defined(__GNUC__) || defined(__GNUG__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#endif
|
BIN
Thirdparty/zeromq/lib/libzmq-mt-4_3_5.lib
vendored
Normal file
BIN
Thirdparty/zeromq/lib/libzmq-mt-4_3_5.lib
vendored
Normal file
Binary file not shown.
13
Thirdparty/zeromq/lib/pkgconfig/libzmq.pc
vendored
Normal file
13
Thirdparty/zeromq/lib/pkgconfig/libzmq.pc
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
prefix=${pcfiledir}/../..
|
||||
exec_prefix=${prefix}
|
||||
libdir=${prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: libzmq
|
||||
Description: 0MQ c++ library
|
||||
Version: 4.3.5
|
||||
Libs: "-L${libdir}" -lzmq
|
||||
Libs.private: -lstdc++
|
||||
Requires.private:
|
||||
Cflags: "-I${includedir}"
|
||||
|
58
Thirdparty/zeromq/share/zeromq/ZeroMQConfig.cmake
vendored
Normal file
58
Thirdparty/zeromq/share/zeromq/ZeroMQConfig.cmake
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
# ZeroMQ cmake module
|
||||
#
|
||||
# The following import targets are created
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# libzmq-static
|
||||
# libzmq
|
||||
#
|
||||
# This module sets the following variables in your project::
|
||||
#
|
||||
# ZeroMQ_FOUND - true if ZeroMQ found on the system
|
||||
# ZeroMQ_INCLUDE_DIR - the directory containing ZeroMQ headers
|
||||
# ZeroMQ_LIBRARY -
|
||||
# ZeroMQ_STATIC_LIBRARY
|
||||
|
||||
|
||||
####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
|
||||
####### Any changes to this file will be overwritten by the next CMake run ####
|
||||
####### The input file was ZeroMQConfig.cmake.in ########
|
||||
|
||||
get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../" ABSOLUTE)
|
||||
|
||||
macro(set_and_check _var _file)
|
||||
set(${_var} "${_file}")
|
||||
if(NOT EXISTS "${_file}")
|
||||
message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(check_required_components _NAME)
|
||||
foreach(comp ${${_NAME}_FIND_COMPONENTS})
|
||||
if(NOT ${_NAME}_${comp}_FOUND)
|
||||
if(${_NAME}_FIND_REQUIRED_${comp})
|
||||
set(${_NAME}_FOUND FALSE)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
####################################################################################
|
||||
|
||||
if(NOT TARGET libzmq AND NOT TARGET libzmq-static)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/ZeroMQTargets.cmake")
|
||||
|
||||
if (TARGET libzmq)
|
||||
get_target_property(ZeroMQ_INCLUDE_DIR libzmq INTERFACE_INCLUDE_DIRECTORIES)
|
||||
else ()
|
||||
get_target_property(ZeroMQ_INCLUDE_DIR libzmq-static INTERFACE_INCLUDE_DIRECTORIES)
|
||||
endif()
|
||||
|
||||
if (TARGET libzmq)
|
||||
get_target_property(ZeroMQ_LIBRARY libzmq LOCATION)
|
||||
endif()
|
||||
if (TARGET libzmq-static)
|
||||
get_target_property(ZeroMQ_STATIC_LIBRARY libzmq-static LOCATION)
|
||||
endif()
|
||||
endif()
|
43
Thirdparty/zeromq/share/zeromq/ZeroMQConfigVersion.cmake
vendored
Normal file
43
Thirdparty/zeromq/share/zeromq/ZeroMQConfigVersion.cmake
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
# This is a basic version file for the Config-mode of find_package().
|
||||
# It is used by write_basic_package_version_file() as input file for configure_file()
|
||||
# to create a version-file which can be installed along a config.cmake file.
|
||||
#
|
||||
# The created file sets PACKAGE_VERSION_EXACT if the current version string and
|
||||
# the requested version string are exactly the same and it sets
|
||||
# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version.
|
||||
# The variable CVF_VERSION must be set before calling configure_file().
|
||||
|
||||
set(PACKAGE_VERSION "4.3.5")
|
||||
|
||||
if (PACKAGE_FIND_VERSION_RANGE)
|
||||
# Package version must be in the requested version range
|
||||
if ((PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MIN)
|
||||
OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX)
|
||||
OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX)))
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
endif()
|
||||
else()
|
||||
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
|
||||
set(PACKAGE_VERSION_EXACT TRUE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
|
||||
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
|
||||
if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8")
|
||||
math(EXPR installedBits "8 * 8")
|
||||
set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
|
||||
set(PACKAGE_VERSION_UNSUITABLE TRUE)
|
||||
endif()
|
20
Thirdparty/zeromq/share/zeromq/ZeroMQTargets-debug.cmake
vendored
Normal file
20
Thirdparty/zeromq/share/zeromq/ZeroMQTargets-debug.cmake
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
#----------------------------------------------------------------
|
||||
# Generated CMake target import file for configuration "Debug".
|
||||
#----------------------------------------------------------------
|
||||
|
||||
# Commands may need to know the format version.
|
||||
set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||
|
||||
# Import target "libzmq" for configuration "Debug"
|
||||
set_property(TARGET libzmq APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
|
||||
set_target_properties(libzmq PROPERTIES
|
||||
IMPORTED_IMPLIB_DEBUG "${_IMPORT_PREFIX}/debug/lib/libzmq-mt-gd-4_3_5.lib"
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG "ws2_32;advapi32;rpcrt4;iphlpapi"
|
||||
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/debug/bin/libzmq-mt-gd-4_3_5.dll"
|
||||
)
|
||||
|
||||
list(APPEND _cmake_import_check_targets libzmq )
|
||||
list(APPEND _cmake_import_check_files_for_libzmq "${_IMPORT_PREFIX}/debug/lib/libzmq-mt-gd-4_3_5.lib" "${_IMPORT_PREFIX}/debug/bin/libzmq-mt-gd-4_3_5.dll" )
|
||||
|
||||
# Commands beyond this point should not need to know the version.
|
||||
set(CMAKE_IMPORT_FILE_VERSION)
|
20
Thirdparty/zeromq/share/zeromq/ZeroMQTargets-release.cmake
vendored
Normal file
20
Thirdparty/zeromq/share/zeromq/ZeroMQTargets-release.cmake
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
#----------------------------------------------------------------
|
||||
# Generated CMake target import file for configuration "Release".
|
||||
#----------------------------------------------------------------
|
||||
|
||||
# Commands may need to know the format version.
|
||||
set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||
|
||||
# Import target "libzmq" for configuration "Release"
|
||||
set_property(TARGET libzmq APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_target_properties(libzmq PROPERTIES
|
||||
IMPORTED_IMPLIB_RELEASE "${_IMPORT_PREFIX}/lib/libzmq-mt-4_3_5.lib"
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "ws2_32;advapi32;rpcrt4;iphlpapi"
|
||||
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/bin/libzmq-mt-4_3_5.dll"
|
||||
)
|
||||
|
||||
list(APPEND _cmake_import_check_targets libzmq )
|
||||
list(APPEND _cmake_import_check_files_for_libzmq "${_IMPORT_PREFIX}/lib/libzmq-mt-4_3_5.lib" "${_IMPORT_PREFIX}/bin/libzmq-mt-4_3_5.dll" )
|
||||
|
||||
# Commands beyond this point should not need to know the version.
|
||||
set(CMAKE_IMPORT_FILE_VERSION)
|
105
Thirdparty/zeromq/share/zeromq/ZeroMQTargets.cmake
vendored
Normal file
105
Thirdparty/zeromq/share/zeromq/ZeroMQTargets.cmake
vendored
Normal file
@ -0,0 +1,105 @@
|
||||
# Generated by CMake
|
||||
|
||||
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.8)
|
||||
message(FATAL_ERROR "CMake >= 2.8.0 required")
|
||||
endif()
|
||||
if(CMAKE_VERSION VERSION_LESS "2.8.3")
|
||||
message(FATAL_ERROR "CMake >= 2.8.3 required")
|
||||
endif()
|
||||
cmake_policy(PUSH)
|
||||
cmake_policy(VERSION 2.8.3...3.27)
|
||||
#----------------------------------------------------------------
|
||||
# Generated CMake target import file.
|
||||
#----------------------------------------------------------------
|
||||
|
||||
# Commands may need to know the format version.
|
||||
set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||
|
||||
# Protect against multiple inclusion, which would fail when already imported targets are added once more.
|
||||
set(_cmake_targets_defined "")
|
||||
set(_cmake_targets_not_defined "")
|
||||
set(_cmake_expected_targets "")
|
||||
foreach(_cmake_expected_target IN ITEMS libzmq)
|
||||
list(APPEND _cmake_expected_targets "${_cmake_expected_target}")
|
||||
if(TARGET "${_cmake_expected_target}")
|
||||
list(APPEND _cmake_targets_defined "${_cmake_expected_target}")
|
||||
else()
|
||||
list(APPEND _cmake_targets_not_defined "${_cmake_expected_target}")
|
||||
endif()
|
||||
endforeach()
|
||||
unset(_cmake_expected_target)
|
||||
if(_cmake_targets_defined STREQUAL _cmake_expected_targets)
|
||||
unset(_cmake_targets_defined)
|
||||
unset(_cmake_targets_not_defined)
|
||||
unset(_cmake_expected_targets)
|
||||
unset(CMAKE_IMPORT_FILE_VERSION)
|
||||
cmake_policy(POP)
|
||||
return()
|
||||
endif()
|
||||
if(NOT _cmake_targets_defined STREQUAL "")
|
||||
string(REPLACE ";" ", " _cmake_targets_defined_text "${_cmake_targets_defined}")
|
||||
string(REPLACE ";" ", " _cmake_targets_not_defined_text "${_cmake_targets_not_defined}")
|
||||
message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_cmake_targets_defined_text}\nTargets not yet defined: ${_cmake_targets_not_defined_text}\n")
|
||||
endif()
|
||||
unset(_cmake_targets_defined)
|
||||
unset(_cmake_targets_not_defined)
|
||||
unset(_cmake_expected_targets)
|
||||
|
||||
|
||||
# Compute the installation prefix relative to this file.
|
||||
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
|
||||
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
|
||||
if(_IMPORT_PREFIX STREQUAL "/")
|
||||
set(_IMPORT_PREFIX "")
|
||||
endif()
|
||||
|
||||
# Create imported target libzmq
|
||||
add_library(libzmq SHARED IMPORTED)
|
||||
|
||||
set_target_properties(libzmq PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
|
||||
)
|
||||
|
||||
# Load information for each installed configuration.
|
||||
file(GLOB _cmake_config_files "${CMAKE_CURRENT_LIST_DIR}/ZeroMQTargets-*.cmake")
|
||||
foreach(_cmake_config_file IN LISTS _cmake_config_files)
|
||||
include("${_cmake_config_file}")
|
||||
endforeach()
|
||||
unset(_cmake_config_file)
|
||||
unset(_cmake_config_files)
|
||||
|
||||
# Cleanup temporary variables.
|
||||
set(_IMPORT_PREFIX)
|
||||
|
||||
# Loop over all imported files and verify that they actually exist
|
||||
foreach(_cmake_target IN LISTS _cmake_import_check_targets)
|
||||
if(CMAKE_VERSION VERSION_LESS "3.28"
|
||||
OR NOT DEFINED _cmake_import_check_xcframework_for_${_cmake_target}
|
||||
OR NOT IS_DIRECTORY "${_cmake_import_check_xcframework_for_${_cmake_target}}")
|
||||
foreach(_cmake_file IN LISTS "_cmake_import_check_files_for_${_cmake_target}")
|
||||
if(NOT EXISTS "${_cmake_file}")
|
||||
message(FATAL_ERROR "The imported target \"${_cmake_target}\" references the file
|
||||
\"${_cmake_file}\"
|
||||
but this file does not exist. Possible reasons include:
|
||||
* The file was deleted, renamed, or moved to another location.
|
||||
* An install or uninstall procedure did not complete successfully.
|
||||
* The installation package was faulty and contained
|
||||
\"${CMAKE_CURRENT_LIST_FILE}\"
|
||||
but not all the files it references.
|
||||
")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
unset(_cmake_file)
|
||||
unset("_cmake_import_check_files_for_${_cmake_target}")
|
||||
endforeach()
|
||||
unset(_cmake_target)
|
||||
unset(_cmake_import_check_targets)
|
||||
|
||||
# This file does not depend on other imported targets which have
|
||||
# been exported from the same project but in a separate export set.
|
||||
|
||||
# Commands beyond this point should not need to know the version.
|
||||
set(CMAKE_IMPORT_FILE_VERSION)
|
||||
cmake_policy(POP)
|
373
Thirdparty/zeromq/share/zeromq/copyright
vendored
Normal file
373
Thirdparty/zeromq/share/zeromq/copyright
vendored
Normal file
@ -0,0 +1,373 @@
|
||||
Mozilla Public License Version 2.0
|
||||
==================================
|
||||
|
||||
1. Definitions
|
||||
--------------
|
||||
|
||||
1.1. "Contributor"
|
||||
means each individual or legal entity that creates, contributes to
|
||||
the creation of, or owns Covered Software.
|
||||
|
||||
1.2. "Contributor Version"
|
||||
means the combination of the Contributions of others (if any) used
|
||||
by a Contributor and that particular Contributor's Contribution.
|
||||
|
||||
1.3. "Contribution"
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
1.4. "Covered Software"
|
||||
means Source Code Form to which the initial Contributor has attached
|
||||
the notice in Exhibit A, the Executable Form of such Source Code
|
||||
Form, and Modifications of such Source Code Form, in each case
|
||||
including portions thereof.
|
||||
|
||||
1.5. "Incompatible With Secondary Licenses"
|
||||
means
|
||||
|
||||
(a) that the initial Contributor has attached the notice described
|
||||
in Exhibit B to the Covered Software; or
|
||||
|
||||
(b) that the Covered Software was made available under the terms of
|
||||
version 1.1 or earlier of the License, but not also under the
|
||||
terms of a Secondary License.
|
||||
|
||||
1.6. "Executable Form"
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. "Larger Work"
|
||||
means a work that combines Covered Software with other material, in
|
||||
a separate file or files, that is not Covered Software.
|
||||
|
||||
1.8. "License"
|
||||
means this document.
|
||||
|
||||
1.9. "Licensable"
|
||||
means having the right to grant, to the maximum extent possible,
|
||||
whether at the time of the initial grant or subsequently, any and
|
||||
all of the rights conveyed by this License.
|
||||
|
||||
1.10. "Modifications"
|
||||
means any of the following:
|
||||
|
||||
(a) any file in Source Code Form that results from an addition to,
|
||||
deletion from, or modification of the contents of Covered
|
||||
Software; or
|
||||
|
||||
(b) any new file in Source Code Form that contains any Covered
|
||||
Software.
|
||||
|
||||
1.11. "Patent Claims" of a Contributor
|
||||
means any patent claim(s), including without limitation, method,
|
||||
process, and apparatus claims, in any patent Licensable by such
|
||||
Contributor that would be infringed, but for the grant of the
|
||||
License, by the making, using, selling, offering for sale, having
|
||||
made, import, or transfer of either its Contributions or its
|
||||
Contributor Version.
|
||||
|
||||
1.12. "Secondary License"
|
||||
means either the GNU General Public License, Version 2.0, the GNU
|
||||
Lesser General Public License, Version 2.1, the GNU Affero General
|
||||
Public License, Version 3.0, or any later versions of those
|
||||
licenses.
|
||||
|
||||
1.13. "Source Code Form"
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
1.14. "You" (or "Your")
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, "You" includes any entity that
|
||||
controls, is controlled by, or is under common control with You. For
|
||||
purposes of this definition, "control" means (a) the power, direct
|
||||
or indirect, to cause the direction or management of such entity,
|
||||
whether by contract or otherwise, or (b) ownership of more than
|
||||
fifty percent (50%) of the outstanding shares or beneficial
|
||||
ownership of such entity.
|
||||
|
||||
2. License Grants and Conditions
|
||||
--------------------------------
|
||||
|
||||
2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
(a) under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or
|
||||
as part of a Larger Work; and
|
||||
|
||||
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
||||
for sale, have made, import, and otherwise transfer either its
|
||||
Contributions or its Contributor Version.
|
||||
|
||||
2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution
|
||||
become effective for each Contribution on the date the Contributor first
|
||||
distributes such Contribution.
|
||||
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under
|
||||
this License. No additional rights or licenses will be implied from the
|
||||
distribution or licensing of Covered Software under this License.
|
||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||
Contributor:
|
||||
|
||||
(a) for any code that a Contributor has removed from Covered Software;
|
||||
or
|
||||
|
||||
(b) for infringements caused by: (i) Your and any other third party's
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
(c) under Patent Claims infringed by Covered Software in the absence of
|
||||
its Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks,
|
||||
or logos of any Contributor (except as may be necessary to comply with
|
||||
the notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this
|
||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||
permitted under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its
|
||||
Contributions are its original creation(s) or it has sufficient rights
|
||||
to grant the rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under
|
||||
applicable copyright doctrines of fair use, fair dealing, or other
|
||||
equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
||||
in Section 2.1.
|
||||
|
||||
3. Responsibilities
|
||||
-------------------
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under
|
||||
the terms of this License. You must inform recipients that the Source
|
||||
Code Form of the Covered Software is governed by the terms of this
|
||||
License, and how they can obtain a copy of this License. You may not
|
||||
attempt to alter or restrict the recipients' rights in the Source Code
|
||||
Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
(a) such Covered Software must also be made available in Source Code
|
||||
Form, as described in Section 3.1, and You must inform recipients of
|
||||
the Executable Form how they can obtain a copy of such Source Code
|
||||
Form by reasonable means in a timely manner, at a charge no more
|
||||
than the cost of distribution to the recipient; and
|
||||
|
||||
(b) You may distribute such Executable Form under the terms of this
|
||||
License, or sublicense it under different terms, provided that the
|
||||
license for the Executable Form does not attempt to limit or alter
|
||||
the recipients' rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for
|
||||
the Covered Software. If the Larger Work is a combination of Covered
|
||||
Software with a work governed by one or more Secondary Licenses, and the
|
||||
Covered Software is not Incompatible With Secondary Licenses, this
|
||||
License permits You to additionally distribute such Covered Software
|
||||
under the terms of such Secondary License(s), so that the recipient of
|
||||
the Larger Work may, at their option, further distribute the Covered
|
||||
Software under the terms of either this License or such Secondary
|
||||
License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices
|
||||
(including copyright notices, patent notices, disclaimers of warranty,
|
||||
or limitations of liability) contained within the Source Code Form of
|
||||
the Covered Software, except that You may alter any license notices to
|
||||
the extent required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on
|
||||
behalf of any Contributor. You must make it absolutely clear that any
|
||||
such warranty, support, indemnity, or liability obligation is offered by
|
||||
You alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
---------------------------------------------------
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this
|
||||
License with respect to some or all of the Covered Software due to
|
||||
statute, judicial order, or regulation then You must: (a) comply with
|
||||
the terms of this License to the maximum extent possible; and (b)
|
||||
describe the limitations and the code they affect. Such description must
|
||||
be placed in a text file included with all distributions of the Covered
|
||||
Software under this License. Except to the extent prohibited by statute
|
||||
or regulation, such description must be sufficiently detailed for a
|
||||
recipient of ordinary skill to be able to understand it.
|
||||
|
||||
5. Termination
|
||||
--------------
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically
|
||||
if You fail to comply with any of its terms. However, if You become
|
||||
compliant, then the rights granted under this License from a particular
|
||||
Contributor are reinstated (a) provisionally, unless and until such
|
||||
Contributor explicitly and finally terminates Your grants, and (b) on an
|
||||
ongoing basis, if such Contributor fails to notify You of the
|
||||
non-compliance by some reasonable means prior to 60 days after You have
|
||||
come back into compliance. Moreover, Your grants from a particular
|
||||
Contributor are reinstated on an ongoing basis if such Contributor
|
||||
notifies You of the non-compliance by some reasonable means, this is the
|
||||
first time You have received notice of non-compliance with this License
|
||||
from such Contributor, and You become compliant prior to 30 days after
|
||||
Your receipt of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions,
|
||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||
directly or indirectly infringes any patent, then the rights granted to
|
||||
You by any and all Contributors for the Covered Software under Section
|
||||
2.1 of this License shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
||||
end user license agreements (excluding distributors and resellers) which
|
||||
have been validly granted by You or Your distributors under this License
|
||||
prior to termination shall survive termination.
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 6. Disclaimer of Warranty *
|
||||
* ------------------------- *
|
||||
* *
|
||||
* Covered Software is provided under this License on an "as is" *
|
||||
* basis, without warranty of any kind, either expressed, implied, or *
|
||||
* statutory, including, without limitation, warranties that the *
|
||||
* Covered Software is free of defects, merchantable, fit for a *
|
||||
* particular purpose or non-infringing. The entire risk as to the *
|
||||
* quality and performance of the Covered Software is with You. *
|
||||
* Should any Covered Software prove defective in any respect, You *
|
||||
* (not any Contributor) assume the cost of any necessary servicing, *
|
||||
* repair, or correction. This disclaimer of warranty constitutes an *
|
||||
* essential part of this License. No use of any Covered Software is *
|
||||
* authorized under this License except under this disclaimer. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 7. Limitation of Liability *
|
||||
* -------------------------- *
|
||||
* *
|
||||
* Under no circumstances and under no legal theory, whether tort *
|
||||
* (including negligence), contract, or otherwise, shall any *
|
||||
* Contributor, or anyone who distributes Covered Software as *
|
||||
* permitted above, be liable to You for any direct, indirect, *
|
||||
* special, incidental, or consequential damages of any character *
|
||||
* including, without limitation, damages for lost profits, loss of *
|
||||
* goodwill, work stoppage, computer failure or malfunction, or any *
|
||||
* and all other commercial damages or losses, even if such party *
|
||||
* shall have been informed of the possibility of such damages. This *
|
||||
* limitation of liability shall not apply to liability for death or *
|
||||
* personal injury resulting from such party's negligence to the *
|
||||
* extent applicable law prohibits such limitation. Some *
|
||||
* jurisdictions do not allow the exclusion or limitation of *
|
||||
* incidental or consequential damages, so this exclusion and *
|
||||
* limitation may not apply to You. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
8. Litigation
|
||||
-------------
|
||||
|
||||
Any litigation relating to this License may be brought only in the
|
||||
courts of a jurisdiction where the defendant maintains its principal
|
||||
place of business and such litigation shall be governed by laws of that
|
||||
jurisdiction, without reference to its conflict-of-law provisions.
|
||||
Nothing in this Section shall prevent a party's ability to bring
|
||||
cross-claims or counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
----------------
|
||||
|
||||
This License represents the complete agreement concerning the subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. Any law or regulation which provides
|
||||
that the language of a contract shall be construed against the drafter
|
||||
shall not be used to construe this License against a Contributor.
|
||||
|
||||
10. Versions of the License
|
||||
---------------------------
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version
|
||||
of the License under which You originally received the Covered Software,
|
||||
or under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a
|
||||
modified version of this License if you rename the license and remove
|
||||
any references to the name of the license steward (except to note that
|
||||
such modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||
Licenses
|
||||
|
||||
If You choose to distribute Source Code Form that is Incompatible With
|
||||
Secondary Licenses under the terms of this version of the License, the
|
||||
notice described in Exhibit B of this License must be attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
-------------------------------------------
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular
|
||||
file, then You may include the notice in a location (such as a LICENSE
|
||||
file in a relevant directory) where a recipient would be likely to look
|
||||
for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||
---------------------------------------------------------
|
||||
|
||||
This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
defined by the Mozilla Public License, v. 2.0.
|
9
Thirdparty/zeromq/share/zeromq/vcpkg-cmake-wrapper.cmake
vendored
Normal file
9
Thirdparty/zeromq/share/zeromq/vcpkg-cmake-wrapper.cmake
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
_find_package(${ARGS})
|
||||
|
||||
if(TARGET libzmq AND NOT TARGET libzmq-static)
|
||||
add_library(libzmq-static INTERFACE IMPORTED)
|
||||
set_target_properties(libzmq-static PROPERTIES INTERFACE_LINK_LIBRARIES libzmq)
|
||||
elseif(TARGET libzmq-static AND NOT TARGET libzmq)
|
||||
add_library(libzmq INTERFACE IMPORTED)
|
||||
set_target_properties(libzmq PROPERTIES INTERFACE_LINK_LIBRARIES libzmq-static)
|
||||
endif()
|
154
Thirdparty/zeromq/share/zeromq/vcpkg.spdx.json
vendored
Normal file
154
Thirdparty/zeromq/share/zeromq/vcpkg.spdx.json
vendored
Normal file
@ -0,0 +1,154 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/spdx/spdx-spec/v2.2.1/schemas/spdx-schema.json",
|
||||
"spdxVersion": "SPDX-2.2",
|
||||
"dataLicense": "CC0-1.0",
|
||||
"SPDXID": "SPDXRef-DOCUMENT",
|
||||
"documentNamespace": "https://spdx.org/spdxdocs/zeromq-x64-windows-4.3.5#1-349127b2-9538-443a-9e20-551b46fc22e0",
|
||||
"name": "zeromq:x64-windows@4.3.5#1 48055f4994a97a653c3cbc44973eeba770ab272f83c012f810b1343e1b945c7a",
|
||||
"creationInfo": {
|
||||
"creators": [
|
||||
"Tool: vcpkg-d6945642ee5c3076addd1a42c331bbf4cfc97457"
|
||||
],
|
||||
"created": "2024-12-08T08:19:21Z"
|
||||
},
|
||||
"relationships": [
|
||||
{
|
||||
"spdxElementId": "SPDXRef-port",
|
||||
"relationshipType": "GENERATES",
|
||||
"relatedSpdxElement": "SPDXRef-binary"
|
||||
},
|
||||
{
|
||||
"spdxElementId": "SPDXRef-port",
|
||||
"relationshipType": "CONTAINS",
|
||||
"relatedSpdxElement": "SPDXRef-file-0"
|
||||
},
|
||||
{
|
||||
"spdxElementId": "SPDXRef-port",
|
||||
"relationshipType": "CONTAINS",
|
||||
"relatedSpdxElement": "SPDXRef-file-1"
|
||||
},
|
||||
{
|
||||
"spdxElementId": "SPDXRef-port",
|
||||
"relationshipType": "CONTAINS",
|
||||
"relatedSpdxElement": "SPDXRef-file-2"
|
||||
},
|
||||
{
|
||||
"spdxElementId": "SPDXRef-port",
|
||||
"relationshipType": "CONTAINS",
|
||||
"relatedSpdxElement": "SPDXRef-file-3"
|
||||
},
|
||||
{
|
||||
"spdxElementId": "SPDXRef-binary",
|
||||
"relationshipType": "GENERATED_FROM",
|
||||
"relatedSpdxElement": "SPDXRef-port"
|
||||
},
|
||||
{
|
||||
"spdxElementId": "SPDXRef-file-0",
|
||||
"relationshipType": "CONTAINED_BY",
|
||||
"relatedSpdxElement": "SPDXRef-port"
|
||||
},
|
||||
{
|
||||
"spdxElementId": "SPDXRef-file-1",
|
||||
"relationshipType": "CONTAINED_BY",
|
||||
"relatedSpdxElement": "SPDXRef-port"
|
||||
},
|
||||
{
|
||||
"spdxElementId": "SPDXRef-file-2",
|
||||
"relationshipType": "CONTAINED_BY",
|
||||
"relatedSpdxElement": "SPDXRef-port"
|
||||
},
|
||||
{
|
||||
"spdxElementId": "SPDXRef-file-3",
|
||||
"relationshipType": "CONTAINED_BY",
|
||||
"relatedSpdxElement": "SPDXRef-port"
|
||||
}
|
||||
],
|
||||
"packages": [
|
||||
{
|
||||
"name": "zeromq",
|
||||
"SPDXID": "SPDXRef-port",
|
||||
"versionInfo": "4.3.5#1",
|
||||
"downloadLocation": "git+https://github.com/Microsoft/vcpkg#ports/zeromq",
|
||||
"homepage": "https://github.com/zeromq/libzmq",
|
||||
"licenseConcluded": "MPL-2.0",
|
||||
"licenseDeclared": "NOASSERTION",
|
||||
"copyrightText": "NOASSERTION",
|
||||
"description": "The ZeroMQ lightweight messaging kernel is a library which extends the standard socket interfaces with features traditionally provided by specialised messaging middleware products",
|
||||
"comment": "This is the port (recipe) consumed by vcpkg."
|
||||
},
|
||||
{
|
||||
"name": "zeromq:x64-windows",
|
||||
"SPDXID": "SPDXRef-binary",
|
||||
"versionInfo": "48055f4994a97a653c3cbc44973eeba770ab272f83c012f810b1343e1b945c7a",
|
||||
"downloadLocation": "NONE",
|
||||
"licenseConcluded": "MPL-2.0",
|
||||
"licenseDeclared": "NOASSERTION",
|
||||
"copyrightText": "NOASSERTION",
|
||||
"comment": "This is a binary package built by vcpkg."
|
||||
},
|
||||
{
|
||||
"SPDXID": "SPDXRef-resource-1",
|
||||
"name": "zeromq/libzmq",
|
||||
"downloadLocation": "git+https://github.com/zeromq/libzmq@v4.3.5",
|
||||
"licenseConcluded": "NOASSERTION",
|
||||
"licenseDeclared": "NOASSERTION",
|
||||
"copyrightText": "NOASSERTION",
|
||||
"checksums": [
|
||||
{
|
||||
"algorithm": "SHA512",
|
||||
"checksumValue": "108d9c5fa761c111585c30f9c651ed92942dda0ac661155bca52cc7b6dbeb3d27b0dd994abde206eacfc3bc88d19ed24e45b291050c38469e34dca5f8c9a037d"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"files": [
|
||||
{
|
||||
"fileName": "./D:/vcpkg/ports/zeromq/fix-arm.patch",
|
||||
"SPDXID": "SPDXRef-file-0",
|
||||
"checksums": [
|
||||
{
|
||||
"algorithm": "SHA256",
|
||||
"checksumValue": "4d231802a3981e3beb343818314826e58813732bfd70851c31b76682b88f0b97"
|
||||
}
|
||||
],
|
||||
"licenseConcluded": "NOASSERTION",
|
||||
"copyrightText": "NOASSERTION"
|
||||
},
|
||||
{
|
||||
"fileName": "./D:/vcpkg/ports/zeromq/portfile.cmake",
|
||||
"SPDXID": "SPDXRef-file-1",
|
||||
"checksums": [
|
||||
{
|
||||
"algorithm": "SHA256",
|
||||
"checksumValue": "f25d59456e32ea7fb294369bda6db00d9d7d1d786d611bbebdb90e55422d1fa2"
|
||||
}
|
||||
],
|
||||
"licenseConcluded": "NOASSERTION",
|
||||
"copyrightText": "NOASSERTION"
|
||||
},
|
||||
{
|
||||
"fileName": "./D:/vcpkg/ports/zeromq/vcpkg-cmake-wrapper.cmake",
|
||||
"SPDXID": "SPDXRef-file-2",
|
||||
"checksums": [
|
||||
{
|
||||
"algorithm": "SHA256",
|
||||
"checksumValue": "19043ac8e3a04cce2d94c59de9909704fa130cf2a340ea164d2a484bc7ce66dc"
|
||||
}
|
||||
],
|
||||
"licenseConcluded": "NOASSERTION",
|
||||
"copyrightText": "NOASSERTION"
|
||||
},
|
||||
{
|
||||
"fileName": "./D:/vcpkg/ports/zeromq/vcpkg.json",
|
||||
"SPDXID": "SPDXRef-file-3",
|
||||
"checksums": [
|
||||
{
|
||||
"algorithm": "SHA256",
|
||||
"checksumValue": "431f307cadda8a3a6b52a407534180e066ca51830708d3b5843fcb39f4ffe559"
|
||||
}
|
||||
],
|
||||
"licenseConcluded": "NOASSERTION",
|
||||
"copyrightText": "NOASSERTION"
|
||||
}
|
||||
]
|
||||
}
|
19
Thirdparty/zeromq/share/zeromq/vcpkg_abi_info.txt
vendored
Normal file
19
Thirdparty/zeromq/share/zeromq/vcpkg_abi_info.txt
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
cmake 3.29.2
|
||||
features core
|
||||
fix-arm.patch 4d231802a3981e3beb343818314826e58813732bfd70851c31b76682b88f0b97
|
||||
portfile.cmake f25d59456e32ea7fb294369bda6db00d9d7d1d786d611bbebdb90e55422d1fa2
|
||||
ports.cmake 0500e9e2422fe0084c99bdd0c9de4c7069b76da14c8b58228a7e95ebac43058a
|
||||
post_build_checks 2
|
||||
powershell 7.2.16
|
||||
triplet x64-windows
|
||||
triplet_abi 4556164a2cd3dd6f4742101eabb46def7e71b6e5856faa88e5d005aac12a803c-e36df1c7f50ab25f9c182fa927d06c19ae082e0d599f132b3f655784b49e4b33-c543948ecd5e4a5a4e61ec771337c095046b3106
|
||||
vcpkg-cmake 72c5fcc62d00fc527722f20df38cecd04017a2536592f15d130686fee7f84fae
|
||||
vcpkg-cmake-config 78775ea32d130eefb88a2359faa43f7a017f907f38b1ed404424fe22953155ff
|
||||
vcpkg-cmake-wrapper.cmake 19043ac8e3a04cce2d94c59de9909704fa130cf2a340ea164d2a484bc7ce66dc
|
||||
vcpkg.json 431f307cadda8a3a6b52a407534180e066ca51830708d3b5843fcb39f4ffe559
|
||||
vcpkg_check_features 943b217e0968d64cf2cb9c272608e6a0b497377e792034f819809a79e1502c2b
|
||||
vcpkg_copy_pdbs d57e4f196c82dc562a9968c6155073094513c31e2de475694143d3aa47954b1c
|
||||
vcpkg_fixup_pkgconfig 904e67c46ecbb67379911bc1d7222855c0cbfcf1129bf47783858bcf0cc44970
|
||||
vcpkg_from_git 96ed81968f76354c00096dd8cd4e63c6a235fa969334a11ab18d11c0c512ff58
|
||||
vcpkg_from_github b743742296a114ea1b18ae99672e02f142c4eb2bef7f57d36c038bedbfb0502f
|
||||
vcpkg_install_copyright ba6c169ab4e59fa05682e530cdeb883767de22c8391f023d4e6844a7ec5dd3d2
|
@ -25,6 +25,7 @@ INCLUDE_DIRECTORIES(
|
||||
${Thirdparty}
|
||||
${Thirdparty}/spdlog/include
|
||||
${Thirdparty}/libipc/include
|
||||
${Thirdparty}/zeromq/include
|
||||
)
|
||||
|
||||
link_directories(
|
||||
@ -32,6 +33,7 @@ link_directories(
|
||||
${Thirdparty}/glew/lib
|
||||
${Thirdparty}/spdlog/lib
|
||||
${Thirdparty}/libipc/lib
|
||||
${Thirdparty}/zeromq/debug/lib
|
||||
)
|
||||
|
||||
# IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
@ -64,11 +66,13 @@ IF(WIN32)
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE
|
||||
Winmm
|
||||
opengl32
|
||||
glew32s
|
||||
glfw3
|
||||
debug spdlogd
|
||||
optimized spdlog
|
||||
libzmq-mt-gd-4_3_5
|
||||
)
|
||||
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
#include "Texture2D.h"
|
||||
#include "Core/Thread/ScopeLock.h"
|
||||
#include "VHI/VHI.h"
|
||||
#include "Ipc/IpcMoudle.h"
|
||||
|
||||
ImageBuffer* Singleton<ImageBuffer>::instance_ = nullptr;
|
||||
|
||||
@ -19,12 +21,6 @@ void ImageBuffer::PushImage(ImageBuffer::IBType type, std::vector<unsigned char>
|
||||
case ImageBuffer::IBType::Human:
|
||||
PushHumanImage(std::move(data), width, height, comp);
|
||||
break;
|
||||
case ImageBuffer::IBType::Face:
|
||||
PushFaceImage(std::move(data), width, height, comp);
|
||||
break;
|
||||
case ImageBuffer::IBType::FaceMask:
|
||||
PushFaceMaskImage(std::move(data), width, height, comp);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -35,39 +31,56 @@ void ImageBuffer::Update(IBType type, Texture2D* texture) {
|
||||
case ImageBuffer::IBType::Human:
|
||||
UpdateHuman(texture);
|
||||
break;
|
||||
|
||||
case IBType::Face:
|
||||
UpdateFace(texture);
|
||||
|
||||
case IBType::FaceMask:
|
||||
UpdateFaceMask(texture);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ImageBuffer::PushHumanImage(std::vector<uint8> data, uint32 width, uint32 height, uint32 comp) {
|
||||
ScopeLock<CriticalSection> lock(&human_cs_);
|
||||
Image image{ std::move(data), width, height, comp, false };
|
||||
|
||||
human_.data = std::move(data);
|
||||
human_.width = width;
|
||||
human_.height = height;
|
||||
human_.comp = comp;
|
||||
human_.updated = true;
|
||||
{
|
||||
ScopeLock<CriticalSection> lock(&human_cs_);
|
||||
human_.emplace(std::move(image));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ImageBuffer::UpdateHuman(Texture2D* texture) {
|
||||
if (human_.data.empty()) {
|
||||
int count = 0;
|
||||
{
|
||||
ScopeLock<CriticalSection> lock(&human_cs_);
|
||||
if (human_.empty()) {
|
||||
return;
|
||||
}
|
||||
count = human_.size();
|
||||
}
|
||||
|
||||
if (playedIndex_ > VHI::Get()->GetAudioRender()->GetClock()+2) {
|
||||
return;
|
||||
}
|
||||
|
||||
ScopeLock<CriticalSection> lock(&human_cs_);
|
||||
if (!human_.updated) {
|
||||
return;
|
||||
if (count > 10) {
|
||||
constexpr char full[] = "full";
|
||||
IpcMoudle::Get()->Send(full, sizeof(full) / sizeof(full[0]));
|
||||
} else if (count < 3) {
|
||||
constexpr char empty[] = "empty";
|
||||
IpcMoudle::Get()->Send(empty, sizeof(empty) / sizeof(empty[0]));
|
||||
} else {
|
||||
constexpr char normal[] = "normal";
|
||||
IpcMoudle::Get()->Send(normal, sizeof(normal) / sizeof(normal[0]));
|
||||
}
|
||||
human_.updated = false;
|
||||
texture->Update(human_.width, human_.height, human_.comp, human_.data.data());
|
||||
|
||||
++playedIndex_;
|
||||
Image image;
|
||||
{
|
||||
ScopeLock<CriticalSection> lock(&human_cs_);
|
||||
image = std::move(human_.front());
|
||||
human_.pop();
|
||||
}
|
||||
|
||||
|
||||
texture->Update(image.width, image.height, image.comp, image.data.data());
|
||||
}
|
||||
|
||||
void ImageBuffer::PushFaceImage(std::vector<uint8> data, uint32 width, uint32 height, uint32 comp) {
|
||||
|
@ -10,8 +10,6 @@ class ImageBuffer : public Singleton<ImageBuffer> {
|
||||
public:
|
||||
enum class IBType {
|
||||
Human,
|
||||
Face,
|
||||
FaceMask,
|
||||
};
|
||||
public:
|
||||
explicit ImageBuffer() noexcept = default;
|
||||
@ -44,7 +42,8 @@ private:
|
||||
bool updated{false};
|
||||
};
|
||||
CriticalSection human_cs_;
|
||||
Image human_;
|
||||
std::queue<Image> human_;
|
||||
uint64 playedIndex_{ 0 };
|
||||
|
||||
CriticalSection face_cs_;
|
||||
Image face_;
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "Core/Core.h"
|
||||
#include "Ipc/ipclib.h"
|
||||
#include "ImageBuffer.h"
|
||||
#include "VHI/VHI.h"
|
||||
|
||||
IpcMoudle* Singleton<IpcMoudle>::instance_ = nullptr;
|
||||
|
||||
@ -19,32 +20,14 @@ void OnParseImageData(const char* data, size_t size) {
|
||||
|
||||
// Extract identifier
|
||||
char identifier = data[0];
|
||||
|
||||
// Extract width
|
||||
int width;
|
||||
std::memcpy(&width, data + 1, sizeof(int));
|
||||
|
||||
// Extract height
|
||||
int height;
|
||||
std::memcpy(&height, data + 5, sizeof(int));
|
||||
|
||||
// Extract bit depth
|
||||
int bit_depth;
|
||||
std::memcpy(&bit_depth, data + 9, sizeof(int));
|
||||
|
||||
// Extract image bytes
|
||||
const char* img_bytes = data + 13;
|
||||
size_t img_size = size - 13;
|
||||
std::vector<uint8> img_data(img_size);
|
||||
memcpy(img_data.data(), img_bytes, img_size);
|
||||
|
||||
const char* buffer = data + 1;
|
||||
if (0x01 == identifier) {
|
||||
ImageBuffer::Get()->PushImage(ImageBuffer::IBType::Human, std::move(img_data), width, height, bit_depth);
|
||||
IpcMoudle::Get()->PushImage(buffer, size - 1);
|
||||
} else if (0x02 == identifier) {
|
||||
ImageBuffer::Get()->PushImage(ImageBuffer::IBType::Face, std::move(img_data), width, height, bit_depth);
|
||||
} else if (0x03 == identifier) {
|
||||
ImageBuffer::Get()->PushImage(ImageBuffer::IBType::FaceMask, std::move(img_data), width, height, bit_depth);
|
||||
IpcMoudle::Get()->PushVoice(buffer, size - 1);
|
||||
}
|
||||
|
||||
INFOLOG("identifier {}", static_cast<int32>(identifier));
|
||||
}
|
||||
|
||||
bool IpcMoudle::Initialize() {
|
||||
@ -63,16 +46,25 @@ bool IpcMoudle::Initialize() {
|
||||
ERRORLOG("ipc listen failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
//auto callback = [](const char* data, unsigned int size) {
|
||||
// //INFOLOG("ipc recive data:{}", size);
|
||||
// OnParseImageData(data, size);
|
||||
//};
|
||||
//zmqMoudle_ = std::make_unique<ZmqMoudle>(callback);
|
||||
//zmqMoudle_->Start();
|
||||
lastHeartbeatTime_ = std::chrono::steady_clock::now();
|
||||
return true;
|
||||
}
|
||||
|
||||
void IpcMoudle::Uninitialize() {
|
||||
//zmqMoudle_->Stop();
|
||||
uninitialize();
|
||||
}
|
||||
|
||||
bool IpcMoudle::Send(const char* data, unsigned int size) {
|
||||
return send(data, size);
|
||||
return false;
|
||||
}
|
||||
|
||||
void IpcMoudle::OnFrame() {
|
||||
@ -80,11 +72,42 @@ void IpcMoudle::OnFrame() {
|
||||
auto duration = std::chrono::duration_cast<std::chrono::seconds>(now - lastHeartbeatTime_);
|
||||
|
||||
if (duration.count() >= 2) {
|
||||
constexpr char heartbeat[] = "heartbeat";
|
||||
if (!send("heartbeat", sizeof(heartbeat) / sizeof(heartbeat[0]))) {
|
||||
ERRORLOG("send heartbeat failed");
|
||||
reConnect();
|
||||
}
|
||||
/* constexpr char heartbeat[] = "heartbeat";
|
||||
if (!send("heartbeat", sizeof(heartbeat) / sizeof(heartbeat[0]))) {
|
||||
ERRORLOG("send heartbeat failed");
|
||||
reConnect();
|
||||
}*/
|
||||
lastHeartbeatTime_ = now;
|
||||
}
|
||||
}
|
||||
|
||||
void IpcMoudle::PushImage(const char* data, uint32 size) {
|
||||
// Extract width
|
||||
int width;
|
||||
std::memcpy(&width, data, sizeof(int));
|
||||
|
||||
// Extract height
|
||||
int height;
|
||||
std::memcpy(&height, data + 4, sizeof(int));
|
||||
|
||||
// Extract bit depth
|
||||
int bit_depth;
|
||||
std::memcpy(&bit_depth, data + 8, sizeof(int));
|
||||
|
||||
// Extract image bytes
|
||||
const char* img_bytes = data + 12;
|
||||
size_t img_size = size - 12;
|
||||
std::vector<uint8> img_data(img_size);
|
||||
memcpy(img_data.data(), img_bytes, img_size);
|
||||
|
||||
ImageBuffer::Get()->PushImage(ImageBuffer::IBType::Human, std::move(img_data), width, height, bit_depth);
|
||||
}
|
||||
|
||||
void IpcMoudle::PushVoice(const char* data, uint32 size) {
|
||||
IAudioRender* audioRender = VHI::Get()->GetAudioRender();
|
||||
if (nullptr == audioRender) {
|
||||
return;
|
||||
}
|
||||
|
||||
audioRender->Write(data, size);
|
||||
}
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include "Core/Singleton.h"
|
||||
#include "Core/Constant.h"
|
||||
|
||||
#include "Ipc/ZmqMoudle.h"
|
||||
|
||||
class IpcMoudle : public Singleton<IpcMoudle> {
|
||||
NON_COPYABLE(IpcMoudle)
|
||||
|
||||
@ -14,12 +16,16 @@ public:
|
||||
bool Initialize() override;
|
||||
void Uninitialize() override;
|
||||
|
||||
bool Send(const char* data, unsigned int size);
|
||||
bool Send(const char* data, uint32 size);
|
||||
|
||||
void OnFrame();
|
||||
|
||||
void PushImage(const char* data, uint32 size);
|
||||
void PushVoice(const char* data, uint32 size);
|
||||
|
||||
private:
|
||||
std::chrono::time_point<std::chrono::steady_clock> lastHeartbeatTime_;
|
||||
|
||||
std::unique_ptr<ZmqMoudle> zmqMoudle_;
|
||||
};
|
||||
|
||||
|
60
src/Ipc/ZmqMoudle.cpp
Normal file
60
src/Ipc/ZmqMoudle.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
#include "Ipc/ZmqMoudle.h"
|
||||
|
||||
#include <memory>
|
||||
#include <assert.h>
|
||||
|
||||
#include <zmq.hpp>
|
||||
|
||||
ZmqMoudle::ZmqMoudle(ZmqMoudleCallback callback)
|
||||
: callback_(callback){
|
||||
|
||||
}
|
||||
|
||||
void ZmqMoudle::Start() {
|
||||
if (work_) {
|
||||
return;
|
||||
}
|
||||
|
||||
shouldExit_.store(false);
|
||||
auto run = [this]() {
|
||||
zmq::context_t context(1);
|
||||
zmq::socket_t subscriber(context, ZMQ_SUB);
|
||||
subscriber.connect("tcp://127.0.0.1:55661");
|
||||
subscriber.setsockopt(ZMQ_SUBSCRIBE, "", 0);
|
||||
|
||||
bool isFirst = true;
|
||||
while (!shouldExit_.load()) {
|
||||
zmq::message_t message;
|
||||
if (subscriber.recv(message, zmq::recv_flags::none)) {
|
||||
if (isFirst) {
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
|
||||
// 打印自 Epoch 以来的时间(以秒为单位)
|
||||
auto duration = std::chrono::duration<double>(start.time_since_epoch());
|
||||
int64_t time = duration.count();
|
||||
time = 0;
|
||||
isFirst = true;
|
||||
}
|
||||
const char* data = static_cast<const char*>(message.data());
|
||||
if (nullptr != callback_) {
|
||||
callback_(data, message.size());
|
||||
}
|
||||
} else {
|
||||
::_sleep(1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
work_.reset(new std::thread(run));
|
||||
}
|
||||
|
||||
void ZmqMoudle::Stop() {
|
||||
if (!work_) {
|
||||
return;
|
||||
}
|
||||
|
||||
shouldExit_.store(true);
|
||||
if (work_->joinable()) {
|
||||
work_->join();
|
||||
}
|
||||
}
|
21
src/Ipc/ZmqMoudle.h
Normal file
21
src/Ipc/ZmqMoudle.h
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
|
||||
using ZmqMoudleCallback = std::function<void(const char* , unsigned int)>;
|
||||
class ZmqMoudle {
|
||||
public:
|
||||
ZmqMoudle(ZmqMoudleCallback callback);
|
||||
|
||||
void Start();
|
||||
void Stop();
|
||||
|
||||
private:
|
||||
ZmqMoudleCallback callback_;
|
||||
std::unique_ptr<std::thread> work_;
|
||||
void* context_{ nullptr };
|
||||
std::atomic<bool> shouldExit_;
|
||||
};
|
12
src/Main.cpp
12
src/Main.cpp
@ -10,6 +10,7 @@
|
||||
|
||||
#include "Core/Logger.h"
|
||||
#include "Ipc/IpcMoudle.h"
|
||||
#include "VHI/VHI.h"
|
||||
#include "ImageBuffer.h"
|
||||
#include "shader_s.h"
|
||||
#include "Texture2D.h"
|
||||
@ -17,8 +18,10 @@
|
||||
|
||||
static int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow) {
|
||||
Logger::Init();
|
||||
IpcMoudle::Init();
|
||||
ImageBuffer::Init();
|
||||
VHI::Init();
|
||||
IpcMoudle::Init();
|
||||
|
||||
auto glfwErrorCallback = [](int error, const char* description) {
|
||||
ERRORLOG("code={}, description={}", error, description);
|
||||
};
|
||||
@ -172,14 +175,15 @@ static int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevI
|
||||
//glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
//glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
|
||||
|
||||
constexpr char quit[] = "quit";
|
||||
IpcMoudle::Get()->Send(quit, sizeof(quit)/ sizeof(quit[0]));
|
||||
/*constexpr char quit[] = "quit";
|
||||
IpcMoudle::Get()->Send(quit, sizeof(quit)/ sizeof(quit[0]));*/
|
||||
|
||||
glfwDestroyWindow(window);
|
||||
glfwTerminate();
|
||||
|
||||
ImageBuffer::Shotdown();
|
||||
IpcMoudle::Shotdown();
|
||||
VHI::Shotdown();
|
||||
ImageBuffer::Shotdown();
|
||||
Logger::Shotdown();
|
||||
return 0;
|
||||
}
|
||||
|
18
src/VHI/AudioRenderStd.cpp
Normal file
18
src/VHI/AudioRenderStd.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include "AudioRenderStd.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "Core/Core.h"
|
||||
#include "VHI/Windows/WavAudioRender.h"
|
||||
|
||||
IAudioRender* IAudioRender::Create() {
|
||||
return new WavAudioRender();
|
||||
}
|
||||
|
||||
AudioRenderStd::AudioRenderStd() noexcept {
|
||||
|
||||
}
|
||||
|
||||
void AudioRenderStd::WirteLog(int32 level, const std::string& log) {
|
||||
INFOLOG(log);
|
||||
}
|
22
src/VHI/AudioRenderStd.h
Normal file
22
src/VHI/AudioRenderStd.h
Normal file
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "IAudioRender.h"
|
||||
|
||||
class AudioRenderStd : public IAudioRender {
|
||||
public:
|
||||
enum LOG_LEVEL {
|
||||
DEBUG,
|
||||
LOG
|
||||
};
|
||||
public:
|
||||
explicit AudioRenderStd() noexcept;
|
||||
~AudioRenderStd() override = default;
|
||||
uint64 GetClock() override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void WirteLog(int32 level, const std::string& log);
|
||||
};
|
||||
|
23
src/VHI/IAudioRender.h
Normal file
23
src/VHI/IAudioRender.h
Normal file
@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
#include "Core/Core.h"
|
||||
|
||||
|
||||
struct AudioFrame {
|
||||
std::vector<uint8> data_;
|
||||
};
|
||||
|
||||
|
||||
class IAudioRender {
|
||||
public:
|
||||
using LogCallback = std::function<void(int32, const int8*, uint32)>;
|
||||
static IAudioRender* Create();
|
||||
|
||||
public:
|
||||
virtual ~IAudioRender() = default;
|
||||
virtual uint64 GetClock() = 0;
|
||||
virtual bool Write(const char* data, uint32 size) = 0;
|
||||
};
|
28
src/VHI/VHI.cpp
Normal file
28
src/VHI/VHI.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
#include "VHI/VHI.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <memory>
|
||||
|
||||
#include "Core/Core.h"
|
||||
|
||||
#include "IAudioRender.h"
|
||||
|
||||
VHI* Singleton<VHI>::instance_ = nullptr;
|
||||
|
||||
VHI::VHI() noexcept {
|
||||
|
||||
}
|
||||
|
||||
VHI::~VHI() {
|
||||
|
||||
}
|
||||
|
||||
bool VHI::Initialize() {
|
||||
audioRender_.reset(IAudioRender::Create());
|
||||
return true;
|
||||
}
|
||||
|
||||
void VHI::Uninitialize() {
|
||||
audioRender_.reset();
|
||||
}
|
||||
|
21
src/VHI/VHI.h
Normal file
21
src/VHI/VHI.h
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/Singleton.h"
|
||||
|
||||
#include "VHI/IAudioRender.h"
|
||||
|
||||
class VHI : public Singleton<VHI> {
|
||||
public:
|
||||
explicit VHI() noexcept;
|
||||
~VHI() override;
|
||||
|
||||
bool Initialize() override;
|
||||
void Uninitialize() override;
|
||||
|
||||
IAudioRender* GetAudioRender() const noexcept {
|
||||
return audioRender_.get();
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<IAudioRender> audioRender_;
|
||||
};
|
1
src/VHI/Windows/CoreAudioRender.cpp
Normal file
1
src/VHI/Windows/CoreAudioRender.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "CoreAudioRender.h"
|
7
src/VHI/Windows/CoreAudioRender.h
Normal file
7
src/VHI/Windows/CoreAudioRender.h
Normal file
@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "VHI/IAudioRender.h"
|
||||
|
||||
class CoreAudioRender : public IAudioRender {
|
||||
};
|
||||
|
222
src/VHI/Windows/WavAudioRender.cpp
Normal file
222
src/VHI/Windows/WavAudioRender.cpp
Normal file
@ -0,0 +1,222 @@
|
||||
#include "VHI/Windows/WavAudioRender.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
|
||||
|
||||
static WAVEHDR* AllocateBlocks(uint32 size, int32 count) {
|
||||
uint32 totalBufferSize = (size + sizeof(WAVEHDR)) * count;
|
||||
|
||||
uint8* buffer{ nullptr };
|
||||
if ((buffer = reinterpret_cast<uint8*>(HeapAlloc(
|
||||
GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
totalBufferSize
|
||||
))) == NULL) {
|
||||
ExitProcess(1);
|
||||
}
|
||||
|
||||
WAVEHDR* blocks = reinterpret_cast<WAVEHDR*>(buffer);
|
||||
buffer += sizeof(WAVEHDR) * count;
|
||||
for (int32 index = 0; index < count; ++index) {
|
||||
blocks[index].dwBufferLength = size;
|
||||
blocks[index].lpData = (LPSTR)buffer;
|
||||
blocks[index].dwFlags = 0;
|
||||
buffer += size;
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
static void FreeBlocks(WAVEHDR* blockArray) {
|
||||
HeapFree(GetProcessHeap(), 0, blockArray);
|
||||
}
|
||||
|
||||
|
||||
class WavAudioRenderImpl {
|
||||
public:
|
||||
using UtilComplateCallback = std::function<void()>;
|
||||
public:
|
||||
explicit WavAudioRenderImpl(UtilComplateCallback callback) noexcept;
|
||||
~WavAudioRenderImpl();
|
||||
|
||||
bool Write(const char* data, uint32 size);
|
||||
static void CALLBACK waveOutProc(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance,
|
||||
DWORD_PTR dwParam1, DWORD_PTR dwParam2);
|
||||
void FreeBlock();
|
||||
|
||||
private:
|
||||
static constexpr int BlockSize_{ 1280 };
|
||||
static constexpr int BlockCount_{ 10 };
|
||||
|
||||
uint32 freeBlockCounter_{ BlockCount_ };
|
||||
uint32 waveCurrentBlock_{ 0 };
|
||||
|
||||
WAVEHDR* waveBlocks_{ nullptr };
|
||||
HWAVEOUT hWavout_{ nullptr };
|
||||
bool initialized_{ false };
|
||||
UtilComplateCallback callback_;
|
||||
};
|
||||
|
||||
WavAudioRenderImpl::WavAudioRenderImpl(UtilComplateCallback callback) noexcept
|
||||
: callback_(callback){
|
||||
HWAVEOUT hWaveOut = nullptr;
|
||||
|
||||
waveBlocks_ = AllocateBlocks(BlockSize_, BlockCount_);
|
||||
|
||||
constexpr int32 rate = 16000;
|
||||
constexpr int32 channel = 1;
|
||||
constexpr int32 bitePerSample = 16;
|
||||
|
||||
WAVEFORMATEX waveform;
|
||||
waveform.wFormatTag = WAVE_FORMAT_PCM;
|
||||
waveform.nChannels = channel;
|
||||
waveform.nSamplesPerSec = rate;
|
||||
waveform.nAvgBytesPerSec = rate * channel * 2;
|
||||
waveform.nBlockAlign = channel * 2;
|
||||
waveform.wBitsPerSample = bitePerSample;
|
||||
waveform.cbSize = 0;
|
||||
|
||||
|
||||
MMRESULT hr = waveOutOpen(&hWaveOut, WAVE_MAPPER, &waveform,
|
||||
reinterpret_cast<DWORD_PTR>(WavAudioRenderImpl::waveOutProc),
|
||||
reinterpret_cast<DWORD_PTR>(this), CALLBACK_FUNCTION);
|
||||
if (MMSYSERR_NOERROR != hr) {
|
||||
return;
|
||||
}
|
||||
|
||||
hWavout_ = std::move(hWaveOut);
|
||||
initialized_ = true;
|
||||
}
|
||||
|
||||
WavAudioRenderImpl::~WavAudioRenderImpl() {
|
||||
initialized_ = false;
|
||||
if (nullptr == hWavout_) {
|
||||
return;
|
||||
}
|
||||
waveOutReset(hWavout_);
|
||||
for (int i = 0; i < BlockCount_; i++) {
|
||||
if (waveBlocks_[i].dwFlags & WHDR_PREPARED) {
|
||||
waveOutUnprepareHeader(hWavout_, &waveBlocks_[i], sizeof(WAVEHDR));
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
MMRESULT ret = waveOutClose(hWavout_);
|
||||
if (MMSYSERR_NOERROR == ret) {
|
||||
break;
|
||||
} else if (WAVERR_STILLPLAYING == ret) {
|
||||
::Sleep(1);
|
||||
} else if (MMSYSERR_NOMEM == ret) {
|
||||
break;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
FreeBlocks(waveBlocks_);
|
||||
}
|
||||
|
||||
bool WavAudioRenderImpl::Write(const char* data, uint32 size) {
|
||||
if (nullptr == hWavout_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
WAVEHDR* current;
|
||||
int32 remain;
|
||||
current = &waveBlocks_[waveCurrentBlock_];
|
||||
while (size > 0) {
|
||||
if (current->dwFlags & WHDR_PREPARED) {
|
||||
waveOutUnprepareHeader(hWavout_, current, sizeof(WAVEHDR));
|
||||
}
|
||||
if (size < (int)(BlockSize_ - current->dwUser)) {
|
||||
memcpy(current->lpData + current->dwUser, data, size);
|
||||
current->dwUser += size;
|
||||
break;
|
||||
}
|
||||
remain = BlockSize_ - static_cast<int32>(current->dwUser);
|
||||
memcpy(current->lpData + current->dwUser, data, remain);
|
||||
size -= remain;
|
||||
data += remain;
|
||||
current->dwBufferLength = BlockSize_;
|
||||
waveOutPrepareHeader(hWavout_, current, sizeof(WAVEHDR));
|
||||
waveOutWrite(hWavout_, current, sizeof(WAVEHDR));
|
||||
--freeBlockCounter_;
|
||||
|
||||
while (!freeBlockCounter_ && initialized_) {
|
||||
Sleep(1);
|
||||
}
|
||||
if (!initialized_) {
|
||||
break;
|
||||
}
|
||||
|
||||
++waveCurrentBlock_;
|
||||
waveCurrentBlock_ %= BlockCount_;
|
||||
current = &waveBlocks_[waveCurrentBlock_];
|
||||
current->dwUser = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CALLBACK WavAudioRenderImpl::waveOutProc(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance,
|
||||
DWORD_PTR dwParam1, DWORD_PTR dwParam2) {
|
||||
WavAudioRenderImpl* self = reinterpret_cast<WavAudioRenderImpl*>(dwInstance);
|
||||
|
||||
if (uMsg != WOM_DONE)
|
||||
return;
|
||||
|
||||
self->FreeBlock();
|
||||
}
|
||||
|
||||
void WavAudioRenderImpl::FreeBlock() {
|
||||
++freeBlockCounter_;
|
||||
if (nullptr != callback_) {
|
||||
callback_();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
WavAudioRender::WavAudioRender() noexcept {
|
||||
auto utilComplatedCallback = [this]() {
|
||||
++playedIndex_;
|
||||
};
|
||||
|
||||
auto run = [this, utilComplatedCallback]() {
|
||||
WavAudioRenderImpl impl(utilComplatedCallback);
|
||||
std::vector<int8> temp;
|
||||
while (!showExit_.load()) {
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
cv_.wait(lock, [&]() {return !audioQueue_.empty() || showExit_.load(); });
|
||||
if (showExit_.load()) {
|
||||
break;
|
||||
}
|
||||
temp = std::move(audioQueue_.front());
|
||||
audioQueue_.pop();
|
||||
}
|
||||
impl.Write(temp.data(), temp.size());
|
||||
}
|
||||
};
|
||||
|
||||
work_.reset(new std::thread(run));
|
||||
}
|
||||
|
||||
WavAudioRender::~WavAudioRender() {
|
||||
showExit_.store(true);
|
||||
cv_.notify_one();
|
||||
if (work_->joinable()) {
|
||||
work_->join();
|
||||
}
|
||||
}
|
||||
|
||||
bool WavAudioRender::Write(const char* data, uint32 size) {
|
||||
WirteLog(DEBUG, "WavAudioRender::Write");
|
||||
|
||||
std::vector<int8> frame(size, 0);
|
||||
memcpy(&frame[0], data, size);
|
||||
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
audioQueue_.emplace(std::move(frame));
|
||||
cv_.notify_one();
|
||||
return true;
|
||||
}
|
||||
|
27
src/VHI/Windows/WavAudioRender.h
Normal file
27
src/VHI/Windows/WavAudioRender.h
Normal file
@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <queue>
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
|
||||
#include "VHI/AudioRenderStd.h"
|
||||
|
||||
class WavAudioRender : public AudioRenderStd {
|
||||
public:
|
||||
explicit WavAudioRender() noexcept;
|
||||
~WavAudioRender() override;
|
||||
|
||||
bool Write(const char* data, uint32 size) override;
|
||||
uint64 GetClock() override {
|
||||
return playedIndex_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::atomic<bool> showExit_{ false };
|
||||
std::mutex mutex_;
|
||||
std::condition_variable cv_;
|
||||
std::queue<std::vector<int8>> audioQueue_;
|
||||
std::unique_ptr<std::thread> work_;
|
||||
uint64 playedIndex_{ 0 };
|
||||
};
|
Loading…
Reference in New Issue
Block a user