Agora RTC Objective-C API Reference Refactor

AgoraExtensionProviderEntry.h
Go to the documentation of this file.
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 #if defined (__GNUC__)
31 #define REGISTER_AGORA_EXTENSION_PROVIDER(PROVIDER_NAME, PROVIDER_CLASS, PROVIDER_INTERFACE_USED, ...) \
32 DECLARE_CREATE_AND_REGISTER_PROVIDER(PROVIDER_NAME, PROVIDER_CLASS, PROVIDER_INTERFACE_USED, __VA_ARGS__); \
33 __attribute__((constructor, used)) \
34 static void _##PROVIDER_NAME##_provider_entry() { \
35 registerProviderEntry(#PROVIDER_NAME, register_##PROVIDER_NAME##_to_agora); \
36 } \
37
38 #elif defined (_MSC_VER)
39 #define REGISTER_AGORA_EXTENSION_PROVIDER(PROVIDER_NAME, PROVIDER_CLASS, PROVIDER_INTERFACE_USED, ...) \
40 DECLARE_CREATE_AND_REGISTER_PROVIDER(PROVIDER_NAME, PROVIDER_CLASS, PROVIDER_INTERFACE_USED, __VA_ARGS__); \
41 static int _##PROVIDER_NAME##_provider_entry() { \
42 registerProviderEntry(#PROVIDER_NAME, register_##PROVIDER_NAME##_to_agora); \
43 return 0; \
44 } \
45 const int DUMMY_AGORA_REGEXT_##PROVIDE_NAME##_VAR = _##PROVIDER_NAME##_provider_entry(); \
46
47 #else
48 #error Unsupported Compilation Toolchain!
49 #endif
declareProviderVersion
AGORA_API void AGORA_CALL declareProviderVersion(const char *, const agora::rtc::ExtensionVersion &)
agora_ext_entry_func_t
void(* agora_ext_entry_func_t)(void)
Definition: AgoraExtensionProviderEntry.h:15
agora::rtc::ExtensionVersion
Definition: AgoraExtensionVersion.h:14
getAgoraExtensionControl
AGORA_API agora::rtc::IExtensionControl *AGORA_CALL getAgoraExtensionControl()
NGIAgoraExtensionControl.h
registerProviderEntry
AGORA_API void AGORA_CALL registerProviderEntry(const char *, agora_ext_entry_func_t)
AGORA_API
#define AGORA_API
Definition: AgoraBase.h:60
AGORA_CALL
#define AGORA_CALL
Definition: AgoraBase.h:61
agora::rtc::IExtensionControl
Definition: NGIAgoraExtensionControl.h:23