Struct librice::stream::Stream

source ·
pub struct Stream { /* private fields */ }

Implementations§

Add a Component to this stream.

Examples

Add a Component

let agent = Agent::default();
let stream = agent.add_stream();
let component = stream.add_component().unwrap();
assert_eq!(component.id, component::RTP);

Remove a Component from this stream. If the index doesn’t exist or a component is not available at that index, an error is returned

Examples

Remove a Component

let agent = Agent::default();
let stream = agent.add_stream();
let component = stream.add_component().unwrap();
assert_eq!(component.id, component::RTP);
assert!(stream.remove_component(component::RTP).is_ok());

Removing a Component that was never added will return an error

let agent = Agent::default();
let stream = agent.add_stream();
assert!(matches!(stream.remove_component(component::RTP), Err(AgentError::ResourceNotFound)));

Retrieve a Component from this stream. If the index doesn’t exist or a component is not available at that index, an error is returned

Examples

Remove a Component

let agent = Agent::default();
let stream = agent.add_stream();
let component = stream.add_component().unwrap();
assert_eq!(component.id, component::RTP);
assert!(stream.component(component::RTP).is_some());

Retrieving a Component that doesn’t exist will return None

let agent = Agent::default();
let stream = agent.add_stream();
assert!(stream.component(component::RTP).is_none());

Set local ICE credentials for this Stream.

Examples
let agent = Agent::default();
let stream = agent.add_stream();
let credentials = Credentials {ufrag: "1".to_owned(), passwd: "2".to_owned()};
stream.set_local_credentials(credentials);

Retreive the previouly set local ICE credentials for this Stream.

Examples
let agent = Agent::default();
let stream = agent.add_stream();
let credentials = Credentials {ufrag: "1".to_owned(), passwd: "2".to_owned()};
stream.set_local_credentials(credentials.clone());
assert_eq!(stream.local_credentials(), Some(credentials));

Set remote ICE credentials for this Stream.

Examples
let agent = Agent::default();
let stream = agent.add_stream();
let credentials = Credentials {ufrag: "1".to_owned(), passwd: "2".to_owned()};
stream.set_remote_credentials(credentials);

Retreive the previouly set remote ICE credentials for this Stream.

Examples
let agent = Agent::default();
let stream = agent.add_stream();
let credentials = Credentials {ufrag: "1".to_owned(), passwd: "2".to_owned()};
stream.set_remote_credentials(credentials.clone());
assert_eq!(stream.remote_credentials(), Some(credentials));

Add a remote candidate for connection checks for use with this stream

Examples
let agent = Agent::default();
let stream = agent.add_stream();
let component = stream.add_component().unwrap();
let addr = "127.0.0.1:9999".parse().unwrap();
let candidate = Candidate::builder(
    0,
    CandidateType::Host,
    TransportType::Udp,
    "0",
    addr
)
.build();
stream.add_remote_candidate(component.id, candidate).unwrap();

Start gathering local candidates. Credentials must have been set before this function can be called.

Examples
let agent = Agent::default();
let stream = agent.add_stream();
let local_credentials = Credentials {ufrag: "luser".to_owned(), passwd: "lpass".to_owned()};
stream.set_local_credentials(local_credentials);
let remote_credentials = Credentials {ufrag: "ruser".to_owned(), passwd: "rpass".to_owned()};
stream.set_remote_credentials(remote_credentials);
let component = stream.add_component().unwrap();
task::block_on(async move {
    stream.gather_candidates().await.unwrap();
});

Retrieve previously gathered local candidates

Examples
let agent = Agent::default();
let stream = agent.add_stream();
let local_credentials = Credentials {ufrag: "luser".to_owned(), passwd: "lpass".to_owned()};
stream.set_local_credentials(local_credentials);
let remote_credentials = Credentials {ufrag: "ruser".to_owned(), passwd: "rpass".to_owned()};
stream.set_remote_credentials(remote_credentials);
let component = stream.add_component().unwrap();
task::block_on(async move {
    stream.gather_candidates().await.unwrap();
    let local_candidates = stream.local_candidates();
});

Retrieve previously set remote candidates for connection checks from this stream

Examples
let agent = Agent::default();
let stream = agent.add_stream();
let component = stream.add_component().unwrap();
let addr = "127.0.0.1:9999".parse().unwrap();
let candidate = Candidate::builder(
    0,
    CandidateType::Host,
    TransportType::Udp,
    "0",
    addr
)
.build();
stream.add_remote_candidate(component.id, candidate.clone()).unwrap();
let remote_cands = stream.remote_candidates();
assert_eq!(remote_cands.len(), 1);
assert_eq!(remote_cands[0], candidate);

Trait Implementations§

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more