Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ cmake-build-debug
.cargo/
test/
libwebrtc/
libwebrtc_android/
CMakeLists.txt
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ glob = "0.3.0"
regex = "1.0"

[lib]
crate-type = ["cdylib"]
crate-type = ["staticlib", "cdylib"]
bench = false
19 changes: 15 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ use std::io::Write;
use std::path;

fn main() {
let target_os = "android";
// TODO Download precompiled binaries of WebRTC for the target_os

let target_os = "ios";
//let target_arch = "arm64";

let libwebrtc_dir = path::PathBuf::from("libwebrtc");
Expand All @@ -16,12 +18,15 @@ fn main() {
libwebrtc_dir.join("include/"),
libwebrtc_dir.join("include/third_party/abseil-cpp/"),
libwebrtc_dir.join("include/third_party/libc++/"),

// For mac & ios
libwebrtc_dir.join("include/sdk/objc"),
libwebrtc_dir.join("include/sdk/objc/base"),
];

let mut builder = cxx_build::bridges(&["src/lib.rs"]);
builder.flag("-std=c++17");
builder.file("src/peer_connection_factory.cpp");
builder.file("src/jni_onload.cc");

for include in includes {
builder.include(include);
Expand All @@ -31,7 +36,6 @@ fn main() {
"cargo:rustc-link-search=native={}",
libwebrtc_dir.canonicalize().unwrap().to_str().unwrap()
);
println!("cargo:rustc-link-lib=static=webrtc");

match target_os {
"macos" => {
Expand All @@ -51,7 +55,13 @@ fn main() {
.define("WEBRTC_MAC", None);
}
"ios" => {
// TODO(theomonnom)

builder
.file("src/objc_test.mm")
.define("WEBRTC_ENABLE_OBJC_SYMBOL_EXPORT", None)
.define("WEBRTC_MAC", None)
.define("WEBRTC_POSIX", None)
.define("WEBRTC_IOS", None);
}
"android" => {
let ndk_env = env::var("ANDROID_NDK_HOME").expect(
Expand Down Expand Up @@ -102,6 +112,7 @@ fn main() {
// JNI Version Script & Keep JNI symbols
let vs_path = path::PathBuf::from(env::var("OUT_DIR").unwrap()).join("webrtc_jni.map");
let mut vs_file = fs::File::create(&vs_path).unwrap();
builder.file("src/jni_onload.cc");
println!("cargo:rustc-link-arg=-Wl,--undefined=JNI_OnLoad");

write!(vs_file, "JNI_WEBRTC {{\n\tglobal: ").unwrap();
Expand Down
5 changes: 5 additions & 0 deletions include/objc_test.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//
// Created by Théo Monnom on 16/08/2022.
//

void LKPrintDevices();
1 change: 0 additions & 1 deletion include/peer_connection_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#define PEER_CONNECTION_FACTORY_H

#include "api/peer_connection_interface.h"
#include "sdk/android/src/jni/jni_helpers.h"

namespace lk {

Expand Down
12 changes: 12 additions & 0 deletions src/objc_test.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#import "sdk/objc/base/RTCVideoCapturer.h"
#import "sdk/objc/components/capturer/RTCCameraVideoCapturer.h"

void LKPrintDevices() {
NSArray<AVCaptureDevice*>* devices = [RTCCameraVideoCapturer captureDevices];
[devices enumerateObjectsUsingBlock:^(AVCaptureDevice* device, NSUInteger i,
BOOL* stop) {
NSLog(@"%@", device.localizedName);
NSLog(@"%@", device.uniqueID);
NSLog(@"%@", device.modelID);
}];
}
3 changes: 3 additions & 0 deletions src/peer_connection_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "peer_connection_factory.h"
#include <iostream>
#include "objc_test.h"

namespace lk{

Expand Down Expand Up @@ -33,6 +34,8 @@ namespace lk{
}

std::unique_ptr<PeerConnectionFactory> CreatePeerConnectionFactory() {
LKPrintDevices(); // Just a tess

return std::make_unique<PeerConnectionFactory>();
}

Expand Down