Skip to content

Commit

Permalink
feat: Upgrade libwebrtc M116 (#973)
Browse files Browse the repository at this point in the history
* libwebrtc M116

* fix

* fix for m116

* fix stats
  • Loading branch information
karasusan authored Sep 11, 2023
1 parent d050e78 commit 65666ea
Show file tree
Hide file tree
Showing 24 changed files with 42 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .yamato/package.metafile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ upm:
registry_url: https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm
package_version: stable
webrtc_version:
name: M115
name: M116

editors:
- version: 2020.3
Expand Down
2 changes: 1 addition & 1 deletion BuildScripts~/build_libwebrtc_android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fi

export COMMAND_DIR=$(cd $(dirname $0); pwd)
export PATH="$(pwd)/depot_tools:$PATH"
export WEBRTC_VERSION=5790
export WEBRTC_VERSION=5845
export OUTPUT_DIR="$(pwd)/out"
export ARTIFACTS_DIR="$(pwd)/artifacts"
export PYTHON3_BIN="$(pwd)/depot_tools/python-bin/python3"
Expand Down
2 changes: 1 addition & 1 deletion BuildScripts~/build_libwebrtc_ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fi

export COMMAND_DIR=$(cd $(dirname $0); pwd)
export PATH="$(pwd)/depot_tools:$PATH"
export WEBRTC_VERSION=5790
export WEBRTC_VERSION=5845
export OUTPUT_DIR="$(pwd)/out"
export ARTIFACTS_DIR="$(pwd)/artifacts"
export PYTHON3_BIN="$(pwd)/depot_tools/python-bin/python3"
Expand Down
2 changes: 1 addition & 1 deletion BuildScripts~/build_libwebrtc_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fi

export COMMAND_DIR=$(cd $(dirname $0); pwd)
export PATH="$(pwd)/depot_tools:$PATH"
export WEBRTC_VERSION=5790
export WEBRTC_VERSION=5845
export OUTPUT_DIR="$(pwd)/out"
export ARTIFACTS_DIR="$(pwd)/artifacts"
export PYTHON3_BIN="$(pwd)/depot_tools/python-bin/python3"
Expand Down
2 changes: 1 addition & 1 deletion BuildScripts~/build_libwebrtc_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fi

export COMMAND_DIR=$(cd $(dirname $0); pwd)
export PATH="$(pwd)/depot_tools:$PATH"
export WEBRTC_VERSION=5790
export WEBRTC_VERSION=5845
export OUTPUT_DIR="$(pwd)/out"
export ARTIFACTS_DIR="$(pwd)/artifacts"
export PYTHON3_BIN="$(pwd)/depot_tools/python-bin/python3"
Expand Down
2 changes: 1 addition & 1 deletion BuildScripts~/build_libwebrtc_win.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if not exist depot_tools (

set COMMAND_DIR=%~dp0
set PATH=%cd%\depot_tools;%PATH%
set WEBRTC_VERSION=5790
set WEBRTC_VERSION=5845
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
set GYP_GENERATORS=ninja,msvs-ninja
set GYP_MSVS_VERSION=2022
Expand Down
2 changes: 1 addition & 1 deletion BuildScripts~/build_plugin_android.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -eu

export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M115/webrtc-android.zip
export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M116/webrtc-android.zip
export SOLUTION_DIR=$(pwd)/Plugin~
export PLUGIN_DIR=$(pwd)/Runtime/Plugins/Android

Expand Down
2 changes: 1 addition & 1 deletion BuildScripts~/build_plugin_ios.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -eu

export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M115/webrtc-ios.zip
export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M116/webrtc-ios.zip
export SOLUTION_DIR=$(pwd)/Plugin~
export WEBRTC_FRAMEWORK_DIR=$(pwd)/Runtime/Plugins/iOS
export WEBRTC_ARCHIVE_DIR=build/webrtc.xcarchive
Expand Down
2 changes: 1 addition & 1 deletion BuildScripts~/build_plugin_linux.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -eu

export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M115/webrtc-linux.zip
export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M116/webrtc-linux.zip
export SOLUTION_DIR=$(pwd)/Plugin~
export OUTPUT_FILEPATH=$(pwd)/Runtime/Plugins/x86_64/libwebrtc.so
export LIBCXX_BUILD_DIR=$(pwd)/llvm-project/build
Expand Down
2 changes: 1 addition & 1 deletion BuildScripts~/build_plugin_mac.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -eu

export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M115/webrtc-mac.zip
export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M116/webrtc-mac.zip
export SOLUTION_DIR=$(pwd)/Plugin~
export DYLIB_FILE=$(pwd)/Runtime/Plugins/macOS/libwebrtc.dylib

Expand Down
2 changes: 1 addition & 1 deletion BuildScripts~/build_plugin_win.cmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@echo off

set LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M115/webrtc-win.zip
set LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M116/webrtc-win.zip
set SOLUTION_DIR=%cd%\Plugin~

echo Download LibWebRTC
Expand Down
2 changes: 1 addition & 1 deletion BuildScripts~/build_testrunner_android.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -eu

export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M115/webrtc-android.zip
export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M116/webrtc-android.zip
export SOLUTION_DIR=$(pwd)/Plugin~
export ARCH_ABI=arm64-v8a

Expand Down
2 changes: 1 addition & 1 deletion BuildScripts~/build_testrunner_linux.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -eu

export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M115/webrtc-linux.zip
export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M116/webrtc-linux.zip
export SOLUTION_DIR=$(pwd)/Plugin~

source ~/.profile
Expand Down
2 changes: 1 addition & 1 deletion BuildScripts~/build_testrunner_mac.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -eu

export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M115/webrtc-mac.zip
export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M116/webrtc-mac.zip
export SOLUTION_DIR=$(pwd)/Plugin~

# Install cmake
Expand Down
2 changes: 1 addition & 1 deletion BuildScripts~/build_testrunner_win.cmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@echo off

set LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M115/webrtc-win.zip
set LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M116/webrtc-win.zip
set SOLUTION_DIR=%cd%\Plugin~

echo -------------------
Expand Down
26 changes: 13 additions & 13 deletions BuildScripts~/patches/fetch_exclude_examples.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
--- depot_tools/fetch_configs/webrtc.py 2023-03-22 06:38:50.000000000 +0900
+++ depot_tools/fetch_configs/webrtc.py.patch 2023-03-27 09:33:06.000000000 +0900
@@ -22,7 +22,9 @@ class WebRTC(config_util.Config):
'url': url,
'deps_file': 'DEPS',
'managed': False,
- 'custom_deps': {},
+ 'custom_deps': {
+ "src/examples/androidtests/third_party/gradle": None
+ },
},
],
'with_branch_heads': True,
--- fetch_configs/webrtc.py 2023-09-07 18:44:46.485574800 +0900
+++ fetch_configs/webrtc.py.patch 2023-09-07 18:46:11.601268700 +0900
@@ -21,7 +21,9 @@
'url': url,
'deps_file': 'DEPS',
'managed': False,
- 'custom_deps': {},
+ 'custom_deps': {
+ "src/examples/androidtests/third_party/gradle": None
+ },
},
],
'with_branch_heads':
2 changes: 1 addition & 1 deletion BuildScripts~/test_plugin_android.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -eu

