diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a8bfc698..3a5616af 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,11 +47,11 @@ jobs: # CUDA のインストールバイナリのダウンロードは 3GB ぐらいあって、 # ビルドの度に取得するのはつらいのでキャッシュする # (インストールする nvcc は解凍後で 100MB 程度なのでキャッシュ可能) - - name: Cache NVCC ${{ steps.versions.outputs.cuda_version }} + - name: Cache CUDA ${{ steps.versions.outputs.cuda_version }} id: cache-cuda uses: actions/cache@v4 with: - path: _install\windows_x86_64\release\cuda\nvcc + path: _install\windows_x86_64\release\cuda key: windows-cuda-${{ steps.versions.outputs.cuda_version }}.v1 - run: echo "${CUDA_VERSION}" > _install\windows_x86_64\release\cuda.version if: steps.cache-cuda.outputs.cache-hit == 'true' @@ -163,19 +163,18 @@ jobs: if: matrix.name == 'ubuntu-20.04_x86_64' || matrix.name == 'ubuntu-22.04_x86_64' run: | source VERSION - # clang-15 と CUDA を入れる + # clang-18 と CUDA を入れる sudo apt-get update sudo apt-get install -y software-properties-common - # CUDA 10 なので ubuntu1804 で正しい - wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin - sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600 - sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub - sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /" + + wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb + sudo dpkg -i cuda-keyring_*all.deb + sudo apt-get update DEBIAN_FRONTEND=noninteractive sudo apt-get -y install cuda=$CUDA_VERSION wget https://apt.llvm.org/llvm.sh chmod a+x llvm.sh - sudo ./llvm.sh 15 + sudo ./llvm.sh 18 # Intel Media SDK のために libva-dev, libdrm-dev を入れる DEBIAN_FRONTEND=noninteractive sudo apt-get -y install libva-dev libdrm-dev diff --git a/CHANGES.md b/CHANGES.md index 4924fe21..c463c4a7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,8 +11,16 @@ ## develop +- [CHANGE] WebRTC を `m121.6167.3.0` にあげる + - libwebrtc から cricket::MediaEngineDependencies が削除されたため、 SoraClientContextConfig から configure_media_dependencies を削除した + - @torikizi @enm10k - [UPDATE] Boost を1.84.0 にあげる + - @enm10k - [UPDATE] CMake を3.28.1 にあげる + - @enm10k +- [UPDATE] CUDA を 11.8 にあげる + - 更新時に発生したビルド・エラーを回避するために `include/sora/fix_cuda_noinline_macro_error.h` を追加した + - @enm10k ## 2024.1.0 (2024-01-16) diff --git a/VERSION b/VERSION index 8d76514b..7d727616 100644 --- a/VERSION +++ b/VERSION @@ -1,11 +1,11 @@ SORA_CPP_SDK_VERSION=2024.1.0 -WEBRTC_BUILD_VERSION=m120.6099.1.2 +WEBRTC_BUILD_VERSION=m121.6167.3.0 BOOST_VERSION=1.84.0 CMAKE_VERSION=3.28.1 BAZEL_VERSION=5.4.1 LYRA_VERSION=1.3.0 LYRA_COMPATIBLE_VERSION=1.3.0 -CUDA_VERSION=10.2.89-1 +CUDA_VERSION=11.8.0-1 ANDROID_NDK_VERSION=r26b ANDROID_NATIVE_API_LEVEL=29 ANDROID_SDK_CMDLINE_TOOLS_VERSION=8092744 diff --git a/include/sora/fix_cuda_noinline_macro_error.h b/include/sora/fix_cuda_noinline_macro_error.h new file mode 100644 index 00000000..721747e9 --- /dev/null +++ b/include/sora/fix_cuda_noinline_macro_error.h @@ -0,0 +1,22 @@ +/* +## 背景 + +WebRTC を M121 に更新した際に以下のビルド・エラーが発生した + +``` +error: use of undeclared identifier 'noinline'; did you mean 'inline' +``` + +WebRTC に含まれる libcxx のバージョンが更新されたことが原因だと思われる + +## 対応 + +同様の問題を解消したと思われる LLVM の [PR](https://github.com/llvm/llvm-project-release-prs/pull/698) を調査したところ、 PR で追加されたファイルは存在するにも関わらず、問題が継続して発生していることがわかった +(libcxx に bits/basic_string.h が含まれておらず、 cuda_wrappers 以下のファイルがインクルードされていないようだった) + +上記 PR を参考に、ファイルを直接修正したところエラーが解消したため、このヘッダー・ファイルをエラーが発生する箇所でインクルードすることにした +オリジナルのパッチには push_macro や pop_macro が含まれているが、省いても問題が無かったため省略している + +*/ + +#undef __noinline__ \ No newline at end of file diff --git a/include/sora/hwenc_nvcodec/nvcodec_decoder_cuda.h b/include/sora/hwenc_nvcodec/nvcodec_decoder_cuda.h index e432556c..b2711a3c 100644 --- a/include/sora/hwenc_nvcodec/nvcodec_decoder_cuda.h +++ b/include/sora/hwenc_nvcodec/nvcodec_decoder_cuda.h @@ -2,7 +2,11 @@ #define SORA_HWENC_NVCODEC_NVCODEC_DECODER_CUDA_H_ #include + +// clang-format off +#include "sora/fix_cuda_noinline_macro_error.h" #include +// clang-format on #include "sora/cuda_context.h" diff --git a/include/sora/sora_client_context.h b/include/sora/sora_client_context.h index 77619eed..5430a1e4 100644 --- a/include/sora/sora_client_context.h +++ b/include/sora/sora_client_context.h @@ -18,12 +18,6 @@ struct SoraClientContextConfig { // false にするとソフトウェアエンコーダ/デコーダのみになる(H.264 は利用できない) bool use_hardware_encoder = true; - // MediaEngineDependencies をカスタマイズするためのコールバック関数 - // デフォルトの値が設定された上で、cricket::CreateMediaEngine を生成する直前に呼ばれる - std::function - configure_media_dependencies; - // PeerConnectionFactoryDependencies をカスタマイズするためのコールバック関数 // デフォルトの値が設定された上で、PeerConnectionFactory を生成する直前に呼ばれる std::function @@ -43,9 +37,6 @@ struct SoraClientContextConfig { // 使い方: // sora::SoraClientContextConfig context_config; // // 必要なら context_config をカスタマイズする -// context_config.configure_media_dependencies = -// [](const webrtc::PeerConnectionFactoryDependencies& dep, -// cricket::MediaEngineDependencies& mdep) { ... }; // context_config.configure_dependencies = [](webrtc::PeerConnectionFactoryDependencies& dep) { ... }; // // Android に対応する場合は get_android_application_context を設定する // context_config.get_android_application_context = [](void* env) { ... }; diff --git a/run.py b/run.py index ac0f595f..a23ef41e 100644 --- a/run.py +++ b/run.py @@ -9,6 +9,7 @@ import argparse import multiprocessing import hashlib +import glob from typing import Callable, NamedTuple, Optional, List, Union, Dict if platform.system() == 'Windows': import winreg @@ -351,6 +352,18 @@ def apply_patch(patch, dir, depth): with open(patch) as stdin: cmd(['patch', f'-p{depth}'], stdin=stdin) +# NOTE(enm10k): shutil.copytree に Python 3.8 で追加された dirs_exist_ok=True を指定して使いたかったが、 GitHub Actions の Windows のランナー (widnwos-2019) にインストールされている Python のバージョンが古くて利用できなかった +# actions/setup-python で Python 3.8 を設定してビルドしたところ、 Lyra のビルドがエラーになったためこの関数を自作した +# Windows のランナーを更新した場合は、この関数は不要になる可能性が高い +def copytree(src_dir, dst_dir): + for file_path in glob.glob(src_dir + '/**', recursive=True): + dest_path = os.path.join(dst_dir, os.path.relpath(file_path, src_dir)) + + if os.path.isdir(file_path): + os.makedirs(dest_path, exist_ok=True) + else: + shutil.copy2(file_path, dest_path) + @versioned def install_webrtc(version, source_dir, install_dir, platform: str): @@ -701,6 +714,8 @@ def install_cuda_windows(version, source_dir, build_dir, install_dir): rm_rf(os.path.join(install_dir, 'cuda')) if version == '10.2.89-1': url = 'http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_441.22_win10.exe' # noqa: E501 + elif version == '11.8.0-1': + url = 'https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_522.06_windows.exe' # noqa: E501 else: raise f'Unknown CUDA version {version}' file = download(url, source_dir) @@ -709,7 +724,8 @@ def install_cuda_windows(version, source_dir, build_dir, install_dir): mkdir_p(os.path.join(install_dir, 'cuda')) with cd(os.path.join(build_dir, 'cuda')): cmd(['7z', 'x', file]) - os.rename(os.path.join(build_dir, 'cuda', 'nvcc'), os.path.join(install_dir, 'cuda', 'nvcc')) + copytree(os.path.join(build_dir, 'cuda', 'cuda_nvcc', 'nvcc'), os.path.join(install_dir, 'cuda')) + copytree(os.path.join(build_dir, 'cuda', 'cuda_cudart', 'cudart'), os.path.join(install_dir, 'cuda')) @versioned @@ -1272,6 +1288,7 @@ def install_deps(platform: Platform, source_dir, build_dir, install_dir, debug, '-D_LIBCPP_ABI_NAMESPACE=Cr', '-D_LIBCPP_ABI_VERSION=2', '-D_LIBCPP_DISABLE_AVAILABILITY', + '-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE', '-nostdinc++', '-std=gnu++17', f"-isystem{os.path.join(webrtc_info.libcxx_dir, 'include')}", @@ -1298,6 +1315,7 @@ def install_deps(platform: Platform, source_dir, build_dir, install_dir, debug, '-D_LIBCPP_ABI_NAMESPACE=Cr', '-D_LIBCPP_ABI_VERSION=2', '-D_LIBCPP_DISABLE_AVAILABILITY', + '-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE', '-nostdinc++', '-std=gnu++17', f"-isystem{os.path.join(webrtc_info.libcxx_dir, 'include')}", @@ -1315,6 +1333,7 @@ def install_deps(platform: Platform, source_dir, build_dir, install_dir, debug, '-D_LIBCPP_ABI_NAMESPACE=Cr', '-D_LIBCPP_ABI_VERSION=2', '-D_LIBCPP_DISABLE_AVAILABILITY', + '-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE', '-nostdinc++', f"-isystem{os.path.join(webrtc_info.libcxx_dir, 'include')}", '-fPIC', @@ -1403,14 +1422,15 @@ def install_deps(platform: Platform, source_dir, build_dir, install_dir, debug, install_vpl_args['cmake_args'].append(f"-DCMAKE_CXX_FLAGS={' '.join(cxxflags)}") if platform.target.os == 'ubuntu': cmake_args = [] - cmake_args.append("-DCMAKE_C_COMPILER=clang-15") - cmake_args.append("-DCMAKE_CXX_COMPILER=clang++-15") + cmake_args.append("-DCMAKE_C_COMPILER=clang-18") + cmake_args.append("-DCMAKE_CXX_COMPILER=clang++-18") path = cmake_path(os.path.join(webrtc_info.libcxx_dir, 'include')) cmake_args.append(f"-DCMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES={path}") flags = [ '-nostdinc++', '-D_LIBCPP_ABI_NAMESPACE=Cr', '-D_LIBCPP_ABI_VERSION=2', '-D_LIBCPP_DISABLE_AVAILABILITY', '-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS', - '-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS', '-D_LIBCPP_ENABLE_NODISCARD'] + '-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS', '-D_LIBCPP_ENABLE_NODISCARD', + '-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE'] cmake_args.append(f"-DCMAKE_CXX_FLAGS={' '.join(flags)}") install_vpl_args['cmake_args'] += cmake_args install_vpl(**install_vpl_args) @@ -1481,8 +1501,8 @@ def install_deps(platform: Platform, source_dir, build_dir, install_dir, debug, cmake_args.append(f'-DCMAKE_SYSROOT={sysroot}') if platform.target.os == 'ubuntu': if platform.target.package_name in ('ubuntu-20.04_x86_64', 'ubuntu-22.04_x86_64'): - cmake_args.append("-DCMAKE_C_COMPILER=clang-15") - cmake_args.append("-DCMAKE_CXX_COMPILER=clang++-15") + cmake_args.append("-DCMAKE_C_COMPILER=clang-18") + cmake_args.append("-DCMAKE_CXX_COMPILER=clang++-18") else: cmake_args.append( f"-DCMAKE_C_COMPILER={cmake_path(os.path.join(webrtc_info.clang_dir, 'bin', 'clang'))}") @@ -1490,7 +1510,8 @@ def install_deps(platform: Platform, source_dir, build_dir, install_dir, debug, f"-DCMAKE_CXX_COMPILER={cmake_path(os.path.join(webrtc_info.clang_dir, 'bin', 'clang++'))}") path = cmake_path(os.path.join(webrtc_info.libcxx_dir, 'include')) cmake_args.append(f"-DCMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES={path}") - cmake_args.append(f"-DCMAKE_CXX_FLAGS={' '.join(['-nostdinc++'])}") + cxxflags = ['-nostdinc++', '-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE'] + cmake_args.append(f"-DCMAKE_CXX_FLAGS={' '.join(cxxflags)}") if platform.target.os == 'jetson': sysroot = os.path.join(install_dir, 'rootfs') cmake_args.append('-DCMAKE_SYSTEM_NAME=Linux') @@ -1509,7 +1530,8 @@ def install_deps(platform: Platform, source_dir, build_dir, install_dir, debug, cmake_args.append('-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH') path = cmake_path(os.path.join(webrtc_info.libcxx_dir, 'include')) cmake_args.append(f"-DCMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES={path}") - cmake_args.append(f"-DCMAKE_CXX_FLAGS={' '.join(['-nostdinc++'])}") + cxxflags = ['-nostdinc++', '-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE'] + cmake_args.append(f"-DCMAKE_CXX_FLAGS={' '.join(cxxflags)}") if platform.target.os == 'ios': cmake_args += ['-G', 'Xcode'] cmake_args.append("-DCMAKE_SYSTEM_NAME=iOS") @@ -1532,7 +1554,8 @@ def install_deps(platform: Platform, source_dir, build_dir, install_dir, debug, # https://github.com/android/ndk/issues/1618 cmake_args.append('-DCMAKE_ANDROID_EXCEPTIONS=ON') cmake_args.append('-DANDROID_NDK=OFF') - cmake_args.append(f"-DCMAKE_CXX_FLAGS={' '.join(['-nostdinc++'])}") + cxxflags = ['-nostdinc++', '-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE'] + cmake_args.append(f"-DCMAKE_CXX_FLAGS={' '.join(cxxflags)}") install_blend2d_args['cmake_args'] = cmake_args install_blend2d(**install_blend2d_args) @@ -1636,8 +1659,8 @@ def main(): cmake_args.append(f'-DCMAKE_SYSTEM_VERSION={WINDOWS_SDK_VERSION}') if platform.target.os == 'ubuntu': if platform.target.package_name in ('ubuntu-20.04_x86_64', 'ubuntu-22.04_x86_64'): - cmake_args.append("-DCMAKE_C_COMPILER=clang-15") - cmake_args.append("-DCMAKE_CXX_COMPILER=clang++-15") + cmake_args.append("-DCMAKE_C_COMPILER=clang-18") + cmake_args.append("-DCMAKE_CXX_COMPILER=clang++-18") else: cmake_args.append( f"-DCMAKE_C_COMPILER={cmake_path(os.path.join(webrtc_info.clang_dir, 'bin', 'clang'))}") @@ -1646,6 +1669,8 @@ def main(): cmake_args.append("-DUSE_LIBCXX=ON") cmake_args.append( f"-DLIBCXX_INCLUDE_DIR={cmake_path(os.path.join(webrtc_info.libcxx_dir, 'include'))}") + cxxflags = ['-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE'] + cmake_args.append(f"-DCMAKE_CXX_FLAGS={' '.join(cxxflags)}") if platform.target.os == 'macos': sysroot = cmdcap(['xcrun', '--sdk', 'macosx', '--show-sdk-path']) target = 'x86_64-apple-darwin' if platform.target.arch == 'x86_64' else 'aarch64-apple-darwin' @@ -1678,6 +1703,8 @@ def main(): cmake_args.append('-DCMAKE_ANDROID_EXCEPTIONS=ON') cmake_args.append('-DANDROID_NDK=OFF') cmake_args.append(f"-DSORA_WEBRTC_LDFLAGS={os.path.join(install_dir, 'webrtc.ldflags')}") + cxxflags = ['-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE'] + cmake_args.append(f"-DCMAKE_CXX_FLAGS={' '.join(cxxflags)}") if platform.target.os == 'jetson': sysroot = os.path.join(install_dir, 'rootfs') cmake_args.append('-DCMAKE_SYSTEM_NAME=Linux') @@ -1694,12 +1721,14 @@ def main(): cmake_args.append( f"-DCMAKE_CXX_COMPILER={cmake_path(os.path.join(webrtc_info.clang_dir, 'bin', 'clang++'))}") cmake_args.append('-DUSE_JETSON_ENCODER=ON') + cxxflags = ['-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE'] + cmake_args.append(f"-DCMAKE_CXX_FLAGS={' '.join(cxxflags)}") # NvCodec if platform.target.os in ('windows', 'ubuntu') and platform.target.arch == 'x86_64': cmake_args.append('-DUSE_NVCODEC_ENCODER=ON') if platform.target.os == 'windows': - cmake_args.append(f"-DCUDA_TOOLKIT_ROOT_DIR={cmake_path(os.path.join(install_dir, 'cuda', 'nvcc'))}") + cmake_args.append(f"-DCUDA_TOOLKIT_ROOT_DIR={cmake_path(os.path.join(install_dir, 'cuda'))}") if platform.target.os in ('windows', 'ubuntu') and platform.target.arch == 'x86_64': cmake_args.append('-DUSE_VPL_ENCODER=ON') @@ -1792,8 +1821,8 @@ def main(): cmake_args.append(f'-DCMAKE_SYSROOT={sysroot}') if platform.target.os == 'ubuntu': if platform.target.package_name in ('ubuntu-20.04_x86_64', 'ubuntu-22.04_x86_64'): - cmake_args.append("-DCMAKE_C_COMPILER=clang-15") - cmake_args.append("-DCMAKE_CXX_COMPILER=clang++-15") + cmake_args.append("-DCMAKE_C_COMPILER=clang-18") + cmake_args.append("-DCMAKE_CXX_COMPILER=clang++-18") else: cmake_args.append( f"-DCMAKE_C_COMPILER={cmake_path(os.path.join(webrtc_info.clang_dir, 'bin', 'clang'))}") @@ -1802,6 +1831,8 @@ def main(): cmake_args.append("-DUSE_LIBCXX=ON") cmake_args.append( f"-DLIBCXX_INCLUDE_DIR={cmake_path(os.path.join(webrtc_info.libcxx_dir, 'include'))}") + cxxflags = ['-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE'] + cmake_args.append(f"-DCMAKE_CXX_FLAGS={' '.join(cxxflags)}") if platform.target.os == 'jetson': sysroot = os.path.join(install_dir, 'rootfs') cmake_args.append('-DJETSON=ON') @@ -1822,6 +1853,8 @@ def main(): f"-DCMAKE_C_COMPILER={cmake_path(os.path.join(webrtc_info.clang_dir, 'bin', 'clang'))}") cmake_args.append( f"-DCMAKE_CXX_COMPILER={cmake_path(os.path.join(webrtc_info.clang_dir, 'bin', 'clang++'))}") + cxxflags = ['-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE'] + cmake_args.append(f"-DCMAKE_CXX_FLAGS={' '.join(cxxflags)}") if platform.target.os in ('windows', 'macos', 'ubuntu'): cmake_args.append("-DTEST_CONNECT_DISCONNECT=ON") diff --git a/src/cuda_context_cuda.cpp b/src/cuda_context_cuda.cpp index d7a11b96..d59437a4 100644 --- a/src/cuda_context_cuda.cpp +++ b/src/cuda_context_cuda.cpp @@ -1,3 +1,5 @@ +#include "sora/fix_cuda_noinline_macro_error.h" + #include "sora/cuda_context.h" #if !USE_NVCODEC_ENCODER diff --git a/src/hwenc_nvcodec/nvcodec_h264_encoder.cpp b/src/hwenc_nvcodec/nvcodec_h264_encoder.cpp index 01418039..ec24d935 100644 --- a/src/hwenc_nvcodec/nvcodec_h264_encoder.cpp +++ b/src/hwenc_nvcodec/nvcodec_h264_encoder.cpp @@ -1,3 +1,5 @@ +#include "sora/fix_cuda_noinline_macro_error.h" + #include "sora/hwenc_nvcodec/nvcodec_h264_encoder.h" #ifdef _WIN32 diff --git a/src/hwenc_nvcodec/nvcodec_h264_encoder_cuda.cpp b/src/hwenc_nvcodec/nvcodec_h264_encoder_cuda.cpp index 7ebe497b..e5ba12a0 100644 --- a/src/hwenc_nvcodec/nvcodec_h264_encoder_cuda.cpp +++ b/src/hwenc_nvcodec/nvcodec_h264_encoder_cuda.cpp @@ -1,3 +1,5 @@ +#include "sora/fix_cuda_noinline_macro_error.h" + #include "nvcodec_h264_encoder_cuda.h" #include diff --git a/src/sora_client_context.cpp b/src/sora_client_context.cpp index e920134e..4527dc18 100644 --- a/src/sora_client_context.cpp +++ b/src/sora_client_context.cpp @@ -2,14 +2,18 @@ // WebRTC #include +#include +#include #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -55,17 +59,13 @@ std::shared_ptr SoraClientContext::Create( dependencies.worker_thread = c->worker_thread_.get(); dependencies.signaling_thread = c->signaling_thread_.get(); dependencies.task_queue_factory = webrtc::CreateDefaultTaskQueueFactory(); - dependencies.call_factory = webrtc::CreateCallFactory(); dependencies.event_log_factory = absl::make_unique( dependencies.task_queue_factory.get()); void* env = sora::GetJNIEnv(); - // media_dependencies - cricket::MediaEngineDependencies media_dependencies; - media_dependencies.task_queue_factory = dependencies.task_queue_factory.get(); - media_dependencies.adm = c->worker_thread_->BlockingCall([&] { + dependencies.adm = c->worker_thread_->BlockingCall([&] { sora::AudioDeviceModuleConfig config; if (!c->config_.use_audio_device) { config.audio_layer = webrtc::AudioDeviceModule::kDummyAudio; @@ -79,10 +79,8 @@ std::shared_ptr SoraClientContext::Create( return sora::CreateAudioDeviceModule(config); }); - media_dependencies.audio_encoder_factory = - sora::CreateBuiltinAudioEncoderFactory(); - media_dependencies.audio_decoder_factory = - sora::CreateBuiltinAudioDecoderFactory(); + dependencies.audio_encoder_factory = sora::CreateBuiltinAudioEncoderFactory(); + dependencies.audio_decoder_factory = sora::CreateBuiltinAudioDecoderFactory(); std::shared_ptr cuda_context; if (c->config_.use_hardware_encoder) { @@ -95,7 +93,7 @@ std::shared_ptr SoraClientContext::Create( ? sora::GetDefaultVideoEncoderFactoryConfig(cuda_context, env) : sora::GetSoftwareOnlyVideoEncoderFactoryConfig(); config.use_simulcast_adapter = true; - media_dependencies.video_encoder_factory = + dependencies.video_encoder_factory = absl::make_unique(std::move(config)); } { @@ -103,25 +101,19 @@ std::shared_ptr SoraClientContext::Create( c->config_.use_hardware_encoder ? sora::GetDefaultVideoDecoderFactoryConfig(cuda_context, env) : sora::GetSoftwareOnlyVideoDecoderFactoryConfig(); - media_dependencies.video_decoder_factory = + dependencies.video_decoder_factory = absl::make_unique(std::move(config)); } - media_dependencies.audio_mixer = nullptr; - media_dependencies.audio_processing = - webrtc::AudioProcessingBuilder().Create(); - - if (c->config_.configure_media_dependencies) { - c->config_.configure_media_dependencies(dependencies, media_dependencies); - } - - dependencies.media_engine = - cricket::CreateMediaEngine(std::move(media_dependencies)); + dependencies.audio_mixer = nullptr; + dependencies.audio_processing = webrtc::AudioProcessingBuilder().Create(); if (c->config_.configure_dependencies) { c->config_.configure_dependencies(dependencies); } + webrtc::EnableMedia(dependencies); + c->factory_ = sora::CreateModularPeerConnectionFactoryWithContext( std::move(dependencies), c->connection_context_); diff --git a/src/sora_peer_connection_factory.cpp b/src/sora_peer_connection_factory.cpp index ec9b62a6..4ab8922e 100644 --- a/src/sora_peer_connection_factory.cpp +++ b/src/sora_peer_connection_factory.cpp @@ -1,6 +1,7 @@ #include "sora/sora_peer_connection_factory.h" // WebRTC +#include #include #include @@ -13,7 +14,8 @@ class PeerConnectionFactoryWithContext : public webrtc::PeerConnectionFactory { PeerConnectionFactoryWithContext( webrtc::PeerConnectionFactoryDependencies dependencies) : PeerConnectionFactoryWithContext( - webrtc::ConnectionContext::Create(&dependencies), + webrtc::ConnectionContext::Create(webrtc::CreateEnvironment(), + &dependencies), &dependencies) {} PeerConnectionFactoryWithContext( rtc::scoped_refptr context, diff --git a/test/android/app/build.gradle b/test/android/app/build.gradle index 04f47af1..3c85ef7f 100644 --- a/test/android/app/build.gradle +++ b/test/android/app/build.gradle @@ -42,7 +42,8 @@ android { "-DANDROID_ABI=arm64-v8a", "-DANDROID_CPP_FEATURES=exceptions rtti", "-DANDROID_NDK=OFF", - "-DCMAKE_ANDROID_EXCEPTIONS=ON" + "-DCMAKE_ANDROID_EXCEPTIONS=ON", + "-DCMAKE_CXX_FLAGS='-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE'" } ndk { abiFilters 'arm64-v8a' diff --git a/third_party/NvCodec/NvCodec/.clang-format b/third_party/NvCodec/NvCodec/.clang-format new file mode 100644 index 00000000..47a38a93 --- /dev/null +++ b/third_party/NvCodec/NvCodec/.clang-format @@ -0,0 +1,2 @@ +DisableFormat: true +SortIncludes: Never diff --git a/third_party/NvCodec/NvCodec/NvDecoder/NvDecoder.cpp b/third_party/NvCodec/NvCodec/NvDecoder/NvDecoder.cpp index c722f7b1..5eb86679 100644 --- a/third_party/NvCodec/NvCodec/NvDecoder/NvDecoder.cpp +++ b/third_party/NvCodec/NvCodec/NvDecoder/NvDecoder.cpp @@ -9,6 +9,8 @@ * */ +#include "sora/fix_cuda_noinline_macro_error.h" + #include #include #include diff --git a/third_party/NvCodec/NvCodec/NvEncoder/NvEncoderCuda.cpp b/third_party/NvCodec/NvCodec/NvEncoder/NvEncoderCuda.cpp index d038f636..1f11bf43 100644 --- a/third_party/NvCodec/NvCodec/NvEncoder/NvEncoderCuda.cpp +++ b/third_party/NvCodec/NvCodec/NvEncoder/NvEncoderCuda.cpp @@ -9,6 +9,8 @@ * */ +#include "sora/fix_cuda_noinline_macro_error.h" + #include "NvEncoder/NvEncoderCuda.h" #include "sora/dyn/cuda.h" diff --git a/third_party/lyra/toolchain/android/BUILD.tpl b/third_party/lyra/toolchain/android/BUILD.tpl index a459ad79..3995fac1 100644 --- a/third_party/lyra/toolchain/android/BUILD.tpl +++ b/third_party/lyra/toolchain/android/BUILD.tpl @@ -93,6 +93,7 @@ cc_toolchain_config( "-D_LIBCPP_ABI_NAMESPACE=Cr", "-D_LIBCPP_ABI_VERSION=2", "-D_LIBCPP_DISABLE_AVAILABILITY", + '-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE', "-fexperimental-relative-c++-abi-vtables", "-fexceptions", ], diff --git a/third_party/lyra/toolchain/linux_x86_64/BUILD.tpl b/third_party/lyra/toolchain/linux_x86_64/BUILD.tpl index 56a5aa87..0c8fc3fd 100644 --- a/third_party/lyra/toolchain/linux_x86_64/BUILD.tpl +++ b/third_party/lyra/toolchain/linux_x86_64/BUILD.tpl @@ -90,6 +90,7 @@ cc_toolchain_config( "-D_LIBCPP_ABI_NAMESPACE=Cr", "-D_LIBCPP_ABI_VERSION=2", "-D_LIBCPP_DISABLE_AVAILABILITY", + '-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE', ], link_flags = [ "-Wl,-no-as-needed", @@ -213,6 +214,7 @@ cc_toolchain_config( "-D_LIBCPP_ABI_NAMESPACE=Cr", "-D_LIBCPP_ABI_VERSION=2", "-D_LIBCPP_DISABLE_AVAILABILITY", + '-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE', ], link_flags = [ "-Wl,-no-as-needed",