@@ -4,4 +4,5 @@ cmake-build-debug
|
||||
.cargo/
|
||||
test/
|
||||
libwebrtc/
|
||||
libwebrtc_android/
|
||||
CMakeLists.txt
|
||||
|
||||
+1
-1
@@ -16,5 +16,5 @@ glob = "0.3.0"
|
||||
regex = "1.0"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
crate-type = ["staticlib", "cdylib"]
|
||||
bench = false
|
||||
|
||||
@@ -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");
|
||||
@@ -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);
|
||||
@@ -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" => {
|
||||
@@ -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(
|
||||
@@ -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();
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
//
|
||||
// Created by Théo Monnom on 16/08/2022.
|
||||
//
|
||||
|
||||
void LKPrintDevices();
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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);
|
||||
}];
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "peer_connection_factory.h"
|
||||
#include <iostream>
|
||||
#include "objc_test.h"
|
||||
|
||||
namespace lk{
|
||||
|
||||
@@ -33,6 +34,8 @@ namespace lk{
|
||||
}
|
||||
|
||||
std::unique_ptr<PeerConnectionFactory> CreatePeerConnectionFactory() {
|
||||
LKPrintDevices(); // Just a tess
|
||||
|
||||
return std::make_unique<PeerConnectionFactory>();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user