-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API and example for printing a session's SDP
This is useful for debugging.
- Loading branch information
Showing
5 changed files
with
74 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (C) 2022 Scott Lamb <[email protected]> | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
|
||
//! Gets info about available streams and exits. | ||
use anyhow::Error; | ||
|
||
#[derive(structopt::StructOpt)] | ||
pub struct Opts { | ||
#[structopt(flatten)] | ||
src: super::Source, | ||
|
||
/// Prints the SDP (Session Description Protocol) session description. | ||
#[structopt(long)] | ||
print_sdp: bool, | ||
|
||
/// Prints debug output for each decoded stream. | ||
#[structopt(long)] | ||
print_streams: bool, | ||
} | ||
|
||
pub async fn run(opts: Opts) -> Result<(), Error> { | ||
let creds = super::creds(opts.src.username.clone(), opts.src.password.clone()); | ||
let session = retina::client::Session::describe( | ||
opts.src.url.clone(), | ||
retina::client::SessionOptions::default() | ||
.creds(creds) | ||
.user_agent("Retina sdp example".to_owned()), | ||
) | ||
.await?; | ||
if opts.print_sdp { | ||
println!("SDP:\n{}\n\n", std::str::from_utf8(session.sdp())?); | ||
} | ||
if opts.print_streams { | ||
for (i, stream) in session.streams().iter().enumerate() { | ||
println!("stream {}:\n{:#?}\n\n", i, stream); | ||
} | ||
} | ||
if !opts.print_sdp && !opts.print_streams { | ||
eprintln!("You probably wanted at least one of --print-sdp or --print-streams?"); | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters