Skip to content

Commit

Permalink
comment: recapitalize FairplaySessionManager
Browse files Browse the repository at this point in the history
  • Loading branch information
daytime-em committed May 1, 2024
1 parent a35b4ab commit 7b080c7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation
import AVFoundation

class FairplaySessionManager {
class FairPlaySessionManager {

private var playbackOptionsByPlaybackID: [String: PlaybackOptions] = [:]
// note - null on simulators or other environments where fairplay isn't supported
Expand Down Expand Up @@ -103,8 +103,6 @@ class FairplaySessionManager {
// POST body is the SPC bytes
request.httpMethod = "POST"
request.httpBody = spcData
//print("Raw (non-percent encoded) SPC base64:", spcData.base64EncodedString()) // we dump the encoded version too


// QUERY PARAMS
request.setValue("application/octet-stream", forHTTPHeaderField: "Content-Type")
Expand Down Expand Up @@ -135,7 +133,7 @@ class FairplaySessionManager {
}
// strange edge case: 200 with no response body
// this happened because of a client-side encoding difference causing an error
// with our drm vendor and probably shouldn't be relevant, but lets not crash
// with our drm vendor and probably shouldn't be reachable, but lets not crash
guard let data = data else {
print("No CKC data despite server returning success")
requestCompletion(Result.failure(TempError())) // todo - real Error type
Expand Down Expand Up @@ -218,10 +216,6 @@ class FairplaySessionManager {
sessionDelegate: AVContentKeySessionDelegate?,
sessionDelegateQueue: DispatchQueue
) {
// TODO: Remove when app cert endpoint is available
// print(">>>>>>>>>>>>>>>>>")
// print(ProcessInfo.processInfo.environment["APP_CERT_BASE64"])

contentKeySession?.setDelegate(sessionDelegate, queue: sessionDelegateQueue)

self.contentKeySession = contentKeySession
Expand Down
4 changes: 2 additions & 2 deletions Sources/MuxPlayerSwift/GlobalLifecycle/PlayerSDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ class PlayerSDK {

let keyValueObservation: KeyValueObservation

let fairplaySessionManager: FairplaySessionManager
let fairplaySessionManager: FairPlaySessionManager

init() {
self.monitor = Monitor()
self.keyValueObservation = KeyValueObservation()
self.fairplaySessionManager = FairplaySessionManager()
self.fairplaySessionManager = FairPlaySessionManager()
}

class KeyValueObservation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,11 @@ fileprivate func makePlaybackURL(
fileprivate func makeAVAsset(playbackID: String, playbackOptions: PlaybackOptions) -> AVAsset {
let url = makePlaybackURL(playbackID: playbackID, playbackOptions: playbackOptions)

var asset: AVURLAsset
let asset = AVURLAsset(url: url)
if case .drm(_) = playbackOptions.playbackPolicy {
PlayerSDK.shared.fairplaySessionManager.registerPlaybackOptions(playbackOptions, for: playbackID)
asset = AVURLAsset(url: url)
// asset must be attached as early as possible to avoid crashes when attaching later
PlayerSDK.shared.fairplaySessionManager.addContentKeyRecipient(asset)
} else {
asset = AVURLAsset(url: url)
}

return asset
Expand Down

0 comments on commit 7b080c7

Please sign in to comment.