feat: add publishing & audio to ffi (#46)
- Divide FFI protocol into multiple files
- Audio support
- AV Streams/Sources
- Create tracks
- Use Dashmap to store handles
- Add a capture test
- Ignored by GHA atm
This commit is contained in:
+2
-3
@@ -70,7 +70,6 @@ fn download_prebuilt_webrtc(
|
||||
for i in 0..archive.len() {
|
||||
let mut inner_file = archive.by_index(i)?;
|
||||
let relative_path = inner_file.mangled_name();
|
||||
|
||||
if relative_path.to_string_lossy().is_empty() {
|
||||
continue; // Ignore root
|
||||
}
|
||||
@@ -133,7 +132,7 @@ fn main() {
|
||||
webrtc_include.join("sdk/objc/base"),
|
||||
];
|
||||
|
||||
let mut builder = cxx_build::bridges(&[
|
||||
let mut builder = cxx_build::bridges([
|
||||
"src/peer_connection.rs",
|
||||
"src/peer_connection_factory.rs",
|
||||
"src/media_stream.rs",
|
||||
@@ -248,7 +247,7 @@ fn main() {
|
||||
println!("cargo:rustc-link-arg=-ObjC");
|
||||
|
||||
let sysroot = Command::new("xcrun")
|
||||
.args(&["--sdk", "macosx", "--show-sdk-path"])
|
||||
.args(["--sdk", "macosx", "--show-sdk-path"])
|
||||
.output()
|
||||
.unwrap();
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ class VideoFrame {
|
||||
public:
|
||||
explicit VideoFrame(const webrtc::VideoFrame& frame);
|
||||
|
||||
int width() const;
|
||||
int height() const;
|
||||
unsigned int width() const;
|
||||
unsigned int height() const;
|
||||
uint32_t size() const;
|
||||
uint16_t id() const;
|
||||
int64_t timestamp_us() const;
|
||||
|
||||
@@ -46,8 +46,8 @@ class VideoFrameBuffer {
|
||||
|
||||
VideoFrameBufferType buffer_type() const;
|
||||
|
||||
int width() const;
|
||||
int height() const;
|
||||
unsigned int width() const;
|
||||
unsigned int height() const;
|
||||
|
||||
std::unique_ptr<I420Buffer> to_i420() const;
|
||||
|
||||
@@ -68,12 +68,12 @@ class PlanarYuvBuffer : public VideoFrameBuffer {
|
||||
public:
|
||||
explicit PlanarYuvBuffer(rtc::scoped_refptr<webrtc::PlanarYuvBuffer> buffer);
|
||||
|
||||
int chroma_width() const;
|
||||
int chroma_height() const;
|
||||
unsigned int chroma_width() const;
|
||||
unsigned int chroma_height() const;
|
||||
|
||||
int stride_y() const;
|
||||
int stride_u() const;
|
||||
int stride_v() const;
|
||||
unsigned int stride_y() const;
|
||||
unsigned int stride_u() const;
|
||||
unsigned int stride_v() const;
|
||||
|
||||
private:
|
||||
webrtc::PlanarYuvBuffer* buffer() const;
|
||||
@@ -110,11 +110,11 @@ class BiplanarYuvBuffer : public VideoFrameBuffer {
|
||||
explicit BiplanarYuvBuffer(
|
||||
rtc::scoped_refptr<webrtc::BiplanarYuvBuffer> buffer);
|
||||
|
||||
int chroma_width() const;
|
||||
int chroma_height() const;
|
||||
unsigned int chroma_width() const;
|
||||
unsigned int chroma_height() const;
|
||||
|
||||
int stride_y() const;
|
||||
int stride_uv() const;
|
||||
unsigned int stride_y() const;
|
||||
unsigned int stride_uv() const;
|
||||
|
||||
private:
|
||||
webrtc::BiplanarYuvBuffer* buffer() const;
|
||||
@@ -145,7 +145,7 @@ class I420ABuffer : public I420Buffer {
|
||||
public:
|
||||
explicit I420ABuffer(rtc::scoped_refptr<webrtc::I420ABufferInterface> buffer);
|
||||
|
||||
int stride_a() const;
|
||||
unsigned int stride_a() const;
|
||||
const uint8_t* data_a() const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -61,7 +61,7 @@ pub mod ffi {
|
||||
fn create_rtc_configuration(conf: RTCConfiguration) -> UniquePtr<NativeRTCConfiguration>;
|
||||
|
||||
/// # Safety
|
||||
/// The observer must live as long as the PeerConnection
|
||||
/// The observer must live as long as the PeerConnection does
|
||||
unsafe fn create_peer_connection(
|
||||
self: &PeerConnectionFactory,
|
||||
config: UniquePtr<NativeRTCConfiguration>,
|
||||
|
||||
@@ -24,10 +24,10 @@ namespace livekit {
|
||||
VideoFrame::VideoFrame(const webrtc::VideoFrame& frame)
|
||||
: frame_(std::move(frame)) {}
|
||||
|
||||
int VideoFrame::width() const {
|
||||
unsigned int VideoFrame::width() const {
|
||||
return frame_.width();
|
||||
}
|
||||
int VideoFrame::height() const {
|
||||
unsigned int VideoFrame::height() const {
|
||||
return frame_.height();
|
||||
}
|
||||
uint32_t VideoFrame::size() const {
|
||||
|
||||
@@ -22,8 +22,8 @@ pub mod ffi {
|
||||
|
||||
type VideoFrame;
|
||||
|
||||
fn width(self: &VideoFrame) -> i32;
|
||||
fn height(self: &VideoFrame) -> i32;
|
||||
fn width(self: &VideoFrame) -> u32;
|
||||
fn height(self: &VideoFrame) -> u32;
|
||||
fn size(self: &VideoFrame) -> u32;
|
||||
fn id(self: &VideoFrame) -> u16;
|
||||
fn timestamp_us(self: &VideoFrame) -> i64;
|
||||
|
||||
@@ -26,11 +26,11 @@ VideoFrameBufferType VideoFrameBuffer::buffer_type() const {
|
||||
return static_cast<VideoFrameBufferType>(buffer_->type());
|
||||
}
|
||||
|
||||
int VideoFrameBuffer::width() const {
|
||||
unsigned int VideoFrameBuffer::width() const {
|
||||
return buffer_->width();
|
||||
}
|
||||
|
||||
int VideoFrameBuffer::height() const {
|
||||
unsigned int VideoFrameBuffer::height() const {
|
||||
return buffer_->height();
|
||||
}
|
||||
|
||||
@@ -83,23 +83,23 @@ PlanarYuvBuffer::PlanarYuvBuffer(
|
||||
rtc::scoped_refptr<webrtc::PlanarYuvBuffer> buffer)
|
||||
: VideoFrameBuffer(buffer) {}
|
||||
|
||||
int PlanarYuvBuffer::chroma_width() const {
|
||||
unsigned int PlanarYuvBuffer::chroma_width() const {
|
||||
return buffer()->ChromaWidth();
|
||||
}
|
||||
|
||||
int PlanarYuvBuffer::chroma_height() const {
|
||||
unsigned int PlanarYuvBuffer::chroma_height() const {
|
||||
return buffer()->ChromaHeight();
|
||||
}
|
||||
|
||||
int PlanarYuvBuffer::stride_y() const {
|
||||
unsigned int PlanarYuvBuffer::stride_y() const {
|
||||
return buffer()->StrideY();
|
||||
}
|
||||
|
||||
int PlanarYuvBuffer::stride_u() const {
|
||||
unsigned int PlanarYuvBuffer::stride_u() const {
|
||||
return buffer()->StrideU();
|
||||
}
|
||||
|
||||
int PlanarYuvBuffer::stride_v() const {
|
||||
unsigned int PlanarYuvBuffer::stride_v() const {
|
||||
return buffer()->StrideV();
|
||||
}
|
||||
|
||||
@@ -151,19 +151,19 @@ BiplanarYuvBuffer::BiplanarYuvBuffer(
|
||||
rtc::scoped_refptr<webrtc::BiplanarYuvBuffer> buffer)
|
||||
: VideoFrameBuffer(buffer) {}
|
||||
|
||||
int BiplanarYuvBuffer::chroma_width() const {
|
||||
unsigned int BiplanarYuvBuffer::chroma_width() const {
|
||||
return buffer()->ChromaWidth();
|
||||
}
|
||||
|
||||
int BiplanarYuvBuffer::chroma_height() const {
|
||||
unsigned int BiplanarYuvBuffer::chroma_height() const {
|
||||
return buffer()->ChromaHeight();
|
||||
}
|
||||
|
||||
int BiplanarYuvBuffer::stride_y() const {
|
||||
unsigned int BiplanarYuvBuffer::stride_y() const {
|
||||
return buffer()->StrideY();
|
||||
}
|
||||
|
||||
int BiplanarYuvBuffer::stride_uv() const {
|
||||
unsigned int BiplanarYuvBuffer::stride_uv() const {
|
||||
return buffer()->StrideUV();
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ I420ABuffer::I420ABuffer(
|
||||
rtc::scoped_refptr<webrtc::I420ABufferInterface> buffer)
|
||||
: I420Buffer(buffer) {}
|
||||
|
||||
int I420ABuffer::stride_a() const {
|
||||
unsigned int I420ABuffer::stride_a() const {
|
||||
return buffer()->StrideA();
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ pub mod ffi {
|
||||
type NV12Buffer;
|
||||
|
||||
fn buffer_type(self: &VideoFrameBuffer) -> VideoFrameBufferType;
|
||||
fn width(self: &VideoFrameBuffer) -> i32;
|
||||
fn height(self: &VideoFrameBuffer) -> i32;
|
||||
fn width(self: &VideoFrameBuffer) -> u32;
|
||||
fn height(self: &VideoFrameBuffer) -> u32;
|
||||
|
||||
/// # SAFETY
|
||||
/// If the buffer type is I420, the buffer must be cloned before
|
||||
@@ -47,11 +47,11 @@ pub mod ffi {
|
||||
unsafe fn get_i010(self: Pin<&mut VideoFrameBuffer>) -> UniquePtr<I010Buffer>;
|
||||
unsafe fn get_nv12(self: Pin<&mut VideoFrameBuffer>) -> UniquePtr<NV12Buffer>;
|
||||
|
||||
fn chroma_width(self: &PlanarYuvBuffer) -> i32;
|
||||
fn chroma_height(self: &PlanarYuvBuffer) -> i32;
|
||||
fn stride_y(self: &PlanarYuvBuffer) -> i32;
|
||||
fn stride_u(self: &PlanarYuvBuffer) -> i32;
|
||||
fn stride_v(self: &PlanarYuvBuffer) -> i32;
|
||||
fn chroma_width(self: &PlanarYuvBuffer) -> u32;
|
||||
fn chroma_height(self: &PlanarYuvBuffer) -> u32;
|
||||
fn stride_y(self: &PlanarYuvBuffer) -> u32;
|
||||
fn stride_u(self: &PlanarYuvBuffer) -> u32;
|
||||
fn stride_v(self: &PlanarYuvBuffer) -> u32;
|
||||
|
||||
fn data_y(self: &PlanarYuv8Buffer) -> *const u8;
|
||||
fn data_u(self: &PlanarYuv8Buffer) -> *const u8;
|
||||
@@ -61,15 +61,15 @@ pub mod ffi {
|
||||
fn data_u(self: &PlanarYuv16BBuffer) -> *const u16;
|
||||
fn data_v(self: &PlanarYuv16BBuffer) -> *const u16;
|
||||
|
||||
fn chroma_width(self: &BiplanarYuvBuffer) -> i32;
|
||||
fn chroma_height(self: &BiplanarYuvBuffer) -> i32;
|
||||
fn stride_y(self: &BiplanarYuvBuffer) -> i32;
|
||||
fn stride_uv(self: &BiplanarYuvBuffer) -> i32;
|
||||
fn chroma_width(self: &BiplanarYuvBuffer) -> u32;
|
||||
fn chroma_height(self: &BiplanarYuvBuffer) -> u32;
|
||||
fn stride_y(self: &BiplanarYuvBuffer) -> u32;
|
||||
fn stride_uv(self: &BiplanarYuvBuffer) -> u32;
|
||||
|
||||
fn data_y(self: &BiplanarYuv8Buffer) -> *const u8;
|
||||
fn data_uv(self: &BiplanarYuv8Buffer) -> *const u8;
|
||||
|
||||
fn stride_a(self: &I420ABuffer) -> i32;
|
||||
fn stride_a(self: &I420ABuffer) -> u32;
|
||||
fn data_a(self: &I420ABuffer) -> *const u8;
|
||||
|
||||
fn new_i420_buffer(width: i32, height: i32) -> UniquePtr<I420Buffer>;
|
||||
|
||||
Reference in New Issue
Block a user