Commit 3a0c9723 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

WebRTC/SDP WIP

parent 9a3ef2e9
......@@ -12,6 +12,7 @@ members = [
"gstreamer-sdp",
"gstreamer-video",
"gstreamer-pbutils",
"gstreamer-webrtc",
"examples",
"tutorials",
]
......@@ -5,7 +5,7 @@ version = "1.0"
min_cfg_version = "1.8"
target_path = "gstreamer-sdp"
work_mode = "normal"
concurrency = "send+sync"
concurrency = "send"
generate_safety_asserts = true
doc_target_path = "docs/gstreamer-sdp/docs.md"
......@@ -28,7 +28,7 @@ generate = [
"GstSdp.MIKEYSecSRTP",
"GstSdp.MIKEYTSType",
"GstSdp.MIKEYType",
"GstSdp.SDPResult"
"GstSdp.SDPResult",
]
manual = [
......@@ -38,3 +38,23 @@ manual = [
name = "Gst.Caps"
status = "manual"
ref_mode = "ref"
[[object]]
name = "GstSdp.SDPMessage"
status = "generate"
use_boxed_functions = true
[[object.function]]
name = "new"
# special return type...
ignore = true
[[object.function]]
name = "uninit"
# unsafe
ignore = true
[[object]]
name = "GstSdp.SDPMedia"
status = "generate"
[options]
girs_dir = "gir-files"
library = "GstWebRTC"
version = "1.0"
min_cfg_version = "1.14"
target_path = "gstreamer-webrtc"
work_mode = "normal"
concurrency = "send+sync"
generate_safety_asserts = true
external_libraries = [
"GLib",
"GObject",
"Gst",
"GstSdp",
]
generate = [
"GstWebRTC.WebRTCDTLSTransportState",
"GstWebRTC.WebRTCICEGatheringState",
"GstWebRTC.WebRTCICEConnectionState",
"GstWebRTC.WebRTCICERole",
"GstWebRTC.WebRTCICEComponent",
"GstWebRTC.WebRTCSDPType",
]
manual = [
"GObject.Object",
"Gst.Structure",
"GstSdp.SDPMessage",
]
[[object]]
name = "GstWebRTC.WebRTCDTLSTransport"
status = "generate"
trait = false
[[object]]
name = "GstWebRTC.WebRTCICETransport"
status = "generate"
trait = false
[[object]]
name = "GstWebRTC.WebRTCRTPReceiver"
status = "generate"
trait = false
[[object]]
name = "GstWebRTC.WebRTCRTPSender"
status = "generate"
trait = false
[[object]]
name = "GstWebRTC.WebRTCRTPTransceiver"
status = "generate"
trait = false
[[object]]
name = "GstWebRTC.WebRTCSessionDescription"
status = "generate"
trait = false
This diff is collapsed.
......@@ -2,6 +2,12 @@
// from gir-files (https://github.com/gtk-rs/gir-files @ ???)
// DO NOT EDIT
mod s_d_p_media;
pub use self::s_d_p_media::SDPMedia;
mod s_d_p_message;
pub use self::s_d_p_message::SDPMessage;
mod enums;
pub use self::enums::MIKEYCacheType;
pub use self::enums::MIKEYEncAlg;
......
// This file was generated by gir (https://github.com/gtk-rs/gir @ d1e0127)
// from gir-files (https://github.com/gtk-rs/gir-files @ ???)
// DO NOT EDIT
use SDPResult;
use ffi;
use glib::translate::*;
use glib_ffi;
use gst;
use std::mem;
use std::ptr;
glib_wrapper! {
pub struct SDPMedia(Boxed<ffi::GstSDPMedia>);
match fn {
copy => |ptr| ffi::gst_sdp_media_copy(mut_override(ptr)),
free => |ptr| ffi::gst_sdp_media_free(ptr),
}
}
impl SDPMedia {
pub fn add_attribute<'a, P: Into<Option<&'a str>>>(&mut self, key: &str, value: P) -> SDPResult {
let value = value.into();
let value = value.to_glib_none();
unsafe {
from_glib(ffi::gst_sdp_media_add_attribute(self.to_glib_none_mut().0, key.to_glib_none().0, value.0))
}
}
pub fn add_bandwidth(&mut self, bwtype: &str, bandwidth: u32) -> SDPResult {
unsafe {
from_glib(ffi::gst_sdp_media_add_bandwidth(self.to_glib_none_mut().0, bwtype.to_glib_none().0, bandwidth))
}
}
pub fn add_connection(&mut self, nettype: &str, addrtype: &str, address: &str, ttl: u32, addr_number: u32) -> SDPResult {
unsafe {
from_glib(ffi::gst_sdp_media_add_connection(self.to_glib_none_mut().0, nettype.to_glib_none().0, addrtype.to_glib_none().0, address.to_glib_none().0, ttl, addr_number))
}
}
pub fn add_format(&mut self, format: &str) -> SDPResult {
unsafe {
from_glib(ffi::gst_sdp_media_add_format(self.to_glib_none_mut().0, format.to_glib_none().0))
}
}
pub fn as_text(&self) -> Option<String> {
unsafe {
from_glib_full(ffi::gst_sdp_media_as_text(self.to_glib_none().0))
}
}
pub fn attributes_len(&self) -> u32 {
unsafe {
ffi::gst_sdp_media_attributes_len(self.to_glib_none().0)
}
}
pub fn attributes_to_caps(&self, caps: &gst::Caps) -> SDPResult {
unsafe {
from_glib(ffi::gst_sdp_media_attributes_to_caps(self.to_glib_none().0, caps.to_glib_none().0))
}
}
pub fn bandwidths_len(&self) -> u32 {
unsafe {
ffi::gst_sdp_media_bandwidths_len(self.to_glib_none().0)
}
}
pub fn connections_len(&self) -> u32 {
unsafe {
ffi::gst_sdp_media_connections_len(self.to_glib_none().0)
}
}
pub fn formats_len(&self) -> u32 {
unsafe {
ffi::gst_sdp_media_formats_len(self.to_glib_none().0)
}
}
//pub fn get_attribute(&self, idx: u32) -> /*Ignored*/Option<SDPAttribute> {
// unsafe { TODO: call ffi::gst_sdp_media_get_attribute() }
//}
pub fn get_attribute_val(&self, key: &str) -> Option<String> {
unsafe {
from_glib_none(ffi::gst_sdp_media_get_attribute_val(self.to_glib_none().0, key.to_glib_none().0))
}
}
pub fn get_attribute_val_n(&self, key: &str, nth: u32) -> Option<String> {
unsafe {
from_glib_none(ffi::gst_sdp_media_get_attribute_val_n(self.to_glib_none().0, key.to_glib_none().0, nth))
}
}
//pub fn get_bandwidth(&self, idx: u32) -> /*Ignored*/Option<SDPBandwidth> {
// unsafe { TODO: call ffi::gst_sdp_media_get_bandwidth() }
//}
pub fn get_caps_from_media(&self, pt: i32) -> Option<gst::Caps> {
unsafe {
from_glib_full(ffi::gst_sdp_media_get_caps_from_media(self.to_glib_none().0, pt))
}
}
//pub fn get_connection(&self, idx: u32) -> /*Ignored*/Option<SDPConnection> {
// unsafe { TODO: call ffi::gst_sdp_media_get_connection() }
//}
pub fn get_format(&self, idx: u32) -> Option<String> {
unsafe {
from_glib_none(ffi::gst_sdp_media_get_format(self.to_glib_none().0, idx))
}
}
pub fn get_information(&self) -> Option<String> {
unsafe {
from_glib_none(ffi::gst_sdp_media_get_information(self.to_glib_none().0))
}
}
//pub fn get_key(&self) -> /*Ignored*/Option<SDPKey> {
// unsafe { TODO: call ffi::gst_sdp_media_get_key() }
//}
pub fn get_media(&self) -> Option<String> {
unsafe {
from_glib_none(ffi::gst_sdp_media_get_media(self.to_glib_none().0))
}
}
pub fn get_num_ports(&self) -> u32 {
unsafe {
ffi::gst_sdp_media_get_num_ports(self.to_glib_none().0)
}
}
pub fn get_port(&self) -> u32 {
unsafe {
ffi::gst_sdp_media_get_port(self.to_glib_none().0)
}
}
pub fn get_proto(&self) -> Option<String> {
unsafe {
from_glib_none(ffi::gst_sdp_media_get_proto(self.to_glib_none().0))
}
}
pub fn init(&mut self) -> SDPResult {
unsafe {
from_glib(ffi::gst_sdp_media_init(self.to_glib_none_mut().0))
}
}
//pub fn insert_attribute(&mut self, idx: i32, attr: /*Ignored*/&mut SDPAttribute) -> SDPResult {
// unsafe { TODO: call ffi::gst_sdp_media_insert_attribute() }
//}
//pub fn insert_bandwidth(&mut self, idx: i32, bw: /*Ignored*/&mut SDPBandwidth) -> SDPResult {
// unsafe { TODO: call ffi::gst_sdp_media_insert_bandwidth() }
//}
//pub fn insert_connection(&mut self, idx: i32, conn: /*Ignored*/&mut SDPConnection) -> SDPResult {
// unsafe { TODO: call ffi::gst_sdp_media_insert_connection() }
//}
pub fn insert_format(&mut self, idx: i32, format: &str) -> SDPResult {
unsafe {
from_glib(ffi::gst_sdp_media_insert_format(self.to_glib_none_mut().0, idx, format.to_glib_none().0))
}
}
//#[cfg(any(feature = "v1_8_1", feature = "dox"))]
//pub fn parse_keymgmt(&self, mikey: /*Ignored*/MIKEYMessage) -> SDPResult {
// unsafe { TODO: call ffi::gst_sdp_media_parse_keymgmt() }
//}
pub fn remove_attribute(&mut self, idx: u32) -> SDPResult {
unsafe {
from_glib(ffi::gst_sdp_media_remove_attribute(self.to_glib_none_mut().0, idx))
}
}
pub fn remove_bandwidth(&mut self, idx: u32) -> SDPResult {
unsafe {
from_glib(ffi::gst_sdp_media_remove_bandwidth(self.to_glib_none_mut().0, idx))
}
}
pub fn remove_connection(&mut self, idx: u32) -> SDPResult {
unsafe {
from_glib(ffi::gst_sdp_media_remove_connection(self.to_glib_none_mut().0, idx))
}
}
pub fn remove_format(&mut self, idx: u32) -> SDPResult {
unsafe {
from_glib(ffi::gst_sdp_media_remove_format(self.to_glib_none_mut().0, idx))
}
}
//pub fn replace_attribute(&mut self, idx: u32, attr: /*Ignored*/&mut SDPAttribute) -> SDPResult {
// unsafe { TODO: call ffi::gst_sdp_media_replace_attribute() }
//}
//pub fn replace_bandwidth(&mut self, idx: u32, bw: /*Ignored*/&mut SDPBandwidth) -> SDPResult {
// unsafe { TODO: call ffi::gst_sdp_media_replace_bandwidth() }
//}
//pub fn replace_connection(&mut self, idx: u32, conn: /*Ignored*/&mut SDPConnection) -> SDPResult {
// unsafe { TODO: call ffi::gst_sdp_media_replace_connection() }
//}
pub fn replace_format(&mut self, idx: u32, format: &str) -> SDPResult {
unsafe {
from_glib(ffi::gst_sdp_media_replace_format(self.to_glib_none_mut().0, idx, format.to_glib_none().0))
}
}
pub fn set_information(&mut self, information: &str) -> SDPResult {
unsafe {
from_glib(ffi::gst_sdp_media_set_information(self.to_glib_none_mut().0, information.to_glib_none().0))
}
}
pub fn set_key(&mut self, type_: &str, data: &str) -> SDPResult {
unsafe {
from_glib(ffi::gst_sdp_media_set_key(self.to_glib_none_mut().0, type_.to_glib_none().0, data.to_glib_none().0))
}
}
pub fn set_media(&mut self, med: &str) -> SDPResult {
unsafe {
from_glib(ffi::gst_sdp_media_set_media(self.to_glib_none_mut().0, med.to_glib_none().0))
}
}
pub fn set_port_info(&mut self, port: u32, num_ports: u32) -> SDPResult {
unsafe {
from_glib(ffi::gst_sdp_media_set_port_info(self.to_glib_none_mut().0, port, num_ports))
}
}
pub fn set_proto(&mut self, proto: &str) -> SDPResult {
unsafe {
from_glib(ffi::gst_sdp_media_set_proto(self.to_glib_none_mut().0, proto.to_glib_none().0))
}
}
pub fn uninit(&mut self) -> SDPResult {
unsafe {
from_glib(ffi::gst_sdp_media_uninit(self.to_glib_none_mut().0))
}
}
pub fn new() -> (SDPResult, SDPMedia) {
assert_initialized_main_thread!();
unsafe {
let mut media = ptr::null_mut();
let ret = from_glib(ffi::gst_sdp_media_new(&mut media));
(ret, from_glib_full(media))
}
}
pub fn set_media_from_caps(caps: &gst::Caps, media: &mut SDPMedia) -> SDPResult {
assert_initialized_main_thread!();
unsafe {
from_glib(ffi::gst_sdp_media_set_media_from_caps(caps.to_glib_none().0, media.to_glib_none_mut().0))
}
}
}
impl Default for SDPMedia {
fn default() -> Self {
Self::new()
}
}
unsafe impl Send for SDPMedia {}
This diff is collapsed.
// This file was generated by gir (https://github.com/gtk-rs/gir @ d1e0127)
// from gir-files (https://github.com/gtk-rs/gir-files @ ???)
// DO NOT EDIT
use SDPResult;
use ffi;
use glib::translate::*;
use glib_ffi;
use std::mem;
use std::ptr;
impl SDPMessage {
pub fn new() -> SDPMessage {
assert_initialized_main_thread!();
unsafe {
let msg = glib_ffi::g_malloc(mem::size_of::<ffi::GstSDPMessage>());
let _ = ffi::gst_sdp_message_new(msg);
from_glib_full(msg)
}
}
}
[package]
name = "gstreamer-webrtc"
version = "0.11.0"
authors = ["Sebastian Dröge <sebastian@centricular.com>"]
categories = ["api-bindings", "multimedia"]
description = "Rust bindings for GStreamer WebRTC library"
repository = "https://github.com/sdroege/gstreamer-rs"
license = "MIT/Apache-2.0"
readme = "README.md"
homepage = "https://gstreamer.freedesktop.org"
documentation = "https://sdroege.github.io/rustdoc/gstreamer/gstreamer_webrtc"
keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"]
build = "build.rs"
[dependencies]
libc = "0.2"
glib-sys = { git = "https://github.com/gtk-rs/sys" }
gobject-sys = { git = "https://github.com/gtk-rs/sys" }
gstreamer-sys = { git = "https://github.com/sdroege/gstreamer-sys", branch = "1.14" }
gstreamer-webrtc-sys = { git = "https://github.com/sdroege/gstreamer-sys", branch = "1.14" }
glib = { git = "https://github.com/gtk-rs/glib" }
gstreamer = { path = "../gstreamer", features = ["v1_14"] }
gstreamer-sdp = { path = "../gstreamer-sdp" }
[build-dependencies.rustdoc-stripper]
version = "0.1"
optional = true
[features]
embed-lgpl-docs = ["rustdoc-stripper"]
purge-lgpl-docs = ["rustdoc-stripper"]
dox = ["gstreamer-webrtc-sys/dox", "glib/dox", "gstreamer/dox"]
default-features = []
[badges]
travis-ci = { repository = "sdroege/gstreamer-rs", branch = "master" }
fn main() {
manage_docs();
}
#[cfg(any(feature = "embed-lgpl-docs", feature = "purge-lgpl-docs"))]
fn manage_docs() {
extern crate stripper_lib;
use std::io;
let path = "src";
let ignores: &[&str] = &[];
stripper_lib::loop_over_files(
path.as_ref(),
&mut |w, s| stripper_lib::strip_comments(w, s, &mut io::sink(), true),
&ignores,
false,
);
#[cfg(feature = "embed-lgpl-docs")]
{
let docs = include_str!("../docs/gstreamer-webrtc/docs.md");
let mut infos = stripper_lib::parse_cmts(docs.lines(), true);
stripper_lib::loop_over_files(
path.as_ref(),
&mut |w, s| stripper_lib::regenerate_comments(w, s, &mut infos, true, true),
&ignores,
false,
);
}
}
#[cfg(not(any(feature = "embed-lgpl-docs", feature = "purge-lgpl-docs")))]
fn manage_docs() {}
// This file was generated by gir (https://github.com/gtk-rs/gir @ d1e0127)
// from gir-files (https://github.com/gtk-rs/gir-files @ ???)
// DO NOT EDIT
use ffi;
use glib::translate::*;
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum WebRTCDTLSTransportState {
New,
Closed,
Failed,
Connecting,
Connected,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl ToGlib for WebRTCDTLSTransportState {
type GlibType = ffi::GstWebRTCDTLSTransportState;
fn to_glib(&self) -> ffi::GstWebRTCDTLSTransportState {
match *self {
WebRTCDTLSTransportState::New => ffi::GST_WEBRTC_DTLS_TRANSPORT_STATE_NEW,
WebRTCDTLSTransportState::Closed => ffi::GST_WEBRTC_DTLS_TRANSPORT_STATE_CLOSED,
WebRTCDTLSTransportState::Failed => ffi::GST_WEBRTC_DTLS_TRANSPORT_STATE_FAILED,
WebRTCDTLSTransportState::Connecting => ffi::GST_WEBRTC_DTLS_TRANSPORT_STATE_CONNECTING,
WebRTCDTLSTransportState::Connected => ffi::GST_WEBRTC_DTLS_TRANSPORT_STATE_CONNECTED,
WebRTCDTLSTransportState::__Unknown(value) => value
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstWebRTCDTLSTransportState> for WebRTCDTLSTransportState {
fn from_glib(value: ffi::GstWebRTCDTLSTransportState) -> Self {
skip_assert_initialized!();
match value {
0 => WebRTCDTLSTransportState::New,
1 => WebRTCDTLSTransportState::Closed,
2 => WebRTCDTLSTransportState::Failed,
3 => WebRTCDTLSTransportState::Connecting,
4 => WebRTCDTLSTransportState::Connected,
value => WebRTCDTLSTransportState::__Unknown(value),
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum WebRTCICEComponent {
Rtp,
Rtcp,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl ToGlib for WebRTCICEComponent {
type GlibType = ffi::GstWebRTCICEComponent;
fn to_glib(&self) -> ffi::GstWebRTCICEComponent {
match *self {
WebRTCICEComponent::Rtp => ffi::GST_WEBRTC_ICE_COMPONENT_RTP,
WebRTCICEComponent::Rtcp => ffi::GST_WEBRTC_ICE_COMPONENT_RTCP,
WebRTCICEComponent::__Unknown(value) => value
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstWebRTCICEComponent> for WebRTCICEComponent {
fn from_glib(value: ffi::GstWebRTCICEComponent) -> Self {
skip_assert_initialized!();
match value {
0 => WebRTCICEComponent::Rtp,
1 => WebRTCICEComponent::Rtcp,
value => WebRTCICEComponent::__Unknown(value),
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum WebRTCICEConnectionState {
New,
Checking,
Connected,
Completed,
Failed,
Disconnected,
Closed,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl ToGlib for WebRTCICEConnectionState {
type GlibType = ffi::GstWebRTCICEConnectionState;
fn to_glib(&self) -> ffi::GstWebRTCICEConnectionState {
match *self {
WebRTCICEConnectionState::New => ffi::GST_WEBRTC_ICE_CONNECTION_STATE_NEW,
WebRTCICEConnectionState::Checking => ffi::GST_WEBRTC_ICE_CONNECTION_STATE_CHECKING,
WebRTCICEConnectionState::Connected => ffi::GST_WEBRTC_ICE_CONNECTION_STATE_CONNECTED,
WebRTCICEConnectionState::Completed => ffi::GST_WEBRTC_ICE_CONNECTION_STATE_COMPLETED,
WebRTCICEConnectionState::Failed => ffi::GST_WEBRTC_ICE_CONNECTION_STATE_FAILED,
WebRTCICEConnectionState::Disconnected => ffi::GST_WEBRTC_ICE_CONNECTION_STATE_DISCONNECTED,
WebRTCICEConnectionState::Closed => ffi::GST_WEBRTC_ICE_CONNECTION_STATE_CLOSED,
WebRTCICEConnectionState::__Unknown(value) => value
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstWebRTCICEConnectionState> for WebRTCICEConnectionState {
fn from_glib(value: ffi::GstWebRTCICEConnectionState) -> Self {
skip_assert_initialized!();
match value {
0 => WebRTCICEConnectionState::New,
1 => WebRTCICEConnectionState::Checking,
2 => WebRTCICEConnectionState::Connected,
3 => WebRTCICEConnectionState::Completed,
4 => WebRTCICEConnectionState::Failed,
5 => WebRTCICEConnectionState::Disconnected,
6 => WebRTCICEConnectionState::Closed,
value => WebRTCICEConnectionState::__Unknown(value),
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum WebRTCICEGatheringState {
New,
Gathering,
Complete,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl ToGlib for WebRTCICEGatheringState {
type GlibType = ffi::GstWebRTCICEGatheringState;
fn to_glib(&self) -> ffi::GstWebRTCICEGatheringState {
match *self {
WebRTCICEGatheringState::New => ffi::GST_WEBRTC_ICE_GATHERING_STATE_NEW,
WebRTCICEGatheringState::Gathering => ffi::GST_WEBRTC_ICE_GATHERING_STATE_GATHERING,
WebRTCICEGatheringState::Complete => ffi::GST_WEBRTC_ICE_GATHERING_STATE_COMPLETE,
WebRTCICEGatheringState::__Unknown(value) => value
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstWebRTCICEGatheringState> for WebRTCICEGatheringState {
fn from_glib(value: ffi::GstWebRTCICEGatheringState) -> Self {
skip_assert_initialized!();
match value {
0 => WebRTCICEGatheringState::New,
1 => WebRTCICEGatheringState::Gathering,
2 => WebRTCICEGatheringState::Complete,
value => WebRTCICEGatheringState::__Unknown(value),
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum WebRTCICERole {
Controlled,
Controlling,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl ToGlib for WebRTCICERole {
type GlibType = ffi::GstWebRTCICERole;
fn to_glib(&self) -> ffi::GstWebRTCICERole {
match *self {
WebRTCICERole::Controlled => ffi::GST_WEBRTC_ICE_ROLE_CONTROLLED,
WebRTCICERole::Controlling => ffi::GST_WEBRTC_ICE_ROLE_CONTROLLING,
WebRTCICERole::__Unknown(value) => value
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstWebRTCICERole> for WebRTCICERole {
fn from_glib(value: ffi::GstWebRTCICERole) -> Self {
skip_assert_initialized!();
match value {
0 => WebRTCICERole::Controlled,
1 => WebRTCICERole::Controlling,
value => WebRTCICERole::__Unknown(value),
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum WebRTCSDPType {
Offer,
Pranswer,
Answer,
Rollback,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]