Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
f90462b9
Unverified
提交
f90462b9
authored
11月 28, 2021
作者:
Nazar Mokrynskyi
提交者:
GitHub
11月 28, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #719 from nazar-pc/rust-windows-support
Windows support in Rust library
上级
f0ebd809
72e8c9cf
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
135 行增加
和
29 行删除
+135
-29
mediasoup-rust.yaml
.github/workflows/mediasoup-rust.yaml
+12
-0
CHANGELOG.md
rust/CHANGELOG.md
+1
-0
active_speaker_observer.rs
rust/src/router/active_speaker_observer.rs
+8
-2
audio_level_observer.rs
rust/src/router/audio_level_observer.rs
+8
-2
consumer.rs
rust/src/router/consumer.rs
+12
-3
data_consumer.rs
rust/src/router/data_consumer.rs
+12
-3
direct_transport.rs
rust/src/router/direct_transport.rs
+13
-3
pipe_transport.rs
rust/src/router/pipe_transport.rs
+8
-2
plain_transport.rs
rust/src/router/plain_transport.rs
+8
-2
producer.rs
rust/src/router/producer.rs
+8
-2
webrtc_transport.rs
rust/src/router/webrtc_transport.rs
+8
-2
build.rs
worker/build.rs
+37
-8
没有找到文件。
.github/workflows/mediasoup-rust.yaml
浏览文件 @
f90462b9
...
...
@@ -12,6 +12,7 @@ jobs:
os
:
-
ubuntu-20.04
-
macos-10.15
-
windows-2019
rust
:
-
stable
# - nightly
...
...
@@ -19,6 +20,17 @@ jobs:
runs-on
:
${{ matrix.os }}
steps
:
-
name
:
Add MSVC compiler
uses
:
ilammy/msvc-dev-cmd@v1
if
:
runner.os == 'Windows'
# This is needed as a workaround for GNU linker being first in PATH and thus preventing Meson from finding MSVC
# linker.
-
name
:
Remove GNU linker for MSVC
shell
:
bash
run
:
rm /usr/bin/link
if
:
runner.os == 'Windows'
-
name
:
Checkout
uses
:
actions/checkout@v2
...
...
rust/CHANGELOG.md
浏览文件 @
f90462b9
...
...
@@ -8,6 +8,7 @@
*
Switch from file descriptors to function calls when communicating with worker
*
Various optimizations that caused minor breaking changes to public API
*
Requests no longer have internal timeout, but they can now be cancelled, add your own timeouts on top if needed
*
Windows support
# 0.8.5
...
...
rust/src/router/active_speaker_observer.rs
浏览文件 @
f90462b9
...
...
@@ -86,7 +86,7 @@ struct Inner {
closed
:
AtomicBool
,
// Drop subscription to audio speaker observer-specific notifications when observer itself is
// dropped
_subscription_handler
:
Option
<
SubscriptionHandler
>
,
subscription_handler
:
Mutex
<
Option
<
SubscriptionHandler
>
>
,
_on_router_close_handler
:
Mutex
<
HandlerId
>
,
}
...
...
@@ -113,11 +113,17 @@ impl Inner {
rtp_observer_id
:
self
.id
,
},
};
let
subscription_handler
=
self
.subscription_handler
.lock
()
.take
();
self
.executor
.spawn
(
async
move
{
if
let
Err
(
error
)
=
channel
.request
(
request
)
.await
{
error!
(
"active speaker observer closing failed on drop: {}"
,
error
);
}
// Drop from a different thread to avoid deadlock with recursive dropping
// from within another subscription drop.
drop
(
subscription_handler
);
})
.detach
();
}
...
...
@@ -348,7 +354,7 @@ impl ActiveSpeakerObserver {
app_data
,
router
,
closed
:
AtomicBool
::
new
(
false
),
_subscription_handler
:
subscription_handler
,
subscription_handler
:
Mutex
::
new
(
subscription_handler
)
,
_on_router_close_handler
:
Mutex
::
new
(
on_router_close_handler
),
});
...
...
rust/src/router/audio_level_observer.rs
浏览文件 @
f90462b9
...
...
@@ -97,7 +97,7 @@ struct Inner {
closed
:
AtomicBool
,
// Drop subscription to audio level observer-specific notifications when observer itself is
// dropped
_subscription_handler
:
Option
<
SubscriptionHandler
>
,
subscription_handler
:
Mutex
<
Option
<
SubscriptionHandler
>
>
,
_on_router_close_handler
:
Mutex
<
HandlerId
>
,
}
...
...
@@ -124,11 +124,17 @@ impl Inner {
rtp_observer_id
:
self
.id
,
},
};
let
subscription_handler
=
self
.subscription_handler
.lock
()
.take
();
self
.executor
.spawn
(
async
move
{
if
let
Err
(
error
)
=
channel
.request
(
request
)
.await
{
error!
(
"audio level observer closing failed on drop: {}"
,
error
);
}
// Drop from a different thread to avoid deadlock with recursive dropping
// from within another subscription drop.
drop
(
subscription_handler
);
})
.detach
();
}
...
...
@@ -366,7 +372,7 @@ impl AudioLevelObserver {
app_data
,
router
,
closed
:
AtomicBool
::
new
(
false
),
_subscription_handler
:
subscription_handler
,
subscription_handler
:
Mutex
::
new
(
subscription_handler
)
,
_on_router_close_handler
:
Mutex
::
new
(
on_router_close_handler
),
});
...
...
rust/src/router/consumer.rs
浏览文件 @
f90462b9
...
...
@@ -19,10 +19,10 @@ use event_listener_primitives::{Bag, BagOnce, HandlerId};
use
log
::{
debug
,
error
};
use
parking_lot
::
Mutex
;
use
serde
::{
Deserialize
,
Serialize
};
use
std
::
fmt
;
use
std
::
fmt
::
Debug
;
use
std
::
sync
::
atomic
::{
AtomicBool
,
Ordering
};
use
std
::
sync
::{
Arc
,
Weak
};
use
std
::{
fmt
,
mem
};
uuid_based_wrapper_type!
(
/// [`Consumer`] identifier.
...
...
@@ -378,7 +378,7 @@ struct Inner {
weak_producer
:
WeakProducer
,
closed
:
Arc
<
AtomicBool
>
,
// Drop subscription to consumer-specific notifications when consumer itself is dropped
_subscription_handlers
:
Vec
<
Option
<
SubscriptionHandler
>>
,
subscription_handlers
:
Mutex
<
Vec
<
Option
<
SubscriptionHandler
>
>>
,
_on_transport_close_handler
:
Mutex
<
HandlerId
>
,
}
...
...
@@ -407,6 +407,8 @@ impl Inner {
producer_id
:
self
.producer_id
,
},
};
let
subscription_handlers
:
Vec
<
_
>
=
mem
::
take
(
&
mut
self
.subscription_handlers
.lock
());
let
weak_producer
=
self
.weak_producer
.clone
();
self
.executor
...
...
@@ -415,6 +417,10 @@ impl Inner {
if
let
Err
(
error
)
=
channel
.request
(
request
)
.await
{
error!
(
"consumer closing failed on drop: {}"
,
error
);
}
// Drop from a different thread to avoid deadlock with recursive dropping
// from within another subscription drop.
drop
(
subscription_handlers
);
}
})
.detach
();
...
...
@@ -592,7 +598,10 @@ impl Consumer {
transport
,
weak_producer
:
producer
.downgrade
(),
closed
,
_subscription_handlers
:
vec!
[
subscription_handler
,
payload_subscription_handler
],
subscription_handlers
:
Mutex
::
new
(
vec!
[
subscription_handler
,
payload_subscription_handler
,
]),
_on_transport_close_handler
:
Mutex
::
new
(
on_transport_close_handler
),
});
...
...
rust/src/router/data_consumer.rs
浏览文件 @
f90462b9
...
...
@@ -19,10 +19,10 @@ use log::{debug, error};
use
parking_lot
::
Mutex
;
use
serde
::{
Deserialize
,
Serialize
};
use
std
::
borrow
::
Cow
;
use
std
::
fmt
;
use
std
::
fmt
::
Debug
;
use
std
::
sync
::
atomic
::{
AtomicBool
,
Ordering
};
use
std
::
sync
::{
Arc
,
Weak
};
use
std
::{
fmt
,
mem
};
uuid_based_wrapper_type!
(
/// [`DataConsumer`] identifier.
...
...
@@ -208,7 +208,7 @@ struct Inner {
weak_data_producer
:
WeakDataProducer
,
closed
:
Arc
<
AtomicBool
>
,
// Drop subscription to consumer-specific notifications when consumer itself is dropped
_subscription_handlers
:
Vec
<
Option
<
SubscriptionHandler
>>
,
subscription_handlers
:
Mutex
<
Vec
<
Option
<
SubscriptionHandler
>
>>
,
_on_transport_close_handler
:
Mutex
<
HandlerId
>
,
}
...
...
@@ -237,6 +237,8 @@ impl Inner {
data_producer_id
:
self
.data_producer_id
,
},
};
let
subscription_handlers
:
Vec
<
_
>
=
mem
::
take
(
&
mut
self
.subscription_handlers
.lock
());
let
weak_data_producer
=
self
.weak_data_producer
.clone
();
self
.executor
...
...
@@ -246,6 +248,10 @@ impl Inner {
error!
(
"consumer closing failed on drop: {}"
,
error
);
}
}
// Drop from a different thread to avoid deadlock with recursive dropping
// from within another subscription drop.
drop
(
subscription_handlers
);
})
.detach
();
}
...
...
@@ -445,7 +451,10 @@ impl DataConsumer {
transport
,
weak_data_producer
:
data_producer
.downgrade
(),
closed
,
_subscription_handlers
:
vec!
[
subscription_handler
,
payload_subscription_handler
],
subscription_handlers
:
Mutex
::
new
(
vec!
[
subscription_handler
,
payload_subscription_handler
,
]),
_on_transport_close_handler
:
Mutex
::
new
(
on_transport_close_handler
),
});
...
...
rust/src/router/direct_transport.rs
浏览文件 @
f90462b9
...
...
@@ -25,9 +25,9 @@ use log::{debug, error};
use
nohash_hasher
::
IntMap
;
use
parking_lot
::
Mutex
;
use
serde
::{
Deserialize
,
Serialize
};
use
std
::
fmt
;
use
std
::
sync
::
atomic
::{
AtomicBool
,
AtomicUsize
,
Ordering
};
use
std
::
sync
::{
Arc
,
Weak
};
use
std
::{
fmt
,
mem
};
/// [`DirectTransport`] options.
#[derive(Debug,
Clone)]
...
...
@@ -147,7 +147,7 @@ struct Inner {
router
:
Router
,
closed
:
AtomicBool
,
// Drop subscription to transport-specific notifications when transport itself is dropped
_subscription_handlers
:
Vec
<
Option
<
SubscriptionHandler
>>
,
subscription_handlers
:
Mutex
<
Vec
<
Option
<
SubscriptionHandler
>
>>
,
_on_router_close_handler
:
Mutex
<
HandlerId
>
,
}
...
...
@@ -174,11 +174,18 @@ impl Inner {
transport_id
:
self
.id
,
},
};
let
subscription_handlers
:
Vec
<
_
>
=
mem
::
take
(
&
mut
self
.subscription_handlers
.lock
());
self
.executor
.spawn
(
async
move
{
if
let
Err
(
error
)
=
channel
.request
(
request
)
.await
{
error!
(
"transport closing failed on drop: {}"
,
error
);
}
// Drop from a different thread to avoid deadlock with recursive dropping
// from within another subscription drop.
drop
(
subscription_handlers
);
})
.detach
();
}
...
...
@@ -515,7 +522,10 @@ impl DirectTransport {
app_data
,
router
,
closed
:
AtomicBool
::
new
(
false
),
_subscription_handlers
:
vec!
[
subscription_handler
,
payload_subscription_handler
],
subscription_handlers
:
Mutex
::
new
(
vec!
[
subscription_handler
,
payload_subscription_handler
,
]),
_on_router_close_handler
:
Mutex
::
new
(
on_router_close_handler
),
});
...
...
rust/src/router/pipe_transport.rs
浏览文件 @
f90462b9
...
...
@@ -198,7 +198,7 @@ struct Inner {
router
:
Router
,
closed
:
AtomicBool
,
// Drop subscription to transport-specific notifications when transport itself is dropped
_subscription_handler
:
Option
<
SubscriptionHandler
>
,
subscription_handler
:
Mutex
<
Option
<
SubscriptionHandler
>
>
,
_on_router_close_handler
:
Mutex
<
HandlerId
>
,
}
...
...
@@ -225,11 +225,17 @@ impl Inner {
transport_id
:
self
.id
,
},
};
let
subscription_handler
=
self
.subscription_handler
.lock
()
.take
();
self
.executor
.spawn
(
async
move
{
if
let
Err
(
error
)
=
channel
.request
(
request
)
.await
{
error!
(
"transport closing failed on drop: {}"
,
error
);
}
// Drop from a different thread to avoid deadlock with recursive dropping
// from within another subscription drop.
drop
(
subscription_handler
);
})
.detach
();
}
...
...
@@ -540,7 +546,7 @@ impl PipeTransport {
app_data
,
router
,
closed
:
AtomicBool
::
new
(
false
),
_subscription_handler
:
subscription_handler
,
subscription_handler
:
Mutex
::
new
(
subscription_handler
)
,
_on_router_close_handler
:
Mutex
::
new
(
on_router_close_handler
),
});
...
...
rust/src/router/plain_transport.rs
浏览文件 @
f90462b9
...
...
@@ -235,7 +235,7 @@ struct Inner {
router
:
Router
,
closed
:
AtomicBool
,
// Drop subscription to transport-specific notifications when transport itself is dropped
_subscription_handler
:
Option
<
SubscriptionHandler
>
,
subscription_handler
:
Mutex
<
Option
<
SubscriptionHandler
>
>
,
_on_router_close_handler
:
Mutex
<
HandlerId
>
,
}
...
...
@@ -262,11 +262,17 @@ impl Inner {
transport_id
:
self
.id
,
},
};
let
subscription_handler
=
self
.subscription_handler
.lock
()
.take
();
self
.executor
.spawn
(
async
move
{
if
let
Err
(
error
)
=
channel
.request
(
request
)
.await
{
error!
(
"transport closing failed on drop: {}"
,
error
);
}
// Drop from a different thread to avoid deadlock with recursive dropping
// from within another subscription drop.
drop
(
subscription_handler
);
})
.detach
();
}
...
...
@@ -580,7 +586,7 @@ impl PlainTransport {
app_data
,
router
,
closed
:
AtomicBool
::
new
(
false
),
_subscription_handler
:
subscription_handler
,
subscription_handler
:
Mutex
::
new
(
subscription_handler
)
,
_on_router_close_handler
:
Mutex
::
new
(
on_router_close_handler
),
});
...
...
rust/src/router/producer.rs
浏览文件 @
f90462b9
...
...
@@ -305,7 +305,7 @@ struct Inner {
transport
:
Box
<
dyn
Transport
>
,
closed
:
AtomicBool
,
// Drop subscription to producer-specific notifications when producer itself is dropped
_subscription_handler
:
Option
<
SubscriptionHandler
>
,
subscription_handler
:
Mutex
<
Option
<
SubscriptionHandler
>
>
,
_on_transport_close_handler
:
Mutex
<
HandlerId
>
,
}
...
...
@@ -333,10 +333,16 @@ impl Inner {
producer_id
:
self
.id
,
},
};
let
subscription_handler
=
self
.subscription_handler
.lock
()
.take
();
self
.executor
.spawn
(
async
move
{
if
let
Err
(
error
)
=
channel
.request
(
request
)
.await
{
error!
(
"producer closing failed on drop: {}"
,
error
);
// Drop from a different thread to avoid deadlock with recursive dropping
// from within another subscription drop.
drop
(
subscription_handler
);
}
})
.detach
();
...
...
@@ -509,7 +515,7 @@ impl Producer {
app_data
,
transport
,
closed
:
AtomicBool
::
new
(
false
),
_subscription_handler
:
subscription_handler
,
subscription_handler
:
Mutex
::
new
(
subscription_handler
)
,
_on_transport_close_handler
:
Mutex
::
new
(
on_transport_close_handler
),
});
...
...
rust/src/router/webrtc_transport.rs
浏览文件 @
f90462b9
...
...
@@ -282,7 +282,7 @@ struct Inner {
router
:
Router
,
closed
:
AtomicBool
,
// Drop subscription to transport-specific notifications when transport itself is dropped
_subscription_handler
:
Option
<
SubscriptionHandler
>
,
subscription_handler
:
Mutex
<
Option
<
SubscriptionHandler
>
>
,
_on_router_close_handler
:
Mutex
<
HandlerId
>
,
}
...
...
@@ -309,11 +309,17 @@ impl Inner {
transport_id
:
self
.id
,
},
};
let
subscription_handler
=
self
.subscription_handler
.lock
()
.take
();
self
.executor
.spawn
(
async
move
{
if
let
Err
(
error
)
=
channel
.request
(
request
)
.await
{
error!
(
"transport closing failed on drop: {}"
,
error
);
}
// Drop from a different thread to avoid deadlock with recursive dropping
// from within another subscription drop.
drop
(
subscription_handler
);
})
.detach
();
}
...
...
@@ -651,7 +657,7 @@ impl WebRtcTransport {
app_data
,
router
,
closed
:
AtomicBool
::
new
(
false
),
_subscription_handler
:
subscription_handler
,
subscription_handler
:
Mutex
::
new
(
subscription_handler
)
,
_on_router_close_handler
:
Mutex
::
new
(
on_router_close_handler
),
});
...
...
worker/build.rs
浏览文件 @
f90462b9
...
...
@@ -7,7 +7,9 @@ fn main() {
return
;
}
let
build_type
=
if
cfg!
(
debug_assertions
)
{
// On Windows Rust always links against release version of MSVC runtime, thus requires Release
// build here.
let
build_type
=
if
cfg!
(
all
(
debug_assertions
,
not
(
windows
)))
{
"Debug"
}
else
{
"Release"
...
...
@@ -73,19 +75,15 @@ fn main() {
}
#[cfg(target_os
=
"windows"
)]
{
panic!
(
"Building on Windows is not currently supported"
);
// TODO: Didn't bother, feel free to PR
// Nothing special is needed so far
}
// The build here is a bit awkward since we can't just specify custom target directory as
// openssl will fail to build with `make[1]: /bin/sh: Argument list too long` due to large
// number of files. So instead we build in place, copy files to out directory and then clean
// after ourselves
{
// Build
if
!
Command
::
new
(
"make"
)
.arg
(
"libmediasoup-worker"
)
.env
(
"MEDIASOUP_OUT_DIR"
,
&
out_dir
)
// Force forward slashes on Windows too so that is plays well with our dumb `Makefile`
.env
(
"MEDIASOUP_OUT_DIR"
,
&
out_dir
.replace
(
'\\'
,
"/"
))
.env
(
"MEDIASOUP_BUILDTYPE"
,
&
build_type
)
.spawn
()
.expect
(
"Failed to start"
)
...
...
@@ -111,6 +109,37 @@ fn main() {
}
}
#[cfg(target_os
=
"windows"
)]
{
let
dot_a
=
format!
(
"{}/{}/libmediasoup-worker.a"
,
out_dir
,
build_type
);
let
dot_lib
=
format!
(
"{}/{}/mediasoup-worker.lib"
,
out_dir
,
build_type
);
// Meson builds `libmediasoup-worker.a` on Windows instead of `*.lib` file under MinGW
if
std
::
path
::
Path
::
new
(
&
dot_a
)
.exists
()
{
std
::
fs
::
copy
(
&
dot_a
,
&
dot_lib
)
.unwrap_or_else
(|
_
|
{
panic!
(
"Failed to copy static library from {} to {}"
,
dot_a
,
dot_lib
,
)
});
}
// These are required by libuv on Windows
println!
(
"cargo:rustc-link-lib=psapi"
);
println!
(
"cargo:rustc-link-lib=user32"
);
println!
(
"cargo:rustc-link-lib=advapi32"
);
println!
(
"cargo:rustc-link-lib=iphlpapi"
);
println!
(
"cargo:rustc-link-lib=userenv"
);
println!
(
"cargo:rustc-link-lib=ws2_32"
);
// These are required by OpenSSL on Windows
println!
(
"cargo:rustc-link-lib=ws2_32"
);
println!
(
"cargo:rustc-link-lib=gdi32"
);
println!
(
"cargo:rustc-link-lib=advapi32"
);
println!
(
"cargo:rustc-link-lib=crypt32"
);
println!
(
"cargo:rustc-link-lib=user32"
);
}
println!
(
"cargo:rustc-link-lib=static=mediasoup-worker"
);
println!
(
"cargo:rustc-link-search=native={}/{}"
,
out_dir
,
build_type
);
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论