mirror of
https://github.com/sile/hls_m3u8.git
synced 2025-01-10 20:25:25 +00:00
Switch to 2018-edition
This commit is contained in:
parent
625d037b27
commit
02d7c80b2b
13 changed files with 52 additions and 64 deletions
|
@ -8,6 +8,7 @@ repository = "https://github.com/sile/hls_m3u8"
|
|||
readme = "README.md"
|
||||
license = "MIT"
|
||||
keywords = ["hls", "m3u8"]
|
||||
edition = "2018"
|
||||
|
||||
[badges]
|
||||
travis-ci = {repository = "sile/hls_m3u8"}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
use crate::{ErrorKind, Result};
|
||||
use std::collections::HashSet;
|
||||
use std::str;
|
||||
|
||||
use {ErrorKind, Result};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct AttributePairs<'a> {
|
||||
input: &'a str,
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
use crate::tags;
|
||||
use crate::types::SingleLineString;
|
||||
use crate::{Error, ErrorKind, Result};
|
||||
use std::fmt;
|
||||
use std::str::FromStr;
|
||||
|
||||
use tags;
|
||||
use types::SingleLineString;
|
||||
use {Error, ErrorKind, Result};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Lines<'a> {
|
||||
input: &'a str,
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
use crate::line::{Line, Lines, Tag};
|
||||
use crate::tags::{
|
||||
ExtM3u, ExtXIFrameStreamInf, ExtXIndependentSegments, ExtXMedia, ExtXSessionData,
|
||||
ExtXSessionKey, ExtXStart, ExtXStreamInf, ExtXVersion, MasterPlaylistTag,
|
||||
};
|
||||
use crate::types::{ClosedCaptions, MediaType, ProtocolVersion, QuotedString};
|
||||
use crate::{Error, ErrorKind, Result};
|
||||
use std::collections::HashSet;
|
||||
use std::fmt;
|
||||
use std::iter;
|
||||
use std::str::FromStr;
|
||||
|
||||
use line::{Line, Lines, Tag};
|
||||
use tags::{
|
||||
ExtM3u, ExtXIFrameStreamInf, ExtXIndependentSegments, ExtXMedia, ExtXSessionData,
|
||||
ExtXSessionKey, ExtXStart, ExtXStreamInf, ExtXVersion, MasterPlaylistTag,
|
||||
};
|
||||
use types::{ClosedCaptions, MediaType, ProtocolVersion, QuotedString};
|
||||
use {Error, ErrorKind, Result};
|
||||
|
||||
/// Master playlist builder.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct MasterPlaylistBuilder {
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
use std::fmt;
|
||||
use std::iter;
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
|
||||
use line::{Line, Lines, Tag};
|
||||
use media_segment::{MediaSegment, MediaSegmentBuilder};
|
||||
use tags::{
|
||||
use crate::line::{Line, Lines, Tag};
|
||||
use crate::media_segment::{MediaSegment, MediaSegmentBuilder};
|
||||
use crate::tags::{
|
||||
ExtM3u, ExtXDiscontinuitySequence, ExtXEndList, ExtXIFramesOnly, ExtXIndependentSegments,
|
||||
ExtXMediaSequence, ExtXPlaylistType, ExtXStart, ExtXTargetDuration, ExtXVersion,
|
||||
MediaPlaylistTag,
|
||||
};
|
||||
use types::ProtocolVersion;
|
||||
use {Error, ErrorKind, Result};
|
||||
use crate::types::ProtocolVersion;
|
||||
use crate::{Error, ErrorKind, Result};
|
||||
use std::fmt;
|
||||
use std::iter;
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
|
||||
/// Media playlist builder.
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -122,7 +121,7 @@ impl MediaPlaylistBuilder {
|
|||
let mut last_range_uri = None;
|
||||
for s in &self.segments {
|
||||
// CHECK: `#EXT-X-TARGETDURATION`
|
||||
let mut segment_duration = s.inf_tag().duration();
|
||||
let segment_duration = s.inf_tag().duration();
|
||||
let rounded_segment_duration = if segment_duration.subsec_nanos() < 500_000_000 {
|
||||
Duration::from_secs(segment_duration.as_secs())
|
||||
} else {
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
use std::fmt;
|
||||
use std::iter;
|
||||
|
||||
use tags::{
|
||||
use crate::tags::{
|
||||
ExtInf, ExtXByteRange, ExtXDateRange, ExtXDiscontinuity, ExtXKey, ExtXMap, ExtXProgramDateTime,
|
||||
MediaSegmentTag,
|
||||
};
|
||||
use types::{ProtocolVersion, SingleLineString};
|
||||
use {ErrorKind, Result};
|
||||
use crate::types::{ProtocolVersion, SingleLineString};
|
||||
use crate::{ErrorKind, Result};
|
||||
use std::fmt;
|
||||
use std::iter;
|
||||
|
||||
/// Media segment builder.
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
use crate::types::ProtocolVersion;
|
||||
use crate::{Error, ErrorKind, Result};
|
||||
use std::fmt;
|
||||
use std::str::FromStr;
|
||||
|
||||
use types::ProtocolVersion;
|
||||
use {Error, ErrorKind, Result};
|
||||
|
||||
/// [4.3.1.1. EXTM3U]
|
||||
///
|
||||
/// [4.3.1.1. EXTM3U]: https://tools.ietf.org/html/rfc8216#section-4.3.1.1
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
use std::fmt;
|
||||
use std::str::FromStr;
|
||||
|
||||
use super::{parse_u64, parse_yes_or_no};
|
||||
use attribute::AttributePairs;
|
||||
use types::{
|
||||
use crate::attribute::AttributePairs;
|
||||
use crate::types::{
|
||||
ClosedCaptions, DecimalFloatingPoint, DecimalResolution, DecryptionKey, HdcpLevel, InStreamId,
|
||||
MediaType, ProtocolVersion, QuotedString, SessionData, SingleLineString,
|
||||
};
|
||||
use {Error, ErrorKind, Result};
|
||||
use crate::{Error, ErrorKind, Result};
|
||||
use std::fmt;
|
||||
use std::str::FromStr;
|
||||
|
||||
/// `ExtXMedia` builder.
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -498,7 +497,7 @@ impl FromStr for ExtXStreamInf {
|
|||
type Err = Error;
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
let mut lines = s.splitn(2, '\n');
|
||||
let first_line = lines.next().expect("Never fails").trim_right_matches('\r');
|
||||
let first_line = lines.next().expect("Never fails").trim_end_matches('\r');
|
||||
let second_line = track_assert_some!(lines.next(), ErrorKind::InvalidInput);
|
||||
|
||||
track_assert!(
|
||||
|
@ -837,7 +836,7 @@ impl FromStr for ExtXSessionKey {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use types::{EncryptionMethod, InitializationVector};
|
||||
use crate::types::{EncryptionMethod, InitializationVector};
|
||||
|
||||
#[test]
|
||||
fn ext_x_media() {
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
use super::parse_yes_or_no;
|
||||
use crate::attribute::AttributePairs;
|
||||
use crate::types::{ProtocolVersion, SignedDecimalFloatingPoint};
|
||||
use crate::{Error, ErrorKind, Result};
|
||||
use std::fmt;
|
||||
use std::str::FromStr;
|
||||
|
||||
use super::parse_yes_or_no;
|
||||
use attribute::AttributePairs;
|
||||
use types::{ProtocolVersion, SignedDecimalFloatingPoint};
|
||||
use {Error, ErrorKind, Result};
|
||||
|
||||
/// [4.3.5.1. EXT-X-INDEPENDENT-SEGMENTS]
|
||||
///
|
||||
/// [4.3.5.1. EXT-X-INDEPENDENT-SEGMENTS]: https://tools.ietf.org/html/rfc8216#section-4.3.5.1
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
use crate::types::{PlaylistType, ProtocolVersion};
|
||||
use crate::{Error, ErrorKind, Result};
|
||||
use std::fmt;
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
use trackable::error::ErrorKindExt;
|
||||
|
||||
use types::{PlaylistType, ProtocolVersion};
|
||||
use {Error, ErrorKind, Result};
|
||||
|
||||
/// [4.3.3.1. EXT-X-TARGETDURATION]
|
||||
///
|
||||
/// [4.3.3.1. EXT-X-TARGETDURATION]: https://tools.ietf.org/html/rfc8216#section-4.3.3.1
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
use crate::attribute::AttributePairs;
|
||||
use crate::types::{
|
||||
ByteRange, DecimalFloatingPoint, DecryptionKey, ProtocolVersion, QuotedString, SingleLineString,
|
||||
};
|
||||
use crate::{Error, ErrorKind, Result};
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt;
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
use trackable::error::ErrorKindExt;
|
||||
|
||||
use attribute::AttributePairs;
|
||||
use types::{
|
||||
ByteRange, DecimalFloatingPoint, DecryptionKey, ProtocolVersion, QuotedString, SingleLineString,
|
||||
};
|
||||
use {Error, ErrorKind, Result};
|
||||
|
||||
/// [4.3.2.1. EXTINF]
|
||||
///
|
||||
/// [4.3.2.1. EXTINF]: https://tools.ietf.org/html/rfc8216#section-4.3.2.1
|
||||
|
@ -479,10 +478,9 @@ impl FromStr for ExtXDateRange {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::time::Duration;
|
||||
|
||||
use super::*;
|
||||
use types::{EncryptionMethod, InitializationVector};
|
||||
use crate::types::{EncryptionMethod, InitializationVector};
|
||||
use std::time::Duration;
|
||||
|
||||
#[test]
|
||||
fn extinf() {
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
//! [4.3. Playlist Tags]
|
||||
//!
|
||||
//! [4.3. Playlist Tags]: https://tools.ietf.org/html/rfc8216#section-4.3
|
||||
use crate::{ErrorKind, Result};
|
||||
use trackable::error::ErrorKindExt;
|
||||
|
||||
use {ErrorKind, Result};
|
||||
|
||||
macro_rules! may_invalid {
|
||||
($expr:expr) => {
|
||||
$expr.map_err(|e| track!(Error::from(ErrorKind::InvalidInput.cause(e))))
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
//! Miscellaneous types.
|
||||
use crate::attribute::AttributePairs;
|
||||
use crate::{Error, ErrorKind, Result};
|
||||
use std::fmt;
|
||||
use std::ops::Deref;
|
||||
use std::str::{self, FromStr};
|
||||
use std::time::Duration;
|
||||
use trackable::error::ErrorKindExt;
|
||||
|
||||
use attribute::AttributePairs;
|
||||
use {Error, ErrorKind, Result};
|
||||
|
||||
/// String that represents a single line in a playlist file.
|
||||
///
|
||||
/// See: [4.1. Definition of a Playlist]
|
||||
|
|
Loading…
Reference in a new issue