1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#![allow(dead_code)]
extern crate lazy_static;
#[macro_use]
mod macros;
#[macro_use]
pub mod connection;
pub mod audio_device;
mod enums;
pub mod log;
pub mod publisher;
pub mod session;
pub mod stream;
pub mod subscriber;
pub mod video_capturer;
pub mod video_frame;
pub use crate::enums::{IntoResult, OtcError, OtcResult};
use std::ptr;
pub fn init() -> OtcResult {
unsafe { ffi::otc_init(ptr::null_mut()) }.into_result()
}
pub fn deinit() -> OtcResult {
audio_device::AudioDevice::stop();
for (_, publisher) in publisher::INSTANCES.lock().unwrap().drain() {
let _ = publisher.unpublish();
}
for (_, subscriber) in subscriber::INSTANCES.lock().unwrap().drain() {
let _ = subscriber.unsubscribe();
}
for (_, session) in session::INSTANCES.lock().unwrap().drain() {
let _ = session.disconnect();
}
unsafe { ffi::otc_destroy() }.into_result()
}