export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M115/webrtc-android.zip
export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M116/webrtc-android.zip
export SOLUTION_DIR=$(pwd)/Plugin~
export ARCH_ABI=arm64-v8a

Expand Down
2 changes: 1 addition & 1 deletion BuildScripts~/test_plugin_ios.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -eu

export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M115/webrtc-ios.zip
export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M116/webrtc-ios.zip
export SOLUTION_DIR=$(pwd)/Plugin~

# Install cmake
Expand Down
4 changes: 2 additions & 2 deletions Plugin~/WebRTCPlugin/Codec/NvCodec/NvCodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ namespace webrtc
std::unique_ptr<VideoEncoder> NvEncoderFactory::CreateVideoEncoder(const SdpVideoFormat& format)
{
// todo(kazuki):: add CUmemorytype::CU_MEMORYTYPE_DEVICE option
return NvEncoder::Create(cricket::VideoCodec(format), context_, CU_MEMORYTYPE_ARRAY, format_, profiler_);
return NvEncoder::Create(cricket::CreateVideoCodec(format), context_, CU_MEMORYTYPE_ARRAY, format_, profiler_);
}

NvDecoderFactory::NvDecoderFactory(CUcontext context, ProfilerMarkerFactory* profiler)
Expand All @@ -211,7 +211,7 @@ namespace webrtc

