Jelajahi Sumber

Add more dllexports, leave RTC_CPP_EXPORT only in log.hpp, and ignore C4251 warning.

Hanseul Jun 4 tahun lalu
induk
melakukan
679c0ccd2e

+ 4 - 1
CMakeLists.txt

@@ -247,7 +247,10 @@ add_library(LibDataChannel::LibDataChannelStatic ALIAS datachannel-static)
 install(TARGETS datachannel LIBRARY DESTINATION lib)
 install(FILES ${LIBDATACHANNEL_HEADERS} DESTINATION include/rtc)
 
-if(NOT MSVC)
+if(MSVC)
+	target_compile_options(datachannel PRIVATE /wd4251)
+	target_compile_options(datachannel-static PRIVATE /wd4251)
+else()
 	target_compile_options(datachannel PRIVATE -Wall -Wextra)
 	target_compile_options(datachannel-static PRIVATE -Wall -Wextra)
 endif()

+ 3 - 3
include/rtc/candidate.hpp

@@ -76,8 +76,8 @@ private:
 
 } // namespace rtc
 
-std::ostream &operator<<(std::ostream &out, const rtc::Candidate &candidate);
-std::ostream &operator<<(std::ostream &out, const rtc::Candidate::Type &type);
-std::ostream &operator<<(std::ostream &out, const rtc::Candidate::TransportType &transportType);
+RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, const rtc::Candidate &candidate);
+RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, const rtc::Candidate::Type &type);
+RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, const rtc::Candidate::TransportType &transportType);
 
 #endif

+ 2 - 2
include/rtc/configuration.hpp

@@ -51,7 +51,7 @@ struct RTC_CPP_EXPORT IceServer {
 	RelayType relayType;
 };
 
