Commit a00243d5 authored by Mathieu Duponchelle's avatar Mathieu Duponchelle 🐸 Committed by Sebastian Dröge

Add initial libgstsdp, libgstrtsp and libgstrtspserver bindings

Only automatic bindings for now, which is enough to allow
implementing a simple rtsp-server example.

Depends on https://github.com/sdroege/gstreamer-sys/pull/8

Uses a new gir feature proposed at
https://github.com/gtk-rs/gir/pull/539 to make doc regeneration
easier.

Fixes https://github.com/sdroege/gstreamer-rs/pull/80
parent 08dbde4c
......@@ -7,6 +7,9 @@ members = [
"gstreamer-base",
"gstreamer-net",
"gstreamer-player",
"gstreamer-rtsp",
"gstreamer-rtsp-server",
"gstreamer-sdp",
"gstreamer-video",
"examples",
"tutorials",
......
[options]
girs_dir = "gir-files"
library = "GstRtsp"
version = "1.0"
min_cfg_version = "1.8"
target_path = "gstreamer-rtsp"
work_mode = "normal"
concurrency = "send+sync"
generate_safety_asserts = true
doc_target_path = "docs/gstreamer-rtsp/docs.md"
external_libraries = [
"GLib",
"GObject",
"Gio",
"GstSdp"
]
generate = [
"GstRtsp.RTSPAuthMethod",
"GstRtsp.RTSPEvent",
"GstRtsp.RTSPFamily",
"GstRtsp.RTSPHeaderField",
"GstRtsp.RTSPLowerTrans",
"GstRtsp.RTSPMethod",
"GstRtsp.RTSPMsgType",
"GstRtsp.RTSPProfile",
"GstRtsp.RTSPRangeUnit",
"GstRtsp.RTSPResult",
"GstRtsp.RTSPState",
"GstRtsp.RTSPStatusCode",
"GstRtsp.RTSPTimeType",
"GstRtsp.RTSPTransMode"
]
manual = [
"GLib.MainContext",
]
[[object]]
name = "GstRtsp.RTSPUrl"
status = "generate"
concurrency = "send"
[[object.function]]
name = "get_port"
ignore = true
[[object]]
name = "GstRtsp.RTSPAuthParam"
status = "generate"
concurrency="send"
[[object]]
name = "Gst.ClockTime"
status = "manual"
conversion_type = "scalar"
[[object]]
name = "Gst.Caps"
status = "manual"
ref_mode = "ref"
[[object]]
name = "Gst.Structure"
status = "manual"
ref_mode = "ref-mut"
[options]
girs_dir = "gir-files"
library = "GstRtspServer"
version = "1.0"
min_cfg_version = "1.8"
target_path = "gstreamer-rtsp-server"
work_mode = "normal"
concurrency = "send+sync"
generate_safety_asserts = true
doc_target_path = "docs/gstreamer-rtsp-server/docs.md"
external_libraries = [
"GLib",
"GObject",
"Gio",
"Gst",
"GstNet",
"GstRtsp",
"GstSDP"
]
generate = [
"GstRtspServer.RTSPAddressFlags",
"GstRtspServer.RTSPAddressPoolResult",
"GstRtspServer.RTSPMediaFactory",
"GstRtspServer.RTSPMediaFactoryURI",
"GstRtspServer.RTSPMediaStatus",
"GstRtspServer.RTSPMountPoints",
"GstRtspServer.RTSPPublishClockMode",
"GstRtspServer.RTSPSession",
"GstRtspServer.RTSPSuspendMode",
"GstRtspServer.RTSPThreadPool",
"GstRtspServer.RTSPThreadType",
"GstRtspServer.RTSPTransportMode"
]
manual = [
"GLib.MainContext",
"GLib.IOCondition",
"GLib.Source",
"GLib.MainLoop",
"GLib.ThreadPool",
"GLib.Error",
"GObject.Object",
"Gio.TlsCertificateFlags",
"Gio.TlsCertificate",
"Gio.Socket",
"Gio.Cancellable",
"Gio.SocketFamily",
"Gst.Element",
"Gst.State",
"Gst.Clock",
"Gst.Pipeline",
"Gst.Pad",
"Gst.Bin",
"Gst.FlowReturn",
"GstRtsp.RTSPAuthMethod",
"GstRtsp.RTSPUrl",
"GstRtsp.RTSPResult",
"GstRtsp.RTSPStatusCode",
"GstRtsp.RTSPRangeUnit",
"GstRtsp.RTSPProfile",
"GstRtsp.RTSPLowerTrans"
]
[[object]]
name = "Gst.Message"
status = "manual"
ref_mode = "ref"
[[object]]
name = "Gst.Structure"
status = "manual"
ref_mode = "ref-mut"
[[object]]
name = "Gst.Buffer"
status = "manual"
ref_mode = "ref"
[[object]]
name = "Gst.Caps"
status = "manual"
ref_mode = "ref"
[[object]]
name = "Gst.ClockTime"
status = "manual"
conversion_type = "scalar"
[[object]]
name = "GstRtspServer.RTSPServer"
status = "generate"
[[object.function]]
name = "attach"
ignore = true
[[object]]
name = "GstRtspServer.RTSPClient"
status = "generate"
[[object.function]]
name = "attach"
ignore = true
[[object]]
name = "GstRtspServer.RTSPStream"
status = "generate"
[[object.function]]
name = "query_position"
ignore = true
[[object.function]]
name = "query_stop"
ignore = true
[[object.function]]
name = "add_transport"
[object.function.return]
bool_return_is_error = "Failed to add transport"
[[object.function]]
name = "remove_transport"
[object.function.return]
bool_return_is_error = "Failed to remove transport"
[[object.function]]
name = "join_bin"
[object.function.return]
bool_return_is_error = "Failed to join bin"
[[object.function]]
name = "leave_bin"
[object.function.return]
bool_return_is_error = "Failed to leave bin"
[[object]]
name = "GstRtspServer.RTSPAddress"
status = "generate"
concurrency = "send"
[[object]]
name = "GstRtspServer.RTSPStreamTransport"
status = "generate"
concurrency = "none"
[[object.function]]
name = "send_rtcp"
[object.function.return]
bool_return_is_error = "Failed to send rtcp"
[[object.function]]
name = "send_rtp"
[object.function.return]
bool_return_is_error = "Failed to send rtp"
[[object.function]]
name = "set_active"
[object.function.return]
bool_return_is_error = "Failed to set active"
[[object]]
name = "GstRtspServer.RTSPAddressPool"
status = "generate"
[[object.function]]
name = "add_range"
[object.function.return]
bool_return_is_error = "Failed to add address range"
[[object.function]]
name = "reserve_address"
ignore = true
[[object]]
name = "GstRtspServer.RTSPMedia"
status = "generate"
[[object.function]]
name = "suspend"
[object.function.return]
bool_return_is_error = "Failed to suspend media"
[[object.function]]
name = "unprepare"
[object.function.return]
bool_return_is_error = "Failed to unprepare media"
[[object.function]]
name = "unsuspend"
[object.function.return]
bool_return_is_error = "Failed to unsuspend media"
[[object]]
name = "GstRtspServer.RTSPSessionMedia"
status = "generate"
[[object.function]]
name = "set_state"
[object.function.return]
bool_return_is_error = "Failed to set state of session media"
[[object]]
name = "GstRtspServer.RTSPSessionPool"
status = "generate"
[[object.function]]
name = "remove"
[object.function.return]
bool_return_is_error = "Failed to remove session from pool"
[[object.function]]
name = "create_watch"
# GSource return
ignore = true
[[object]]
name="GstRtspServer.RTSPAuth"
status="generate"
[[object.function]]
name = "make_basic"
[object.function.return]
nullable = false
[options]
girs_dir = "gir-files"
library = "GstSdp"
version = "1.0"
min_cfg_version = "1.8"
target_path = "gstreamer-sdp"
work_mode = "normal"
concurrency = "send+sync"
generate_safety_asserts = true
doc_target_path = "docs/gstreamer-sdp/docs.md"
external_libraries = [
"GLib",
"GObject",
"Gst",
]
generate = [
"GstSdp.MIKEYCacheType",
"GstSdp.MIKEYEncAlg",
"GstSdp.MIKEYKVType",
"GstSdp.MIKEYKeyDataType",
"GstSdp.MIKEYMacAlg",
"GstSdp.MIKEYMapType",
"GstSdp.MIKEYPRFFunc",
"GstSdp.MIKEYPayloadType",
"GstSdp.MIKEYSecProto",
"GstSdp.MIKEYSecSRTP",
"GstSdp.MIKEYTSType",
"GstSdp.MIKEYType",
"GstSdp.SDPResult"
]
manual = [
]
[[object]]
name = "Gst.Caps"
status = "manual"
ref_mode = "ref"
This diff is collapsed.
<!-- file * -->
<!-- enum RTSPAuthMethod -->
Authentication methods, ordered by strength
<!-- enum RTSPAuthMethod::variant None -->
no authentication
<!-- enum RTSPAuthMethod::variant Basic -->
basic authentication
<!-- enum RTSPAuthMethod::variant Digest -->
digest authentication
<!-- struct RTSPAuthParam -->
<!-- enum RTSPFamily -->
The possible network families.
<!-- enum RTSPFamily::variant None -->
unknown network family
<!-- enum RTSPFamily::variant Inet -->
internet
<!-- enum RTSPFamily::variant Inet6 -->
internet V6
<!-- enum RTSPHeaderField -->
Enumeration of rtsp header fields
<!-- enum RTSPMsgType -->
The type of a message.
<!-- enum RTSPMsgType::variant Invalid -->
invalid message type
<!-- enum RTSPMsgType::variant Request -->
RTSP request message
<!-- enum RTSPMsgType::variant Response -->
RTSP response message
<!-- enum RTSPMsgType::variant HttpRequest -->
HTTP request message.
<!-- enum RTSPMsgType::variant HttpResponse -->
HTTP response message.
<!-- enum RTSPMsgType::variant Data -->
data message
<!-- enum RTSPRangeUnit -->
Different possible time range units.
<!-- enum RTSPRangeUnit::variant Smpte -->
SMPTE timecode
<!-- enum RTSPRangeUnit::variant Smpte30Drop -->
29.97 frames per second
<!-- enum RTSPRangeUnit::variant Smpte25 -->
25 frames per second
<!-- enum RTSPRangeUnit::variant Npt -->
Normal play time
<!-- enum RTSPRangeUnit::variant Clock -->
Absolute time expressed as ISO 8601 timestamps
<!-- enum RTSPResult -->
Result codes from the RTSP functions.
<!-- enum RTSPResult::variant Ok -->
no error
<!-- enum RTSPResult::variant Error -->
some unspecified error occured
<!-- enum RTSPResult::variant Einval -->
invalid arguments were provided to a function
<!-- enum RTSPResult::variant Eintr -->
an operation was canceled
<!-- enum RTSPResult::variant Enomem -->
no memory was available for the operation
<!-- enum RTSPResult::variant Eresolv -->
a host resolve error occured
<!-- enum RTSPResult::variant Enotimpl -->
function not implemented
<!-- enum RTSPResult::variant Esys -->
a system error occured, errno contains more details
<!-- enum RTSPResult::variant Eparse -->
a persing error occured
<!-- enum RTSPResult::variant Ewsastart -->
windows networking could not start
<!-- enum RTSPResult::variant Ewsaversion -->
windows networking stack has wrong version
<!-- enum RTSPResult::variant Eeof -->
end-of-file was reached
<!-- enum RTSPResult::variant Enet -->
a network problem occured, h_errno contains more details
<!-- enum RTSPResult::variant Enotip -->
the host is not an IP host
<!-- enum RTSPResult::variant Etimeout -->
a timeout occured
<!-- enum RTSPResult::variant Etget -->
the tunnel GET request has been performed
<!-- enum RTSPResult::variant Etpost -->
the tunnel POST request has been performed
<!-- enum RTSPResult::variant Elast -->
last error
<!-- enum RTSPState -->
The different RTSP states.
<!-- enum RTSPState::variant Invalid -->
invalid state
<!-- enum RTSPState::variant Init -->
initializing
<!-- enum RTSPState::variant Ready -->
ready for operation
<!-- enum RTSPState::variant Seeking -->
seeking in progress
<!-- enum RTSPState::variant Playing -->
playing
<!-- enum RTSPState::variant Recording -->
recording
<!-- enum RTSPStatusCode -->
Enumeration of rtsp status codes
<!-- enum RTSPTimeType -->
Possible time types.
<!-- enum RTSPTimeType::variant Seconds -->
seconds
<!-- enum RTSPTimeType::variant Now -->
now
<!-- enum RTSPTimeType::variant End -->
end
<!-- enum RTSPTimeType::variant Frames -->
frames and subframes
<!-- enum RTSPTimeType::variant Utc -->
UTC time
<!-- struct RTSPUrl -->
Provides helper functions to handle RTSP urls.
<!-- impl RTSPUrl::fn copy -->
Make a copy of `self`.
# Returns
a copy of `self`. Free with gst_rtsp_url_free () after usage.
<!-- impl RTSPUrl::fn decode_path_components -->
Splits the path of `self` on '/' boundaries, decoding the resulting components,
The decoding performed by this routine is "URI decoding", as defined in RFC
3986, commonly known as percent-decoding. For example, a string "foo\%2fbar"
will decode to "foo/bar" -- the \%2f being replaced by the corresponding byte
with hex value 0x2f. Note that there is no guarantee that the resulting byte
sequence is valid in any given encoding. As a special case, \%00 is not
unescaped to NUL, as that would prematurely terminate the string.
Also note that since paths usually start with a slash, the first component
will usually be the empty string.
# Returns
`None`-terminated array of URL components. Free with
`g_strfreev` when no longer needed.
<!-- impl RTSPUrl::fn free -->
Free the memory used by `self`.
<!-- impl RTSPUrl::fn get_port -->
Get the port number of `self`.
## `port`
location to hold the port
# Returns
`RTSPResult::Ok`.
<!-- impl RTSPUrl::fn get_request_uri -->
Get a newly allocated string describing the request URI for `self`.
# Returns
a string with the request URI. `g_free` after usage.
<!-- impl RTSPUrl::fn set_port -->
Set the port number in `self` to `port`.
## `port`
the port
# Returns
`RTSPResult::Ok`.
<!-- impl RTSPUrl::fn parse -->
Parse the RTSP `urlstr` into a newly allocated `RTSPUrl`. Free after usage
with `RTSPUrl::free`.
## `urlstr`
the url string to parse
## `url`
location to hold the result.
# Returns
a `RTSPResult`.
<!-- file * -->
<!-- enum MIKEYCacheType -->
The different cache types
<!-- enum MIKEYCacheType::variant None -->
The envelope key MUST NOT be cached
<!-- enum MIKEYCacheType::variant Always -->
The envelope key MUST be cached
<!-- enum MIKEYCacheType::variant ForCsb -->
The envelope key MUST be cached, but only
to be used for the specific CSB.
<!-- enum MIKEYEncAlg -->
The encryption algorithm used to encrypt the Encr data field
<!-- enum MIKEYEncAlg::variant Null -->
no encryption
<!-- enum MIKEYEncAlg::variant AesCm128 -->
AES-CM using a 128-bit key
<!-- enum MIKEYEncAlg::variant AesKw128 -->
AES Key Wrap using a 128-bit key
<!-- enum MIKEYKVType -->
The key validity type
<!-- enum MIKEYKVType::variant Null -->
No specific usage rule
<!-- enum MIKEYKVType::variant Spi -->
The key is associated with the SPI/MKI
<!-- enum MIKEYKVType::variant Interval -->
The key has a start and expiration time
<!-- enum MIKEYKeyDataType -->
The type of key.
<!-- enum MIKEYKeyDataType::variant Tgk -->
a TEK Generation Key
<!-- enum MIKEYKeyDataType::variant Tek -->
Traffic-Encrypting Key
<!-- enum MIKEYMacAlg -->
Specifies the authentication algorithm used
<!-- enum MIKEYMacAlg::variant Null -->
no authentication
<!-- enum MIKEYMacAlg::variant HmacSha1160 -->
HMAC-SHA-1-160
<!-- enum MIKEYMapType -->
Specifies the method of uniquely mapping Crypto Sessions to the security
protocol sessions.
<!-- enum MIKEYPRFFunc -->
The PRF function that has been/will be used for key derivation
<!-- enum MIKEYPRFFunc::variant MikeyPrfMikey1 -->
MIKEY-1 PRF function
<!-- enum MIKEYPayloadType -->
Different MIKEY Payload types.
<!-- enum MIKEYPayloadType::variant Last -->
Last payload
<!-- enum MIKEYPayloadType::variant Kemac -->
Key data transport payload
<!-- enum MIKEYPayloadType::variant Pke -->
Envelope data payload
<!-- enum MIKEYPayloadType::variant Dh -->
DH data payload
<!-- enum MIKEYPayloadType::variant Sign -->
Signature payload
<!-- enum MIKEYPayloadType::variant T -->
Timestamp payload
<!-- enum MIKEYPayloadType::variant Id -->
ID payload
<!-- enum MIKEYPayloadType::variant Cert -->
Certificate Payload
<!-- enum MIKEYPayloadType::variant Chash -->
Cert hash payload
<!-- enum MIKEYPayloadType::variant V -->
Verfication message payload
<!-- enum MIKEYPayloadType::variant Sp -->
Security Policy payload
<!-- enum MIKEYPayloadType::variant Rand -->
RAND payload
<!-- enum MIKEYPayloadType::variant Err -->
Error payload
<!-- enum MIKEYPayloadType::variant KeyData -->
Key data sub-payload
<!-- enum MIKEYPayloadType::variant GenExt -->
General Extension Payload
<!-- enum MIKEYSecProto -->
Specifies the security protocol
<!-- enum MIKEYSecSRTP -->
This policy specifies the parameters for SRTP and SRTCP
<!-- enum MIKEYSecSRTP::variant EncAlg -->
Encryption algorithm
<!-- enum MIKEYSecSRTP::variant EncKeyLen -->
Session Encr. key length
<!-- enum MIKEYSecSRTP::variant AuthAlg -->
Authentication algorithm
<!-- enum MIKEYSecSRTP::variant AuthKeyLen -->
Session Auth. key length
<!-- enum MIKEYSecSRTP::variant SaltKeyLen -->
Session Salt key length
<!-- enum MIKEYSecSRTP::variant Prf -->
SRTP Pseudo Random Function
<!-- enum MIKEYSecSRTP::variant KeyDerivRate -->
Key derivation rate
<!-- enum MIKEYSecSRTP::variant SrtpEnc -->
SRTP encryption off/on, 0 if off, 1 if on
<!-- enum MIKEYSecSRTP::variant SrtcpEnc -->
SRTCP encryption off/on, 0 if off, 1 if on
<!-- enum MIKEYSecSRTP::variant FecOrder -->
sender's FEC order
<!-- enum MIKEYSecSRTP::variant SrtpAuth -->
SRTP authentication off/on, 0 if off, 1 if on
<!-- enum MIKEYSecSRTP::variant AuthTagLen -->
Authentication tag length
<!-- enum MIKEYSecSRTP::variant SrtpPrefixLen -->
SRTP prefix length
<!-- enum MIKEYTSType -->
Specifies the timestamp type.
<!-- enum MIKEYTSType::variant NtpUtc -->
an NTP time in UTC timezone
<!-- enum MIKEYTSType::variant Ntp -->
an NTP time
<!-- enum MIKEYTSType::variant Counter -->
a counter
<!-- enum MIKEYType -->
Different MIKEY data types.
<!-- enum MIKEYType::variant Invalid -->
Invalid type
<!-- enum MIKEYType::variant PskInit -->
Initiator's pre-shared key message
<!-- enum MIKEYType::variant PskVerify -->
Verification message of a Pre-shared key message
<!-- enum MIKEYType::variant PkInit -->
Initiator's public-key transport message
<!-- enum MIKEYType::variant PkVerify -->
Verification message of a public-key message
<!-- enum MIKEYType::variant DhInit -->
Initiator's DH exchange message
<!-- enum MIKEYType::variant DhResp -->
Responder's DH exchange message
<!-- enum MIKEYType::variant Error -->
Error message
<!-- enum SDPResult -->
Return values for the SDP functions.
<!-- enum SDPResult::variant Ok -->
A successful return value
<!-- enum SDPResult::variant Einval -->
a function was given invalid parameters
......@@ -10,6 +10,7 @@ gstreamer-app = { path = "../gstreamer-app" }
gstreamer-audio = { path = "../gstreamer-audio" }
gstreamer-video = { path = "../gstreamer-video" }
gstreamer-player = { path = "../gstreamer-player", optional = true }
gstreamer-rtsp-server = { path = "../gstreamer-rtsp-server", optional = true }
gtk = { git = "https://github.com/gtk-rs/gtk", features = ["v3_6"], optional = true }
gdk = { git = "https://github.com/gtk-rs/gdk", optional = true }
gio = { git = "https://github.com/gtk-rs/gio", optional = true }
......@@ -27,6 +28,7 @@ gtkvideooverlay = ["gtk", "gdk", "gio"]
gtkvideooverlay-x11 = ["gtkvideooverlay"]
gtkvideooverlay-quartz = ["gtkvideooverlay"]
tokio = ["gstreamer/futures", "futures", "tokio-core"]
gst-rtsp-server = ["gstreamer-rtsp-server"]
default-features = []
v1_10 = ["gstreamer/v1_10"]
......
#[cfg(feature = "gst-rtsp-server")]
use std::env;
extern crate gstreamer as gst;
#[cfg(feature = "gst-rtsp-server")]
extern crate gstreamer_rtsp_server as gst_rtsp_server;
#[cfg(feature = "gst-rtsp-server")]
use gst_rtsp_server::prelude::*;
extern crate glib;
extern crate failure;
use failure::Error;
#[cfg(feature = "gst-rtsp-server")]
#[macro_use]
extern crate failure_derive;
#[path = "../examples-common.rs"]
mod examples_common;
#[derive(Debug, Fail)]
#[fail(display = "Could not get mount points")]
#[cfg(feature = "gst-rtsp-server")]
struct NoMountPoints;
#[derive(Debug, Fail)]
#[fail(display = "Usage: {} LAUNCH_LINE", _0)]
#[cfg(feature = "gst-rtsp-server")]
struct UsageError(String);
#[cfg(feature = "gst-rtsp-server")]
fn main_loop() -> Result<(), Error> {
let args: Vec<_> = env::args().collect();
if args.len() != 2 {
return Err(Error::from(UsageError(args[0].clone())));
}
let main_loop = glib::MainLoop::new(None, false);
let server = gst_rtsp_server::RTSPServer::new();
let factory = gst_rtsp_server::RTSPMediaFactory::new();
let mounts = server.get_mount_points().ok_or(NoMountPoints)?;
factory.set_launch(args[1].as_str());
factory.set_shared(true);
mounts.add_factory("/test", &factory);
server.attach(None);
println!("Stream ready at rtsp://127.0.0.1:{}/test", server.get_bound_port());
main_loop.run();
Ok(())
}
fn example_main() -> Result<(), Error> {
gst::init()?;
#[cfg(not(feature