|
1 | 1 | use super::*;
|
2 | 2 |
|
| 3 | +use crate::api::interceptor_registry::register_default_interceptors; |
| 4 | +use crate::api::media_engine::MediaEngine; |
3 | 5 | use crate::api::media_engine::MIME_TYPE_VP8;
|
4 | 6 | use crate::api::APIBuilder;
|
5 | 7 | use crate::ice_transport::ice_candidate_pair::RTCIceCandidatePair;
|
| 8 | +use crate::ice_transport::ice_server::RTCIceServer; |
| 9 | +use crate::peer_connection::configuration::RTCConfiguration; |
6 | 10 | use crate::rtp_transceiver::rtp_codec::RTCRtpCodecCapability;
|
7 | 11 | use crate::stats::StatsReportType;
|
8 | 12 | use crate::track::track_local::track_local_static_sample::TrackLocalStaticSample;
|
| 13 | +use crate::Error; |
| 14 | +use interceptor::registry::Registry; |
| 15 | + |
9 | 16 | use bytes::Bytes;
|
10 | 17 | use media::Sample;
|
11 | 18 | use std::sync::atomic::AtomicU32;
|
| 19 | +use std::sync::Arc; |
12 | 20 | use tokio::time::Duration;
|
13 | 21 | use util::vnet::net::{Net, NetConfig};
|
14 | 22 | use util::vnet::router::{Router, RouterConfig};
|
@@ -374,3 +382,41 @@ async fn test_get_stats() -> Result<()> {
|
374 | 382 |
|
375 | 383 | Ok(())
|
376 | 384 | }
|
| 385 | + |
| 386 | +#[tokio::test] |
| 387 | +async fn test_peer_connection_close_is_send() -> Result<()> { |
| 388 | + let handle = tokio::spawn(async move { peer().await }); |
| 389 | + tokio::join!(handle).0.unwrap() |
| 390 | +} |
| 391 | + |
| 392 | +async fn peer() -> Result<()> { |
| 393 | + let mut m = MediaEngine::default(); |
| 394 | + m.register_default_codecs()?; |
| 395 | + let mut registry = Registry::new(); |
| 396 | + registry = register_default_interceptors(registry, &mut m)?; |
| 397 | + let api = APIBuilder::new() |
| 398 | + .with_media_engine(m) |
| 399 | + .with_interceptor_registry(registry) |
| 400 | + .build(); |
| 401 | + |
| 402 | + let config = RTCConfiguration { |
| 403 | + ice_servers: vec![RTCIceServer { |
| 404 | + urls: vec!["stun:stun.l.google.com:19302".to_owned()], |
| 405 | + ..Default::default() |
| 406 | + }], |
| 407 | + ..Default::default() |
| 408 | + }; |
| 409 | + |
| 410 | + let peer_connection = Arc::new(api.new_peer_connection(config).await?); |
| 411 | + |
| 412 | + let offer = peer_connection.create_offer(None).await?; |
| 413 | + let mut gather_complete = peer_connection.gathering_complete_promise().await; |
| 414 | + peer_connection.set_local_description(offer).await?; |
| 415 | + let _ = gather_complete.recv().await; |
| 416 | + |
| 417 | + if let Some(_) = peer_connection.local_description().await {} |
| 418 | + |
| 419 | + peer_connection.close().await?; |
| 420 | + |
| 421 | + Ok(()) |
| 422 | +} |
0 commit comments