Agora C++ API Reference for All Platforms

AgoraExtensionProviderEntry.h
1 //
2 // Copyright (c) 2020 Agora.io. All rights reserved
3
4 // This program is confidential and proprietary to Agora.io.
5 // And may not be copied, reproduced, modified, disclosed to others, published
6 // or used, in whole or in part, without the express prior written permission
7 // of Agora.io.
8
9 #pragma once // NOLINT(build/header_guard)
10
11 #include "NGIAgoraExtensionControl.h"
12 AGORA_API agora::rtc::IExtensionControl* AGORA_CALL getAgoraExtensionControl();
13 AGORA_API void AGORA_CALL declareProviderVersion(
14 const char*, const agora::rtc::ExtensionVersion&);
15 typedef void(*agora_ext_entry_func_t)(void);
16 AGORA_API void AGORA_CALL registerProviderEntry(const char*, agora_ext_entry_func_t);
17
18 #define DECLARE_CREATE_AND_REGISTER_PROVIDER(PROVIDER_NAME, PROVIDER_CLASS, PROVIDER_INTERFACE_USED, ...) \
19 static void register_##PROVIDER_NAME##_to_agora() { \
20 auto control = getAgoraExtensionControl(); \
21 agora::rtc::ExtensionVersion version = \
22 agora::rtc::ExtensionInterfaceVersion<PROVIDER_INTERFACE_USED>::Version(); \
23 declareProviderVersion(#PROVIDER_NAME, version); \
24 if (#PROVIDER_NAME && control) { \
25 control->registerProvider(#PROVIDER_NAME, \
26 new agora::RefCountedObject<PROVIDER_CLASS>(__VA_ARGS__)); \
27 } \
28 } \
29
30 #define DECLARE_CREATE_AND_REGISTER_PROVIDER_PTR(PROVIDER_NAME, PROVIDER_INTERFACE_USED, PROVIDER_REF_PTR) \
31 static void register_##PROVIDER_NAME##_to_agora() { \
32 auto control = getAgoraExtensionControl(); \
33 agora::rtc::ExtensionVersion version = \
34 agora::rtc::ExtensionInterfaceVersion<PROVIDER_INTERFACE_USED>::Version(); \
35 declareProviderVersion(#PROVIDER_NAME, version); \
36 if (#PROVIDER_NAME && control) { \
37 control->registerProvider(#PROVIDER_NAME, PROVIDER_REF_PTR); \
38 } \
39 } \
40
41
42 #if defined (__GNUC__)
43 #define REGISTER_AGORA_EXTENSION_PROVIDER(PROVIDER_NAME, PROVIDER_CLASS, PROVIDER_INTERFACE_USED, ...) \
44 DECLARE_CREATE_AND_REGISTER_PROVIDER(PROVIDER_NAME, PROVIDER_CLASS, PROVIDER_INTERFACE_USED, __VA_ARGS__); \
45 __attribute__((constructor, used)) \
46 static void _##PROVIDER_NAME##_provider_entry() { \
47 registerProviderEntry(#PROVIDER_NAME, register_##PROVIDER_NAME##_to_agora); \
48 } \
49
50 #define REGISTER_AGORA_EXTENSION_PROVIDER_PTR(PROVIDER_NAME, PROVIDER_INTERFACE_USED, PROVIDER_REF_PTR) \
51 DECLARE_CREATE_AND_REGISTER_PROVIDER_PTR(PROVIDER_NAME, PROVIDER_INTERFACE_USED, PROVIDER_REF_PTR); \
52 __attribute__((constructor, used)) \
53 static void _##PROVIDER_NAME##_provider_entry() { \
54 registerProviderEntry(#PROVIDER_NAME, register_##PROVIDER_NAME##_to_agora); \
55 } \
56
57
58 #elif defined (_MSC_VER)
59 #define REGISTER_AGORA_EXTENSION_PROVIDER(PROVIDER_NAME, PROVIDER_CLASS, PROVIDER_INTERFACE_USED, ...) \
60 DECLARE_CREATE_AND_REGISTER_PROVIDER(PROVIDER_NAME, PROVIDER_CLASS, PROVIDER_INTERFACE_USED, __VA_ARGS__); \
61 static int _##PROVIDER_NAME##_provider_entry() { \
62 registerProviderEntry(#PROVIDER_NAME, register_##PROVIDER_NAME##_to_agora); \
63 return 0; \
64 } \
65 const int DUMMY_AGORA_REGEXT_##PROVIDE_NAME##_VAR = _##PROVIDER_NAME##_provider_entry(); \
66
67 #define REGISTER_AGORA_EXTENSION_PROVIDER_PTR(PROVIDER_NAME, PROVIDER_INTERFACE_USED, PROVIDER_REF_PTR) \
68 DECLARE_CREATE_AND_REGISTER_PROVIDER_PTR(PROVIDER_NAME, PROVIDER_INTERFACE_USED, PROVIDER_REF_PTR); \
69 static int _##PROVIDER_NAME##_provider_entry() { \
70 registerProviderEntry(#PROVIDER_NAME, register_##PROVIDER_NAME##_to_agora); \
71 return 0; \
72 } \
73 const int DUMMY_AGORA_REGEXT_##PROVIDE_NAME##_VAR = _##PROVIDER_NAME##_provider_entry(); \
74
75 #else
76 #error Unsupported Compilation Toolchain!
77 #endif
agora::rtc::ExtensionVersion
Definition: AgoraExtensionVersion.h:14
agora::rtc::IExtensionControl
Definition: NGIAgoraExtensionControl.h:22