Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions Pantomime.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -300,25 +300,26 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 1020;
LastUpgradeCheck = 1330;
ORGANIZATIONNAME = "Thomas Christensen";
TargetAttributes = {
9EDCE3E31C09D211002FA4A7 = {
CreatedOnToolsVersion = 7.1.1;
DevelopmentTeam = W9ZVWEMJZF;
LastSwiftMigration = 1020;
};
9EDCE3ED1C09D211002FA4A7 = {
CreatedOnToolsVersion = 7.1.1;
DevelopmentTeam = W9ZVWEMJZF;
LastSwiftMigration = 1020;
};
ACE597861C18830D0031451F = {
DevelopmentTeam = W9ZVWEMJZF;
LastSwiftMigration = 0800;
};
ACE597971C18832E0031451F = {
DevelopmentTeam = W9ZVWEMJZF;
LastSwiftMigration = 0800;
ProvisioningStyle = Automatic;
ProvisioningStyle = Manual;
};
};
};
Expand Down Expand Up @@ -515,6 +516,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand All @@ -540,7 +542,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -576,6 +578,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand All @@ -595,10 +598,11 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
ONLY_ACTIVE_ARCH = NO;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_VERSION = 4.0;
VALIDATE_PRODUCT = YES;
VALID_ARCHS = "arm64 armv7 armv7s x86_64";
Expand Down Expand Up @@ -732,55 +736,53 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = W9ZVWEMJZF;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
MACOSX_DEPLOYMENT_TARGET = 11.0;
PRODUCT_BUNDLE_IDENTIFIER = com.nordija.Pantomime;
PRODUCT_NAME = Pantomime;
PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = macosx;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
VALID_ARCHS = "i386 x86_64";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
ACE597A51C18832E0031451F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = W9ZVWEMJZF;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
MACOSX_DEPLOYMENT_TARGET = 11.0;
PRODUCT_BUNDLE_IDENTIFIER = com.nordija.Pantomime;
PRODUCT_NAME = Pantomime;
PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = macosx;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 4.0;
VALID_ARCHS = "i386 x86_64";
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1330"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -29,8 +29,6 @@
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -51,8 +49,6 @@
ReferencedContainer = "container:Pantomime.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
24 changes: 10 additions & 14 deletions Pantomime.xcodeproj/xcshareddata/xcschemes/Pantomime (iOS).xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1330"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9EDCE3E31C09D211002FA4A7"
BuildableName = "Pantomime.framework"
BlueprintName = "Pantomime (iOS)"
ReferencedContainer = "container:Pantomime.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -39,17 +48,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9EDCE3E31C09D211002FA4A7"
BuildableName = "Pantomime.framework"
BlueprintName = "Pantomime (iOS)"
ReferencedContainer = "container:Pantomime.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -70,8 +68,6 @@
ReferencedContainer = "container:Pantomime.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1330"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -29,8 +29,6 @@
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -51,8 +49,6 @@
ReferencedContainer = "container:Pantomime.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
56 changes: 44 additions & 12 deletions Sources/ManifestBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ open class ManifestBuilder {
*/
fileprivate func parseMasterPlaylist(_ reader: BufferedReader, onMediaPlaylist:
((_ playlist: MediaPlaylist) -> Void)?) -> MasterPlaylist {
var masterPlaylist = MasterPlaylist()
let masterPlaylist = MasterPlaylist()
var currentMediaPlaylist: MediaPlaylist?

defer {
reader.close()
}

while let line = reader.readLine() {
if line.isEmpty {
// Skip empty lines
Expand All @@ -36,18 +37,39 @@ open class ManifestBuilder {

} else if line.hasPrefix("#EXT-X-STREAM-INF") {
// #EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=200000
currentMediaPlaylist = MediaPlaylist()
do {
let programIdString = try line.replace("(.*)=(\\d+),(.*)", replacement: "$2")
let bandwidthString = try line.replace("(.*),(.*)=(\\d+)(.*)", replacement: "$3")
if let currentMediaPlaylistExist = currentMediaPlaylist {
currentMediaPlaylistExist.programId = Int(programIdString)!
currentMediaPlaylistExist.bandwidth = Int(bandwidthString)!
if let type = parseLine(line, attribute: "TYPE"), let mediaType = MediaType(rawValue: type) {
currentMediaPlaylist = MediaPlaylist(type: mediaType)
}
if let mediaPlaylist = currentMediaPlaylist {
do {
if let brandwidth = parseLine(line, attribute: "BANDWIDTH") {
mediaPlaylist.bandwidth = Int(brandwidth)!
}

let programIdString = try line.replace("(.*)=(\\d+),(.*)", replacement: "$2")
mediaPlaylist.programId = Int(programIdString)!

} catch {
print("Failed to parse program-id and bandwidth on master playlist. Line = \(line)")
}
}
} else if line.hasPrefix("#EXT-X-MEDIA:TYPE=SUBTITLES") {
// #EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",LANGUAGE="eng",NAME="English",AUTOSELECT=YES,DEFAULT=YES,URI="subtitles/eng/prog_index.m3u8",FORCED=NO
if let type = parseLine(line, attribute: "TYPE"), let mediaType = MediaType(rawValue: type) {
currentMediaPlaylist = MediaPlaylist(type: mediaType)
}

if let mediaPlaylist = currentMediaPlaylist {
mediaPlaylist.path = parseLine(line, attribute: "URI")?.replacingOccurrences(of: "\"", with: "")
mediaPlaylist.language = parseLine(line, attribute: "LANGUAGE")
mediaPlaylist.name = parseLine(line, attribute: "NAME")

mediaPlaylist.masterPlaylist = masterPlaylist
masterPlaylist.addPlaylist(mediaPlaylist)
if let callableOnMediaPlaylist = onMediaPlaylist {
callableOnMediaPlaylist(mediaPlaylist)
}
} catch {
print("Failed to parse program-id and bandwidth on master playlist. Line = \(line)")
}

}
} else if line.hasPrefix("#") {
// Comments are ignored
Expand All @@ -67,6 +89,16 @@ open class ManifestBuilder {

return masterPlaylist
}

private func parseLine(_ line: String, attribute: String) -> String? {
let params = line.split(separator: ",")

if let index = params.firstIndex(where: { $0.trimmingCharacters(in: .whitespaces).contains(attribute)}) {
return params[index].split(separator: "=").map(String.init).last
}

return nil
}

/**
* Parses Media Playlist manifests
Expand Down
21 changes: 21 additions & 0 deletions Sources/MasterPlaylist.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import Foundation

open class MasterPlaylist {
var playlists = [MediaPlaylist]()
// var subtitles = [MediaSubtitle]()

open var path: String?

public init() {}
Expand All @@ -28,4 +30,23 @@ open class MasterPlaylist {
open func getPlaylistCount() -> Int {
return playlists.count
}

open func getPlaylists(type: MediaType) -> [MediaPlaylist] {
return playlists.filter { $0.type == type }
}

// open func getSubtitleCount() -> Int {
// return subtitles.count
// }
//
// open func addSubtitle(_ subtitle: MediaSubtitle) {
// subtitles.append(subtitle)
// }
//
// open func getSubtitle(_ index: Int) -> MediaSubtitle? {
// if index >= subtitles.count {
// return nil
// }
// return subtitles[index]
// }
}
Loading