Remove stub impl of ContentDirectoryBrowseProvider
This commit is contained in:
parent
0cb34d9bf1
commit
f96a9024e1
2 changed files with 22 additions and 14 deletions
|
|
@ -6,12 +6,28 @@ use std::{
|
|||
use anyhow::Context;
|
||||
use axum::routing::get;
|
||||
use librqbit_upnp_serve::{
|
||||
services::content_directory::browse::response::{Item, ItemOrContainer},
|
||||
services::content_directory::{
|
||||
browse::response::{Item, ItemOrContainer},
|
||||
ContentDirectoryBrowseProvider,
|
||||
},
|
||||
UpnpServer, UpnpServerOptions,
|
||||
};
|
||||
use mime_guess::Mime;
|
||||
use tracing::{error, info};
|
||||
|
||||
struct VecWrap(Vec<ItemOrContainer>);
|
||||
|
||||
impl ContentDirectoryBrowseProvider for VecWrap {
|
||||
fn browse_direct_children(&self, _parent_id: usize, _http_host: &str) -> Vec<ItemOrContainer> {
|
||||
self.0.clone()
|
||||
}
|
||||
|
||||
fn browse_metadata(&self, _object_id: usize, _http_hostname: &str) -> Vec<ItemOrContainer> {
|
||||
// TODO. Remove the vec provider from core code.
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
if std::env::var("RUST_LOG").is_err() {
|
||||
|
|
@ -20,14 +36,14 @@ async fn main() -> anyhow::Result<()> {
|
|||
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
let items: Vec<ItemOrContainer> = vec![ItemOrContainer::Item(Item {
|
||||
let items = VecWrap(vec![ItemOrContainer::Item(Item {
|
||||
title: "Example".to_owned(),
|
||||
mime_type: Some(Mime::from_str("video/x-matroska")?),
|
||||
url: "http://192.168.0.165:3030/torrents/4/stream/0/file.mkv".to_owned(),
|
||||
id: 1,
|
||||
parent_id: 0,
|
||||
size: 1,
|
||||
})];
|
||||
})]);
|
||||
|
||||
const HTTP_PORT: u16 = 9005;
|
||||
const HTTP_PREFIX: &str = "/upnp";
|
||||
|
|
|
|||
|
|
@ -147,6 +147,9 @@ pub mod browse {
|
|||
</DIDL-Lite>"#,
|
||||
items = envelope.items
|
||||
);
|
||||
|
||||
// This COULD have been done with CDATA, but some Samsung TVs don't like that, they want
|
||||
// escaped XML instead.
|
||||
let items_encoded = quick_xml::escape::escape(items_encoded.as_ref());
|
||||
|
||||
format!(
|
||||
|
|
@ -339,17 +342,6 @@ pub trait ContentDirectoryBrowseProvider: Send + Sync {
|
|||
fn browse_metadata(&self, object_id: usize, http_hostname: &str) -> Vec<ItemOrContainer>;
|
||||
}
|
||||
|
||||
impl ContentDirectoryBrowseProvider for Vec<ItemOrContainer> {
|
||||
fn browse_direct_children(&self, _parent_id: usize, _http_host: &str) -> Vec<ItemOrContainer> {
|
||||
self.clone()
|
||||
}
|
||||
|
||||
fn browse_metadata(&self, _object_id: usize, _http_hostname: &str) -> Vec<ItemOrContainer> {
|
||||
// TODO. Remove the vec provider from core code.
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue