#[non_exhaustive]pub struct RtmpTarget {
pub host: Host<String>,
pub port: u16,
pub tls: bool,
pub app: String,
pub stream_key: String,
/* private fields */
}target only.Expand description
A parsed RTMP publish target.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.host: Host<String>Host, never a pre-formatted string. rtmp is a non-special URL scheme, so
the url crate reports an IPv4 literal as Host::Domain("127.0.0.1")
(resolve handles it, lookup_host accepts literals); only a bracketed IPv6
literal becomes Host::Ipv6.
port: u16TCP port; 1935 (rtmp) or 443 (rtmps) when the URL has none.
tls: boolWhether the scheme is rtmps: the connection must run over TLS, which
the caller supplies (the tokio adapter’s AsyncRtmpClient::connect
opens plain TCP and refuses a TLS target).
app: StringThe RTMP app, percent-decoded (RFC 3986 §2.1).
stream_key: StringThe path remainder, percent-decoded (RFC 3986 §2.1), plus ?query kept
as written: the query is an opaque string the origin parses itself.
Implementations§
Source§impl RtmpTarget
impl RtmpTarget
Sourcepub fn parse(url: &str) -> Result<Self, RtmpUrlError>
pub fn parse(url: &str) -> Result<Self, RtmpUrlError>
Parses rtmp[s]://host[:port]/app/stream-key[?query] by the
nginx-rtmp convention, shared by publish and play: the first path
segment is the app, and every later segment is part of the stream key.
Non-empty segments are percent-decoded individually (RFC 3986 §2.1:
b%20c names b c), joined with /, and the query is appended as
written. Empty segments and a trailing slash are ignored, so
rtmp://h/app/inst/key names app app and key inst/key, and
rtmp://h/live/a/b%20c?token=x names app live and key
a/b c?token=x. A path of one segment names only an app.
Sourcepub fn parse_app(url: &str) -> Result<String, RtmpUrlError>
pub fn parse_app(url: &str) -> Result<String, RtmpUrlError>
The app a URL names, without requiring a stream key: used by a caller that can publish with a configured default key.
Sourcepub fn parse_or_default(
url: &str,
app: &str,
stream_key: &str,
) -> Result<Self, RtmpUrlError>
pub fn parse_or_default( url: &str, app: &str, stream_key: &str, ) -> Result<Self, RtmpUrlError>
Parse a URL, substituting a caller’s app when it names none and
stream_key when it names no key. Other errors are returned unchanged
so the caller can report or skip the output.
Sourcepub fn from_parts(
base: &str,
app: &str,
stream_key: &str,
) -> Result<Self, RtmpUrlError>
pub fn from_parts( base: &str, app: &str, stream_key: &str, ) -> Result<Self, RtmpUrlError>
Host and port from base (any path/query is ignored), app and
stream_key given separately.
Sourcepub fn tc_url(&self) -> &str
pub fn tc_url(&self) -> &str
The RTMP tcUrl to send in the connect command:
rtmp[s]://host[:port]/app, IPv6 bracketed, userinfo/query/fragment
removed. Derived from host/port/tls/app, so it can never
disagree with them.
Sourcepub async fn resolve(&self) -> Result<Vec<SocketAddr>>
Available on crate feature tokio only.
pub async fn resolve(&self) -> Result<Vec<SocketAddr>>
tokio only.Resolved socket addresses (DNS only for Host::Domain).
Trait Implementations§
Source§impl Clone for RtmpTarget
impl Clone for RtmpTarget
Source§impl Debug for RtmpTarget
Manual Debug: the stream key (path remainder plus query) is the publish
secret and never renders (issue #1142).
impl Debug for RtmpTarget
Manual Debug: the stream key (path remainder plus query) is the publish
secret and never renders (issue #1142).