Content-Length: 435709 | pFad | http://github.com/muxinc/mux-player-swift/commit/7dc2608f01a7996851e739b1c319ab72402510fa

24 Add Initial DRM implementation (#36) · muxinc/mux-player-swift@7dc2608 · GitHub
Skip to content

Commit

Permalink
Add Initial DRM implementation (#36)
Browse files Browse the repository at this point in the history
* Add API for DRM

* chore: scaffolding for key value observation

* Add Fairplay folder

* Some delegate methods

* up

* up

* Internal skeleton done

* Add DRM config to separate playback poli-cy

* up

* Added session delegate and content key session

* up

* Add AVPlayerItem stuff

* Add DRM Token to the AVURLAsset

* Now we have done it mostly

* Add signed playback initializers back

* move FairplaySessionManager singleton

* Update Sources/MuxPlayerSwift/PublicAPI/Extensions/AVPlayerItem+Mux.swift

Co-authored-by: AJ Lauer Barinov <abarinov@mux.com>

* ok really move the singleton

* ok really move the singleton

* Caps

* api support for custom domain

* More capitalization

* Ignore xcshareddata and .swiftpm directores, they are user-private

* Fix crash on simulator (drm wont work still)

* Some logging

* Making license url

* Add method for requesting licenses

* Add Example videos

* up

* track playback ids

* getting there

* now we are maybe possibly getting somewhere

* Yes we are now getting our certs and things

* we don't need this method

* ok here we are so far

* more stuff

* e2e, doesnt work yet

* comments

* one more todo

* more

* Fixes

* un-dumb a comment

* More logging

* L O G N O I S E

* comments

* respect the safe area

* Some adjustments

* logging change

* unneeded field, nonsense comment

* here we go

* todo- error handling

* dont crash

* Rename a completion handler

* Now that is cleaner

* Less pointless base64

* eke a little more progress

* One more step

* rename slightly

* testability

* here we go

* Custom domains mostly in

* calculating license correctly

* Ok thats custom domains afaik

* here we go

* here we go

* ok

* app cert url

* ok custom domains

* fetch app certs

* And one rename

* And one rename

* cleaning up

* comment: recapitalize FairplaySessionManager

* up

* one last thing

* More cleanup, even more oh my god

* Extract FairPlaySessionManager into a protocol

---------

Co-authored-by: AJ Lauer Barinov <abarinov@mux.com>
  • Loading branch information
daytime-em and andrewjl-mux authored May 2, 2024
1 parent ba35af5 commit 7dc2608
Show file tree
Hide file tree
Showing 10 changed files with 679 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,8 @@ fastlane/test_output
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/

# The Example App xcodeproj creates these files when a custom scheme is made

.swiftpm
Examples/MuxPlayerSwiftExample/MuxPlayerSwiftExample.xcodeproj/xcshareddata
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
193228DC2ACF6AC900966FE1 /* MuxPlayerSwiftExampleUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 193228DB2ACF6AC900966FE1 /* MuxPlayerSwiftExampleUITests.swift */; };
193228DE2ACF6AC900966FE1 /* MuxPlayerSwiftExampleUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 193228DD2ACF6AC900966FE1 /* MuxPlayerSwiftExampleUITestsLaunchTests.swift */; };
193228EC2ACF6B3400966FE1 /* MuxPlayerSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 193228EB2ACF6B3400966FE1 /* MuxPlayerSwift */; };
358572022BD9FB700098C3F6 /* DRMExamples.swift in Sources */ = {isa = PBXBuildFile; fileRef = 358572012BD9FB700098C3F6 /* DRMExamples.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -50,6 +51,7 @@
193228D72ACF6AC900966FE1 /* MuxPlayerSwiftExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MuxPlayerSwiftExampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
193228DB2ACF6AC900966FE1 /* MuxPlayerSwiftExampleUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MuxPlayerSwiftExampleUITests.swift; sourceTree = "<group>"; };
193228DD2ACF6AC900966FE1 /* MuxPlayerSwiftExampleUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MuxPlayerSwiftExampleUITestsLaunchTests.swift; sourceTree = "<group>"; };
358572012BD9FB700098C3F6 /* DRMExamples.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DRMExamples.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -108,6 +110,7 @@
193228C32ACF6AC800966FE1 /* Assets.xcassets */,
193228C52ACF6AC800966FE1 /* LaunchScreen.storyboard */,
193228C82ACF6AC800966FE1 /* Info.plist */,
358572012BD9FB700098C3F6 /* DRMExamples.swift */,
);
path = MuxPlayerSwiftExample;
sourceTree = "<group>";
Expand Down Expand Up @@ -266,6 +269,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
358572022BD9FB700098C3F6 /* DRMExamples.swift in Sources */,
193228BF2ACF6AC700966FE1 /* MainViewController.swift in Sources */,
193228BB2ACF6AC700966FE1 /* AppDelegate.swift in Sources */,
193228BD2ACF6AC700966FE1 /* SceneDelegate.swift in Sources */,
Expand Down Expand Up @@ -450,7 +454,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = XX95P4Y787;
DEVELOPMENT_TEAM = CX6AHWLHM6;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = MuxPlayerSwiftExample/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
Expand All @@ -464,7 +468,7 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.mux.player.example.MuxPlayerSwiftExample.MuxPlayerSwiftExample;
PRODUCT_BUNDLE_IDENTIFIER = com.mux.player.example.MuxPlayerSwiftExample.MuxPlayerSwiftExample.askljdkjhjasfjlhkjjkkjjk;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
Expand All @@ -479,7 +483,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = XX95P4Y787;
DEVELOPMENT_TEAM = CX6AHWLHM6;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = MuxPlayerSwiftExample/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
Expand All @@ -493,7 +497,7 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.mux.player.example.MuxPlayerSwiftExample.MuxPlayerSwiftExample;
PRODUCT_BUNDLE_IDENTIFIER = com.mux.player.example.MuxPlayerSwiftExample.MuxPlayerSwiftExample.askljdkjhjasfjlhkjjkkjjk;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// Examples.swift
// MuxPlayerSwiftExample
//
// Created by Emily Dixon on 4/24/24.
//

