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
39 changes: 28 additions & 11 deletions Pantomime.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -300,19 +300,22 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0820;
ORGANIZATIONNAME = "Thomas Christensen";
TargetAttributes = {
9EDCE3E31C09D211002FA4A7 = {
CreatedOnToolsVersion = 7.1.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 0820;
ProvisioningStyle = Manual;
};
9EDCE3ED1C09D211002FA4A7 = {
CreatedOnToolsVersion = 7.1.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 0820;
ProvisioningStyle = Manual;
};
ACE597861C18830D0031451F = {
LastSwiftMigration = 0800;
ProvisioningStyle = Manual;
};
ACE597971C18832E0031451F = {
LastSwiftMigration = 0800;
Expand Down Expand Up @@ -501,8 +504,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand Down Expand Up @@ -550,8 +555,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand Down Expand Up @@ -584,7 +591,9 @@
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
Expand All @@ -595,7 +604,7 @@
PRODUCT_NAME = Pantomime;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -604,7 +613,9 @@
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
Expand All @@ -615,40 +626,44 @@
PRODUCT_NAME = Pantomime;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Release;
};
9EDCE3FC1C09D211002FA4A7 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = NO;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = PantomimeTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.nordija.PantomimeTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
9EDCE3FD1C09D211002FA4A7 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = NO;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = PantomimeTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.nordija.PantomimeTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Release;
};
ACE597931C18830D0031451F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
Expand All @@ -662,7 +677,7 @@
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "appletvsimulator appletvos";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
VALID_ARCHS = "$(ARCHS_STANDARD)";
};
name = Debug;
Expand All @@ -671,7 +686,9 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
Expand All @@ -685,7 +702,7 @@
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "appletvsimulator appletvos";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
VALID_ARCHS = "$(ARCHS_STANDARD)";
};
name = Release;
Expand All @@ -709,7 +726,7 @@
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
VALID_ARCHS = "i386 x86_64";
};
name = Debug;
Expand All @@ -733,7 +750,7 @@
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
VALID_ARCHS = "i386 x86_64";
};
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 = "0800"
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
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 = "0800"
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
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 = "0800"
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
58 changes: 29 additions & 29 deletions PantomimeTests/PantomimeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import XCTest
class PantomimeTests: XCTestCase {

func testParseMediaPlaylist() {
let bundle = NSBundle(forClass: self.dynamicType)
let path = bundle.pathForResource("media", ofType: "m3u8")!
let bundle = Bundle(for: type(of: self))
let path = bundle.path(forResource: "media", ofType: "m3u8")!

let manifestBuilder = ManifestBuilder()
let mediaPlaylist = manifestBuilder.parseMediaPlaylistFromFile(path, onMediaSegment: {
Expand All @@ -33,7 +33,7 @@ class PantomimeTests: XCTestCase {
XCTAssert(mediaPlaylist.segments[2].path! == "http://media.example.com/third.ts")
XCTAssert(mediaPlaylist.duration() == Float(21.021))

if let path2 = bundle.pathForResource("media2", ofType: "m3u8") {
if let path2 = bundle.path(forResource: "media2", ofType: "m3u8") {
let mediaPlaylist2 = manifestBuilder.parseMediaPlaylistFromFile(path2, onMediaSegment: {
(segment: MediaSegment) -> Void in
XCTAssertNotNil(segment.sequence)
Expand All @@ -43,8 +43,8 @@ class PantomimeTests: XCTestCase {
}

func testParseMasterPlaylist() {
let bundle = NSBundle(forClass: self.dynamicType)
let path = bundle.pathForResource("master", ofType: "m3u8")!
let bundle = Bundle(for: type(of: self))
let path = bundle.path(forResource: "master", ofType: "m3u8")!

let manifestBuilder = ManifestBuilder()

Expand All @@ -64,12 +64,12 @@ class PantomimeTests: XCTestCase {
* fetch the manifest files and then parse the text.
*/
func testParseFromString() {
let bundle = NSBundle(forClass: self.dynamicType)
let file = bundle.pathForResource("master", ofType: "m3u8")!
let path = NSURL(fileURLWithPath: file)
let bundle = Bundle(for: type(of: self))
let file = bundle.path(forResource: "master", ofType: "m3u8")!
let path = URL(fileURLWithPath: file)
do {

let manifestText = try String(contentsOfURL: path, encoding: NSUTF8StringEncoding)
let manifestText = try String(contentsOf: path, encoding: String.Encoding.utf8)
let manifestBuilder = ManifestBuilder()
let masterPlaylist = manifestBuilder.parseMasterPlaylistFromString(manifestText)
XCTAssert(masterPlaylist.playlists.count == 4)
Expand All @@ -85,57 +85,57 @@ class PantomimeTests: XCTestCase {
// Keep baseURL separate to contruct the nested media playlist URL's
let baseURL = "http://devimages.apple.com/iphone/samples/bipbop"
let path = "bipbopall.m3u8"
let URL = NSURL(string: baseURL + "/" + path)!
let URL = Foundation.URL(string: baseURL + "/" + path)!
XCTAssertEqual("http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8", URL.absoluteString)

let expectation = expectationWithDescription("Testing parsing of the apple bipbop HTTP Live Stream sample")
let expectation = self.expectation(description: "Testing parsing of the apple bipbop HTTP Live Stream sample")

let session = NSURLSession.sharedSession()
let session = URLSession.shared

// Request master playlist
let task = session.dataTaskWithURL(URL) {
let task = session.dataTask(with: URL, completionHandler: {
data, response, error in

XCTAssertNotNil(data, "data should not be nil")
XCTAssertNil(error, "error should be nil")

if let httpResponse = response as? NSHTTPURLResponse,
responseURL = httpResponse.URL,
mimeType = httpResponse.MIMEType {
if let httpResponse = response as? HTTPURLResponse,
let responseURL = httpResponse.url,
let mimeType = httpResponse.mimeType {

XCTAssertEqual(responseURL.absoluteString, URL.absoluteString, "No redirect expected")
XCTAssertEqual(httpResponse.statusCode, 200, "HTTP response status code should be 200")
XCTAssertEqual(mimeType, "audio/x-mpegurl", "HTTP response content type should be text/html")

// Parse master playlist and perform verification of it
if let dataFound = data, manifestText = String(data: dataFound, encoding: NSUTF8StringEncoding) {
if let dataFound = data, let manifestText = String(data: dataFound, encoding: String.Encoding.utf8) {

let masterPlaylist = manifestBuilder.parseMasterPlaylistFromString(manifestText,
onMediaPlaylist: {
(mep: MediaPlaylist) -> Void in

// Deduct full media playlist URL from path
if let path = mep.path, mepURL = NSURL(string: baseURL + "/" + path) {
if let path = mep.path, let mepURL = Foundation.URL(string: baseURL + "/" + path) {

// Request each found media playlist
let mepTask = session.dataTaskWithURL(mepURL) {
let mepTask = session.dataTask(with: mepURL, completionHandler: {
mepData, mepResponse, mepError in

XCTAssertNotNil(mepData, "data should not be nil")
XCTAssertNil(mepError, "error should be nil")

// Parse the media playlist and perform validation
if let mepDataFound = mepData,
mepManifest = String(data: mepDataFound, encoding: NSUTF8StringEncoding) {
let mepManifest = String(data: mepDataFound, encoding: String.Encoding.utf8) {
let mediaPlaylist = manifestBuilder.parseMediaPlaylistFromString(mepManifest)
XCTAssertEqual(181, mediaPlaylist.segments.count)
}

// In case we have requested, parsed and validated the last one
if path.containsString("gear4/prog_index.m3u8") {
if path.contains("gear4/prog_index.m3u8") {
expectation.fulfill()
}
}
})

mepTask.resume()
}
Expand All @@ -146,11 +146,11 @@ class PantomimeTests: XCTestCase {
} else {
XCTFail("Response was not NSHTTPURLResponse")
}
}
})

task.resume()

waitForExpectationsWithTimeout(task.originalRequest!.timeoutInterval) {
waitForExpectations(timeout: task.originalRequest!.timeoutInterval) {
error in
if let error = error {
XCTFail("Error: \(error.localizedDescription)")
Expand All @@ -164,8 +164,8 @@ class PantomimeTests: XCTestCase {

// Check using String with contentsOfURL
do {
if let url = NSURL(string: "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8") {
let content = try String(contentsOfURL: url, encoding: NSUTF8StringEncoding)
if let url = URL(string: "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8") {
let content = try String(contentsOf: url, encoding: String.Encoding.utf8)
let master = builder.parseMasterPlaylistFromString(content)
XCTAssertEqual(4, master.playlists.count, "Number of media playlists in master does not match")
} else {
Expand All @@ -178,15 +178,15 @@ class PantomimeTests: XCTestCase {

func testSimpleFullParse() {
let builder = ManifestBuilder()
if let url = NSURL(string: "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8") {
if let url = URL(string: "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8") {
let manifest = builder.parse(url)
XCTAssertEqual(4, manifest.playlists.count)
}
}

func testFullParse() {
let builder = ManifestBuilder()
if let url = NSURL(string: "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8") {
if let url = URL(string: "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8") {
let manifest = builder.parse(url, onMediaPlaylist: {
(media: MediaPlaylist) -> Void in
XCTAssertNotNil(media.path)
Expand All @@ -203,7 +203,7 @@ class PantomimeTests: XCTestCase {

func testFullParseWithFullPathInManifests() {
let builder = ManifestBuilder()
if let url = NSURL(string: "https://mnmedias.api.telequebec.tv/m3u8/29880.m3u8") {
if let url = URL(string: "https://mnmedias.api.telequebec.tv/m3u8/29880.m3u8") {
let manifest = builder.parse(url, onMediaPlaylist: {
(media: MediaPlaylist) -> Void in
XCTAssertNotNil(media.path)
Expand Down
Loading