Skip to content

Commit

Permalink
Fix iOS integration tests (#162)
Browse files Browse the repository at this point in the history
Additionally:
- upgrade `libwebrtc-bin` to `126.0.6478.182-r2` version
  • Loading branch information
evdokimovs authored Jul 25, 2024
1 parent c8bcd8b commit 64a149e
Show file tree
Hide file tree
Showing 18 changed files with 97 additions and 149 deletions.
39 changes: 37 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ jobs:
- macos
- windows
runs-on: ${{ (matrix.platform == 'windows' && 'windows-latest')
|| 'macos-11' }}
|| 'macos-13' }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@v1
Expand All @@ -151,7 +151,7 @@ jobs:
# Pin Xcode version for better compatibility.
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "12.4"
xcode-version: "15.2"
if: ${{ matrix.platform == 'macos' }}

- run: make cargo.build platform=${{ matrix.platform }} debug=no
Expand Down Expand Up @@ -217,6 +217,7 @@ jobs:
- windows
runs-on: ${{ (matrix.platform == 'linux' && 'ubuntu-latest')
|| (matrix.platform == 'windows' && 'windows-latest')
|| (matrix.platform == 'ios' && 'macos-14')
|| 'macos-13' }}
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -259,6 +260,40 @@ jobs:
script: make flutter.test.mobile
if: ${{ matrix.platform == 'android' }}

- name: Add TCC permissions on macOS
run: |
configure_user_tccdb () {
local values=$1
local dbPath="$HOME/Library/Application Support/com.apple.TCC/TCC.db"
local sqlQuery="INSERT OR REPLACE INTO access VALUES($values);"
sqlite3 "$dbPath" "$sqlQuery"
}
configure_sys_tccdb () {
local values=$1
local dbPath="/Library/Application Support/com.apple.TCC/TCC.db"
local sqlQuery="INSERT OR REPLACE INTO access VALUES($values);"
sudo sqlite3 "$dbPath" "$sqlQuery"
}
userValuesArray=(
"'kTCCServiceMicrophone','/usr/local/opt/runner/provisioner/provisioner',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159"
"'kTCCServiceCamera','/usr/local/opt/runner/provisioner/provisioner',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159"
"'kTCCServiceBluetoothAlways','/usr/local/opt/runner/provisioner/provisioner',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159"
)
for values in "${userValuesArray[@]}"; do
# Sonoma and higher have a few extra values:
# https://github.com/actions/runner-images/blob/main/images/macos/scripts/build/configure-tccdb-macos.sh
if [ "$OSTYPE" = "darwin23" ]; then
configure_user_tccdb "$values,NULL,NULL,'UNUSED',${values##*,}"
configure_sys_tccdb "$values,NULL,NULL,'UNUSED',${values##*,}"
else
configure_user_tccdb "$values"
configure_sys_tccdb "$values"
fi
done
if: ${{ matrix.platform == 'ios' }}

- name: Start iOS simulator
id: simulator
uses: futureware-tech/simulator-action@v3
Expand Down
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ All user visible changes to this project will be documented in this file. This p

### Changed