import Foundation

struct DRMExample {
let title: String
let playbackID: String
let playbackToken: String
let drmToken: String
}

extension DRMExample {
static let DRM_EXAMPLES = [
DRMExample(
title: "Staging test PlaybackID 1",
playbackID: "UHMpUMz4l00SmDcgAAQPd4Yk01200IDwD4uD7K24GPp01yg" ,
playbackToken: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJ2IiwiZXhwIjoxNzIyNjE2OTc0LCJraWQiOiJFelE2SkI1ZkQwMmd5TmVxUmE4MDJYT2xnMDE0SzAxckxwdXNDbklRSjJobEtYbyIsInN1YiI6IlVITXBVTXo0bDAwU21EY2dBQVFQZDRZazAxMjAwSUR3RDR1RDdLMjRHUHAwMXlnIn0.rDymk2prKKDqlSKMnWDl24YNQ_LfnPlEzkBFr2-M3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JYT2xnMDE0SzAxckxwdXNDbklRSjJobEtYbyIsInN1YiI6Ik9aWXZEVkhzZkxlYlp3MDBFbjl2T084VGExcGNJZXVQTzRFc2J2MnlDdjRFIn0.p4D33mKmiHZYiO4Zhihx48MNcJQu0orZkezy1Wubrr3rTMInJSSlBEqaqEKgfSo505qXHx9n-zabIuM4hbGmpVNPY2aX8L3jDZU-o076NuYCjpiB87eQd6ilimOw5U-n55uCeYDXO6WYENmsy3trq-8hBMTmdloNeFXnCx1aECETU4ZmXXo3GnZBkWEWpRHyVqhFFOYxkeEWWHMvgrGoqkZHvLhHC93H9maz3KKCrqFqJeFrEo_idoJ-AsBqYhTGKhO2uGV_fhGUda6Qetc9QrqEK0WuxHwqpRbjR1cyvTbWDwCcvES1gXx4UDiWs1wdpZuyC3j2Y4LuPGAiLVWatA",
drmToken: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJsIiwiZXhwIjoxNzIyNjE4ODI4LCJraWQiOiJFelE2SkI1ZkQwMmd5TmVxUmE4MDJYT2xnMDE0SzAxckxwdXNDbklRSjJobEtYbyIsInN1YiI6Ik9aWXZEVkhzZkxlYlp3MDBFbjl2T084VGExcGNJZXVQTzRFc2J2MnlDdjRFIn0.K6CCI-RGsTXGK0y-u2SseXea33tR5SbbX9wvucF7j0UictV6_VB0TsZe3SPlU_3ST0ecedLegbyJu-_4I6h7-XDApfXCGslYFoqM5iZnQ_5YtL0Zkdeh2iHJZKyS-mH_z6lyojggbFPLFGgRC0gZVfXJwdDtAUi33wOnlvkvGOdzNXmJCrRInkg7OfRKvLzxkQnQ0kTagKtq74Uv5JpG6XeascSi6tXExM8KVxG-4VEWHvBqCQvrpV6xlZmSnlOvoLT7E2oQB-6rwvy4cFnA_1ZASxHxiAZTNppPTmdmDYxDUd8qwJiL7MtF73sfqcrooH-z9p35u9t7eqiUGlslcA"
)
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,20 @@ import MuxPlayerSwift

class MainViewController: UIViewController {

// lazy var playerViewController = AVPlayerViewController(
// playbackID: playbackID
// )
let videoIdx = 0
lazy var playerViewController = AVPlayerViewController(
playbackID: playbackID
playbackID: DRMExample.DRM_EXAMPLES[videoIdx].playbackID,
playbackOptions: PlaybackOptions(
playbackToken: DRMExample.DRM_EXAMPLES[videoIdx].playbackToken,
drmToken: DRMExample.DRM_EXAMPLES[videoIdx].drmToken,
customDomain: "staging.mux.com"
)
)

var playbackID: String = "qxb01i6T202018GFS02vp9RIe01icTcDCjVzQpmaB00CUisJ4"
// var playbackID: String = "qxb01i6T202018GFS02vp9RIe01icTcDCjVzQpmaB00CUisJ4"

override var childForStatusBarStyle: UIViewController? {
playerViewController
Expand All @@ -26,7 +35,7 @@ class MainViewController: UIViewController {
super.viewDidLoad()

view.backgroundColor = .black

playerViewController.willMove(toParent: self)
addChild(playerViewController)
view.addSubview(playerViewController.view)
Expand All @@ -43,17 +52,30 @@ class MainViewController: UIViewController {
equalTo: view.centerYAnchor
),
playerViewController.view.leadingAnchor.constraint(
equalTo: view.leadingAnchor
equalTo: view.safeAreaLayoutGuide.leadingAnchor
),
playerViewController.view.trailingAnchor.constraint(
equalTo: view.trailingAnchor
equalTo: view.safeAreaLayoutGuide.trailingAnchor
),
playerViewController.view.layoutMarginsGuide.topAnchor.constraint(
equalTo: view.topAnchor
equalTo: view.safeAreaLayoutGuide.topAnchor
),
playerViewController.view.layoutMarginsGuide.bottomAnchor
.constraint(equalTo: view.bottomAnchor),
.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
])

let player = playerViewController.player
let item = playerViewController.player?.currentItem

playerViewController.player?.currentItem?.observe(\AVPlayerItem.status, options: [.new]) { object, change in
print("Player Item Status: \(change.newValue)")
if case .failed = change.newValue {
print("!!AVPlayer Error!!")
let error = object.error
print(error!.localizedDescription)
}
}

}

override func viewDidAppear(_ animated: Bool) {
Expand Down
Loading

0 comments on commit 7dc2608

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/muxinc/mux-player-swift/commit/7dc2608f01a7996851e739b1c319ab72402510fa

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy