Skip to main content

gstwebrtchttp/
lib.rs

1// Copyright (C) 2022, Asymptotic Inc.
2//      Author: Taruntej Kanakamalla <taruntej@asymptotic.io>
3//      Author: Sanchayan Maity <sanchayan@asymptotic.io>
4//
5// This Source Code Form is subject to the terms of the Mozilla Public License, v2.0.
6// If a copy of the MPL was not distributed with this file, You can obtain one at
7// <https://mozilla.org/MPL/2.0/>.
8//
9// SPDX-License-Identifier: MPL-2.0
10#![allow(clippy::non_send_fields_in_send_ty, unused_doc_comments)]
11
12/**
13 * plugin-webrtchttp:
14 *
15 * Since: plugins-rs-0.9.0
16 *
17 * Deprecated: plugins-rs-0.16.0 Use the `whipclientsink` and `whepclientsrc` elements from the
18 * `rswebrtc` plugin instead
19 */
20use gst::glib;
21mod utils;
22mod whepsrc;
23mod whipsink;
24
25#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, glib::Enum)]
26#[repr(u32)]
27#[enum_type(name = "GstRsWebRTCICETransportPolicy")]
28#[non_exhaustive]
29pub enum IceTransportPolicy {
30    #[enum_value(name = "All: get both STUN and TURN candidate pairs", nick = "all")]
31    All = 0,
32    #[enum_value(name = "Relay: get only TURN candidate pairs", nick = "relay")]
33    Relay = 1,
34}
35
36fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
37    #[cfg(feature = "doc")]
38    {
39        use gst::prelude::*;
40
41        IceTransportPolicy::static_type().mark_as_plugin_api(gst::PluginAPIFlags::empty());
42    }
43
44    #[cfg(feature = "v1_24")]
45    plugin.add_status_warning(
46        "This plugin is now deprecated. \
47        Please use `whipclientsink` and `whepclientsrc` \
48        from the rswebrtc plugin instead of `whipsink` and `whepsrc`.",
49    );
50
51    #[cfg(all(feature = "rustls-ring", not(feature = "rustls-aws-lc-rs")))]
52    {
53        let _ = rustls::crypto::ring::default_provider().install_default();
54    }
55    #[cfg(feature = "rustls-aws-lc-rs")]
56    {
57        let _ = rustls::crypto::aws_lc_rs::default_provider().install_default();
58    }
59    #[cfg(all(not(feature = "rustls-ring"), not(feature = "rustls-aws-lc-rs")))]
60    {
61        if rustls::crypto::CryptoProvider::get_default().is_none() {
62            panic!(
63                "No rustls crypto provider is configured. \
64        Application must install a crypto provider. For example: \
65        `rustls::crypto::ring::default_provider().install_default().unwrap();` \
66        See https://docs.rs/rustls/latest/rustls/#cryptography-providers for details."
67            );
68        }
69    }
70
71    whipsink::register(plugin)?;
72    whepsrc::register(plugin)?;
73
74    Ok(())
75}
76
77gst::plugin_define!(
78    webrtchttp,
79    env!("CARGO_PKG_DESCRIPTION"),
80    plugin_init,
81    concat!(env!("CARGO_PKG_VERSION"), "-", env!("COMMIT_ID")),
82    "MPL",
83    env!("CARGO_PKG_NAME"),
84    env!("CARGO_PKG_NAME"),
85    env!("CARGO_PKG_REPOSITORY"),
86    env!("BUILD_REL_DATE")
87);