livekit-utils crate + VideoRenderer proto

This commit is contained in:
Théo Monnom
2022-12-02 16:39:42 +01:00
parent 59e7ccbffe
commit 686f5db969
30 changed files with 2208 additions and 87 deletions
@@ -1,2 +1 @@
/libwebrtc
/cmake-build-debug
+14 -7
View File
@@ -55,17 +55,17 @@ fn main() {
let target_os = "windows";
//let target_arch = "arm64";
let libwebrtc_dir = path::PathBuf::from("libwebrtc");
let libwebrtc_dir = path::PathBuf::from("libwebrtc/src");
// Just required for the bridge build to succeed.
let includes = &[
path::PathBuf::from("./include"),
libwebrtc_dir.join("include/"),
libwebrtc_dir.join("include/third_party/abseil-cpp/"),
libwebrtc_dir.join("include/third_party/libc++/"),
libwebrtc_dir.clone(),
libwebrtc_dir.join("third_party/abseil-cpp/"),
libwebrtc_dir.join("third_party/libc++/"),
// For mac & ios
libwebrtc_dir.join("include/sdk/objc"),
libwebrtc_dir.join("include/sdk/objc/base"),
libwebrtc_dir.join("sdk/objc"),
libwebrtc_dir.join("sdk/objc/base"),
];
let mut builder = cxx_build::bridges(&[
@@ -81,6 +81,7 @@ fn main() {
"src/webrtc.rs",
"src/video_frame.rs",
"src/video_frame_buffer.rs",
"src/yuv_helper.rs",
]);
builder.file("src/peer_connection.cpp");
@@ -100,7 +101,12 @@ fn main() {
println!(
"cargo:rustc-link-search=native={}",
libwebrtc_dir.canonicalize().unwrap().to_str().unwrap()
libwebrtc_dir
.join("out/Default/obj")
.canonicalize()
.unwrap()
.to_str()
.unwrap()
);
match target_os {
@@ -124,6 +130,7 @@ fn main() {
.flag("/std:c++17")
.flag("/EHsc")
.define("WEBRTC_WIN", None)
//.define("WEBRTC_ENABLE_SYMBOL_EXPORT", None) Not necessary when using WebRTC as a static library
.define("NOMINMAX", None);
}
"macos" => {
@@ -1,8 +1,8 @@
-xc++
-std=c++17
-Iinclude
-Ilibwebrtc/include
-Ilibwebrtc/include/third_party/abseil-cpp
-Ilibwebrtc/include/third_party/libc++
-Ilibwebrtc/src
-Ilibwebrtc/src/third_party/abseil-cpp
-Ilibwebrtc/src/third_party/libc++
-I../../../target/cxxbridge
-DWEBRTC_WIN
@@ -0,0 +1,30 @@
//
// Created by Théo Monnom on 01/12/2022.
//
#ifndef CLIENT_SDK_NATIVE_YUV_HELPER_H
#define CLIENT_SDK_NATIVE_YUV_HELPER_H
#include <memory>
#include "api/video/yuv_helper.h"
namespace livekit {
static void i420_to_abgr(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_rgba,
int dst_stride_abgr,
int width,
int height) {
webrtc::I420ToABGR(src_y, src_stride_y, src_u, src_stride_u, src_v,
src_stride_v, dst_rgba, dst_stride_abgr, width, height);
}
} // namespace livekit
#endif // CLIENT_SDK_NATIVE_YUV_HELPER_H
@@ -0,0 +1,11 @@
solutions = [
{
"name" : 'src',
"url" : 'https://github.com/webrtc-sdk/webrtc.git',
"deps_file" : 'DEPS',
"managed" : False,
"custom_deps" : {
},
"custom_vars": {},
},
]
@@ -0,0 +1,3 @@
.cipd
src
.gclient_*
@@ -0,0 +1,19 @@
import subprocess
GN_ARGS = [
"is_debug=false",
"treat_warnings_as_errors=false",
'target_os="win"',
'target_cpu="x64"',
"rtc_include_tests=false",
"rtc_use_h264=false",
"is_component_build=false",
"rtc_build_examples=false",
"use_rtti=true",
"rtc_build_tools=false",
"use_custom_libcxx=false",
"strip_debug_info=true",
"symbol_level=0"
]
subprocess.call(["gn", "gen", "out/Default", "--args=" + ' '.join(GN_ARGS)], shell=True)
@@ -10,6 +10,7 @@ pub mod rtp_transceiver;
pub mod video_frame;
pub mod video_frame_buffer;
pub mod webrtc;
pub mod yuv_helper;
pub const MEDIA_TYPE_VIDEO: &str = "video";
pub const MEDIA_TYPE_AUDIO: &str = "audio";
@@ -0,0 +1,19 @@
#[cxx::bridge(namespace = "livekit")]
pub mod ffi {
unsafe extern "C++" {
include!("livekit/yuv_helper.h");
unsafe fn i420_to_abgr(
src_y: *const u8,
src_stride_y: i32,
src_u: *const u8,
src_stride_u: i32,
src_v: *const u8,
src_stride_v: i32,
dst_abgr: *mut u8,
dst_stride_abgr: i32,
width: i32,
height: i32,
);
}
}