- Upgraded [libwebrtc] to [123.0.6312.105] version. ([#155])
- Upgraded [libwebrtc] to [126.0.6478.182-r2] version. ([#155], [#162])
- Disable [H264] software encoders and decoders. ([#153])

### Fixed
Expand All @@ -44,7 +44,8 @@ All user visible changes to this project will be documented in this file. This p
[#153]: https://github.com/instrumentisto/medea-flutter-webrtc/pull/153
[#155]: https://github.com/instrumentisto/medea-flutter-webrtc/pull/155
[#156]: https://github.com/instrumentisto/medea-flutter-webrtc/pull/156
[123.0.6312.105]: https://github.com/instrumentisto/libwebrtc-bin/releases/tag/123.0.6312.105
[#162]: https://github.com/instrumentisto/medea-flutter-webrtc/pull/162
[126.0.6478.182-r2]: https://github.com/instrumentisto/libwebrtc-bin/releases/tag/126.0.6478.182-r2



Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Medea Flutter-WebRTC
====================

[![pub](https://img.shields.io/pub/v/medea_flutter_webrtc "pub")](https://pub.dev/packages/medea_flutter_webrtc)
[![libwebrtc](https://img.shields.io/badge/libwebrtc-123.0.6312.105-blue "libwebrtc")](https://github.com/instrumentisto/libwebrtc-bin/releases/tag/123.0.6312.105)
[![libwebrtc](https://img.shields.io/badge/libwebrtc-126.0.6478.182-r2-blue "libwebrtc")](https://github.com/instrumentisto/libwebrtc-bin/releases/tag/126.0.6478.182-r2)
[![OpenAL](https://img.shields.io/badge/OpenAL-1.23.1-blue "OpenAL")](https://github.com/kcat/openal-soft/releases/tag/1.23.1)

[Changelog](https://github.com/instrumentisto/medea-flutter-webrtc/blob/main/CHANGELOG.md)
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ android {
}

dependencies {
implementation 'com.github.instrumentisto:libwebrtc-bin:123.0.6312.105@aar'
implementation 'com.github.instrumentisto:libwebrtc-bin:126.0.6478.182-r2@aar'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
}
5 changes: 4 additions & 1 deletion crates/libwebrtc-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
[package]
name = "libwebrtc-sys"
version = "0.0.0+123.0.6312.105"
version = "0.0.0+126.0.6478.182-r2"
edition = "2021"
rust-version = "1.62"
publish = false
links = "webrtc"

[features]
fake-media = []

[dependencies]
anyhow = "1.0"
cxx = "1.0"
Expand Down
14 changes: 7 additions & 7 deletions crates/libwebrtc-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use walkdir::{DirEntry, WalkDir};
/// [`libwebrtc-bin`]: https://github.com/instrumentisto/libwebrtc-bin
static LIBWEBRTC_URL: &str =
"https://github.com/instrumentisto/libwebrtc-bin/releases/download\
/123.0.6312.105";
/126.0.6478.182-r2";

/// URL for downloading `openal-soft` source code.
static OPENAL_URL: &str =
Expand Down Expand Up @@ -90,7 +90,7 @@ fn main() -> anyhow::Result<()> {
build.flag("-DWEBRTC_WIN").flag("/std:c++20");
}

#[cfg(feature = "fake_media")]
#[cfg(feature = "fake-media")]
{
build.flag("-DFAKE_MEDIA");
}
Expand Down Expand Up @@ -120,19 +120,19 @@ fn get_target() -> anyhow::Result<String> {
fn get_expected_libwebrtc_hash() -> anyhow::Result<&'static str> {
Ok(match get_target()?.as_str() {
"aarch64-unknown-linux-gnu" => {
"db6504b732fcc59541ea37279ff1e2ce8bc6c7c7018ac2973b782e69d3702889"
"f35ef4076a4c6a9adce54717f14c7408a5a3e2d9e09c3f112a70a823b7369933"
}
"x86_64-unknown-linux-gnu" => {
"6b212cc8f91fb1e4ec8358ab1f9c2147e39f0e655bb1f6521df2a84239da95bd"
"9bc1995fcd28d6b26191717a92bae64e13e583d15e8c582322527b43be2b7c84"
}
"aarch64-apple-darwin" => {
"cac4b30b08c95751ab0c299d1f8bb3552df0b7a50dc90b9741fa893a8f9b412e"
"8e135face9e03b3f90c9fd73d02bc9a024fe9f1ac07fd8aa6d4c1dfaef61de86"
}
"x86_64-apple-darwin" => {
"f2ed68ac50750b609f3371c7e38d4fd6931a234d36523b36f516b127a5c1fb49"
"0ffcee42398804e27408f1c4acadefce69f88e425ac311eda8a6ff0f9da12eb1"
}
"x86_64-pc-windows-msvc" => {
"6604e95fe102bc62e45da3230aabfb088cfdf3cc2859f3ced310136466d658b0"
"7dda117194077d0408d9e644014cca499f80dd4df4c78dc069ba09ac4b95549a"
}
arch => return Err(anyhow::anyhow!("Unsupported target: {arch}")),
})
Expand Down
2 changes: 2 additions & 0 deletions crates/libwebrtc-sys/src/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2811,6 +2811,7 @@ pub(crate) mod webrtc {
/// # Safety
///
/// Caller must ensure that the provided `buffer` is large enough.
#[allow(clippy::missing_safety_doc)] // false positive
pub unsafe fn video_frame_to_abgr(frame: &VideoFrame, buffer: *mut u8);

/// Converts the provided [`webrtc::VideoFrame`] pixels to the `ARGB`
Expand All @@ -2819,6 +2820,7 @@ pub(crate) mod webrtc {
/// # Safety
///
/// Caller must ensure that the provided `buffer` is large enough.
#[allow(clippy::missing_safety_doc)] // false positive
pub unsafe fn video_frame_to_argb(
frame: &VideoFrame,
argb_stride: i32,
Expand Down
5 changes: 4 additions & 1 deletion crates/native/src/devices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,10 @@ pub mod linux_device_change {
pub struct AudioMonitor {
/// [PulseAudio] context.
///
/// [PulseAudio]: https://freedesktop.org/wiki/Software/PulseAudio
/// [PulseAudio]: https://freedesktop.org/wiki/Software/PulseAudio`.
// It's not read, but is required to live for correct destruction of
// the PulseAudio `Context`.
#[allow(dead_code)] // for destruction
pub context: Context,

/// [PulseAudio] main loop.
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
16 changes: 6 additions & 10 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
PODS:
- Flutter (1.0.0)
- instrumentisto-libwebrtc-bin (123.0.6312.105)
- instrumentisto-libwebrtc-bin (126.0.6478.182-r2)
- integration_test (0.0.1):
- Flutter
- libyuv-iOS (1.0.2)
- medea_flutter_webrtc (0.10.0-dev):
- Flutter
- instrumentisto-libwebrtc-bin (= 123.0.6312.105)
- libyuv-iOS
- instrumentisto-libwebrtc-bin (= 126.0.6478.182-r2)

DEPENDENCIES:
- Flutter (from `Flutter`)
Expand All @@ -17,7 +15,6 @@ DEPENDENCIES:
SPEC REPOS:
trunk:
- instrumentisto-libwebrtc-bin
- libyuv-iOS

EXTERNAL SOURCES:
Flutter:
Expand All @@ -28,11 +25,10 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/medea_flutter_webrtc/ios"

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
instrumentisto-libwebrtc-bin: 295e1721ff9a8ccfc030c0de5f095c7d6b3e53ce
integration_test: 13825b8a9334a850581300559b8839134b124670
libyuv-iOS: 5a154ccc84ec754029886ecb607512731fe30640
medea_flutter_webrtc: ca2335744f08d45963f26f8db159c6dcd19a31a3
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
instrumentisto-libwebrtc-bin: 146854184f62ca80d79ff3d95bf9446eff5e54a9
integration_test: ce0a3ffa1de96d1a89ca0ac26fca7ea18a749ef4
medea_flutter_webrtc: 37c4a65c3d4709bea5a612f655c79b4cf143cee7

PODFILE CHECKSUM: be3ab4e988bb308d23906be69146fcbef66fac55

Expand Down
2 changes: 1 addition & 1 deletion example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
52 changes: 26 additions & 26 deletions ios/Classes/FlutterRtcVideoRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,22 +171,22 @@ class FlutterRtcVideoRenderer: NSObject, FlutterTexture, RTCVideoRenderer {
}

let buffer = RTCI420Buffer(width: rotatedWidth, height: rotatedHeight)
libyuv_I420Rotate(
RTCYUVHelper.i420Rotate(
src.dataY,
src.strideY,
src.dataU,
src.strideU,
src.dataV,
src.strideV,
UnsafeMutablePointer(mutating: buffer.dataY),
buffer.strideY,
UnsafeMutablePointer(mutating: buffer.dataU),
buffer.strideU,
UnsafeMutablePointer(mutating: buffer.dataV),
buffer.strideV,
src.width,
src.height,
rotation
srcStrideY: src.strideY,
srcU: src.dataU,
srcStrideU: src.strideU,
srcV: src.dataV,
srcStrideV: src.strideV,
dstY: UnsafeMutablePointer(mutating: buffer.dataY),
dstStrideY: buffer.strideY,
dstU: UnsafeMutablePointer(mutating: buffer.dataU),
dstStrideU: buffer.strideU,
dstV: UnsafeMutablePointer(mutating: buffer.dataV),
dstStrideV: buffer.strideV,
width: src.width,
height: src.height,
mode: rotation
)
return buffer
}
Expand Down Expand Up @@ -287,17 +287,17 @@ class FlutterRtcVideoRenderer: NSObject, FlutterTexture, RTCVideoRenderer {
)
let dst = CVPixelBufferGetBaseAddress(self.pixelBuffer!)!
let bytesPerRow = CVPixelBufferGetBytesPerRow(self.pixelBuffer!)
libyuv_I420ToARGB(
buffer.dataY,
buffer.strideY,
buffer.dataU,
buffer.strideU,
buffer.dataV,
buffer.strideV,
UnsafeMutablePointer<UInt8>(OpaquePointer(dst)),
Int32(bytesPerRow),
buffer.width,
buffer.height
RTCYUVHelper.i420(
toARGB: buffer.dataY,
srcStrideY: buffer.strideY,
srcU: buffer.dataU,
srcStrideU: buffer.strideU,
srcV: buffer.dataV,
srcStrideV: buffer.strideV,
dstARGB: UnsafeMutablePointer<UInt8>(OpaquePointer(dst)),
dstStrideARGB: Int32(bytesPerRow),
width: buffer.width,
height: buffer.height
)
CVPixelBufferUnlockBaseAddress(
self.pixelBuffer!,
Expand Down
30 changes: 0 additions & 30 deletions ios/Classes/MedeaFlutterWebrtcPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,3 @@
@interface MedeaFlutterWebrtcPlugin : NSObject<FlutterPlugin>
@end

bool libyuv_I420ToARGB(
const uint8_t* src_y,
int src_stride_y,
const uint8_t* src_u,
int src_stride_u,
const uint8_t* src_v,
int src_stride_v,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height
);

void libyuv_I420Rotate(
const uint8_t* srcY,
int srcStrideY,
const uint8_t* srcU,
int srcStrideU,
const uint8_t* srcV,
int srcStrideV,
uint8_t* dstY,
int dstStrideY,
uint8_t* dstU,
int dstStrideU,
uint8_t* dstV,
int dstStrideV,
int width,
int height,
RTCVideoRotation mode
);
Loading

0 comments on commit 64a149e

Please sign in to comment.