mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-01-12 15:33:22 -05:00
API change: cameraConfigs should include rtsp urls
This commit is contained in:
parent
840524ec83
commit
42a6f4d091
@ -53,9 +53,10 @@ request parameters:
|
||||
|
||||
* `days`: a boolean indicating if the days parameter described below
|
||||
should be included.
|
||||
* `cameraConfigs`: a boolean indicating if the `camera.config` parameter
|
||||
described below should be included. This requires the
|
||||
`read_camera_configs` permission as described in `schema.proto`.
|
||||
* `cameraConfigs`: a boolean indicating if the `camera.config` and
|
||||
`camera.stream[].config` parameters described below should be included.
|
||||
This requires the `read_camera_configs` permission as described in
|
||||
`schema.proto`.
|
||||
|
||||
Example request URI (with added whitespace between parameters):
|
||||
|
||||
@ -104,6 +105,9 @@ The `application/json` response will have a dict as follows:
|
||||
time zone. It is usually 24 hours after the start time. It
|
||||
might be 23 hours or 25 hours during spring forward or fall
|
||||
back, respectively.
|
||||
* `config`: (only included if request parameter `cameraConfigs` is
|
||||
true) a dictionary describing the configuration of the stream:
|
||||
* `rtsp_url`
|
||||
* `signals`: a list of all signals known to the server. Each is a dictionary
|
||||
with the following properties:
|
||||
* `id`: an integer identifier.
|
||||
|
22
src/json.rs
22
src/json.rs
@ -110,6 +110,15 @@ pub struct Stream<'a> {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[serde(serialize_with = "Stream::serialize_days")]
|
||||
pub days: Option<&'a BTreeMap<db::StreamDayKey, db::StreamDayValue>>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub config: Option<StreamConfig<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all="camelCase")]
|
||||
pub struct StreamConfig<'a> {
|
||||
pub rtsp_url: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
@ -203,8 +212,8 @@ impl<'a> Camera<'a> {
|
||||
}),
|
||||
},
|
||||
streams: [
|
||||
Stream::wrap(db, c.streams[0], include_days)?,
|
||||
Stream::wrap(db, c.streams[1], include_days)?,
|
||||
Stream::wrap(db, c.streams[0], include_days, include_config)?,
|
||||
Stream::wrap(db, c.streams[1], include_days, include_config)?,
|
||||
],
|
||||
})
|
||||
}
|
||||
@ -223,7 +232,8 @@ impl<'a> Camera<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Stream<'a> {
|
||||
fn wrap(db: &'a db::LockedDatabase, id: Option<i32>, include_days: bool) -> Result<Option<Self>, Error> {
|
||||
fn wrap(db: &'a db::LockedDatabase, id: Option<i32>, include_days: bool, include_config: bool)
|
||||
-> Result<Option<Self>, Error> {
|
||||
let id = match id {
|
||||
Some(id) => id,
|
||||
None => return Ok(None),
|
||||
@ -236,6 +246,12 @@ impl<'a> Stream<'a> {
|
||||
total_duration_90k: s.duration.0,
|
||||
total_sample_file_bytes: s.sample_file_bytes,
|
||||
days: if include_days { Some(&s.days) } else { None },
|
||||
config: match include_config {
|
||||
false => None,
|
||||
true => Some(StreamConfig {
|
||||
rtsp_url: &s.rtsp_url,
|
||||
}),
|
||||
},
|
||||
}))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user