std::unique_ptr<VideoDecoder> NvDecoderFactory::CreateVideoDecoder(const SdpVideoFormat& format)
{
return NvDecoder::Create(cricket::VideoCodec(format), context_, profiler_);
return NvDecoder::Create(cricket::CreateVideoCodec(format), context_, profiler_);
}
}
}
4 changes: 2 additions & 2 deletions Plugin~/WebRTCPluginTest/NvCodec/NvCodecTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ namespace webrtc
protected:
std::unique_ptr<VideoEncoder> CreateEncoder() override
{
cricket::VideoCodec codec = cricket::VideoCodec(cricket::kH264CodecName);
cricket::VideoCodec codec = cricket::CreateVideoCodec(cricket::kH264CodecName);
codec.SetParam(cricket::kH264FmtpProfileLevelId, kProfileLevelIdString());
return NvEncoder::Create(codec, context_, CU_MEMORYTYPE_ARRAY, NV_ENC_BUFFER_FORMAT_ARGB, nullptr);
}

std::unique_ptr<VideoDecoder> CreateDecoder() override
{
cricket::VideoCodec codec = cricket::VideoCodec(cricket::kH264CodecName);
cricket::VideoCodec codec = cricket::CreateVideoCodec(cricket::kH264CodecName);
codec.SetParam(cricket::kH264FmtpProfileLevelId, kProfileLevelIdString());
return NvDecoder::Create(codec, context_, nullptr);
}
Expand Down
6 changes: 3 additions & 3 deletions Plugin~/WebRTCPluginTest/NvCodec/NvEncoderImplTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace webrtc

