Browse Source

Merge pull request #240 from in2core/feature/mac-compatibility

Mac compatibility
Paul-Louis Ageneau 4 years ago
parent
commit
973f58ec8b
2 changed files with 38 additions and 1 deletions
  1. 23 0
      README.md
  2. 15 1
      src/peerconnection.cpp

+ 23 - 0
README.md

@@ -81,6 +81,29 @@ $ cd build
 $ make -j2
 $ make -j2
 ```
 ```
 
 
+#### Apple macOS with XCode project
+
+```bash
+$ cmake -B "$BUILD_DIR" -DUSE_GNUTLS=0 -DUSE_NICE=0 -G Xcode
+```
+
+Xcode project is generated in *build/* directory.
+
+##### Solving **Could NOT find OpenSSL** error
+
+You need to add OpenSSL root directory if your build fails with the following message: 
+
+```
+Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
+system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY
+OPENSSL_INCLUDE_DIR)
+```
+
+for example:
+```bash
+$ cmake -B build -DUSE_GNUTLS=0 -DUSE_NICE=0 -G Xcode -DOPENSSL_ROOT_DIR=/usr/local/Cellar/openssl\@1.1/1.1.1h/
+```
+
 #### Microsoft Windows with MinGW cross-compilation
 #### Microsoft Windows with MinGW cross-compilation
 ```bash
 ```bash
 $ cmake -B build -DCMAKE_TOOLCHAIN_FILE=/usr/share/mingw/toolchain-x86_64-w64-mingw32.cmake # replace with your toolchain file
 $ cmake -B build -DCMAKE_TOOLCHAIN_FILE=/usr/share/mingw/toolchain-x86_64-w64-mingw32.cmake # replace with your toolchain file

+ 15 - 1
src/peerconnection.cpp

@@ -1,5 +1,6 @@
 /**
 /**
  * Copyright (c) 2019 Paul-Louis Ageneau
  * Copyright (c) 2019 Paul-Louis Ageneau
+ * Copyright (c) 2020 Filip Klembara (in2core)
  *
  *
  * This library is free software; you can redistribute it and/or
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * modify it under the terms of the GNU Lesser General Public
@@ -33,6 +34,19 @@
 #include <iomanip>
 #include <iomanip>
 #include <thread>
 #include <thread>
 
 
+#if __clang__
+namespace {
+
+template <typename To, typename From>
+inline std::shared_ptr<To> reinterpret_pointer_cast(std::shared_ptr<From> const & ptr) noexcept {
+    return std::shared_ptr<To>(ptr, reinterpret_cast<To *>(ptr.get()));
+}
+
+}
+#else
+using std::reinterpret_pointer_cast;
+#endif
+
 namespace rtc {
 namespace rtc {
 
 
 using namespace std::placeholders;
 using namespace std::placeholders;
@@ -807,7 +821,7 @@ void PeerConnection::incomingTrack(Description::Media description) {
 void PeerConnection::openTracks() {
 void PeerConnection::openTracks() {
 #if RTC_ENABLE_MEDIA
 #if RTC_ENABLE_MEDIA
 	if (auto transport = std::atomic_load(&mDtlsTransport)) {
 	if (auto transport = std::atomic_load(&mDtlsTransport)) {
-		auto srtpTransport = std::reinterpret_pointer_cast<DtlsSrtpTransport>(transport);
+		auto srtpTransport = reinterpret_pointer_cast<DtlsSrtpTransport>(transport);
 		std::shared_lock lock(mTracksMutex); // read-only
 		std::shared_lock lock(mTracksMutex); // read-only
 		for (auto it = mTracks.begin(); it != mTracks.end(); ++it)
 		for (auto it = mTracks.begin(); it != mTracks.end(); ++it)
 			if (auto track = it->second.lock())
 			if (auto track = it->second.lock())