mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-12-20 17:16:39 +00:00
Improve readability of the code a little
This commit is contained in:
parent
eac466040e
commit
1751b5c400
3 changed files with 16 additions and 26 deletions
|
@ -115,20 +115,18 @@ impl Adapter {
|
||||||
return Ok(Buffer::new());
|
return Ok(Buffer::new());
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(sub) = {
|
let sub = self.deque.front().and_then(|front| {
|
||||||
if let Some(front) = self.deque.front() {
|
if front.get_size() - self.skip >= size {
|
||||||
if front.get_size() - self.skip >= size {
|
let new = front.get_buffer().copy_region(self.skip, Some(size)).unwrap();
|
||||||
let new = front.get_buffer().copy_region(self.skip, Some(size)).unwrap();
|
Some(new)
|
||||||
Some(new)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
} {
|
});
|
||||||
|
|
||||||
|
if let Some(s) = sub {
|
||||||
self.flush(size).unwrap();
|
self.flush(size).unwrap();
|
||||||
return Ok(sub);
|
return Ok(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut new = Buffer::new_with_size(size).unwrap();
|
let mut new = Buffer::new_with_size(size).unwrap();
|
||||||
|
|
|
@ -65,13 +65,12 @@ impl HttpSrc {
|
||||||
-> Result<StreamingState, ErrorMessage> {
|
-> Result<StreamingState, ErrorMessage> {
|
||||||
let mut req = self.client.get(uri.clone());
|
let mut req = self.client.get(uri.clone());
|
||||||
|
|
||||||
if start != 0 || stop.is_some() {
|
match (start != 0, stop) {
|
||||||
req = match stop {
|
(false, None) => (),
|
||||||
None => req.header(Range::Bytes(vec![ByteRangeSpec::AllFrom(start)])),
|
(true, None) => req = req.header(Range::Bytes(vec![ByteRangeSpec::AllFrom(start)])),
|
||||||
Some(stop) => {
|
(_, Some(stop)) => {
|
||||||
req.header(Range::Bytes(vec![ByteRangeSpec::FromTo(start, stop - 1)]))
|
req = req.header(Range::Bytes(vec![ByteRangeSpec::FromTo(start, stop - 1)]))
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let response = try!(req.send().or_else(|err| {
|
let response = try!(req.send().or_else(|err| {
|
||||||
|
@ -84,11 +83,7 @@ impl HttpSrc {
|
||||||
["Failed to fetch {}: {}", uri, response.status()]));
|
["Failed to fetch {}: {}", uri, response.status()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
let size = if let Some(&ContentLength(content_length)) = response.headers().get() {
|
let size = response.headers().get().map(|&ContentLength(cl)| cl + start);
|
||||||
Some(content_length + start)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
let accept_byte_ranges = if let Some(&AcceptRanges(ref ranges)) = response.headers()
|
let accept_byte_ranges = if let Some(&AcceptRanges(ref ranges)) = response.headers()
|
||||||
.get() {
|
.get() {
|
||||||
|
|
|
@ -122,10 +122,7 @@ impl SourceWrapper {
|
||||||
|
|
||||||
fn get_size(&self) -> u64 {
|
fn get_size(&self) -> u64 {
|
||||||
let source = &self.source.lock().unwrap();
|
let source = &self.source.lock().unwrap();
|
||||||
match source.get_size() {
|
source.get_size().unwrap_or(u64::MAX)
|
||||||
Some(size) => size,
|
|
||||||
None => u64::MAX,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn start(&self) -> bool {
|
fn start(&self) -> bool {
|
||||||
|
|
Loading…
Reference in a new issue