-struct ProxyServer {
+struct RTC_CPP_EXPORT ProxyServer {
 	enum class Type { None = 0, Socks5, Http, Last = Http };
 
 	ProxyServer(Type type_, string ip_, uint16_t port_, string username_ = "",
@@ -64,7 +64,7 @@ struct ProxyServer {
 	string password;
 };
 
-struct Configuration {
+struct RTC_CPP_EXPORT Configuration {
 	std::vector<IceServer> iceServers;
 	std::optional<ProxyServer> proxyServer;
 	bool enableIceTcp = false;

+ 1 - 1
include/rtc/datachannel.hpp

@@ -87,7 +87,7 @@ private:
 	friend class PeerConnection;
 };
 
-class NegociatedDataChannel final : public DataChannel {
+class RTC_CPP_EXPORT NegociatedDataChannel final : public DataChannel {
 public:
 	NegociatedDataChannel(std::weak_ptr<PeerConnection> pc, uint16_t stream, string label,
 	                      string protocol, Reliability reliability);

+ 0 - 3
include/rtc/include.hpp

@@ -28,12 +28,9 @@
 #endif
 
 #ifdef _WIN32
-#define RTC_CPP_EXPORT __declspec(dllexport)
 #ifndef _WIN32_WINNT
 #define _WIN32_WINNT 0x0602 // Windows 8
 #endif
-#else
-#define RTC_CPP_EXPORT
 #endif
 
 #include "log.hpp"

+ 1 - 1
include/rtc/init.hpp

@@ -27,7 +27,7 @@ namespace rtc {
 
 using init_token = std::shared_ptr<void>;
 
-class Init {
+class RTC_CPP_EXPORT Init {
 public:
 	static init_token Token();
 	static void Preload();

+ 1 - 1
include/rtc/message.hpp

@@ -29,7 +29,7 @@
 
 namespace rtc {
 
-struct Message : binary {
+struct RTC_CPP_EXPORT Message : binary {
 	enum Type { Binary, String, Control, Reset };
 
 	Message(const Message &message) = default;

+ 1 - 1
include/rtc/peerconnection.hpp

@@ -50,7 +50,7 @@ class SctpTransport;
 using certificate_ptr = std::shared_ptr<Certificate>;
 using future_certificate_ptr = std::shared_future<certificate_ptr>;
 
-struct DataChannelInit {
+struct RTC_CPP_EXPORT DataChannelInit {
 	Reliability reliability = {};
 	bool negotiated = false;
 	std::optional<uint16_t> id = nullopt;

+ 2 - 2
include/rtc/rtcp.hpp

@@ -29,7 +29,7 @@
 
 namespace rtc {
 
-class RtcpHandler {
+class RTC_CPP_EXPORT RtcpHandler {
 protected:
 	/**
 	 * Use this callback when trying to send custom data (such as RTCP) to the client.
@@ -64,7 +64,7 @@ public:
 class Track;
 
 // An RtcpSession can be plugged into a Track to handle the whole RTCP session
-class RtcpReceivingSession : public RtcpHandler {
+class RTC_CPP_EXPORT RtcpReceivingSession : public RtcpHandler {
 public:
 	rtc::message_ptr incoming(rtc::message_ptr ptr) override;
 	rtc::message_ptr outgoing(rtc::message_ptr ptr) override;

+ 1 - 1
include/rtc/track.hpp

@@ -35,7 +35,7 @@ namespace rtc {
 class DtlsSrtpTransport;
 #endif
 
-class Track final : public std::enable_shared_from_this<Track>, public Channel {
+class RTC_CPP_EXPORT Track final : public std::enable_shared_from_this<Track>, public Channel {
 public:
 	Track(Description::Media description);
 	~Track() = default;

+ 1 - 1
include/rtc/websocket.hpp

@@ -38,7 +38,7 @@ class TcpTransport;
 class TlsTransport;
 class WsTransport;
 
-class WebSocket final : public Channel, public std::enable_shared_from_this<WebSocket> {
+class RTC_CPP_EXPORT WebSocket final : public Channel, public std::enable_shared_from_this<WebSocket> {
 public:
 	enum class State : int {
 		Connecting = 0,

+ 5 - 5
src/certificate.hpp

@@ -27,7 +27,7 @@
 
 namespace rtc {
 
-class Certificate {
+class RTC_CPP_EXPORT Certificate {
 public:
 	Certificate(string crt_pem, string key_pem);
 
@@ -53,17 +53,17 @@ private:
 };
 
 #if USE_GNUTLS
-string make_fingerprint(gnutls_x509_crt_t crt);
+RTC_CPP_EXPORT string make_fingerprint(gnutls_x509_crt_t crt);
 #else
-string make_fingerprint(X509 *x509);
+RTC_CPP_EXPORT string make_fingerprint(X509 *x509);
 #endif
 
 using certificate_ptr = std::shared_ptr<Certificate>;
 using future_certificate_ptr = std::shared_future<certificate_ptr>;
 
-future_certificate_ptr make_certificate(string commonName = "libdatachannel"); // cached
+RTC_CPP_EXPORT future_certificate_ptr make_certificate(string commonName = "libdatachannel"); // cached
 
-void CleanupCertificateCache();
+RTC_CPP_EXPORT void CleanupCertificateCache();
 
 } // namespace rtc
 

+ 1 - 1
src/dtlssrtptransport.hpp

@@ -34,7 +34,7 @@
 
 namespace rtc {
 
-class DtlsSrtpTransport final : public DtlsTransport {
+class RTC_CPP_EXPORT DtlsSrtpTransport final : public DtlsTransport {
 public:
 	static void Init();
 	static void Cleanup();

+ 1 - 1
src/icetransport.hpp

@@ -38,7 +38,7 @@
 
 namespace rtc {
 
-class IceTransport : public Transport {
+class RTC_CPP_EXPORT IceTransport : public Transport {
 public:
 	enum class GatheringState { New = 0, InProgress = 1, Complete = 2 };
 

+ 1 - 1
src/processor.hpp

@@ -33,7 +33,7 @@
 namespace rtc {
 
 // Processed tasks in order by delegating them to the thread pool
-class Processor final {
+class RTC_CPP_EXPORT Processor final {
 public:
 	Processor(size_t limit = 0);
 	~Processor();

+ 1 - 1
src/sctptransport.hpp

@@ -37,7 +37,7 @@
 
 namespace rtc {
 
-class SctpTransport final : public Transport {
+class RTC_CPP_EXPORT SctpTransport final : public Transport {
 public:
 	static void Init();
 	static void Cleanup();

+ 2 - 2
src/tcptransport.hpp

@@ -34,7 +34,7 @@
 namespace rtc {
 
 // Utility class to interrupt select()
-class SelectInterrupter {
+class RTC_CPP_EXPORT SelectInterrupter {
 public:
 	SelectInterrupter();
 	~SelectInterrupter();
@@ -51,7 +51,7 @@ private:
 #endif
 };
 
-class TcpTransport : public Transport {
+class RTC_CPP_EXPORT TcpTransport : public Transport {
 public:
 	TcpTransport(const string &hostname, const string &service, state_callback callback);
 	~TcpTransport();

+ 1 - 1
src/threadpool.hpp

@@ -37,7 +37,7 @@ namespace rtc {
 template <class F, class... Args>
 using invoke_future_t = std::future<std::invoke_result_t<std::decay_t<F>, std::decay_t<Args>...>>;
 
-class ThreadPool final {
+class RTC_CPP_EXPORT ThreadPool final {
 public:
 	static ThreadPool &Instance();
 

+ 1 - 1
src/tlstransport.hpp

@@ -32,7 +32,7 @@ namespace rtc {
 
 class TcpTransport;
 
-class TlsTransport : public Transport {
+class RTC_CPP_EXPORT TlsTransport : public Transport {
 public:
 	static void Init();
 	static void Cleanup();

+ 1 - 1
src/transport.hpp

@@ -30,7 +30,7 @@ namespace rtc {
 
 using namespace std::placeholders;
 
-class Transport {
+class RTC_CPP_EXPORT Transport {
 public:
 	enum class State { Disconnected, Connecting, Connected, Completed, Failed };
 	using state_callback = std::function<void(State state)>;

+ 1 - 1
src/verifiedtlstransport.hpp

@@ -25,7 +25,7 @@
 
 namespace rtc {
 
-class VerifiedTlsTransport final : public TlsTransport {
+class RTC_CPP_EXPORT VerifiedTlsTransport final : public TlsTransport {
 public:
 	VerifiedTlsTransport(std::shared_ptr<TcpTransport> lower, string host, state_callback callback);
 	~VerifiedTlsTransport();

+ 1 - 1
src/wstransport.hpp

@@ -29,7 +29,7 @@ namespace rtc {
 class TcpTransport;
 class TlsTransport;
 
-class WsTransport : public Transport {
+class RTC_CPP_EXPORT WsTransport : public Transport {
 public:
 	WsTransport(std::shared_ptr<Transport> lower, string host, string path,
 	            message_callback recvCallback, state_callback stateCallback);