mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-12-25 03:20:30 +00:00
Update to reqwest 0.9, rand 0.6 and parking_lot 0.7
This commit is contained in:
parent
f374d7fedf
commit
04955f61d7
5 changed files with 20 additions and 14 deletions
|
@ -10,7 +10,8 @@ url = "1.1"
|
||||||
glib = { git = "https://github.com/gtk-rs/glib" }
|
glib = { git = "https://github.com/gtk-rs/glib" }
|
||||||
gst-plugin = { path="../gst-plugin" }
|
gst-plugin = { path="../gst-plugin" }
|
||||||
gst-plugin-simple = { path="../gst-plugin-simple" }
|
gst-plugin-simple = { path="../gst-plugin-simple" }
|
||||||
reqwest = "0.8"
|
reqwest = "0.9"
|
||||||
|
hyperx = "0.13"
|
||||||
gstreamer = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
gstreamer = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
|
|
|
@ -6,8 +6,9 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use reqwest::header::{
|
use hyperx::header::{
|
||||||
AcceptRanges, ByteRangeSpec, ContentLength, ContentRange, ContentRangeSpec, Range, RangeUnit,
|
AcceptRanges, ByteRangeSpec, ContentLength, ContentRange, ContentRangeSpec, Headers, Range,
|
||||||
|
RangeUnit,
|
||||||
};
|
};
|
||||||
use reqwest::{Client, Response};
|
use reqwest::{Client, Response};
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
@ -68,18 +69,23 @@ impl HttpSrc {
|
||||||
stop: Option<u64>,
|
stop: Option<u64>,
|
||||||
) -> Result<StreamingState, gst::ErrorMessage> {
|
) -> Result<StreamingState, gst::ErrorMessage> {
|
||||||
let cat = self.cat;
|
let cat = self.cat;
|
||||||
let mut req = self.client.get(uri.clone());
|
let req = self.client.get(uri.clone());
|
||||||
|
|
||||||
|
let mut headers = Headers::new();
|
||||||
|
|
||||||
match (start != 0, stop) {
|
match (start != 0, stop) {
|
||||||
(false, None) => (),
|
(false, None) => (),
|
||||||
(true, None) => {
|
(true, None) => {
|
||||||
req.header(Range::Bytes(vec![ByteRangeSpec::AllFrom(start)]));
|
headers.set(Range::Bytes(vec![ByteRangeSpec::AllFrom(start)]));
|
||||||
}
|
}
|
||||||
(_, Some(stop)) => {
|
(_, Some(stop)) => {
|
||||||
req.header(Range::Bytes(vec![ByteRangeSpec::FromTo(start, stop - 1)]));
|
headers.set(Range::Bytes(vec![ByteRangeSpec::FromTo(start, stop - 1)]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add all headers for the request here
|
||||||
|
let req = req.headers(headers.into());
|
||||||
|
|
||||||
gst_debug!(cat, obj: src, "Doing new request {:?}", req);
|
gst_debug!(cat, obj: src, "Doing new request {:?}", req);
|
||||||
|
|
||||||
let response = try!(req.send().or_else(|err| {
|
let response = try!(req.send().or_else(|err| {
|
||||||
|
@ -98,12 +104,10 @@ impl HttpSrc {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let size = response
|
let headers = Headers::from(response.headers());
|
||||||
.headers()
|
let size = headers.get().map(|&ContentLength(cl)| cl + start);
|
||||||
.get()
|
|
||||||
.map(|&ContentLength(cl)| cl + start);
|
|
||||||
|
|
||||||
let accept_byte_ranges = if let Some(&AcceptRanges(ref ranges)) = response.headers().get() {
|
let accept_byte_ranges = if let Some(&AcceptRanges(ref ranges)) = headers.get() {
|
||||||
ranges.iter().any(|u| *u == RangeUnit::Bytes)
|
ranges.iter().any(|u| *u == RangeUnit::Bytes)
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
@ -114,7 +118,7 @@ impl HttpSrc {
|
||||||
let position = if let Some(&ContentRange(ContentRangeSpec::Bytes {
|
let position = if let Some(&ContentRange(ContentRangeSpec::Bytes {
|
||||||
range: Some((range_start, _)),
|
range: Some((range_start, _)),
|
||||||
..
|
..
|
||||||
})) = response.headers().get()
|
})) = headers.get()
|
||||||
{
|
{
|
||||||
range_start
|
range_start
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -14,6 +14,7 @@ extern crate gst_plugin;
|
||||||
extern crate gst_plugin_simple;
|
extern crate gst_plugin_simple;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate gstreamer as gst;
|
extern crate gstreamer as gst;
|
||||||
|
extern crate hyperx;
|
||||||
extern crate reqwest;
|
extern crate reqwest;
|
||||||
extern crate url;
|
extern crate url;
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ tokio-current-thread = "0.1"
|
||||||
futures = "0.1"
|
futures = "0.1"
|
||||||
lazy_static = "1.0"
|
lazy_static = "1.0"
|
||||||
either = "1.0"
|
either = "1.0"
|
||||||
rand = "0.5"
|
rand = "0.6"
|
||||||
net2 = "0.2"
|
net2 = "0.2"
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
|
|
|
@ -10,7 +10,7 @@ gstreamer = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", fea
|
||||||
gstreamer-video = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
gstreamer-video = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
||||||
gtk = { git = "https://github.com/gtk-rs/gtk", features = ["v3_6"], optional = true }
|
gtk = { git = "https://github.com/gtk-rs/gtk", features = ["v3_6"], optional = true }
|
||||||
gio = { git = "https://github.com/gtk-rs/gio", optional = true }
|
gio = { git = "https://github.com/gtk-rs/gio", optional = true }
|
||||||
parking_lot = "0.6"
|
parking_lot = "0.7"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
either = "1.0"
|
either = "1.0"
|
||||||
|
|
Loading…
Reference in a new issue