net/quic: Rename to quinnquicsink/src

There might be other QUIC elements in the future based on other
libraries. To prevent namespace collision, namespace the elements
with `quinn` prefix.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1036>
This commit is contained in:
Sanchayan Maity 2024-04-30 16:23:53 +05:30
parent 8b64c734e7
commit 22c6a98914
7 changed files with 44 additions and 40 deletions

View file

@ -14,13 +14,13 @@
* Since: plugins-rs-0.11.0 * Since: plugins-rs-0.11.0
*/ */
use gst::glib; use gst::glib;
mod quicsink; mod quinnquicsink;
mod quicsrc; mod quinnquicsrc;
mod utils; mod utils;
fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
quicsink::register(plugin)?; quinnquicsink::register(plugin)?;
quicsrc::register(plugin)?; quinnquicsrc::register(plugin)?;
Ok(()) Ok(())
} }

View file

@ -37,7 +37,11 @@ const DEFAULT_TIMEOUT: u32 = 15;
const DEFAULT_SECURE_CONNECTION: bool = true; const DEFAULT_SECURE_CONNECTION: bool = true;
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
gst::DebugCategory::new("quicsink", gst::DebugColorFlags::empty(), Some("QUIC Sink")) gst::DebugCategory::new(
"quinnquicsink",
gst::DebugColorFlags::empty(),
Some("Quinn QUIC Sink"),
)
}); });
struct Started { struct Started {
@ -81,13 +85,13 @@ impl Default for Settings {
} }
} }
pub struct QuicSink { pub struct QuinnQuicSink {
settings: Mutex<Settings>, settings: Mutex<Settings>,
state: Mutex<State>, state: Mutex<State>,
canceller: Mutex<Option<future::AbortHandle>>, canceller: Mutex<Option<future::AbortHandle>>,
} }
impl Default for QuicSink { impl Default for QuinnQuicSink {
fn default() -> Self { fn default() -> Self {
Self { Self {
settings: Mutex::new(Settings::default()), settings: Mutex::new(Settings::default()),
@ -97,13 +101,13 @@ impl Default for QuicSink {
} }
} }
impl GstObjectImpl for QuicSink {} impl GstObjectImpl for QuinnQuicSink {}
impl ElementImpl for QuicSink { impl ElementImpl for QuinnQuicSink {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| { static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| {
gst::subclass::ElementMetadata::new( gst::subclass::ElementMetadata::new(
"QUIC Sink", "Quinn QUIC Sink",
"Source/Network/QUIC", "Source/Network/QUIC",
"Send data over the network via QUIC", "Send data over the network via QUIC",
"Sanchayan Maity <sanchayan@asymptotic.io>", "Sanchayan Maity <sanchayan@asymptotic.io>",
@ -129,7 +133,7 @@ impl ElementImpl for QuicSink {
} }
} }
impl ObjectImpl for QuicSink { impl ObjectImpl for QuinnQuicSink {
fn constructed(&self) { fn constructed(&self) {
self.parent_constructed(); self.parent_constructed();
} }
@ -264,13 +268,13 @@ impl ObjectImpl for QuicSink {
} }
#[glib::object_subclass] #[glib::object_subclass]
impl ObjectSubclass for QuicSink { impl ObjectSubclass for QuinnQuicSink {
const NAME: &'static str = "GstQUICSink"; const NAME: &'static str = "GstQuinnQUICSink";
type Type = super::QuicSink; type Type = super::QuinnQuicSink;
type ParentType = gst_base::BaseSink; type ParentType = gst_base::BaseSink;
} }
impl BaseSinkImpl for QuicSink { impl BaseSinkImpl for QuinnQuicSink {
fn start(&self) -> Result<(), gst::ErrorMessage> { fn start(&self) -> Result<(), gst::ErrorMessage> {
let settings = self.settings.lock().unwrap(); let settings = self.settings.lock().unwrap();
let timeout = settings.timeout; let timeout = settings.timeout;
@ -392,7 +396,7 @@ impl BaseSinkImpl for QuicSink {
} }
} }
impl QuicSink { impl QuinnQuicSink {
fn send_buffer(&self, src: &[u8]) -> Result<(), Option<gst::ErrorMessage>> { fn send_buffer(&self, src: &[u8]) -> Result<(), Option<gst::ErrorMessage>> {
let settings = self.settings.lock().unwrap(); let settings = self.settings.lock().unwrap();
let timeout = settings.timeout; let timeout = settings.timeout;

View file

@ -13,14 +13,14 @@ use gst::prelude::*;
pub mod imp; pub mod imp;
glib::wrapper! { glib::wrapper! {
pub struct QuicSink(ObjectSubclass<imp::QuicSink>) @extends gst_base::BaseSink, gst::Element, gst::Object; pub struct QuinnQuicSink(ObjectSubclass<imp::QuinnQuicSink>) @extends gst_base::BaseSink, gst::Element, gst::Object;
} }
pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
gst::Element::register( gst::Element::register(
Some(plugin), Some(plugin),
"quicsink", "quinnquicsink",
gst::Rank::MARGINAL, gst::Rank::MARGINAL,
QuicSink::static_type(), QuinnQuicSink::static_type(),
) )
} }

View file

@ -41,9 +41,9 @@ const DEFAULT_SECURE_CONNECTION: bool = true;
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
gst::DebugCategory::new( gst::DebugCategory::new(
"quicsrc", "quinnquicsrc",
gst::DebugColorFlags::empty(), gst::DebugColorFlags::empty(),
Some("QUIC Source"), Some("Quinn QUIC Source"),
) )
}); });
@ -90,13 +90,13 @@ impl Default for Settings {
} }
} }
pub struct QuicSrc { pub struct QuinnQuicSrc {
settings: Mutex<Settings>, settings: Mutex<Settings>,
state: Mutex<State>, state: Mutex<State>,
canceller: Mutex<Option<future::AbortHandle>>, canceller: Mutex<Option<future::AbortHandle>>,
} }
impl Default for QuicSrc { impl Default for QuinnQuicSrc {
fn default() -> Self { fn default() -> Self {
Self { Self {
settings: Mutex::new(Settings::default()), settings: Mutex::new(Settings::default()),
@ -106,15 +106,15 @@ impl Default for QuicSrc {
} }
} }
impl GstObjectImpl for QuicSrc {} impl GstObjectImpl for QuinnQuicSrc {}
impl ElementImpl for QuicSrc { impl ElementImpl for QuinnQuicSrc {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| { static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| {
#[cfg(feature = "doc")] #[cfg(feature = "doc")]
QuicPrivateKeyType::static_type().mark_as_plugin_api(gst::PluginAPIFlags::empty()); QuicPrivateKeyType::static_type().mark_as_plugin_api(gst::PluginAPIFlags::empty());
gst::subclass::ElementMetadata::new( gst::subclass::ElementMetadata::new(
"QUIC Source", "Quinn QUIC Source",
"Source/Network/QUIC", "Source/Network/QUIC",
"Receive data over the network via QUIC", "Receive data over the network via QUIC",
"Sanchayan Maity <sanchayan@asymptotic.io>", "Sanchayan Maity <sanchayan@asymptotic.io>",
@ -164,7 +164,7 @@ impl ElementImpl for QuicSrc {
} }
} }
impl ObjectImpl for QuicSrc { impl ObjectImpl for QuinnQuicSrc {
fn constructed(&self) { fn constructed(&self) {
self.parent_constructed(); self.parent_constructed();
self.obj().set_format(gst::Format::Bytes); self.obj().set_format(gst::Format::Bytes);
@ -314,13 +314,13 @@ impl ObjectImpl for QuicSrc {
} }
#[glib::object_subclass] #[glib::object_subclass]
impl ObjectSubclass for QuicSrc { impl ObjectSubclass for QuinnQuicSrc {
const NAME: &'static str = "GstQUICSrc"; const NAME: &'static str = "GstQuinnQUICSrc";
type Type = super::QuicSrc; type Type = super::QuinnQuicSrc;
type ParentType = gst_base::BaseSrc; type ParentType = gst_base::BaseSrc;
} }
impl BaseSrcImpl for QuicSrc { impl BaseSrcImpl for QuinnQuicSrc {
fn is_seekable(&self) -> bool { fn is_seekable(&self) -> bool {
false false
} }
@ -458,7 +458,7 @@ impl BaseSrcImpl for QuicSrc {
} }
} }
impl QuicSrc { impl QuinnQuicSrc {
fn get(&self, _offset: u64, length: u64) -> Result<Bytes, Option<gst::ErrorMessage>> { fn get(&self, _offset: u64, length: u64) -> Result<Bytes, Option<gst::ErrorMessage>> {
let settings = self.settings.lock().unwrap(); let settings = self.settings.lock().unwrap();
let timeout = settings.timeout; let timeout = settings.timeout;

View file

@ -23,14 +23,14 @@ pub enum QuicPrivateKeyType {
} }
glib::wrapper! { glib::wrapper! {
pub struct QuicSrc(ObjectSubclass<imp::QuicSrc>) @extends gst_base::BaseSrc, gst::Element, gst::Object; pub struct QuinnQuicSrc(ObjectSubclass<imp::QuinnQuicSrc>) @extends gst_base::BaseSrc, gst::Element, gst::Object;
} }
pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
gst::Element::register( gst::Element::register(
Some(plugin), Some(plugin),
"quicsrc", "quinnquicsrc",
gst::Rank::MARGINAL, gst::Rank::MARGINAL,
QuicSrc::static_type(), QuinnQuicSrc::static_type(),
) )
} }

View file

@ -7,7 +7,7 @@
// //
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
use crate::quicsrc::QuicPrivateKeyType; use crate::quinnquicsrc::QuicPrivateKeyType;
use futures::future; use futures::future;
use futures::prelude::*; use futures::prelude::*;
use gst::ErrorMessage; use gst::ErrorMessage;

View file

@ -36,7 +36,7 @@ fn test_send_receive_without_datagram() {
thread::spawn(move || { thread::spawn(move || {
let mut h1 = gst_check::Harness::new_empty(); let mut h1 = gst_check::Harness::new_empty();
h1.add_parse("quicsink secure-connection=false"); h1.add_parse("quinnquicsink secure-connection=false");
h1.set_src_caps(gst::Caps::builder("text/plain").build()); h1.set_src_caps(gst::Caps::builder("text/plain").build());
@ -52,7 +52,7 @@ fn test_send_receive_without_datagram() {
}); });
let mut h2 = gst_check::Harness::new_empty(); let mut h2 = gst_check::Harness::new_empty();
h2.add_parse("quicsrc secure-connection=false"); h2.add_parse("quinnquicsrc secure-connection=false");
h2.play(); h2.play();
@ -79,7 +79,7 @@ fn test_send_receive_with_datagram() {
// in the other test. We get a address already in use error otherwise. // in the other test. We get a address already in use error otherwise.
thread::spawn(move || { thread::spawn(move || {
let mut h1 = gst_check::Harness::new_empty(); let mut h1 = gst_check::Harness::new_empty();
h1.add_parse("quicsrc use-datagram=true server-address=127.0.0.1 server-port=6000 secure-connection=false"); h1.add_parse("quinnquicsrc use-datagram=true server-address=127.0.0.1 server-port=6000 secure-connection=false");
h1.play(); h1.play();
@ -96,7 +96,7 @@ fn test_send_receive_with_datagram() {
}); });
let mut h2 = gst_check::Harness::new_empty(); let mut h2 = gst_check::Harness::new_empty();
h2.add_parse("quicsink use-datagram=true client-address=127.0.0.1 client-port=6001 server-address=127.0.0.1 server-port=6000 secure-connection=false"); h2.add_parse("quinnquicsink use-datagram=true client-address=127.0.0.1 client-port=6001 server-address=127.0.0.1 server-port=6000 secure-connection=false");
h2.set_src_caps(gst::Caps::builder("text/plain").build()); h2.set_src_caps(gst::Caps::builder("text/plain").build());