setup should take a SetupOptions
This commit is contained in:
parent
7879414ff8
commit
1bbaf29dc9
@ -3,6 +3,8 @@
|
|||||||
* BREAKING: remove deprecated `retina::client::Session<Playing>::teardown` and
|
* BREAKING: remove deprecated `retina::client::Session<Playing>::teardown` and
|
||||||
`retina::client::Demuxed::teardown`; made private some items already
|
`retina::client::Demuxed::teardown`; made private some items already
|
||||||
`#[doc(hidden)]`.
|
`#[doc(hidden)]`.
|
||||||
|
* BREAKING: `retina::client::Session<Described>::setup` takes a new
|
||||||
|
`SetupOptions` argument for future expansion.
|
||||||
|
|
||||||
## `v0.3.9` (2022-04-12)
|
## `v0.3.9` (2022-04-12)
|
||||||
|
|
||||||
|
@ -8,7 +8,10 @@ use std::{io::ErrorKind, net::SocketAddr, num::NonZeroU32};
|
|||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use criterion::{criterion_group, criterion_main, Criterion, Throughput};
|
use criterion::{criterion_group, criterion_main, Criterion, Throughput};
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use retina::{client::PlayOptions, codec::CodecItem};
|
use retina::{
|
||||||
|
client::{PlayOptions, SetupOptions},
|
||||||
|
codec::CodecItem,
|
||||||
|
};
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use tokio::io::AsyncWriteExt;
|
use tokio::io::AsyncWriteExt;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
@ -111,7 +114,7 @@ async fn read_to_eof(addr: SocketAddr) {
|
|||||||
retina::client::Session::describe(url, retina::client::SessionOptions::default())
|
retina::client::Session::describe(url, retina::client::SessionOptions::default())
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
session.setup(0).await.unwrap();
|
session.setup(0, SetupOptions::default()).await.unwrap();
|
||||||
let session = session
|
let session = session
|
||||||
.play(PlayOptions::default())
|
.play(PlayOptions::default())
|
||||||
.await
|
.await
|
||||||
|
@ -22,7 +22,7 @@ use bytes::{Buf, BufMut, BytesMut};
|
|||||||
use futures::{Future, StreamExt};
|
use futures::{Future, StreamExt};
|
||||||
use log::{debug, info, warn};
|
use log::{debug, info, warn};
|
||||||
use retina::{
|
use retina::{
|
||||||
client::Transport,
|
client::{SetupOptions, Transport},
|
||||||
codec::{AudioParameters, CodecItem, Parameters, VideoParameters},
|
codec::{AudioParameters, CodecItem, Parameters, VideoParameters},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -766,7 +766,7 @@ pub async fn run(opts: Opts) -> Result<(), Error> {
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
if let Some(i) = video_stream_i {
|
if let Some(i) = video_stream_i {
|
||||||
session.setup(i).await?;
|
session.setup(i, SetupOptions::default()).await?;
|
||||||
}
|
}
|
||||||
let audio_stream = if !opts.no_audio {
|
let audio_stream = if !opts.no_audio {
|
||||||
let s = session
|
let s = session
|
||||||
@ -795,7 +795,7 @@ pub async fn run(opts: Opts) -> Result<(), Error> {
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
if let Some((i, _)) = audio_stream {
|
if let Some((i, _)) = audio_stream {
|
||||||
session.setup(i).await?;
|
session.setup(i, SetupOptions::default()).await?;
|
||||||
}
|
}
|
||||||
if video_stream_i.is_none() && audio_stream.is_none() {
|
if video_stream_i.is_none() && audio_stream.is_none() {
|
||||||
bail!("Exiting because no video or audio stream was selected; see info log messages above");
|
bail!("Exiting because no video or audio stream was selected; see info log messages above");
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
use anyhow::{anyhow, Error};
|
use anyhow::{anyhow, Error};
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
use retina::client::SessionGroup;
|
use retina::client::{SessionGroup, SetupOptions};
|
||||||
use retina::codec::CodecItem;
|
use retina::codec::CodecItem;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
@ -40,7 +40,9 @@ async fn run_inner(opts: Opts, session_group: Arc<SessionGroup>) -> Result<(), E
|
|||||||
.iter()
|
.iter()
|
||||||
.position(|s| matches!(s.parameters(), Some(retina::codec::Parameters::Message(..))))
|
.position(|s| matches!(s.parameters(), Some(retina::codec::Parameters::Message(..))))
|
||||||
.ok_or_else(|| anyhow!("couldn't find onvif stream"))?;
|
.ok_or_else(|| anyhow!("couldn't find onvif stream"))?;
|
||||||
session.setup(onvif_stream_i).await?;
|
session
|
||||||
|
.setup(onvif_stream_i, SetupOptions::default())
|
||||||
|
.await?;
|
||||||
let mut session = session
|
let mut session = session
|
||||||
.play(retina::client::PlayOptions::default().ignore_zero_seq(true))
|
.play(retina::client::PlayOptions::default().ignore_zero_seq(true))
|
||||||
.await?
|
.await?
|
||||||
|
@ -562,6 +562,14 @@ impl SessionOptions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Per-stream options decided for `SETUP` time, for future expansion.
|
||||||
|
///
|
||||||
|
/// There's nothing here yet. Likely in the future this will allow configuring
|
||||||
|
/// the output format for H.264 (Annex B or not).
|
||||||
|
#[derive(Default)]
|
||||||
|
#[non_exhaustive]
|
||||||
|
pub struct SetupOptions {}
|
||||||
|
|
||||||
/// Options which must be decided at `PLAY` time.
|
/// Options which must be decided at `PLAY` time.
|
||||||
///
|
///
|
||||||
/// These are mostly adjustments for non-compliant server implementations.
|
/// These are mostly adjustments for non-compliant server implementations.
|
||||||
@ -1296,7 +1304,8 @@ impl Session<Described> {
|
|||||||
/// inspect that first.
|
/// inspect that first.
|
||||||
///
|
///
|
||||||
/// Panics if `stream_i >= self.streams().len()`.
|
/// Panics if `stream_i >= self.streams().len()`.
|
||||||
pub async fn setup(&mut self, stream_i: usize) -> Result<(), Error> {
|
pub async fn setup(&mut self, stream_i: usize, options: SetupOptions) -> Result<(), Error> {
|
||||||
|
let _ = options; // not yet used.
|
||||||
let inner = &mut self.0.as_mut().project();
|
let inner = &mut self.0.as_mut().project();
|
||||||
let presentation = &mut inner.presentation;
|
let presentation = &mut inner.presentation;
|
||||||
let options = &inner.options;
|
let options = &inner.options;
|
||||||
@ -1313,8 +1322,8 @@ impl Session<Described> {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap_or(&presentation.control)
|
.unwrap_or(&presentation.control)
|
||||||
.clone();
|
.clone();
|
||||||
let mut req = rtsp_types::Request::builder(Method::Setup, rtsp_types::Version::V1_0)
|
let mut req =
|
||||||
.request_uri(url);
|
rtsp_types::Request::builder(Method::Setup, rtsp_types::Version::V1_0).request_uri(url);
|
||||||
match options.transport {
|
match options.transport {
|
||||||
Transport::Tcp => {
|
Transport::Tcp => {
|
||||||
let proposed_channel_id = conn.channels.next_unassigned().ok_or_else(|| {
|
let proposed_channel_id = conn.channels.next_unassigned().ok_or_else(|| {
|
||||||
@ -2402,7 +2411,7 @@ mod tests {
|
|||||||
// SETUP.
|
// SETUP.
|
||||||
tokio::join!(
|
tokio::join!(
|
||||||
async {
|
async {
|
||||||
session.setup(0).await.unwrap();
|
session.setup(0, SetupOptions::default()).await.unwrap();
|
||||||
},
|
},
|
||||||
req_response(
|
req_response(
|
||||||
&mut server,
|
&mut server,
|
||||||
@ -2512,7 +2521,7 @@ mod tests {
|
|||||||
// SETUP.
|
// SETUP.
|
||||||
tokio::join!(
|
tokio::join!(
|
||||||
async {
|
async {
|
||||||
session.setup(0).await.unwrap();
|
session.setup(0, SetupOptions::default()).await.unwrap();
|
||||||
},
|
},
|
||||||
req_response(
|
req_response(
|
||||||
&mut server,
|
&mut server,
|
||||||
@ -2664,7 +2673,7 @@ mod tests {
|
|||||||
// SETUP.
|
// SETUP.
|
||||||
tokio::join!(
|
tokio::join!(
|
||||||
async {
|
async {
|
||||||
session.setup(0).await.unwrap();
|
session.setup(0, SetupOptions::default()).await.unwrap();
|
||||||
},
|
},
|
||||||
req_response(
|
req_response(
|
||||||
&mut server,
|
&mut server,
|
||||||
|
Loading…
Reference in New Issue
Block a user