Skip to content

Commit

Permalink
Merge pull request #106 from Comcast/release/2.2.2
Browse files Browse the repository at this point in the history
Release/2.2.2
  • Loading branch information
jaybpierce authored Aug 20, 2021
2 parents ee38596 + 69ed6dc commit 80c8073
Show file tree
Hide file tree
Showing 16 changed files with 99 additions and 60 deletions.
46 changes: 23 additions & 23 deletions mamba.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Original</string>
<key>PreviewsEnabled</key>
<false/>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion mamba.xcodeproj/xcshareddata/xcschemes/mamba.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1150"
LastUpgradeVersion = "1200"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion mamba.xcodeproj/xcshareddata/xcschemes/mambaMacOS.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1150"
LastUpgradeVersion = "1200"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion mamba.xcodeproj/xcshareddata/xcschemes/mambaTVOS.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1150"
LastUpgradeVersion = "1200"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Mamba.swift
// FrameworkInfo.swift
// mamba
//
// Created by David Coufal on 8/2/16.
Expand All @@ -19,8 +19,8 @@

import Foundation

/// Base object representing the Mamba framework
public enum Mamba {
/// Provides information about the framework
public enum FrameworkInfo {

/// returns the version of the mamba framework
public static var version: String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import Foundation
variantTagGroups[2] 3.m3u8
```
*/
public typealias MasterPlaylistStructure = PlaylistStructureCore<MasterPlaylistStructureData, MasterPlaylistStructureDelegate>
public typealias MasterPlaylistStructure = PlaylistStructureCore<MasterPlaylistStructureDelegate>

extension PlaylistStructureCore: MasterPlaylistTagGroupProvider where PSD == MasterPlaylistStructureDelegate {

Expand All @@ -68,7 +68,7 @@ public protocol MasterPlaylistTagGroupProvider {
var variantTagGroups: [VariantTagGroup] { get }
}

public struct MasterPlaylistStructureData: EmptyInitializerImplementor {
public struct MasterPlaylistStructureData: PlaylistStructure {
public init() {
self.variantTagGroups = [VariantTagGroup]()
}
Expand All @@ -78,7 +78,7 @@ public struct MasterPlaylistStructureData: EmptyInitializerImplementor {
var variantTagGroups: [VariantTagGroup]
}

public final class MasterPlaylistStructureDelegate: PlaylistStructureDelegate, EmptyInitializerImplementor {
public final class MasterPlaylistStructureDelegate: PlaylistStructureDelegate {

public typealias T = MasterPlaylistStructureData

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,27 @@

import Foundation

public final class PlaylistStructureCore<T: EmptyInitializerImplementor, PSD: PlaylistStructureDelegate & EmptyInitializerImplementor>: PlaylistStructureInterface where PSD.T == T {
public final class PlaylistStructureCore<PSD: PlaylistStructureDelegate>: PlaylistStructureInterface {

private var structureState: StructureState = .dirtyRequiresRebuild

private var _tags: [PlaylistTag]
private let delegate: PSD

var _structureData: T
var _structureData: PSD.StructureType

private let queue = DispatchQueue(label: "com.comcast.mamba.playliststructurecore",
qos: .userInitiated)

public convenience init(withTags tags: [PlaylistTag]) {
self.init(withTags: tags,
withDelegate: PSD(),
withStructureData: T())
withStructureData: PSD.StructureType())
}

init(withTags tags: [PlaylistTag],
withDelegate delegate: PSD,
withStructureData structureData: T) {
withStructureData structureData: PSD.StructureType) {
self._tags = tags
self.delegate = delegate
self._structureData = structureData
Expand All @@ -58,7 +58,7 @@ public final class PlaylistStructureCore<T: EmptyInitializerImplementor, PSD: Pl
}
}

public var structureData: T {
public var structureData: PSD.StructureType {
return queue.sync {
rebuildIfRequired()
return _structureData
Expand Down Expand Up @@ -188,7 +188,9 @@ public final class PlaylistStructureCore<T: EmptyInitializerImplementor, PSD: Pl
*/
public protocol PlaylistStructureDelegate: class {

associatedtype T
associatedtype StructureType: PlaylistStructure

init()

/**
Return true if this tag is a marker for structure boundaries in your structure definition.
Expand All @@ -205,9 +207,9 @@ public protocol PlaylistStructureDelegate: class {

- parameter usingTagArray: The list of tags that defines our playlist.

- returns: New structure of `T` type
- returns: New structure of `StructureType` type
*/
func rebuild(usingTagArray tags: [PlaylistTag]) -> T
func rebuild(usingTagArray tags: [PlaylistTag]) -> StructureType

/**
`PlaylistStructureCore` has noted a minor change to the tag array and requests that
Expand All @@ -223,14 +225,14 @@ public protocol PlaylistStructureDelegate: class {
func changed(numberOfTags alterCount: Int,
atIndex index: Int,
inTagArray tags: [PlaylistTag],
withInitialStructure structure: T) -> PlaylistStructureChangeResult<T>
withInitialStructure structure: StructureType) -> PlaylistStructureChangeResult<StructureType>
}

public struct PlaylistStructureChangeResult<T> {
public struct PlaylistStructureChangeResult<StructureType> {
/// `false` if we were able to fix up ourselves, `true` if we has to rebuild structure from scratch
let hadToRebuildFromScratch: Bool
/// New structure after rebuild
let structure: T
let structure: StructureType
}

struct PlaylistStructureConstructor {
Expand Down Expand Up @@ -421,6 +423,6 @@ struct PlaylistStructureConstructor {
}
}

public protocol EmptyInitializerImplementor {
public protocol PlaylistStructure {
init()
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import Foundation
mediaSpans[1] would cover just mediaSegmentGroup[2] (range 2...2). Each media span has its own #EXT-X-KEY tag.

*/
public typealias VariantPlaylistStructure = PlaylistStructureCore<MediaPlaylistStructureData, VariantPlaylistStructureDelegate>
public typealias VariantPlaylistStructure = PlaylistStructureCore<VariantPlaylistStructureDelegate>

extension PlaylistStructureCore: PlaylistTagSource, PlaylistTypeDetermination, VariantPlaylistStructureInterface where PSD == VariantPlaylistStructureDelegate {

Expand Down Expand Up @@ -173,7 +173,7 @@ extension VariantPlaylistStructureInterface {
}
}

public struct MediaPlaylistStructureData: EmptyInitializerImplementor, PlaylistTypeDetermination {
public struct MediaPlaylistStructureData: PlaylistStructure, PlaylistTypeDetermination {
public init() {
self.header = nil
self.mediaSegmentGroups = [MediaSegmentPlaylistTagGroup]()
Expand Down Expand Up @@ -207,7 +207,7 @@ public struct MediaPlaylistStructureData: EmptyInitializerImplementor, PlaylistT
public var playlistType: PlaylistType
}

public final class VariantPlaylistStructureDelegate: PlaylistStructureDelegate, EmptyInitializerImplementor {
public final class VariantPlaylistStructureDelegate: PlaylistStructureDelegate {

public typealias T = MediaPlaylistStructureData

Expand Down
2 changes: 1 addition & 1 deletion mambaSharedFramework/PlaylistWriter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class PlaylistWriter {
try write(string: identityString, toStream: stream)
}
if !suppressMambaIdentityString {
try write(string: " Generated by Mamba(\(Mamba.version)) Copyright (c) 2017 Comcast Corporation", toStream: stream)
try write(string: " Generated by Mamba(\(FrameworkInfo.version)) Copyright (c) 2017 Comcast Corporation", toStream: stream)
}

// write tags
Expand Down
2 changes: 1 addition & 1 deletion mambaSharedFramework/mamba.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// limitations under the License.
//

#import "Availability.h"
#import <Availability.h>

#ifdef __MAC_OS_X_VERSION_MAX_ALLOWED
#import <Cocoa/Cocoa.h>
Expand Down
28 changes: 20 additions & 8 deletions mambaTests/Helpers/XCTestCase+mamba.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import XCTest

extension XCTestCase {

public func parseMasterPlaylist(inData data: Data,
tagTypes: [PlaylistTagDescriptor.Type]? = nil,
url: URL = fakePlaylistURL()) -> MasterPlaylist {
fileprivate func _parseMasterPlaylist(inData data: Data,
tagTypes: [PlaylistTagDescriptor.Type]? = nil,
url: URL = fakePlaylistURL()) -> MasterPlaylist? {
let result = _parsePlaylist(inData: data, tagTypes: tagTypes, url: url)
switch result {
case .parseError(let error):
Expand All @@ -38,9 +38,15 @@ extension XCTestCase {
break
}
// we've already stopped the test at this point
return nil!
return nil
}

public func parseMasterPlaylist(inData data: Data,
tagTypes: [PlaylistTagDescriptor.Type]? = nil,
url: URL = fakePlaylistURL()) -> MasterPlaylist {
return _parseMasterPlaylist(inData: data, tagTypes: tagTypes, url: url)!
}

public func parseMasterPlaylist(inString playlistString: String,
tagTypes: [PlaylistTagDescriptor.Type]? = nil,
url: URL? = fakePlaylistURL()) -> MasterPlaylist {
Expand All @@ -59,9 +65,9 @@ extension XCTestCase {
return parseMasterPlaylist(inData: data! as Data, tagTypes: tagTypes, url: url!)
}

public func parseVariantPlaylist(inData data: Data,
tagTypes: [PlaylistTagDescriptor.Type]? = nil,
url: URL = fakePlaylistURL()) -> VariantPlaylist {
fileprivate func _parseVariantPlaylist(inData data: Data,
tagTypes: [PlaylistTagDescriptor.Type]? = nil,
url: URL = fakePlaylistURL()) -> VariantPlaylist? {
let result = _parsePlaylist(inData: data, tagTypes: tagTypes, url: url)
switch result {
case .parseError(let error):
Expand All @@ -74,7 +80,13 @@ extension XCTestCase {
break
}
// we've already stopped the test at this point
return nil!
return nil
}

public func parseVariantPlaylist(inData data: Data,
tagTypes: [PlaylistTagDescriptor.Type]? = nil,
url: URL = fakePlaylistURL()) -> VariantPlaylist {
return _parseVariantPlaylist(inData: data, tagTypes: tagTypes, url: url)!
}

public func parseVariantPlaylist(inString playlistString: String,
Expand Down
13 changes: 13 additions & 0 deletions mambaTests/MasterPlaylistStreamSummaryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ class MasterPlaylistStreamSummaryTests: XCTestCase {
default:
XCTFail("Unexpected streamInfIndex: \(streamInfIndex)")
}
@unknown default:
XCTFail("Unknown enum case")
}
}

Expand Down Expand Up @@ -333,6 +335,8 @@ class MasterPlaylistStreamSummaryTests: XCTestCase {
default:
XCTFail("Unexpected streamInfIndex: \(streamInfIndex)")
}
@unknown default:
XCTFail("Unknown enum case")
}
}

Expand Down Expand Up @@ -455,6 +459,8 @@ class MasterPlaylistStreamSummaryTests: XCTestCase {
default:
XCTFail("Unexpected streamInfIndex: \(streamInfIndex)")
}
@unknown default:
XCTFail("Unknown enum case")
}
}

Expand Down Expand Up @@ -551,6 +557,8 @@ class MasterPlaylistStreamSummaryTests: XCTestCase {
default:
XCTFail("Unexpected streamInfIndex: \(streamInfIndex)")
}
@unknown default:
XCTFail("Unknown enum case")
}
}

Expand Down Expand Up @@ -624,6 +632,8 @@ class MasterPlaylistStreamSummaryTests: XCTestCase {
default:
XCTFail("Unexpected streamInfIndex: \(streamInfIndex)")
}
@unknown default:
XCTFail("Unknown enum case")
}
}

Expand All @@ -647,7 +657,10 @@ class MasterPlaylistStreamSummaryTests: XCTestCase {
XCTAssert(errorText.contains("Location") && errorText.contains("streamInf"), "Expecting this error to be about location tags")
case .internalIndexError:
XCTFail("Not expecting this error")
@unknown default:
XCTFail("Unknown enum case")
}

return
}
}
Expand Down
2 changes: 1 addition & 1 deletion mambaTests/PlaylistWriterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,5 @@ class PlaylistWriterTests: XCTestCase {
}
}

let standardMambaString = "# Generated by Mamba(\(Mamba.version)) Copyright (c) 2017 Comcast Corporation\n"
let standardMambaString = "# Generated by Mamba(\(FrameworkInfo.version)) Copyright (c) 2017 Comcast Corporation\n"
}
4 changes: 4 additions & 0 deletions mambaTests/ReadMeUnitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class ReadMeUnitTests: XCTestCase {
// handle the PlaylistParserError
myErrorHandler(error: error)
break
@unknown default:
XCTFail("Unknown enum case")
}
})

Expand All @@ -81,6 +83,8 @@ class ReadMeUnitTests: XCTestCase {
// handle the PlaylistParserError
myErrorHandler(error: error)
break
@unknown default:
XCTFail("Unknown enum case")
}

// Validating a HLS Playlist
Expand Down
10 changes: 10 additions & 0 deletions mambaTests/VariantPlaylistTagMatchSegmentInfoTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ segment5.ts
case .timeMatch(let timeRange):
XCTAssertEqual(timeRange.start, CMTime.zero)
XCTAssertEqual(timeRange.duration, CMTime(failableInitWithString: "3.0000")!)
@unknown default:
XCTFail("Unknown enum case")
}

// testing if the "match in header means no match" feature works
Expand All @@ -91,6 +93,8 @@ segment5.ts
case .timeMatch(let timeRange):
XCTAssertEqual(timeRange.start, CMTime(failableInitWithString: "6.0000")!)
XCTAssertEqual(timeRange.duration, CMTime(failableInitWithString: "3.0000")!)
@unknown default:
XCTFail("Unknown enum case")
}

XCTAssertEqual(testSegmentTags[1].containsDiscontinuity, true)
Expand All @@ -105,6 +109,8 @@ segment5.ts
case .timeMatch(let timeRange):
XCTAssertEqual(timeRange.start, CMTime(failableInitWithString: "12.0000")!)
XCTAssertEqual(timeRange.duration, CMTime(failableInitWithString: "3.0000")!)
@unknown default:
XCTFail("Unknown enum case")
}

// quick test of testing more "normal" segment based tags with "match in header means no match"
Expand Down Expand Up @@ -158,6 +164,8 @@ segment5.ts
break
case .timeMatch(_):
XCTFail("Not expecting this value")
@unknown default:
XCTFail("Unknown enum case")
}

XCTAssertEqual(testSegmentTags[1].containsDiscontinuity, true)
Expand All @@ -172,6 +180,8 @@ segment5.ts
break
case .timeMatch(_):
XCTFail("Not expecting this value")
@unknown default:
XCTFail("Unknown enum case")
}
}

Expand Down

0 comments on commit 80c8073

Please sign in to comment.