Skip to content

Commit

Permalink
Remove MediaSegment equality function
Browse files Browse the repository at this point in the history
Use the autogenerated equality function. This required fixing segment
name parsing. Previously the parser would return an empty string for
no name in an #EXTINF tag. Empty names should be nil instead. This was
not an issue because the equality function didn’t account for the
name.
  • Loading branch information
fcanas committed Jan 1, 2019
1 parent a8dffbc commit 4dc792d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
3 changes: 1 addition & 2 deletions Sources/Parsing/Tags.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ let EXTXINDEPENDENTSEGMENTS = { _ in Tag.independentSegments } <^> "#EXT-X-INDEP
let EXTXSTART = Tag.startIndicator <^> ( StartIndicator.init <^!> ( "#EXT-X-START:" *> attributeList ))

// MARK: Media Segment Tags

let EXTINF = Tag.MediaPlaylist.Segment.inf <^> "#EXTINF:" *> (( decimalFloatingPoint <|> decimalInteger ) <* character { $0 == "," } <&> ({ (characters :[Character]) -> String in return String(characters) } <^!> (CharacterSet.newlines.inverted).parser().many))
let EXTINF = Tag.MediaPlaylist.Segment.inf <^> "#EXTINF:" *> (( decimalFloatingPoint <|> decimalInteger ) <* character { $0 == "," } <&> ({ String($0) } <^> (CharacterSet.newlines.inverted).parser().many1).optional)

let EXTXBYTERANGE = Tag.MediaPlaylist.Segment.byteRange <^> ( "#EXT-X-BYTERANGE:" *> TypeParser.byteRange )

Expand Down
9 changes: 1 addition & 8 deletions Sources/Types/HLSCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,7 @@ public struct MediaSegment {

}

extension MediaSegment : Equatable {
public static func ==(lhs: MediaSegment, rhs: MediaSegment) -> Bool {
return lhs.resource == rhs.resource
&& lhs.title ?? "" == rhs.title ?? ""
&& lhs.byteRange == rhs.byteRange
&& lhs.duration == rhs.duration
}
}
extension MediaSegment : Equatable { }

public struct MediaInitializationSection {
public let uri: URL
Expand Down

0 comments on commit 4dc792d

Please sign in to comment.