Skip to content

Commit

Permalink
chore: record DRM details automatically when enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjl-mux committed Jul 22, 2024
1 parent 0aa3009 commit abb0586
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
6 changes: 4 additions & 2 deletions Sources/MuxPlayerSwift/GlobalLifecycle/PlayerSDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ class PlayerSDK {
func registerPlayerLayer(
playerLayer: AVPlayerLayer,
monitoringOptions: MonitoringOptions,
requiresReverseProxying: Bool = false
requiresReverseProxying: Bool = false,
usingDRM: Bool = false
) {
if requiresReverseProxying && !self.reverseProxyServer.hasBeenStarted {
self.reverseProxyServer.start()
Expand All @@ -161,7 +162,8 @@ class PlayerSDK {
func registerPlayerViewController(
playerViewController: AVPlayerViewController,
monitoringOptions: MonitoringOptions,
requiresReverseProxying: Bool = false
requiresReverseProxying: Bool = false,
usingDRM: Bool = false
) {
if requiresReverseProxying && !self.reverseProxyServer.hasBeenStarted {
self.reverseProxyServer.start()
Expand Down
18 changes: 16 additions & 2 deletions Sources/MuxPlayerSwift/Monitoring/Monitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class Monitor {

func setupMonitoring(
playerViewController: AVPlayerViewController,
options: MonitoringOptions
options: MonitoringOptions,
isDRM: Bool = false
) {

let monitoredPlayer: MonitoredPlayer
Expand Down Expand Up @@ -90,6 +91,12 @@ class Monitor {
}
customerData.customerPlayerData = customerPlayerData

if isDRM {
let customerViewData = MUXSDKCustomerViewData()
customerViewData.viewDrmType = "fairplay"
customerData.customerViewData = customerViewData
}

let binding = MUXSDKStats.monitorAVPlayerViewController(
playerViewController,
withPlayerName: options.playerName,
Expand All @@ -109,7 +116,8 @@ class Monitor {

func setupMonitoring(
playerLayer: AVPlayerLayer,
options: MonitoringOptions
options: MonitoringOptions,
isDRM: Bool = false
) {
let monitoredPlayer: MonitoredPlayer

Expand Down Expand Up @@ -155,6 +163,12 @@ class Monitor {
}
customerData.customerPlayerData = customerPlayerData

if isDRM {
let customerViewData = MUXSDKCustomerViewData()
customerViewData.viewDrmType = "fairplay"
customerData.customerViewData = customerViewData
}

let binding = MUXSDKStats.monitorAVPlayerLayer(
playerLayer,
withPlayerName: options.playerName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,21 @@ extension AVPlayerLayer {
playbackID: playbackID
)

PlayerSDK.shared.registerPlayerLayer(
playerLayer: self,
monitoringOptions: monitoringOptions,
requiresReverseProxying: playbackOptions.enableSmartCache
)
if case PlaybackOptions.PlaybackPolicy.drm(_) = playbackOptions.playbackPolicy {
PlayerSDK.shared.registerPlayerLayer(
playerLayer: self,
monitoringOptions: monitoringOptions,
requiresReverseProxying: playbackOptions.enableSmartCache,
usingDRM: true
)
} else {
PlayerSDK.shared.registerPlayerLayer(
playerLayer: self,
monitoringOptions: monitoringOptions,
requiresReverseProxying: playbackOptions.enableSmartCache,
usingDRM: false
)
}
}

/// Initializes an AVPlayerLayer that's configured
Expand Down

0 comments on commit abb0586

Please sign in to comment.