From 2508579b43a0e705b8c4e710ff4d70e855164e2e Mon Sep 17 00:00:00 2001 From: Gal Orlanczyk Date: Mon, 31 Jul 2017 16:23:49 +0300 Subject: [PATCH 1/4] #FEM-1608 (#209) * #FEM-1608 * added referrer to providers * added referrer to playback context service. * fix codacy issues --- .../OTT/Services/OTTAssetService.swift | 12 +++++--- .../OVP/Services/OVPBaseEntryService.swift | 9 ++++-- .../Providers/OTT/PhoenixMediaProvider.swift | 12 +++++++- Classes/Providers/OVP/OVPMediaProvider.swift | 29 ++++++++++++++----- 4 files changed, 46 insertions(+), 16 deletions(-) diff --git a/Classes/Backend/OTT/Services/OTTAssetService.swift b/Classes/Backend/OTT/Services/OTTAssetService.swift index 31fe171d..1299b8bb 100644 --- a/Classes/Backend/OTT/Services/OTTAssetService.swift +++ b/Classes/Backend/OTT/Services/OTTAssetService.swift @@ -31,10 +31,11 @@ class OTTAssetService { struct PlaybackContextOptions { - internal var playbackContextType: PlaybackType - internal var protocls: [String] - internal var assetFileIds: [String]? - + var playbackContextType: PlaybackType + var protocls: [String] + var assetFileIds: [String]? + var referrer: String? + func toDictionary() -> [String: Any] { var dict: [String: Any] = [:] @@ -43,6 +44,9 @@ struct PlaybackContextOptions { if let fileIds = self.assetFileIds { dict["assetFileIds"] = fileIds.joined(separator: ",") } + if let referrer = self.referrer { + dict["referrer"] = referrer + } return dict } } diff --git a/Classes/Backend/OVP/Services/OVPBaseEntryService.swift b/Classes/Backend/OVP/Services/OVPBaseEntryService.swift index 18778440..d0832f1c 100644 --- a/Classes/Backend/OVP/Services/OVPBaseEntryService.swift +++ b/Classes/Backend/OVP/Services/OVPBaseEntryService.swift @@ -45,7 +45,7 @@ class OVPBaseEntryService { internal static func getContextData(baseURL: String, ks: String,entryID: String) -> KalturaRequestBuilder? { if let request: KalturaRequestBuilder = KalturaRequestBuilder(url: baseURL, service: "baseEntry", action: "getContextData") { - let contextData:[String: Any] = [String: Any]() + let contextData: [String: Any] = [String: Any]() request.setBody(key: "ks", value: JSON(ks)) .setBody(key: "entryId", value: JSON(entryID)) .setBody(key: "contextDataParams", value: JSON(contextData)) @@ -56,9 +56,12 @@ class OVPBaseEntryService { } - internal static func getPlaybackContext(baseURL: String, ks: String, entryID: String) -> KalturaRequestBuilder? { + internal static func getPlaybackContext(baseURL: String, ks: String, entryID: String, referrer: String?) -> KalturaRequestBuilder? { if let request: KalturaRequestBuilder = KalturaRequestBuilder(url: baseURL, service: "baseEntry", action: "getPlaybackContext") { - let contextData:[String: Any] = ["objectType":"KalturaContextDataParams"] + var contextData: [String: Any] = ["objectType": "KalturaContextDataParams"] + if let r = referrer { + contextData["referrer"] = r + } request.setBody(key: "ks", value: JSON(ks)) .setBody(key: "entryId", value: JSON(entryID)) .setBody(key: "contextDataParams", value: JSON(contextData)) diff --git a/Classes/Providers/OTT/PhoenixMediaProvider.swift b/Classes/Providers/OTT/PhoenixMediaProvider.swift index b1cb2a2e..9b2fd887 100644 --- a/Classes/Providers/OTT/PhoenixMediaProvider.swift +++ b/Classes/Providers/OTT/PhoenixMediaProvider.swift @@ -136,6 +136,7 @@ public enum PhoenixMediaProviderError: PKError { @objc public var fileIds: [String]? @objc public var playbackContextType: PlaybackContextType = .unknown @objc public var networkProtocol: String? + @objc public var referrer: String? public weak var responseDelegate: MediaEntryProviderResponseDelegate? = nil public var executor: RequestExecutor? @@ -205,6 +206,15 @@ public enum PhoenixMediaProviderError: PKError { return self } + + /// - Parameter referrer: the referrer + /// - Returns: Self + @discardableResult + @nonobjc public func set(referrer: String?) -> Self { + self.referrer = referrer + return self + } + /// - Parameter executor: executor which will be used to send request. /// default is USRExecutor /// - Returns: Self @@ -283,7 +293,7 @@ public enum PhoenixMediaProviderError: PKError { /// - Returns: request builder func loaderRequestBuilder(ks: String?, loaderInfo: LoaderInfo) -> KalturaRequestBuilder? { - let playbackContextOptions = PlaybackContextOptions(playbackContextType: loaderInfo.playbackContextType, protocls: [loaderInfo.networkProtocol], assetFileIds: loaderInfo.fileIds) + let playbackContextOptions = PlaybackContextOptions(playbackContextType: loaderInfo.playbackContextType, protocls: [loaderInfo.networkProtocol], assetFileIds: loaderInfo.fileIds, referrer: self.referrer) if let token = ks { diff --git a/Classes/Providers/OVP/OVPMediaProvider.swift b/Classes/Providers/OVP/OVPMediaProvider.swift index deb84fb5..ba56b26e 100644 --- a/Classes/Providers/OVP/OVPMediaProvider.swift +++ b/Classes/Providers/OVP/OVPMediaProvider.swift @@ -74,7 +74,8 @@ import KalturaNetKit @objc public var sessionProvider: SessionProvider? @objc public var entryId: String? @objc public var uiconfId: NSNumber? - public var executor: RequestExecutor? // TODO: make @objc if needed in the future + @objc public var referrer: String? + public var executor: RequestExecutor? public override init() {} @@ -101,20 +102,31 @@ import KalturaNetKit } /** - executor - which resposible for the network, it can be set to + uiconfId - UI Configuration id */ @discardableResult - @nonobjc public func set(executor: RequestExecutor?) -> Self { - self.executor = executor + @nonobjc public func set(uiconfId: NSNumber?) -> Self { + self.uiconfId = uiconfId + return self + } + + + /// set the provider referrer + /// + /// - Parameter referrer: the app referrer + /// - Returns: Self + @discardableResult + @nonobjc public func set(referrer: String?) -> Self { + self.referrer = referrer return self } /** - uiconfId - UI Configuration id + executor - which resposible for the network, it can be set to */ @discardableResult - @nonobjc public func set(uiconfId: NSNumber?) -> Self{ - self.uiconfId = uiconfId + @nonobjc public func set(executor: RequestExecutor?) -> Self { + self.executor = executor return self } @@ -176,7 +188,8 @@ import KalturaNetKit // Request for Entry playback data in order to build sources to play let getPlaybackContext = OVPBaseEntryService.getPlaybackContext(baseURL: loadInfo.apiServerURL, ks: token, - entryID: loadInfo.entryId) + entryID: loadInfo.entryId, + referrer: self.referrer) let metadataRequest = OVPBaseEntryService.metadata(baseURL: loadInfo.apiServerURL, ks: token, entryID: loadInfo.entryId) From ba4a7be4ed64b5ee3114d72c90eff65884c20f41 Mon Sep 17 00:00:00 2001 From: Eliza Sapir Date: Mon, 31 Jul 2017 18:27:57 +0300 Subject: [PATCH 2/4] remove additional header --- Classes/Backend/Base/Model/KalturaBaseObject.swift | 8 -------- Classes/Backend/OVP/Model/OVPEntry.swift | 8 -------- 2 files changed, 16 deletions(-) diff --git a/Classes/Backend/Base/Model/KalturaBaseObject.swift b/Classes/Backend/Base/Model/KalturaBaseObject.swift index 0994a1ed..73bf056a 100644 --- a/Classes/Backend/Base/Model/KalturaBaseObject.swift +++ b/Classes/Backend/Base/Model/KalturaBaseObject.swift @@ -8,14 +8,6 @@ // https://www.gnu.org/licenses/agpl-3.0.html // =================================================================================================== -// -// KalturaBaseObject.swift -// Pods -// -// Created by Rivka Peleg on 05/07/2017. -// -// - import Foundation protocol KalturaBaseObject { diff --git a/Classes/Backend/OVP/Model/OVPEntry.swift b/Classes/Backend/OVP/Model/OVPEntry.swift index 5b6eeba0..f3cc7911 100644 --- a/Classes/Backend/OVP/Model/OVPEntry.swift +++ b/Classes/Backend/OVP/Model/OVPEntry.swift @@ -8,14 +8,6 @@ // https://www.gnu.org/licenses/agpl-3.0.html // =================================================================================================== -// -// OVPEntry.swift -// Pods -// -// Created by Rivka Peleg on 28/11/2016. -// -// - import UIKit import SwiftyJSON From 5289e5501c6b0ebde1ff62a4de0a69f7984b0c47 Mon Sep 17 00:00:00 2001 From: Eliza Sapir Date: Mon, 31 Jul 2017 18:29:12 +0300 Subject: [PATCH 3/4] bump dev version --- Example/PlayKit/Info.plist | 2 +- PlayKit.podspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Example/PlayKit/Info.plist b/Example/PlayKit/Info.plist index 02954d25..a9708dd4 100644 --- a/Example/PlayKit/Info.plist +++ b/Example/PlayKit/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.1.x-dev + 3.1.x-dev CFBundleSignature ???? CFBundleVersion diff --git a/PlayKit.podspec b/PlayKit.podspec index c35dd6e7..9dcce76f 100644 --- a/PlayKit.podspec +++ b/PlayKit.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'PlayKit' -s.version = '0.4.x-dev' +s.version = '3.1.x-dev' s.summary = 'PlayKit: Kaltura Mobile Player SDK - iOS' s.homepage = 'https://github.com/kaltura/playkit-ios' s.license = { :type => 'AGPLv3', :text => 'AGPLv3' } From f7424a9a5021693e69dd8ac48dd8b31941a8feb7 Mon Sep 17 00:00:00 2001 From: ElizaSapir Date: Mon, 31 Jul 2017 21:44:10 +0300 Subject: [PATCH 4/4] FEM-1603 #comment activate refresh asset & avoid refresh on reachable (#210) * FEM-1603 #comment activate refresh asset & avoid refresh on reachable * minor code style fix --- Classes/Player/PlayerController.swift | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Classes/Player/PlayerController.swift b/Classes/Player/PlayerController.swift index fcffd180..ded97f8a 100644 --- a/Classes/Player/PlayerController.swift +++ b/Classes/Player/PlayerController.swift @@ -166,8 +166,6 @@ class PlayerController: NSObject, Player, PlayerSettings { self.currentPlayer.currentPosition = CMTimeGetSeconds(time) } - - func destroy() { self.currentPlayer.destroy() self.removeAssetRefreshObservers() @@ -275,7 +273,9 @@ extension PlayerController { PKLog.warning("network unreachable") } reachability.onReachable = { [unowned self] reachability in - self.handleRefreshAsset() + if self.shouldRefresh { + self.handleRefreshAsset() + } } } @@ -302,9 +302,7 @@ extension PlayerController { } private func handleRefreshAsset() { - if self.shouldRefresh { - self.shouldRefresh = false - self.refreshAsset() - } + self.shouldRefresh = false + self.refreshAsset() } }