TEST_P(NvEncoderImplTest, CanInitializeWithDefaultParameters)
{
cricket::VideoCodec codec = cricket::VideoCodec(cricket::kH264CodecName);
cricket::VideoCodec codec = cricket::CreateVideoCodec(cricket::kH264CodecName);
codec.SetParam(cricket::kH264FmtpProfileLevelId, kProfileLevelIdString());
NvEncoderImpl encoder(codec, context_, CU_MEMORYTYPE_ARRAY, NV_ENC_BUFFER_FORMAT_ARGB, nullptr);

Expand All @@ -53,7 +53,7 @@ namespace webrtc
{
H264ProfileLevelId profileLevelId(H264Profile::kProfileBaseline, H264Level::kLevel5_1);

cricket::VideoCodec codec = cricket::VideoCodec(cricket::kH264CodecName);
cricket::VideoCodec codec = cricket::CreateVideoCodec(cricket::kH264CodecName);
codec.SetParam(cricket::kH264FmtpProfileLevelId, *H264ProfileLevelIdToString(profileLevelId));
NvEncoderImpl encoder(codec, context_, CU_MEMORYTYPE_ARRAY, NV_ENC_BUFFER_FORMAT_ARGB, nullptr);

Expand All @@ -69,7 +69,7 @@ namespace webrtc
{
H264ProfileLevelId profileLevelId(H264Profile::kProfileBaseline, H264Level::kLevel5_1);

cricket::VideoCodec codec = cricket::VideoCodec(cricket::kH264CodecName);
cricket::VideoCodec codec = cricket::CreateVideoCodec(cricket::kH264CodecName);
codec.SetParam(cricket::kH264FmtpProfileLevelId, *H264ProfileLevelIdToString(profileLevelId));
NvEncoderImpl encoder(codec, context_, CU_MEMORYTYPE_ARRAY, NV_ENC_BUFFER_FORMAT_ARGB, nullptr);

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Please read this if you have an interest to customize native code in this projec
| `3.0.0-pre.4` | [M107](https://groups.google.com/g/discuss-webrtc/c/StVFkKuSRc8) | - Fix bugs | Jan 2023 |
| `3.0.0-pre.5` | [M107](https://groups.google.com/g/discuss-webrtc/c/StVFkKuSRc8) | - Encoded Transform API | Apr 2023 |
| `3.0.0-pre.6` | [M112](https://groups.google.com/g/discuss-webrtc/c/V-XFau9W9gY) | - Fix bugs | Jul 2023 |
| `3.0.0-pre.7` | [M115](https://groups.google.com/g/discuss-webrtc/c/1CTKFxJsrmQ) | - Fix bugs | Sep 2023 |
| `3.0.0-pre.7` | [M116](https://groups.google.com/g/discuss-webrtc/c/bEsO8Lz7psE) | - Fix bugs | Sep 2023 |

## Licenses

Expand Down
10 changes: 2 additions & 8 deletions Runtime/Scripts/RTCStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -837,12 +837,6 @@ public class RTCRTPStreamStats : RTCStats
/// </summary>
public string kind { get { return GetString("kind"); } }

/// <summary>
///
/// </summary>
[Obsolete]
public string trackId { get { return GetString("trackId"); } }

/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -886,7 +880,7 @@ public class RTCSentRtpStreamStats : RTCRTPStreamStats
/// <summary>
///
/// </summary>
public uint packetsSent { get { return GetUnsignedInt("packetsSent"); } }
public ulong packetsSent { get { return GetUnsignedLong("packetsSent"); } }

/// <summary>
///
Expand Down Expand Up @@ -1036,7 +1030,7 @@ public class RTCInboundRTPStreamStats : RTCReceivedRtpStreamStats
/// <summary>
///
/// </summary>
public int framesReceived { get { return GetInt("framesReceived"); } }
public uint framesReceived { get { return GetUnsignedInt("framesReceived"); } }

/// <summary>
///
Expand Down
6 changes: 2 additions & 4 deletions Tests/Runtime/StatsReportTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,9 @@ public static void Test(RTCStats stats)
case RTCStatsType.InboundRtp:
var inboundRtpStreamStats = stats as RTCInboundRTPStreamStats;
Assert.NotNull(inboundRtpStreamStats);
Assert.AreEqual(65, inboundRtpStreamStats.Dict.Count);
Assert.AreEqual(64, inboundRtpStreamStats.Dict.Count);
Ignore.Pass(inboundRtpStreamStats.ssrc);
Assert.IsNotEmpty(inboundRtpStreamStats.kind);
// Obsolete: Ignore.Pass(inboundRtpStreamStats.trackId);
Assert.IsNotEmpty(inboundRtpStreamStats.transportId);
Ignore.Pass(inboundRtpStreamStats.codecId);
Ignore.Pass(inboundRtpStreamStats.jitter);
Expand Down Expand Up @@ -244,10 +243,9 @@ public static void Test(RTCStats stats)
case RTCStatsType.OutboundRtp:
var outboundRtpStreamStats = stats as RTCOutboundRTPStreamStats;
Assert.NotNull(outboundRtpStreamStats);
Assert.AreEqual(37, outboundRtpStreamStats.Dict.Count);
Assert.AreEqual(36, outboundRtpStreamStats.Dict.Count);
Ignore.Pass(outboundRtpStreamStats.ssrc);
Assert.IsNotEmpty(outboundRtpStreamStats.kind);
// Obsolete: Ignore.Pass(outboundRtpStreamStats.trackId);
Assert.IsNotEmpty(outboundRtpStreamStats.transportId);
Ignore.Pass(outboundRtpStreamStats.codecId);
Ignore.Pass(outboundRtpStreamStats.mediaSourceId);
Expand Down

0 comments on commit 65666ea

Please sign in to comment.