Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
gal-orlanczyk committed Jul 31, 2017
2 parents 7229c27 + 4319cf6 commit 5162d33
Show file tree
Hide file tree
Showing 41 changed files with 231 additions and 5 deletions.
22 changes: 20 additions & 2 deletions Example/DownloadToGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
/* Begin PBXBuildFile section */
20AD661C1F174B0900E8E6D7 /* VideoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20AD661B1F174B0900E8E6D7 /* VideoViewController.swift */; };
20AD661E1F17A30C00E8E6D7 /* TracksViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20AD661D1F17A30C00E8E6D7 /* TracksViewController.swift */; };
20EEC2081F28BA0B00535A42 /* HLSLocalizerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20EEC2061F28B9C000535A42 /* HLSLocalizerTests.swift */; };
20EEC25B1F28DA3600535A42 /* Resources in Resources */ = {isa = PBXBuildFile; fileRef = 20EEC25A1F28DA3600535A42 /* Resources */; };
24DB0C162EDDF8BF6A493539 /* Pods_DownloadToGo_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BA4F3EDA67A5435C5B8522DC /* Pods_DownloadToGo_Tests.framework */; };
403D41C56B9FFDF0B83F5774 /* Pods_DownloadToGo_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B402B6E39A3C14EF02EE7E7A /* Pods_DownloadToGo_Example.framework */; };
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; };
Expand All @@ -32,6 +34,8 @@
/* Begin PBXFileReference section */
20AD661B1F174B0900E8E6D7 /* VideoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideoViewController.swift; sourceTree = "<group>"; };
20AD661D1F17A30C00E8E6D7 /* TracksViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TracksViewController.swift; sourceTree = "<group>"; };
20EEC2061F28B9C000535A42 /* HLSLocalizerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = HLSLocalizerTests.swift; path = HLSLocalizer/HLSLocalizerTests.swift; sourceTree = "<group>"; };
20EEC25A1F28DA3600535A42 /* Resources */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Resources; sourceTree = "<group>"; };
25C82E71DD5DC2FA8D73C02C /* DownloadToGo.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = DownloadToGo.podspec; path = ../DownloadToGo.podspec; sourceTree = "<group>"; };
607FACD01AFB9204008FA782 /* DownloadToGo_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DownloadToGo_Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -73,6 +77,14 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
20EEC2051F28B96F00535A42 /* HLSLocalizer */ = {
isa = PBXGroup;
children = (
20EEC2061F28B9C000535A42 /* HLSLocalizerTests.swift */,
);
name = HLSLocalizer;
sourceTree = "<group>";
};
554887763E034356B4C8131D /* Frameworks */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -130,7 +142,9 @@
607FACE81AFB9204008FA782 /* Tests */ = {
isa = PBXGroup;
children = (
20EEC2051F28B96F00535A42 /* HLSLocalizer */,
607FACEB1AFB9204008FA782 /* Tests.swift */,
20EEC25A1F28DA3600535A42 /* Resources */,
607FACE91AFB9204008FA782 /* Supporting Files */,
);
path = Tests;
Expand Down Expand Up @@ -266,6 +280,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
20EEC25B1F28DA3600535A42 /* Resources in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -329,7 +344,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
8669368EA60E351E6844A10D /* [CP] Copy Pods Resources */ = {
Expand Down Expand Up @@ -359,7 +374,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand All @@ -381,6 +396,7 @@
buildActionMask = 2147483647;
files = (
607FACEC1AFB9204008FA782 /* Tests.swift in Sources */,
20EEC2081F28BA0B00535A42 /* HLSLocalizerTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -551,6 +567,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DownloadToGo_Example.app/DownloadToGo_Example";
};
name = Debug;
};
Expand All @@ -568,6 +585,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DownloadToGo_Example.app/DownloadToGo_Example";
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "607FACE41AFB9204008FA782"
BuildableName = "DownloadToGo_Tests.xctest"
BlueprintName = "DownloadToGo_Tests"
ReferencedContainer = "container:DownloadToGo.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
50 changes: 50 additions & 0 deletions Example/Tests/HLSLocalizer/HLSLocalizerTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// HLSLocalizerTests.swift
// DownloadToGo
//
// Created by Gal Orlanczyk on 26/07/2017.
// Copyright © 2017 CocoaPods. All rights reserved.
//

import Quick
import Nimble
@testable import DownloadToGo

class HLSLocalizerTests: QuickSpec {

override func spec() {
describe("HLSLocalizerTests") {

let id = "test"
let bundleURL = Bundle(for: type(of: self)).bundleURL
let url = bundleURL.appendingPathComponent("Resources", isDirectory: true)
.appendingPathComponent("SampleHLS", isDirectory: true)
.appendingPathComponent("master.m3u8")
let downloadPath = DTGFilePaths.itemDirUrl(forItemId: id)

let localizer = HLSLocalizer(id: id, url: url, downloadPath: downloadPath, preferredVideoBitrate: nil)

it("can localize hls m3u8 index file") {
try! localizer.loadMetadata()
let tasks = localizer.tasks
// the sample hls provided has 30 media segments in total make sure it is the same
expect(tasks.count).to(equal(30))
for task in tasks {
let contentFileName = task.contentUrl.absoluteString.md5()
// test file names are ok
expect(tasks.contains { $0.destinationUrl.deletingPathExtension().lastPathComponent == contentFileName }).to(beTrue())
let expectedDestinationUrl = downloadPath.appendingPathComponent(task.trackType.asString(), isDirectory: true)
.appendingPathComponent(task.contentUrl.absoluteString.md5())
.appendingPathExtension(task.contentUrl.pathExtension)
// test destination url is ok
expect(task.destinationUrl.absoluteString).to(equal(expectedDestinationUrl.absoluteString))
}
}

it("can save to to local file system") {
try! localizer.saveLocalFiles()
try! FileManager.default.removeItem(at: DTGFilePaths.itemDirUrl(forItemId: id))
}
}
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-ALLOW-CACHE:YES
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:1
#EXTINF:2.000,
09f1df7dfffa1c2a773c2c4353024a23.ts
#EXTINF:2.000,
973c6d5c9eb550f6fe8faba66f48020c.ts
#EXTINF:2.000,
9a9bd96537ded2ef5bb6921fe68c96c5.ts
#EXTINF:4.000,
83ec0e1e5f2e5a916ca38157f205ca20.ts
#EXTINF:10.000,
a4c7608dcfd18556262b04eb4b8fd221.ts
#EXTINF:5.028,
ee861377ec9e6bce754bc4c9a1c5066e.ts
#EXT-X-ENDLIST
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-ALLOW-CACHE:YES
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:1
#EXTINF:2.000,
8e2e60048fd557eaaeef6e9256630218.ts
#EXTINF:2.000,
a02f21c1d3884fc0d187bdd9016a6009.ts
#EXTINF:2.000,
99712703991cdd23c63018a75f26253d.ts
#EXTINF:4.000,
747391dbd47cd9c55fb7844479fb03ca.ts
#EXTINF:10.000,
207085493d45e7436e17bcffb987e523.ts
#EXTINF:5.003,
60cc9e3ad7277bde95fdda9e317e1c35.ts
#EXT-X-ENDLIST
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-ALLOW-CACHE:YES
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:1
#EXTINF:2.000,
cb38d516ca2453b65c450dadb5c5cb8c.ts
#EXTINF:2.000,
d5fa0546a05acc977bc597911fddd94c.ts
#EXTINF:2.000,
0523eedc55d06eb370dcc64890b67e0f.ts
#EXTINF:4.000,
28cbe2742a45e7c65c0cbd2d88fde3fa.ts
#EXTINF:10.000,
5ce52fa0ee4b38ad26e201759730719c.ts
#EXTINF:5.028,
9d569fd68b225743612b18bbd9d8c05a.ts
#EXT-X-ENDLIST
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-ALLOW-CACHE:YES
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:1
#EXTINF:2.000,
fc97593fdace3270e3de97067540aaa7.ts
#EXTINF:2.000,
1eba9f920bf694b1f8be0fb906ac8903.ts
#EXTINF:2.000,
b077ea93d62f2c41e07c0b8abd2c4e04.ts
#EXTINF:4.000,
410ed85925892d004d68ca9e575f18ca.ts
#EXTINF:10.000,
b9682d336484ef2af9e154b6b7376769.ts
#EXTINF:5.028,
4530bdcf919e7fceef757ec697eff506.ts
#EXT-X-ENDLIST
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
7 changes: 7 additions & 0 deletions Example/Tests/Resources/SampleHLS/master.m3u8
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#EXTM3U
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",LANGUAGE="dan",NAME="Danish",AUTOSELECT=YES,DEFAULT=YES,URI="audio/06ee6199748020cf8bfb1c07879db3b4.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",LANGUAGE="eng",NAME="English",AUTOSELECT=NO,DEFAULT=NO,URI="audio/1cab819c729f528e4140567e099757b7.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",LANGUAGE="cze",NAME="cze",AUTOSELECT=NO,DEFAULT=NO,URI="audio/a26809bf2e43afd67f52109899040ecb.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",LANGUAGE="bul",NAME="Bulgarian",AUTOSELECT=NO,DEFAULT=NO,URI="audio/648ff69d5896bc4d814ec60a1acf482b.m3u8"
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=488448,RESOLUTION=640x360,AUDIO="audio"
video/d2f7828257eab43b55634d1621b8a157.m3u8
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-ALLOW-CACHE:YES
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:1
#EXTINF:2.000,
50e9c897e71fcafef5f915159deae690.ts
#EXTINF:2.000,
29520a3cce2f3648e333b65086eba9e0.ts
#EXTINF:2.000,
deb0c59ea4a8a1e5dbb7e724f78f3753.ts
#EXTINF:4.000,
97aa8c9c21345575264ceff997dd0e4b.ts
#EXTINF:10.000,
9502085a51dbe9e88c9581b644dc4bc1.ts
#EXTINF:5.120,
b2e2f41e9337b12f3d353971bb04728d.ts
#EXT-X-ENDLIST
Binary file not shown.
2 changes: 1 addition & 1 deletion Sources/ContentManager/ContentManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public class ContentManager: NSObject, DTGContentManager {

var item = try findItemOrThrow(id)

let localizer = HLSLocalizer(id: id, url: item.remoteUrl, preferredVideoBitrate: preferredVideoBitrate)
let localizer = HLSLocalizer(id: id, url: item.remoteUrl, downloadPath: DTGFilePaths.itemDirUrl(forItemId: id), preferredVideoBitrate: preferredVideoBitrate)

DispatchQueue.global().async {
do {
Expand Down
4 changes: 2 additions & 2 deletions Sources/ContentManager/HLSLocalizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ class HLSLocalizer {
var selectedAudioStreams = [MediaStream]()
var selectedTextStreams = [MediaStream]()

init(id: String, url: URL, preferredVideoBitrate: Int?) {
init(id: String, url: URL, downloadPath: URL, preferredVideoBitrate: Int?) {
self.itemId = id
self.masterUrl = url
self.preferredVideoBitrate = preferredVideoBitrate
self.downloadPath = DTGFilePaths.itemDirUrl(forItemId: id)
self.downloadPath = downloadPath
}

private func videoTrack(videoStream: M3U8ExtXStreamInf) -> DTGVideoTrack {
Expand Down

0 comments on commit 5162d33

Please sign in to comment.